winfo_exists
Dada
Gr.Dada at lycos.de
Mon Feb 13 14:38:09 EST 2006
I want to know, whether a window is already open or not. Following a
peace of the code.
-----
...
class Auswahlmenue:
def __init__(AM):
AM.Fenster = Toplevel()
...
AM.Fenster.destroy(); Startsortierung()
#-------------------------
class Startsortierung:
def __init__(SS):
#-------------------------
def Abbruch(xxx):
SS.Fenster_2.destroy()
#!! Abfragen, ob bereits ein Auswahlmenü geöffnet ist!
if not Auswahlmenue.Fenster.winfo_exists():
Auswahlmenue()
#-------------------------
def Auswahl(xxx):
Auswahlmenue()
#-------------------------
def weiter(xxx):
SS.Fenster_2.destroy()
#-------------------------
SS.Fenster_2 = Toplevel()
Label(SS.Fenster_2, text= u'... ...').pack()
SF = Button(SS.Fenster_2, text= u'abbrechen', underline= 0)
SF.pack(side= u'left')
SS.Fenster_2.bind(sequence= '<KeyPress-a>', func= Abbruch)
SF = Button(SS.Fenster_2, text= u'Auswahlmenü', underline= 0)
SF.pack(side= u'left')
SS.Fenster_2.bind(sequence= '<KeyPress-A>', func= Auswahl)
SF = Button(SS.Fenster_2, text= u'weiter', underline= 0)
SF.pack(side= u'right')
SS.Fenster_2.bind(sequence= '<KeyPress-w>', func= weiter)
TkFenster.wait_window(SS.Fenster_2)
----
The main programm calls the class Auswahlmenue. In this class the user
can choose Startsortierung. In this class the user may (after a
prozess) go back to Auswahlmenue without destroying the
Startsortierung-window (SS.Fenster_2), because he needs the information
shown there. Or he may go back immeaditely to Auswahlmenue via Abbruch
(destroying SS.Fenster_2 and opening AM.Fenster). In the first way the
user later will close the SS.Fenster_2-window - but how do I get the
information, the AM.Fenster is already open or not? I do not want have
two AM.Fenster open.
I hoped toget this via winfo_exists, but there´s a mistake in the
if-row.
Indeed I could do it with a global flag, but is there a possibility to
do it with winfo_exists()?
Thanks for help
Dada
More information about the Python-list
mailing list