Python Forum
what is this tcl GUI code? - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: GUI (https://python-forum.io/forum-10.html)
+--- Thread: what is this tcl GUI code? (/thread-3202.html)



what is this tcl GUI code? - Luke_Drillbrain - May-05-2017

I've been busy learning tkinter so that I can create GUIs.  I'm making progress via Bucky's tutorials.  In the process, I happened upon a different GUI tutorial using a WYSIWYG editor named Page.  With that, I created the following GUI:

[Image: TCL_test.png]

That's not an application I'm planning on creating.  I was just testing out this tool.  However, the code generated was not tkinter.  It was something called tcl.  Here's that code:

#############################################################################
# Generated by PAGE version 4.8.9
# in conjunction with Tcl version 8.6
set vTcl(timestamp) ""


set vTcl(actual_gui_bg) #d9d9d9
set vTcl(actual_gui_fg) #000000
set vTcl(actual_gui_menu_bg) #d9d9d9
set vTcl(actual_gui_menu_fg) #000000
set vTcl(complement_color) #d9d9d9
set vTcl(analog_color_p) #d9d9d9
set vTcl(analog_color_m) #d9d9d9
set vTcl(active_fg) #000000
set vTcl(actual_gui_menu_active_bg)  #d8d8d8
set vTcl(active_menu_fg) #000000
#################################
#LIBRARY PROCEDURES
#


if {[info exists vTcl(sourcing)]} {

proc vTcl:project:info {} {
    set base .top37
    namespace eval ::widgets::$base {
        set dflt,origin 0
        set runvisible 1
    }
    set site_3_0 $base.fra39
    set site_3_0 $base.fra45
    namespace eval ::widgets_bindings {
        set tagslist _TopLevel
    }
    namespace eval ::vTcl::modules::main {
        set procs {
        }
        set compounds {
        }
        set projectType single
    }
}
}

#################################
# USER DEFINED PROCEDURES
#

#################################
# GENERATED GUI PROCEDURES
#

proc vTclWindow.top37 {base} {
    if {$base == ""} {
        set base .top37
    }
    if {[winfo exists $base]} {
        wm deiconify $base; return
    }
    set top $base
    ###################
    # CREATING WIDGETS
    ###################
    vTcl::widgets::core::toplevel::createCmd $top -class Toplevel \
        -background {#d9d9d9} 
    wm focusmodel $top passive
    wm geometry $top 600x450+431+229
    update
    # set in toplevel.wgt.
    global vTcl
    set vTcl(save,dflt,origin) 0
    wm maxsize $top 1585 870
    wm minsize $top 1 1
    wm overrideredirect $top 0
    wm resizable $top 1 1
    wm deiconify $top
    wm title $top "New Toplevel 1"
    vTcl:DefineAlias "$top" "Toplevel1" vTcl:Toplevel:WidgetProc "" 1
    frame $top.fra39 \
        -borderwidth 2 -relief groove -background {#d9d9d9} -height 55 \
        -width 565 
    vTcl:DefineAlias "$top.fra39" "Frame1" vTcl:WidgetProc "Toplevel1" 1
    set site_3_0 $top.fra39
    button $site_3_0.but40 \
        -activebackground {#d9d9d9} -background {#d9d9d9} \
        -foreground {#000000} -highlightcolor black -text OK 
    vTcl:DefineAlias "$site_3_0.but40" "btnOK" vTcl:WidgetProc "Toplevel1" 1
    button $site_3_0.but41 \
        -activebackground {#d9d9d9} -background {#d9d9d9} \
        -foreground {#000000} -highlightcolor black -text Cancel 
    vTcl:DefineAlias "$site_3_0.but41" "btnCancel" vTcl:WidgetProc "Toplevel1" 1
    button $site_3_0.but43 \
        -activebackground {#d9d9d9} -background {#d9d9d9} \
        -foreground {#000000} -highlightcolor black -text Yes 
    vTcl:DefineAlias "$site_3_0.but43" "btnYes" vTcl:WidgetProc "Toplevel1" 1
    button $site_3_0.but44 \
        -activebackground {#d9d9d9} -background {#d9d9d9} \
        -foreground {#000000} -highlightcolor black -text No 
    vTcl:DefineAlias "$site_3_0.but44" "btnNo" vTcl:WidgetProc "Toplevel1" 1
    place $site_3_0.but40 \
        -in $site_3_0 -x 20 -y 10 -width 97 -relwidth 0 -height 26 \
        -relheight 0 -anchor nw -bordermode ignore 
    place $site_3_0.but41 \
        -in $site_3_0 -x 240 -y 10 -anchor nw -bordermode ignore 
    place $site_3_0.but43 \
        -in $site_3_0 -x 130 -y 10 -anchor nw -bordermode ignore 
    place $site_3_0.but44 \
        -in $site_3_0 -x 190 -y 10 -anchor nw -bordermode ignore 
    frame $top.fra45 \
        -borderwidth 2 -relief groove -background {#d9d9d9} -height 105 \
        -width 205 
    vTcl:DefineAlias "$top.fra45" "Frame2" vTcl:WidgetProc "Toplevel1" 1
    set site_3_0 $top.fra45
    radiobutton $site_3_0.rad47 \
        -activebackground {#d9d9d9} -background {#d9d9d9} \
        -foreground {#000000} -highlightcolor black -justify left \
        -text English -variable {} 
    vTcl:DefineAlias "$site_3_0.rad47" "rdoEnglish" vTcl:WidgetProc "Toplevel1" 1
    radiobutton $site_3_0.rad48 \
        -activebackground {#d9d9d9} -background {#d9d9d9} \
        -foreground {#000000} -highlightcolor black -justify left \
        -text French -variable {} 
    vTcl:DefineAlias "$site_3_0.rad48" "rdoFrench" vTcl:WidgetProc "Toplevel1" 1
    radiobutton $site_3_0.rad49 \
        -activebackground {#d9d9d9} -background {#d9d9d9} \
        -foreground {#000000} -highlightcolor black -justify left \
        -text German -variable {} 
    vTcl:DefineAlias "$site_3_0.rad49" "rdoGerman" vTcl:WidgetProc "Toplevel1" 1
    radiobutton $site_3_0.rad50 \
        -activebackground {#d9d9d9} -background {#d9d9d9} \
        -foreground {#000000} -highlightcolor black -justify left \
        -text Spanish -variable {} 
    vTcl:DefineAlias "$site_3_0.rad50" "rdoSpanish" vTcl:WidgetProc "Toplevel1" 1
    label $site_3_0.lab51 \
        -background {#d9d9d9} -foreground {#000000} \
        -text {Select your language} 
    vTcl:DefineAlias "$site_3_0.lab51" "lblSelectLang" vTcl:WidgetProc "Toplevel1" 1
    place $site_3_0.rad47 \
        -in $site_3_0 -x 10 -y 10 -anchor nw -bordermode ignore 
    place $site_3_0.rad48 \
        -in $site_3_0 -x 10 -y 40 -anchor nw -bordermode ignore 
    place $site_3_0.rad49 \
        -in $site_3_0 -x 110 -y 10 -anchor nw -bordermode ignore 
    place $site_3_0.rad50 \
        -in $site_3_0 -x 110 -y 40 -anchor nw -bordermode ignore 
    place $site_3_0.lab51 \
        -in $site_3_0 -x 20 -y 70 -anchor nw -bordermode ignore 
    listbox $top.lis52 \
        -background white -font TkFixedFont -foreground {#000000} -height 154 \
        -width 544 
    .top37.lis52 configure -font TkFixedFont
    .top37.lis52 insert end text
    vTcl:DefineAlias "$top.lis52" "lstInfo" vTcl:WidgetProc "Toplevel1" 1
    ###################
    # SETTING GEOMETRY
    ###################
    place $top.fra39 \
        -in $top -x 20 -y 10 -width 565 -relwidth 0 -height 55 -relheight 0 \
        -anchor nw -bordermode ignore 
    place $top.fra45 \
        -in $top -x 200 -y 80 -width 205 -relwidth 0 -height 105 -relheight 0 \
        -anchor nw -bordermode ignore 
    place $top.lis52 \
        -in $top -x 20 -y 200 -width 544 -relwidth 0 -height 154 -relheight 0 \
        -anchor nw -bordermode ignore 

    vTcl:FireEvent $base <<Ready>>
}

#############################################################################
## Binding tag:  _TopLevel

bind "_TopLevel" <<Create>> {
    if {![info exists _topcount]} {set _topcount 0}; incr _topcount
}
bind "_TopLevel" <<DeleteWindow>> {
    if {[set ::%W::_modal]} {
                vTcl:Toplevel:WidgetProc %W endmodal
            } else {
                destroy %W; if {$_topcount == 0} {exit}
            }
}
bind "_TopLevel" <Destroy> {
    if {[winfo toplevel %W] == "%W"} {incr _topcount -1}
}

Window show .
Window show .top37
I had hoped that this Page tool would generate tkinter code, which is the type of GUI code I've been studying.  However, it would appear that it doesn't.  Would it be worth it to learn this tcl type of code so that I have the option of using this kind of cool WYSIWYG tool? 

I guess I have all kinds of options.  When I was browsing Bucky's Youtube page, I found that he also had tutorials on how to create your GUI using GTK.  However, I would only want to take the time to learn that if it offers some kind of advantage over tkinter.  I guess that's an option too, as is using PyQT5.  A google of PyQT5 yielded some results of people praising it pretty highly.  

On the other hand, I have been able to create some effective GUIs with tkinter, though I must admit they have a very rudimentary look to them.


RE: what is this tcl GUI code? - Larz60+ - May-05-2017

It's Tcl/Tk see: https://www.tcl.tk/
tkinter is a wrapper around tk. So this is bypassing that step.
The concept was started back in 1987, with the actual Tk being started late 1988.


RE: what is this tcl GUI code? - chesschaser - May-20-2020

If you want to know how to create a simple window:

from tkinter import *
window = Tk()
window.title("My First Window")



RE: what is this tcl GUI code? - DT2000 - May-21-2020

chesschaser… you seem to have forgotten a line that is required.
from tkinter import *
window = Tk()
window.title("My First Window")
window.mainloop()