I am trying to embed the latest tkcon (2.5):
proc console {} {
if {![info exists ::tkcon::PRIV(root)]} {
global argv argc
namespace eval ::tkcon {}
set ::tkcon::OPT(usehistory) 0
::tkcon::Init -color-bg white -font {arial 14}\
-exec {} -root .tkcon
tkcon title "some title"
tkcon attach Main
wm protocol .tkcon WM_DELETE_WINDOW {tkcon hide}
} else {
## Start a new window
set interpreter [uplevel \#0 tkcon new]
$interpeter eval tkcon eval wm protocol . WM_DELETE_WINDOW \
[list tkcon destroy]
$interpeter eval tkcon attach Main
$interpeter eval tkcon console configure \
-bg white -font {arial 14}
}
}
While opening the first tk console works, subsequent calls to "tkcon
new" result in an empty tk window. Can am I doing wrong?
George
When running this in a quick Tcl session, I found this error happened
to prevent the second one:
% console
% console
can't read "interpeter": no such variable
% set errorInfo
can't read "interpeter": no such variable
while executing
"$interpeter eval tkcon eval wm protocol . WM_DELETE_WINDOW [list
tkcon destroy]"
(procedure "console" line 13)
invoked from within
"console"
Note the spelling error.
Jeff
Dear Jeff,
I am sorry, this was just a copy/paste mistake while adapting the code
for presenting it here. The actual code is he following:
## gut_Console
# Open the a TkCon Console
proc gut_Console {} {
global tcl_platform GUI_Options
## Initialise only if we haven't yet
##
if {![info exists ::tkcon::PRIV(root)]} {
global HomeDir ApplicationName argv argc
## Set some tkcon's default values to match our look'n'feel...
namespace eval ::tkcon {}
set ::tkcon::OPT(usehistory) 0
::tkcon::Init -color-bg $GUI_Options(TextBg) -font TextFont \
-exec {} -root .tkcon
gut_ConsoleConfigure {} title "$ApplicationName Main Console..."
gut_ConsoleConfigure {} attach Main
wm protocol .tkcon WM_DELETE_WINDOW {gut_ConsoleConfigure {} hide}
## In the main console, we bind our own text popup...
bind .tkcon <<TkCon_Popup>> {}
return {}
} else {
if {[winfo exists .tkcon] && [string equal [wm state .tkcon]
withdrawn]} {
wm deiconify .tkcon
#tkcon show
return {}
} else {
set interpreter [uplevel \#0 tkcon new]
gut_ConsoleConfigure $interpreter eval wm protocol .
WM_DELETE_WINDOW \
[list tkcon destroy]
gut_ConsoleConfigure $interpreter attach Main
set font [$interpreter eval font create \
[font actual TextFont]]
gut_ConsoleConfigure $interpreter console configure \
-bg $GUI_Options(TextBg) -font $font \
-width $GUI_Options(TextWidth) -height $GUI_Options(TextHeight)
return $interpreter
}
}
}
## gut_ConsoleConfigure
proc gut_ConsoleConfigure {interpeter args} {
if {![string length $interpeter]} {
return [eval tkcon $args]
} else {
return [$interpeter eval tkcon $args]
}
}
George
Again, just run this in the console and you'll see than an error is
thrown. In this case because not enough special vars are defined
ahead of time. I think this may be a lower level bug in tkcon when
mixing the use of exec {}, but I'm not getting what you are trying to
do. I suspect it simply isn't a supported use case.
Really, all you should do is source tkcon.tcl and then do 'tkcon
show'. You can set usehistory and the protocol as well, but 'tkcon
show' is meant to handle most cases. Can you explain what the extra
magic is trying to do?
Jeff