Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - oofoe

#1
OK, see that you're using gs:set-titled-border -- I haven't used that one myself.



Does seem that gs:-set-font won't work for that through the GUIServer.



However, the SWT (successor to AWT which is used by GUIServer, I think) will allow to set a font with the .setFont() method. Perhaps AWT has the same capability and it's just not wired up in the GUIServer. So, if you're comfortable with Java you could get the GUIServer code, find the set-titled-border handler and see if you can change it there, then recompile. See here for possible example: http://stackoverflow.com/questions/7117408/change-group-widget-title-color-in-swt#7118384">//http://stackoverflow.com/questions/7117408/change-group-widget-title-color-in-swt#7118384



Otherwise, make your window a canvas instead and place the widgets and draw the border yourself and label it with the font you prefer.



Another possibility: That looks like a system default font. If you're running in Linux maybe you don't have the "icon" font used for labelling those things installed? I can't remember what the font is, but that would be worth investigating, especially if you see other applications on your system with the same problem.



Good luck!
#2
Can you post source for this GUI display? Not even sure how you're displaying it since NewLisp GUIServer doesn't seem to support the AWT Group widget.



If you're just dropping text over a hand drawn group, you can do it using the gs:set-font function.
#3
Hi!



Thanks very much for fixing that. It's a small thing, but it can really trip someone up when they're trying to make something like that work for the first time.



Any possibility of getting the "(import LIBRARY)" syntax in Windows too? With maybe some way to list the symbols in the library?



Thanks!
#4
Incidentally, here's how to determine if a file is a png image using the standard libpng library:


;; C library functions.
(import "msvcrt.dll" "fopen")
(import "msvcrt.dll" "fread")

;; PNG library functions.
(import "libpng16-16.dll" "png_sig_cmp")

(define (pngfile? path)
  "( path -- f) Determines if path is a %.png file."

  (letn ((header "XXXXXXXX")
(fp (fopen path "rb")))
(fread header 1 (length header) fp)
(zero? (png_sig_cmp header 0 (length header)))))


Sorry, Windows only at this point. UNIX users please substitute library names as appropriate.
#5
Hi!



In my quest to construct a program to derive the question to the answer of Life, the Universe and Everything (which is, as any schoolchild knows, 42), I wrote a very simple genetic algorithm solver.



I don't mean simple as in "simple to use", I mean absolute braindead simple. By some definitions, this is not really a genetic algorithm because the "genome" is the same as the data being operated on (there is no "expression"), but it's a cute toy and somebody else might find it entertaining as well:



https://bitbucket.org/oofoe/ga/src/9523e44cb284aa8e9f030610d0e84e2d922ff10c/adder/?at=default">https://bitbucket.org/oofoe/ga/src/9523 ... at=default">https://bitbucket.org/oofoe/ga/src/9523e44cb284aa8e9f030610d0e84e2d922ff10c/adder/?at=default



I am currently hard at work on a new program which will use a genetic algorithm to do lossy image compression through vector shapes, just have to teach NewLisp about reading %.png files...
#6
newLISP newS / Documentation example error for import...
September 17, 2016, 07:28:10 AM
Hi!



Hope this is the best place to post this...



The first example for import at http://www.newlisp.org/downloads/newlisp_manual.html#import">http://www.newlisp.org/downloads/newlis ... tml#import">http://www.newlisp.org/downloads/newlisp_manual.html#import is incorrect. It should have the following marked line added:

(define LIBC (lookup ostype '(
("Windows" "msvcrt.dll")
("OSX" "libc.dylib")

(import LIBC "printf") ;; This line needs to be added to make example work.

(printf "%g %s %d %cn" 1.23 "hello" 999 65)

Thanks!
#7
Hi!



I have something like this:


(gs:panel 'Panel)
(gs:check-box 'Visible 'checkboxing "visible)
(gs:add-to 'Panel 'Visible)


And it's very nice. I get events when the user changes the value to my checkboxing function and so forth.



However, what if I want to set the value from the program?



(gs:set-value 'Visible true) does not work... Any suggestions?



Thanks!
#8
Hi!



Is there anything like the Python webbrowser library to launch a file in the system specific web browser?



I'm currently using (! (string "explorer.exe " pfile) 0)
where pfile is something like "c:\temp\card-preview.html", but this is very specifically Windows...



Thanks!
#9
Thanks for taking a look!



Macros are supposed to be useful for "writing the code that you would have written if you had the patience". Since guiserver uses symbols, I figured that they would be perfect for button assembly boilerplate. However, I had to cheat with sending strings to guiserver because the symbols weren't getting quoted in the correct namespace. So here I admit there's no real advantage to the macro.



It seems there's also the (macro) function, which may do more what I want. So I'll probably try it later.
#10
OK, think I've got it. Here's the revised macro:


(define-macro (button3 _parent _name _buttons)
  (letn ((panel (sym (string (eval _parent) "-" (eval _name))))
   (slots '("west" "center" "east"))
   (bname nil)
   (i nil))
  (gs:panel panel)
  (gs:set-border-layout panel)
  (dotimes (i (length (eval _buttons)))
    (setq bname (sym (string panel "-" ((eval _buttons) i 0))))
    (gs:button bname
     (if (= 3 (length ((eval _buttons) i)))
 ((eval _buttons) i 2)
 'gs:no-action)
     ((eval _buttons) i 1))
    (gs:add-to panel bname (slots i))
    ))
  )


The key is that the guiserver will accept strings instead of symbols, but you have to indicate the namespace (context):


 (button3 'DC 'West
      '((New   "new..."   "MAIN:card-new")
       (Clone "clone...")
       (Back  "<--"      "MAIN:card-back")))


This will set 'card-new and 'card-back as event handlers, but the clone button will use the default gs:no-action.



It would be nice to know how to do this with proper symbols in the macro, but this is working for now and the macro simplifies my GUI setup code quite a lot.



If anyone has any improvements to suggest, I'm all ears!
#11
newLISP Graphics & Sound / Macros and guiserver?
July 04, 2016, 05:16:16 AM
Hi!



I am experimenting with macros to do more "declarative" setups in guiserver. Here is a macro that I have created to make a three button setup:

(define-macro (button3 _parent _name _buttons)
  (letn ((panel (sym (string (eval _parent) "-" (eval _name))))
   (slots '("west" "center" "east"))
   (bname nil)
   (i nil))
  (gs:panel panel)
  (gs:set-border-layout panel)
  (dotimes (i (length (eval _buttons)))
    (setq bname (sym (string panel "-" ((eval _buttons) i 0))))
  (println "Setting up " bname)
    (gs:button bname 'gs:no-action ((eval _buttons) i 1))
    (gs:add-to panel bname (slots i))
    )))


I call it like this:

 (button3 'DC 'East  '((Next "-->") (View "<o>") (Kill "X")))


This creates a panel (DC-East) that has three buttons (DC-East-Next, DC-East-View and DC-East-Kill). They're all set up and ready to go.



However, I can't figure out how to pass in an optional event handler for each button and have the macro assemble it correctly for the gs:button call. I want to do something like this

 ;; The "View" button doesn't have a handler yet, should default to gs:no-action.
  (button3 'DC 'East  '((Next "-->" 'next-card) (View "<o>") (Kill "X" 'kill-card)))


I am just getting invalid function or macro expansion problems when I try to do this. Any suggestions?



Thanks!
#12
This looks quite interesting! I'll give it a try when I update to the new release.



Thanks for releasing it!
#13
newLISP in the real world / Using xmlrpc-client.lsp...
January 09, 2016, 05:17:43 AM
Hi!



I ran into a little problem when using %xmlrpc-client.lsp with our python/django XMLRPC server at work. It has a very strict interpretation of how many arguments it will accept for certain functions, like system.listMethods, so the default request with the single dummy argument won't work.



I wound up adding something like this to xmlrpc-client.lsp:

(define (format-request method)
  "( method /arg.../ -- XML) Compose XML request."

  (let ((xml (format
     "<?xml version="1.0"?><methodCall><methodName>%s</methodName><params>"
     method)))
    (dolist (value (args))
      (push (format "<param><value>%s</value></param>" value) xml -1))
    (push "</params></methodCall>n" xml -1)))


Then changing system.listMethods to:

(define (system.listMethods url)
    (execute url (format-request "system.listMethods")))


Technically, format-request should also determine the type of the argument values (and encode lists and dictionaries correctly), but if you're only using string arguments, it should suffice.



Maybe someone has a better format-request they could share? ; - )
#14
Christmas is early -- this works great!



The canvas-unclick function was just to show that I had tried to do a gs:update and it hadn't worked either. I wanted to give you a good example to test with.



Thanks very much!
#15
Hi! Thanks for the hint! I am working on repurposing the newlisp-edit.lsp code now.



Periodically, you call a function (set-buffer-dirty). I can't seem to find this defined in either newlisp-edit.lsp or guiserver.lsp. Is it something that I need to have?



EDIT: Actually it seems that the function was missing from v10.6.0, upgraded to v10.6.2 and I found it.