Tk (or other) GUI in newLisp (single executable)

Started by solomon243, November 24, 2016, 01:18:43 PM

Previous topic - Next topic

solomon243

how to make it?

without Java runtime environment

Lutz

#1
http://www.newlisp.org/newlisp-10.7.0/examples/tcltk.lsp">http://www.newlisp.org/newlisp-10.7.0/e ... /tcltk.lsp">http://www.newlisp.org/newlisp-10.7.0/examples/tcltk.lsp



http://www.newlisp.org/index.cgi?page=Tk_and_newLISP">http://www.newlisp.org/index.cgi?page=Tk_and_newLISP

TedWalther

#2
Lutz, what happened to newlisp-tk?  Was it similar to tkinter in Python?  Did the wrapper code stop working?
Cavemen in bearskins invaded the ivory towers of Artificial Intelligence.  Nine months later, they left with a baby named newLISP.  The women of the ivory towers wept and wailed.  \"Abomination!\" they cried.

Lutz

#3
The Tcl/Tk based newLISP GUI in was abandoned in version 9.1.9 in 2007 when the Java based Guiserver was introduced. Since then some minor changes where necessary to adapt to changes in the newLISP API. HPW from http://hpwsoft.de">http://hpwsoft.de made some necessary changes to the newlisp-tk script for subsequent versions of newLISP. Not sure if he still maintains a working version.

HPW

#4
Hello,



My version from 2011 was posted here:



http://www.newlispfanclub.alh.net/forum/viewtopic.php?f=9&t=3902&p=19367&hilit=newlisptk.zip#p19367">http://www.newlispfanclub.alh.net/forum/viewtopic.php?f=9&t=3902&p=19367&hilit=newlisptk.zip#p19367



However I still run a version with the current newlisp version but build not with freewrap as the 2011 version,

instead I use the TCL basekit 8.5.14 from Active State in 2015.



http://www.hpwsoft.de/anmeldung/html1/newLISP/newlisptk_85.zip">http://www.hpwsoft.de/anmeldung/html1/n ... ptk_85.zip">http://www.hpwsoft.de/anmeldung/html1/newLISP/newlisptk_85.zip



When I remember right there were some problem wtih the browser/edit and debugger subwindows.

Runs the demo.lsp fine.



Regards
Hans-Peter

solomon243

#5
Quote from: "HPW"


My version from 2011 was posted here:



http://www.newlispfanclub.alh.net/forum/viewtopic.php?f=9&t=3902&p=19367&hilit=newlisptk.zip#p19367">http://www.newlispfanclub.alh.net/forum/viewtopic.php?f=9&t=3902&p=19367&hilit=newlisptk.zip#p19367



However I still run a version with the current newlisp version but build not with freewrap as the 2011 version,

instead I use the TCL basekit 8.5.14 from Active State in 2015.



http://www.hpwsoft.de/anmeldung/html1/newLISP/newlisptk_85.zip">http://www.hpwsoft.de/anmeldung/html1/n ... ptk_85.zip">http://www.hpwsoft.de/anmeldung/html1/newLISP/newlisptk_85.zip



Regards




Thanks!!

TedWalther

#6
HPW, thank you.  I never used newlisp-tk back when it was maintained.  Can you explain how it works?  Is it an exe that combines tcl/tk and newlisp into one binary, and then tcl/tk shows up as a "tk" or "tcl" function that you send strings to?  What is involved in updating it?  I'd like to use it on Linux and Mac OSX also.  I think.  Is the demo.lsp available somewhere?
Cavemen in bearskins invaded the ivory towers of Artificial Intelligence.  Nine months later, they left with a baby named newLISP.  The women of the ivory towers wept and wailed.  \"Abomination!\" they cried.

HPW

#7
QuoteCan you explain how it works? Is it an exe that combines tcl/tk and newlisp into one binary,


It is a combination of 2 exe. Tcl/tk and the normal newlisp.exe

Both are communicating via TcpIp and are visible in the process list.

Lutz created the newlisptk.tcl file whiich contains everything.

He used freewrap to bind all together to the original Editor enviroment.

When a Tcl package manager is used, you can use it's internal file System.

Newlisp can call tcl-commands and the other way round.



Demo.lsp is only the main file of the original demo by Lutz.

It has a few additional lsp-files for each demo part.

They were bundled with the newlisp Distribution supporting Tk.



I can take a look and grap them together and add it to the zip.



Edit: http://freewrap.sourceforge.net/">http://freewrap.sourceforge.net/



Regards
Hans-Peter

HPW

#8
Hello,



I updated the zip with the demo-files and the tcl-editor file.

I also forgot to mention that you will need a TclTK install and the Bwidget toolset for TK to build/wrap your own package. (I have not tested the newest TClTk versions)



Regards
Hans-Peter

HPW

#9
Hello,



After testing my upload on my win-tablet, I noticed that I had set the imageDir in the config file to a path on my development-pc. So on the tablet I get an error about button-icon not found.

Since the icon were packed into the app, the tcl code needed to be modified to use the embedded icons.



I upload a new zip with the modification.

set Ide(imageDir) "TclApp"


When this is set in the config, the internal icons are loaded.



Regards
Hans-Peter

TedWalther

#10
Thanks HPW!
Cavemen in bearskins invaded the ivory towers of Artificial Intelligence.  Nine months later, they left with a baby named newLISP.  The women of the ivory towers wept and wailed.  \"Abomination!\" they cried.

newBert

#11
Just to inform: on my linux, I usually use this little module (a lightly modified 'runtk') :


;;;;
;;;; Module 'tk'
;;;; newLISP + tk  ('runtk' légèrement modifié - avril 2015)
;;;;
;;;; d'après runtk v 1.4 updated for 10.1 LM Nov 27th, 2009
;;;; original version by Fanda:
;;;;     http://www.intricatevisions.com/index.cgi?page=newlisp
;;;; Run programs written for newlisp-tk without without it
;;;; Only newLISP and a installation of Tcl/Tk is required.
;;;;
;;;; - faire (load "tk") en tête de script          
;;;; - écrire les commandes Tk à l'aide de la fonction (tk ...) qui accepte
;;;;   des chaîne de caractères comme arguments (arguments of 'tk' are strings)
;;;; - ajouter (tk-mainloop) en fin de script   (event loop)  
;;;;

;;; Installer les communications avec Tcl/Tk
(map set '(myin tcout) (pipe))
(map set '(tcin myout) (pipe))
(process "/usr/bin/wish" tcin tcout)

;;; La fonction 'tk' envoie des commandes à Tcl/Tk et retourne les erreurs éventuelles
(define (tk)
  (write-line myout (append "if { [catch { puts ["
              (apply string (args)) "] }] } { "
              [text] tk_messageBox -message $errorInfo; exit }
    [/text]))
   
    (let (str "")
        (while (starts-with (setq str (read-line myin)) "newLISP:")
            (eval-string ((length "newLISP: ") -1 str)))
        str))

(global 'tk)

;;; Sortir à la fermeture de la fenêtre principale
(tk "bind . <Destroy> {puts {(exit)}}")

;;; Boucle événementielle qui traite les requêtes entrantes de newLISP
(define (tk-mainloop)
    (while (read-line myin)
        (eval-string (current-line))))      
;;; NB : il faut ajouter cette fonction à la fin d'un script "newLISP-tk"


and this is a quick and succinct example of application (sorry for partial translation on the run):


(load "tk")

;;; Variables globales
(set 'x1 2 'y1 2)
(set 'x2 (+ x1 40) 'y2 (+ y1 40))
(set 'dx 8 'dy 0)
(set 'coor (string " " x1 " " y1 " " x2 " " y2 " "))
(set 'commut 0)

;;; Procédures gérant les événements
(define (arreter)
    ;; arrêter l'animation
    (setq commut 0))
   
(define (demarrer)
    ;; démarrer l'animation
    (++ commut)
    (if (= commut 1) (animer)))
   
(define (quitter)
    ;; quitter Tk et newLISP
    (tk "exit")
    (exit))
   
;;; Procédure principale
(define (animer)
    ;; déplacer la balle
    (setq x1 (+ x1 dx) y1 (+ y1 dy))
    (setq x2 (+ x1 40) y2 (+ y1 40))
    (setq coor (string " " x1 " " y1 " " x2 " " y2 " "))
    (if (> x1 360)
        (setq x1 360 dx 0 dy 8))
    (if (> y1 360)
        (setq y1 360 dx (- 8) dy 0))
    (if (< x1 2)
        (setq x1 2 dx 0 dy (- 8)))
    (if (< y1 2)
        (setq y1 2 dx 8 dy 0))
    (tk ".canevas coords " balle coor)
    (if (> commut 0)
        (tk "after 20 {puts (animer)}")))
       
;;;
;;; Programme principal
;;;

(tk "wm title . {Animation with newLISP & tk}        
     wm geometry . +200+200                        
     . configure -background DarkGrey")
                   
(tk "canvas .canevas -bg snow -height 400 -width 400        
     pack   .canevas -side left -padx 4 -pady 4")
     
;; Créer et afficher la forme (balle rouge)
(setq balle
    (tk ".canevas create oval " coor " -width 1 -fill red"))

;; Créer et placer les boutons de commande
(setq style
    (join '(" -width 10"                
            " -background RoyalBlue4"
            " -foreground white"
            " -activebackground RoyalBlue4"
            " -activeforeground orange"
            " -font {arial 10 bold}"))) ; 'style' des boutons
                   
(tk "button .demarrer -text Start -command {puts (demarrer)}" style)
(tk "button .arreter -text Stop  -command {puts (arreter) }"  style)
(tk "button .quitter -text Quit  -command {puts (quitter) }"  style)
(tk "pack .demarrer .arreter -padx 4 -pady 4")
(tk "pack .quitter -side bottom -padx 4 -pady 4")

;;;
;;; Scruter les requêtes entrantes de newLISP (boucle Tk)
;;;
(tk-mainloop)
<r><I>>Bertrand<e></e></I> − <COLOR color=\"#808080\">><B>newLISP<e></e></B> v.10.7.6 64-bit <B>>on Linux<e></e></B> (<I>>Linux Mint 20.1<e></e></I>)<e></e></COLOR></r>