TNotebookãŠã£ãžã§ããã¯ãttkã«ç»å ŽããTComboboxãTProgressbarãTSeparatorãTSizegripãšãšãã«ãæ°ãããŠã£ãžã§ããã®1ã€ã§ãã åŸæ¥ã®tkããttkãžã®ã¢ããªã±ãŒã·ã§ã³ã®åãæ¿ãã¯ãæå°éã®åŽåã§æžã¿ãŸãã ããšãã°ããã¿ã³ã®ä»£ããã«ttk :: butonãšæžãã ãã§ååãªå ŽåããããŸãã ãããšã¯å¥ã«ãã³ã³ãããã¯ã¹ã«ã€ããŠèšãããã tkã§èšè¿°ãããã¢ããªã±ãŒã·ã§ã³ã§ã¹ãã³ããã¯ã¹ãŠã£ãžã§ããã䜿çšãããããttk :: comboboxã«çœ®ãæããå Žåããã®ãŠã£ãžã§ããã¯æ¬ èœããŠããã¢ããªã±ãŒã·ã§ã³ã«è¡šç€ºãããŸãã
ããã§ããttkã®äž»ãªãã®ã¯æ°ãããŠã£ãžã§ããã§ã¯ãªãããããã®ãã¶ã€ã³ïŒãããïŒã§ãã ããŒããšã¹ã¿ã€ã«ãã«ã¹ã¿ãã€ãºããã«ã¯ãå¥ã®è°è«ã«å€ããŸãã ãããŠãããã§ç§ã¯éçºè ãå æ¥ïŒ2017幎11æ11æ¥ïŒåºãŠããçŽ æŽããããã¥ãŒããªã¢ã«ã«éããŸãïŒ
ãã€ãèªã§æžãããŠããããç§ã¯è±èªããç¥ããªããšããäºå®ã«ãããããããç§ã¯ããããšãŠãåãã§èªãã ã 圌ããèšãããã«ãããã¯ãæãè ãã®ããã«æžãããŠããŸãã
ttkãŠã£ãžã§ããã«é¢é£ããçµ±åéçºç°å¢/ãã¶ã€ããŒããããã©ããã«èå³ããããŸãã PythonãšTkinterã«ã€ããŠè©±ãå Žåãããã¯Pageããã±ãŒãžã§ãã ãã®ããã±ãŒãžã¯ãã¯ã©ã·ãã¯ãŠã£ãžã§ãããšããŒããŠã£ãžã§ããã®äž¡æ¹ããµããŒãããŠããŸãã äœããã®çç±ã§ãTSeparatoråºåãæåã¯ãµããŒããããŠããŸããã èšèšç°å¢ã¯Tclã¹ã¯ãªããèšèªã§ãã ãã®ããããã®ããã±ãŒãžã«æ»ããŸãã ããŒãžã®çŽãããªãå©ç¹ã¯ããŠã£ãžã§ãããç°¡åãã€äŸ¿å©ã«é 眮ã§ããã€ãŒãŒã«ãååšããããšã§ãã
ããããããã¯Pythonçšã§ãããTclã®æçµè£œåã«èå³ããããŸãã ã¡ããã©1幎åïŒ2016幎11æ27æ¥ïŒãTcl / Tk-designer TKproE 2.20ãçºè¡šãããŸãã ïŒ
ãŸããTSeparatoråºåãæåãå«ãŸããŠããŸãã ãã®ãã¶ã€ããŒã®ãŠããŒã¯ãªæ©èœã¯ãã»ãŒãã¹ãŠã®tcl / tkã¹ã¯ãªãããåãå ¥ããããšã§ãã
ttkãŠã£ãžã§ãããšTKproE-2.20ãã¶ã€ããŒã®äž¡æ¹ã®æ©èœãå®èšŒããããã«ãNSSããã±ãŒãžã®ããšã¬ã¬ã³ããªå°å·ããŠãŒãã£ãªãã£ppã®GUIã€ã³ã¿ãŒãã§ã€ã¹ãéçºãããŸããã ããã«ãè³æ ŒèšŒææžãå«ã蚌ææžã衚瀺ããããã¥ã¡ã³ãã®é»å眲åã衚瀺ããããã®ãã®ãããªãŠãŒãã£ãªãã£ãæ±ããããŠããŸãã ãããŠãTKproEã䜿çšããã°ã©ãã£ã«ã«ã€ã³ã¿ãŒãã§ã€ã¹ãèšèšããã³å®è£ ãããã®ã¯åœŒå¥³ã®ããã§ããã
ãŠãŒãã£ãªãã£ãšããã«ãã€ã³ããããŠããã°ã©ãã£ãã¯ã¯ãããããããŠã³ããŒãã§ããŸãã ä»ã®ãã¶ã€ããŒãšã¯ç°ãªãããã1ã€ã®éåžžã«æ¥œããé©ãã¯ãç»åïŒç»åïŒãšã¢ã€ã³ã³ãæ±ããšãã«åŸ ã£ãŠããããšã§ãã 以åã«ã€ã¡ãŒãžãPEMãšã³ã³ãŒãã£ã³ã°ã«ãå€æãããã³ãŒããã¹ã¯ãªããã«æåã§æ¿å ¥ããå¿ èŠããã£ãå Žåãã€ã¡ãŒãžãã¡ã€ã«ãæå®ããã ãã§ãTKproEããããéžæããŠå€æããŸãã
ããã§ã®å¯äžã®äžäŸ¿ã¯ããã¡ã€ã«åãå ¥åããå¿ èŠãããããšã§ãã ããããããã¯ç°¡åã«ä¿®æ£ã§ããããšãå€æããŸããã tkproe.tc lã¹ã¯ãªããã®è¡7474ããã³7516ã«ååãªã³ãŒãïŒ proc ShowWindow.tpimagesããã·ãŒãžã£ïŒ
label .tpimages.propbitmap.frame14.label12 -activebackground {#dcdcdc} \ -anchor {w} - background {#dcdcdc} -borderwidth {2} -font {Helvetica 10} \ -highlightbackground {#dcdcdc} -text {File:} -width {10}
ã³ãŒãã§çœ®ãæããïŒ
button .tpimages.propbitmap.frame14.label12 -activebackground {#dcdcdc} \ -anchor {w} -background {#dcdcdc} -borderwidth {2} -font {Helvetica 10} \ -highlightbackground {#dcdcdc} -text {File:} -width {10} \ -command { global userDir; set fileTypes {{"File image" *}}; \ set file [tk_getOpenFile -title "Find Image" -filetypes $fileTypes \ -initialdir "$userDir"]; \ .tpimages.propphoto.frame14.entry13 delete 0 end; \ .tpimages.propphoto.frame14.entry13 insert end $file; }
ãããŠãtkproe.tclã¹ã¯ãªããã®5è¡ç®ä»¥éã®ããŒã ãã£ã¬ã¯ããªãããã¡ã€ã«éžæãéå§ãããããã«ã次ã®ã³ãŒããè¿œå ããŸãã
global userDir set userDir $env(HOME)
ããã§ãç»åãå«ããã¡ã€ã«ãéžæããã«ã¯ãããã¡ã€ã«ïŒããã¿ã³ãã¯ãªãã¯ããã ãã§ãã
åžæãã人ã¯ããã®ã³ãŒããæ¹åã§ããŸããããšãã°ãéžæãããã¡ã€ã«ã®ããã©ãŒãããããã£ãŒã«ãã«å ¥åãããããã®éã§ããã©ãŒãããããã¡ã€ã«æ¡åŒµåïŒã¹ã¯ãªãŒã³ã·ã§ããã®ããã¡ã€ã«ã¿ã€ããïŒãšããŠããã©ãŒãããããšã«ãã¡ã€ã«ã®æ€çŽ¢ãæŽçããŸãã
ãã1ã€ã®äžäŸ¿ãªç¹ã¯ãmHOME set $ envïŒHOMEïŒãªã©ã®ãŠãŒã¶ãŒã®ããŒã ãã£ã¬ã¯ããªã®ååŸã§ãã ååãšããŠãããŒã ãã£ã¬ã¯ããªã¯ãã¹ã¯ãªããããã©ãããã©ãŒã ã«äŸåããªãããã«ããããã«å¿ èŠã§ãã TKproEãä»ããŠã©ãã«ãæ¿å ¥ããªãããšãå€æããŸããã TKproEã®ã°ããŒãã«å€æ°ã¯ãTPinitVarsããã·ãŒãžã£ãä»ããŠå®çŸ©ãããŸãã åœç¶ãã°ããŒãã«å€æ°ã®ã¹ã³ãŒãã䜿çšããŠmHOMEå€æ°ãå®çŸ©ããå ŽåïŒ
mHomeå€æ°ã®å€ã¯ã$ envïŒHOMEïŒãã«ãªããŸãã ãã³ã§çŸåšã®ãã£ã¬ã¯ããªã®èšç®ãåããã¹ã¯ãªããã®æ¬äœã«æ¿å ¥ããããã«æãããŸãã TKproEã§ã¹ã¯ãªãããç·šéããªãéããã§ããŸãã ãã以å€ã®å ŽåãTKproEã¯æé©åãåŠçããèšå®ã³ãŒãã®ä»£ããã«ãnHOME $ envïŒHOMEïŒã¯ãã¹ã¯ãªãããäœæ/ç·šéãããã³ã³ãã¥ãŒã¿ãŒã®ããŒã ãã£ã¬ã¯ããªãå«ãã³ãŒããã°ããŒãã«å€æ°åæåæé ã«æ¿å ¥ããŸãã ããã¯ã²ã©ãã§ãã
ããã§ãç§ã¯TKproEã³ãŒãã2åç®ã«ããªããã°ãªããŸããã§ããã ã°ããŒãã«å€æ°myHOMEã®å®çŸ©ãšãçæãããã¹ã¯ãªããã«è¿œå ã³ãŒããå«ããããšã§ããã®ç¶æ³ããæãåºãæ¹æ³ãèŠã€ããŸããã ãããã£ãŠãè¡ïŒ13çªç®ïŒã®çŽåŸã®TP_Clone_appããã·ãŒãžã£ã§ïŒ
set outstr "# Generated by TKproE $TPinfo(revision) - [clock format [clock seconds]]\n\n"
è¡ãè¿œå
append outstr "#Add me\nencoding system utf-8\nglobal myHOME\nset myHOME \$env(HOME)\n\n"
è¡ïŒ10çªç®ïŒã®åŸã®TP_Clone_variablesããã·ãŒãžã£ãž
foreach varname $varlist {
ã³ãŒããæ¿å ¥ãã
if { $varname == "myHOME" } { continue }
ããã«ãããã°ããŒãã«å€æ°myHOMEã®ãªã»ãããç¡å¹ã«ãªããŸãã
ãããŠããããã®æ¹åã®åŸãPPãŠãŒãã£ãªãã£çšã®ã°ã©ãã£ã«ã«ã·ã§ã«ãäœæããããšãã§ããŸããã
ããã¥ã¡ã³ããå«ããã¡ã€ã«ãéžæããŠããŠã£ã³ããŠã«è¡šç€ºããã¿ã³ãã¯ãªãã¯ãããšã次ã®ããã«è¡šç€ºãããŸãã
蚌ææžã®å°å·ç©ã¯ãä»ã®ããã¥ã¡ã³ããšåæ§ã«ããã¡ã€ã«ã«ä¿åã§ããŸãïŒ[蚌ææžãªã©]ã¿ãã®[ãã¡ã€ã«ã«ä¿å]ãã¿ã³ïŒã
TKproEãããžã§ã¯ãã§ãããGUIPPã¹ã¯ãªããã®ãœãŒã¹ã³ãŒãã¯ãããããããŠã³ããŒãã§ããŸãã
äžèšã§ã¯ãããŒãžãã¶ã€ããŒã«æ»ãããšã«ã€ããŠèª¬æããŸããã ããŒãžãã¶ã€ãã§ã¯ããŠã£ãžã§ããïŒå ŽæïŒãèªç±ã«é 眮ããŠGUIãèšèšãããšéåžžã«äŸ¿å©ã§ãã æ¢ã«è¿°ã¹ãããã«ãGUIãããžã§ã¯ãã¯ããŒãžãã¶ã€ãã«ãã£ãŠTcl / Tkã¹ã¯ãªãããšããŠä¿åãããŸããTKproEã®ããŒãžããæ¢è£œã®ã¹ã¯ãªããã䜿çšããããæåã§è¿œå ããã®ã¯é åçã§ãã çŽç²ãªåœ¢åŒã§ã¯ãPageã®ãããžã§ã¯ããå®è¡ããããTKproE-2.20ã«ããŒããããããããšã¯ã§ããŸããã ãã®ãäžæ£ããæé€ããããã«ãPageãããããžã§ã¯ããå®è¡ãããtcl / tkã¹ã¯ãªããã«ç§»è¡ããtclã¹ã¯ãªãããéçºãããŸããã
sh-4.3$ ./fromPageToTcl.tcl Usage: ./fromPageToTcl.tcl <file tcl from Page> sh-4.3$
PageToTcl.tclã®tclã¹ã¯ãªããã³ãŒãã¯æ¬¡ã®ãšããã§ãã
PageToTcl.tclããã®Tclã¹ã¯ãªããã³ãŒã
#!/usr/bin/tclsh # 1 -- source file # return # if {[winfo exists $base]} { #### wm deiconify $base; return # } # ## vTcl:FireEvent $base <<Ready>> # namespace eval vTcl::widgets::ttk::sizegrip { proc CreateCmd {target args} { grid [ttk::sizegrip $target] -column 999 -row 999 -sticky se } } proc vTcl:font:add_GUI_font {font_name font_descr} { # This is called when we load an existing GUI-tcl file. It get rid # of actual fonts and replaces them with the definitions from the # GUI-tcl file. #set font_descr [font configure $font_name] if {[catch { font delete $font_name set newfont [font create $font_name {*}$font_descr ] } result]} { # Create failed set newfont "TkDefaultFont" } #set newkey NEEDS WORK #set ::vTcl(fonts,$newfont,type) $font_type #set ::vTcl(fonts,$newfont,key) $newkey set ::vTcl(fonts,$newfont,font_descr) $font_descr set ::vTcl(fonts,$font_descr,object) $newfont ;# Rozen 8/24/13 #set ::vTcl(fonts,$newkey,object) $newfont } proc {vTcl:font:add_font} {font_descr font_type {newkey {}} {check_fonts {1}}} { global vTcl ## This procedure may be used free of restrictions. ## Exception added by Christian Gavin on 08/08/02. ## Other packages and widget toolkits have different licensing requirements. ## Please read their license agreements for details. # With tk you are not allowed to specify the the font name when # creating a fomt. So if you want to assign a name to a font then # specify then the variable ::vTcl(fonts,$newkey,object) will hold # the correspondance between the actual name of the created name # and the name you wish to use. Rozen set defined_fonts [font names] if {$newkey != ""} { if {[info exists ::vTcl(fonts,$font_descr,object)]} { set test_font $::vTcl(fonts,$font_descr,object) if {[lsearch $defined_fonts $newkey] == -1} { set ::vTcl(fonts,$newkey,object) $test_font return $test_font } } } if {$check_fonts} { if {[info exists ::vTcl(fonts,$font_descr,object)]} { # It already exists return $::vTcl(fonts,$font_descr,object) } if {[lsearch $defined_fonts $font_descr] > -1} { # It's a font already defined.. return $font_descr } } incr ::vTcl(fonts,counter) set newfont [eval font create $font_descr] lappend ::vTcl(fonts,objects) $newfont ## each font has its unique key so that when a project is ## reloaded, the key is used to find the font descriptio if {$newkey == ""} { set newkey vTcl:font$::vTcl(fonts,counter) ## let's find an unused font key while {[vTcl:font:get_font $newkey] != ""} { incr ::vTcl(fonts,counter) set newkey vTcl:font$::vTcl(fonts,counter) } } set ::vTcl(fonts,$newfont,type) $font_type set ::vTcl(fonts,$newfont,key) $newkey set ::vTcl(fonts,$newfont,font_descr) $font_descr set ::vTcl(fonts,$font_descr,object) $newfont set ::vTcl(fonts,$newkey,object) $newfont lappend ::vTcl(fonts,$font_type) $newfont ## in case caller needs it return $newfont } proc vTcl:DefineAlias {abcde} { # puts \"$a.$b\" # puts \"$c.$d.$e\" return } proc Window {type w} { if {$w == "."} { return } toplevel $w set base $w vTclWindow$w $base } #END set largv [llength $argv] if {$largv != 1} { puts "Usage: [info script] <file tcl from Page>\n" exit } set fconf [file exists "$argv"] if { $fconf == "0" } { puts "File=\"$argv\" don't exist\n" puts "Usage: [info script] <file tcl from Page>\n" exit } set srcMy [info script] set fp [open $srcMy r] while {![eof $fp]} { gets $fp res puts $res if { $res == "#END"} { break } } close $fp # Page set fp [open $argv r] while {![eof $fp]} { gets $fp res if { [string first "wm deiconify \$base; return" $res] != -1 } { puts "#Soft" puts "\t\twm deiconify \$base;" continue } if { [string first "vTcl:FireEvent \$base <<Ready>>" $res] != -1 } { puts "#Soft" puts "#\tvTcl:FireEvent \$base <<Ready>>" continue } </spoiler> if { [string first "vTcl:toplevel \$top -class Toplevel \\" $res] != -1 } { puts "#Soft" puts "#vTcl:toplevel \$top -class Toplevel \\" puts "\$top configure \\" continue } if { [string first "vTcl::widgets::core::toplevel::createCmd \$top -class Toplevel \\" $res] != -1 } { puts "#Soft" puts "#vTcl::widgets::core::toplevel::createCmd \$top -class Toplevel \\" puts "\$top configure \\" continue } puts $res } close $fp exit
ãããŠããã©ã«ãã/ page / examples / complexãããµã³ãã«ãååŸããfromPageToTcl.tclã¹ã¯ãªããã䜿çšããŠå®è¡å¯èœãªtcl-scriptãååŸããŸãã
sh-4.3$cd ~/page/examples/complex sh-4.3$ ./fromPageToTcl.tcl complex.tcl > complex_new.tcl sh-4.3$
ä»ãéåžžã«è¯ãã³ãŒããååŸããããã«ãTKproE-2.20ãã¶ã€ããŒã§çµæã®complex_new.tclã¹ã¯ãªãããéããäžèŠã«ãªã£ããã¹ãŠã®ããã·ãŒãžã£ããããžã§ã¯ãããåé€ããŸããããã¯Windowããã·ãŒãžã£ãšvTclãã¬ãã£ãã¯ã¹ãæã€ãã¹ãŠã®ããã·ãŒãžã£ã§ãåä¿åããŸãã
Pageã¯ãã¹ã¯ããŒã«ãŠã£ãžã§ãããããµããŒãããŸããããã¡ãããµããŒãããŠããŸããã
äžè¬ã«ãTKproEãã¶ã€ããŒã¯éåžžã«è¯ãå°è±¡ãæ®ãã圌ãšGUIã®éçºããªãŒãããããšã¯æ¥œããã§ãã ãã¶ã€ããŒPageãTKproEãããã³fromPageToTcl.tclã®ã¹ã¯ãªããã§æ§æãããããªãã«Page x TKproE x fromPageToTcl.tclã¯ããŸãã«çŽ æŽãããäžäœäžäœã§ãã