TkInter wrapper for tcl/tk GUI: Difference between revisions
Created page with "I wanted to see how the tcl/tk interface of ASCEND looks like and used TkInter wrapper to call the tcl legacy code. Here are my notes which I will formulate in detail over t..." |
No edit summary |
||
| Line 1: | Line 1: | ||
This is a guide how you can check out the oldschool 90s tcl/tk interface of ASCEND. This is computers and chemical engineering history and worth conserving! | |||
The TkInter wrapper is used to call the tcl legacy code: | |||
https://wiki.python.org/moin/TkInter | |||
https://en.wikipedia.org/wiki/Tkinter | |||
ascend/tcltk/tk/ | |||
Here are notes which will are going to be formulated in detail over time: | |||
=== Python script to wrap the legacy tcl code with TkInter === | |||
<source lang="python"> | |||
import tkinter | |||
gui = tkinter.Tk() | |||
#Variables | |||
ASCENDTK = tkinter.StringVar() | |||
ASCENDTK.set("./") | |||
ASCENDBITMAPS = tkinter.StringVar() | |||
ASCENDBITMAPS.set("./bitmaps") | |||
TKTABLE_LIBRARY = tkinter.StringVar() #the Tktable issue hasn't been resolved yet | |||
TKTABLE_LIBRARY.set("/usr/lib/tcltk/x86_64-linux-gnu/Tktable2.10") | |||
asc_swap_del_backspace = tkinter.StringVar() | |||
asc_swap_del_backspace.set("1") # for UNIX systems | |||
argc = tkinter.IntVar() | |||
argc.set(0) | |||
#Evaluation | |||
gui.tk.eval('lappend auto_path {%s}' % './') | |||
gui.tk.eval('set env(ASCENDTK) %s' % (ASCENDTK.get())) | |||
gui.tk.eval('set env(ASCENDBITMAPS) %s' % (ASCENDBITMAPS.get())) | |||
gui.tk.eval('set asc_swap_del_backspace %s' % (asc_swap_del_backspace.get())) | |||
gui.tk.eval('set argc %s' % (argc.get())) | |||
#gui.tk.eval('package require Tktable') | |||
gui.tk.eval('source {ascend.tcl}') | |||
#Mainloop | |||
gui.mainloop() | |||
</source> | |||
=== ascend/tcltk/tk/ === | |||
{| class="infobox wikitable" style="margin-left:1em;" | {| class="infobox wikitable" style="margin-left:1em;" | ||
| Line 40: | Line 87: | ||
ascend/tcltk/interface | === ascend/tcltk/interface === | ||
{| class="infobox wikitable" style="margin-left:1em;" | {| class="infobox wikitable" style="margin-left:1em;" | ||
| Line 74: | Line 121: | ||
|} | |} | ||
=== Changes made to the codebase to get the GUI up and running with TkInter === | |||
ASC_IMPORT???: | |||
Definition at line 124 of file ascend/general/platform.h | |||
ASCENDTK: | |||
This environment variable is used to define the location of the Tcl/Tk support files | |||
used by the ASCEND Tcl/Tk GUI. It defaults to $ASCENDDIST/TK. It has no effect on the PyGTK GUI. | |||
asc_swap_del_backspace: | |||
set to "1" for unix systems | |||
__userdata_init: | |||
comment out | |||
argc: | |||
set argument counter argc to 0 | |||
tktable missing: | |||
- install via sudo apt-get install tk-table | |||
- ascend still can't find tktable | |||
- install tcl8.5-dev, tk8.5-dev, libxft-dev, libfontconfig1-dev, libfreetype6-dev, libpng-dev | |||
- error: if {[catch {package require Tktable 2.8} err]} in ascend.tcl | |||
- http://bugs.ascend4.org/view.php?id=254 | |||
- https://github.com/nbro/tktable/issues/3 | |||
- The plot window and the solver window require the | |||
- TkTable exension package by Roland King mthomas 98.05.07: require 1.8 until we debug the memory errors in 2.0 | |||
- comment the if clause block starting with line 225 in ascend.tcl out | |||
- Issue not yet resolved | |||
error because interval.c and interval.h files were missing (trunk bramch) in ascend/compiler/: | |||
bitmap "feet" not defined: | |||
- ascend.tcl line 259: awin all | |||
- awin is in GlobalProc.tcl | |||
- ShowWindow.solver in line 108 in GlobalProc.tcl | |||
- line 138 in solver.tcl | |||
- option -bitmap {feet} was removed because it couldn't be located | |||
- option -bitmap {stop} was removed | |||
Ascend starts with main GUI! Some windows or buttons still don't work. | |||
still having these error messages: | |||
Error calling set_Library_Defaults; invalid command name "libr_query | |||
Error calling set_Probe_Defaults; invalid command name "__probe" | |||
Error calling set_Solver_Defaults; invalid command name "slv_available" | |||
Error calling set_Units_Defaults; can't read "env(ASCENDDIST)": no such variable | |||
Error calling set_Help_Defaults; can't read "env(ASCENDDIST)": no such variable | |||
Revision as of 10:09, 26 December 2018
This is a guide how you can check out the oldschool 90s tcl/tk interface of ASCEND. This is computers and chemical engineering history and worth conserving!
The TkInter wrapper is used to call the tcl legacy code:
https://wiki.python.org/moin/TkInter
https://en.wikipedia.org/wiki/Tkinter
Here are notes which will are going to be formulated in detail over time:
Python script to wrap the legacy tcl code with TkInter
import tkinter gui = tkinter.Tk() #Variables ASCENDTK = tkinter.StringVar() ASCENDTK.set("./") ASCENDBITMAPS = tkinter.StringVar() ASCENDBITMAPS.set("./bitmaps") TKTABLE_LIBRARY = tkinter.StringVar() #the Tktable issue hasn't been resolved yet TKTABLE_LIBRARY.set("/usr/lib/tcltk/x86_64-linux-gnu/Tktable2.10") asc_swap_del_backspace = tkinter.StringVar() asc_swap_del_backspace.set("1") # for UNIX systems argc = tkinter.IntVar() argc.set(0) #Evaluation gui.tk.eval('lappend auto_path {%s}' % './') gui.tk.eval('set env(ASCENDTK) %s' % (ASCENDTK.get())) gui.tk.eval('set env(ASCENDBITMAPS) %s' % (ASCENDBITMAPS.get())) gui.tk.eval('set asc_swap_del_backspace %s' % (asc_swap_del_backspace.get())) gui.tk.eval('set argc %s' % (argc.get())) #gui.tk.eval('package require Tktable') gui.tk.eval('source {ascend.tcl}') #Mainloop gui.mainloop()
ascend/tcltk/tk/
| AscendRC | |
|---|---|
| ascend.tcl | env(ASCENDTK) |
| GlobalProc.tcl | set_global_defaults Glob_do_GNU set_Template_defaults asc_swap_del_backspace -> GlobalProc.tcl ; set to "1" for unix systems set_Global_Defaults {} { __userdata_init |
| View.tcl | |
| main.tcl | load_Templates Util_do_Read |
ascend/tcltk/interface
| config.h | |
|---|---|
| main.c | main() This function creates a Tcl interpreter, initializes Tcl and Tk, initializes the Ascend data structures, sets up the user's environment, sources ASCEND's startup script, and calls Tk_MainLoop so the user can interact with ASCEND. Cleans up and exits the program when Tk_MainLoop returns. This function is based on the functions Tk_Main and Tcl_AppInit from the Tk8.0 distribution. See the files tkMain.c and tkAppInit.c in the Tk sources. |
| Commands.c | __userdata_init |
| Driver.c | AscDriver() |
Changes made to the codebase to get the GUI up and running with TkInter
ASC_IMPORT???:
Definition at line 124 of file ascend/general/platform.h
ASCENDTK:
This environment variable is used to define the location of the Tcl/Tk support files used by the ASCEND Tcl/Tk GUI. It defaults to $ASCENDDIST/TK. It has no effect on the PyGTK GUI.
asc_swap_del_backspace:
set to "1" for unix systems
__userdata_init:
comment out
argc:
set argument counter argc to 0
tktable missing:
- install via sudo apt-get install tk-table
- ascend still can't find tktable
- install tcl8.5-dev, tk8.5-dev, libxft-dev, libfontconfig1-dev, libfreetype6-dev, libpng-dev
- error: if {[catch {package require Tktable 2.8} err]} in ascend.tcl
- http://bugs.ascend4.org/view.php?id=254
- https://github.com/nbro/tktable/issues/3
- The plot window and the solver window require the
- TkTable exension package by Roland King mthomas 98.05.07: require 1.8 until we debug the memory errors in 2.0
- comment the if clause block starting with line 225 in ascend.tcl out
- Issue not yet resolved
error because interval.c and interval.h files were missing (trunk bramch) in ascend/compiler/:
bitmap "feet" not defined:
- ascend.tcl line 259: awin all
- awin is in GlobalProc.tcl
- ShowWindow.solver in line 108 in GlobalProc.tcl
- line 138 in solver.tcl
- option -bitmap {feet} was removed because it couldn't be located
- option -bitmap {stop} was removed
Ascend starts with main GUI! Some windows or buttons still don't work.
still having these error messages:
Error calling set_Library_Defaults; invalid command name "libr_query
Error calling set_Probe_Defaults; invalid command name "__probe"
Error calling set_Solver_Defaults; invalid command name "slv_available"
Error calling set_Units_Defaults; can't read "env(ASCENDDIST)": no such variable
Error calling set_Help_Defaults; can't read "env(ASCENDDIST)": no such variable