Tkinter, tkFileDialog, and checkbuttons

F

Frank Chen

Hi:

The attahced file is an example that confuses me.
When executing test.py and then click [File] menu,
you can see the menu constitutes 'New Window',
'Open File', and an activated checkbutton, 'Show toolbar'.

Now please select 'New Window', which will cause App class
to generate a child root derived from Tk(). The status of the
checkbuttons becomes unselected.

And if you select 'Open File' of child root window, the main root
Tk() will be popped up to the layer above child root.

It will be grateful if someone can tell me how to cope with this.

--Frank
 
L

Lars Behrens

Frank said:
The attahced file is an example that confuses me.

will you please write in plain text, not html. And don't use
attachements, post your text in line. Thank you.

Cheerz Lars
 
M

Michael Peuser

Frank Chen said:
Now please select 'New Window', which will cause App class
to generate a child root derived from Tk(). The status of the
checkbuttons becomes unselected.

All checkbuttons use the same variable, try:
self.checkmark=StringVar()
self.menu.menu.add_checkbutton(label='Show tool bar', underline=0,

variable=self.checkmark,
And if you select 'Open File' of child root window, the main root
Tk() will be popped up to the layer above child root.

Try:
tkFileDialog.askopenfilename(
parent=self.master,

Kindly
MichaelP

BTW there are a lot of questionable constructs in your program. You are
using 'app' as local variable in new_window which might lead to garbage
collecting the App-instance at an inapropriate situation, the packs() will
not work well when resizing the window, why do you separate initialization
from 'create'?, .......
 
C

Cameron Laird

.
.
.
BTW there are a lot of questionable constructs in your program. You are
using 'app' as local variable in new_window which might lead to garbage
collecting the App-instance at an inapropriate situation, the packs() will
not work well when resizing the window, why do you separate initialization
from 'create'?, .......
.
.
.
"... the packs() will not work ...": do you know of
a general fault in pack() that impairs their useful-
ness in all applications, or are you saying that their
use in the example originally posted was suboptimal?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,898
Latest member
BlairH7607

Latest Threads

Top