I am experiencing a long delay using Tk, where it takes 2 seconds to
update the screen. I have attached a working fragment of the application.
It's supposed to be a "Wizard style" thing, with a common label at the
top and common buttons at the bottom, and inbetween there's a frame that
changes for each page.
When the "Next" button is pressed, the children of that frame are de-
structed, and new widgets are then created within the frame. But it
takes 2 seconds for them to appear.
Is there something that I'm doing wrong?
This is Tk 8.3.0 on Linux.
Frank
namespace eval Ass {}
proc Ass::SoftpkgWizSetup1 {} {
variable softwizwidgets
variable softwizdata
$softwizwidgets(info) configure -text \
"Welcome to the Software Package Wizard. It will help\
you to build a Software Package from your Component.\
To create a Software Package, this Wizard requires a\
readily built Component - usually a shared library (DLL)\
or executable - and the corresponding IDL file. Please\
click on the \"Next\" button to proceed."
$softwizwidgets(prev) configure -state disabled
$softwizwidgets(ok) configure -state disabled
$softwizwidgets(cancel) configure -state normal
$softwizwidgets(next) configure -state normal
}
proc Ass::SoftpkgWizNext1 {} {
# nothing to do
}
proc Ass::SoftpkgWizSetup2 {} {
variable softwizwidgets
variable softwizdata
$softwizwidgets(info) configure -text \
"Please select the file that contains your Component\
implementation. Please also select whether this file\
is a shared library (DLL) or executable. If you have\
made both selections, click on the \"Next\" button."
set wiz [frame $softwizwidgets(wiz).wiz]
if {![info exists softwizdata(implfile)]} {
set softwizdata(implfile) ""
}
if {![info exists softwizdata(impltype)]} {
set softwizdata(impltype) ""
}
set f1 [frame $wiz.f1]
set f1lab [label $f1.lab -text "Implementation" -width 15 -anchor w]
set f1ent [entry $f1.ent -width 40 \
-textvariable ::Ass::softwizdata(implfile)]
set f1but [button $f1.but -width 10 \
-text "Select" -anchor c -relief raised -bd 1 \
-command "Ass::SoftpkgWizSelectImplFile $softwizwidgets(top)"]
pack $f1lab -side left
pack $f1ent -side left -fill x -expand yes
pack $f1but -side left -padx 10
pack $f1 -side top -fill x -padx 10
set empty1 [frame $wiz.empty1]
pack $empty1 -side top -fill x -pady 10
set f2 [frame $wiz.f2]
set impltypelab [label $f2.impltypelab -anchor w \
-text "This Implementation File is a ..."]
set impltype1 [radiobutton $f2.impltype1 \
-text "Shared Library (DLL)" -anchor w \
-variable ::Ass::softwizdata(impltype) -value "DLL"]
$impltype1 configure -activebackground [$impltype1 cget -bg]
set impltype2 [radiobutton $f2.impltype2 \
-text "Standalone Executable" -anchor w \
-variable ::Ass::softwizdata(impltype) -value "Executable"]
$impltype2 configure -activebackground [$impltype2 cget -bg]
pack $impltypelab $impltype1 $impltype2 -side top -fill x
pack $f2 -side top -fill x -padx 10
set empty2 [frame $wiz.empty2]
pack $empty2 -side top -fill both -expand yes
$softwizwidgets(prev) configure -state normal
$softwizwidgets(ok) configure -state disabled
$softwizwidgets(cancel) configure -state normal
$softwizwidgets(next) configure -state disabled
pack $wiz -fill both -expand yes
}
proc Ass::SoftpkgWizard {} {
variable softwizwidgets
variable softwizdata
variable status
set top [toplevel .softpkgWizard -width 600 -height 400]
wm title $top "Software Package Wizard"
set title [label $top.title -anchor center \
-font {Arial 18 bold} \
-text "Software Package Wizard"]
pack $title -side top -fill x -pady 10
#set topsep [Separator $top.topsep -orient horizontal]
#pack $topsep -side top -fill x -pady 10
set infolabel [label $top.info -wraplength 500 -height 5 \
-anchor n -justify left]
pack $infolabel -side top -fill x -pady 10
set wizardry [frame $top.wiz]
pack $wizardry -side top -fill both -expand yes
#set botsep [Separator $top.botsep -orient horizontal]
#pack $botsep -side top -fill x -pady 10
set botbuts [frame $top.botbuts]
set botbut1 [button $botbuts.but1 -width 12 \
-text "<< Previous" \
-command "set ::Ass::softwizdata(mutex) 1"]
set botbut2 [button $botbuts.but2 -width 12 \
-text "Cancel" \
-command "set ::Ass::softwizdata(mutex) 2"]
set botbut3 [button $botbuts.but3 -width 12 \
-text "OK" \
-command "set ::Ass::softwizdata(mutex) 3"]
set botbut4 [button $botbuts.but4 -width 12 \
-text "Next >>" \
-command "set ::Ass::softwizdata(mutex) 4"]
pack $botbut1 $botbut2 $botbut3 $botbut4 -side left -pady 10 -padx 10
pack $botbuts
set softwizwidgets(top) $top
set softwizwidgets(info) $infolabel
set softwizwidgets(wiz) $wizardry
set softwizwidgets(prev) $botbut1
set softwizwidgets(cancel) $botbut2
set softwizwidgets(ok) $botbut3
set softwizwidgets(next) $botbut4
set softwizdata(mutex) 0
set softwizdata(curpage) 1
set softwizdata(pagedirty) 1
wm deiconify $top
wm minsize $top 600 400
focus $top
# grab set $top
set status "Wizardry in Progress ..."
while {42} {
if {$softwizdata(pagedirty)} {
foreach subitem [winfo children $softwizwidgets(wiz)] {
catch {destroy $subitem}
}
SoftpkgWizSetup$softwizdata(curpage)
update idletasks
set softwizdata(pagedirty) 0
}
vwait ::Ass::softwizdata(mutex)
switch -- $::Ass::softwizdata(mutex) {
1 {
incr softwizdata(curpage) -1
set softwizdata(pagedirty) 1
}
2 {
break
}
3 {
if {![catch {SoftpkgWizOkay$softwizdata(curpage)}]} {
break
}
}
4 {
if {![catch {SoftpkgWizNext$softwizdata(curpage)}]} {
incr softwizdata(curpage) 1
set softwizdata(pagedirty) 1
}
}
}
}
# grab release $top
destroy $top
}
wm withdraw .
Ass::SoftpkgWizard
--
Frank Pilhofer ........................................... f...@fpx.de
Living on a budget is the same as living beyond your means, except
that now you have a record of it. - Alfred E. Neuman
I don't see a particular problem, but there was an issue with Tk and
oddly written window managers on Unix (like Enlightenment 0.15) where
'raise' would cause a 2 second delay. This isn't an issue with *twm,
openlook, cde or others. This was worked around in 8.3.3 or 8.3.4, so
you might check if the 8.3.4 corrects the problem (or upgrade your wm,
I know that Enlightenment 0.16 didn't have the problem).
--
Jeff Hobbs The Tcl Guy
Senior Developer http://www.ActiveState.com/
Tcl Support and Productivity Solutions
I'm using a fairly old version of fvwm2 here. Tk 8.3.4 does not
help.
Frank
> I'm using a fairly old version of fvwm2 here. Tk 8.3.4 does not
> help.
The same thing happens with Perl/Tk - I'm pretty sure recent fvwm2's do not
have this problem.
Steve
--
@_=map{eval"100${_}"}split/!/,'/5!*2!+$]!/10+$]';use Tk;$m=tkinit;$t='just an'.
'other perl hacker';$z='createText';$c=$m->Canvas(-wi,$_[1],-he,25)->grid;$c->$
z(@_[2,3],-te,$t,-fi,'gray50');$c->$z($_[2]-$],$_[3]-$],-te,$t);$m->bind('<En'.
'ter>',sub{$y=int(rand($m->screenheight));$m->geometry("+$y+$y")});MainLoop;
Tom Wilkason
I may have met the similar problem before.
When I adjust the size of frames or widgets the trouble disappeared.
Do not know the reasons.
Chang
Hi,
what do you mean with "adjusting the size"?
Frank
--
Frank Pilhofer ........................................... f...@fpx.de
You'll never get rid of a bad temper by losing it! - Alfred E. Neuman
After reading the appropriate manual pages, I've found a fix/workaround.
The problem seems to be caused by requesting a fixed size from the window
manager `wm minsize $top 600 400' and bad interaction with the pack geo-
metry manager trying to resize the frames.
Apart from removing the "minsize" statement, I instead requested the
main frame to have a certain size and disabled geometry propagation.
Change
>
> set wizardry [frame $top.wiz]
> pack $wizardry -side top -fill both -expand yes
>
to
set wizardry [frame $top.wiz -width 600 -height 200]
pack $wizardry -side top -fill both -expand yes
pack propagate $wizardry 0
BTW, I found that with geometry propagation enabled, the "wizardry"
frame was always later downsized to fit it slaves. I was surprised by
this behavior; I would have thought that once I assign a size, it
would be fixed - especially since that frame was already packed. But
then, I'm obviously no pack wizard yet.
Frank
--
Frank Pilhofer ........................................... f...@fpx.de
It's not just the ups and downs that make life difficult, it's the
jerks. - Alfred E. Neuman