Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > opening new window in one window using Tkinter -- Help please

Reply
Thread Tools

opening new window in one window using Tkinter -- Help please

 
 
Clara
Guest
Posts: n/a
 
      04-24-2005
Hi,...
I meant to write an application where there is a button in a window and
when you click on the button, it will open a new window, but I want the
first window to close, replaced by the second window.
I open a login window and start the mainloop, when the user click on
the login button, the __call__ function of VerifyProcessor is executed
and it will call the new window which is the file manager window
The thing is,.. I don't know how to exit the first mainloop and then
display the second window...I even tried calling the mainloop again but
a weird thing happens. I really need help because otherwise I'm stuck
here and I can't complete my assignment. The following is my code:

from login import LoginMenu
app = LoginMenu()
app.master.title("Login Menu")
app.master.maxsize(300,200)
app.mainloop()
======================================
class LoginMenu(Frame):

def createWidgets(self):
self.loginButton = Button(self, text='Login', command =
VerifyProcessor(self.x, self.y, self.msg, self.messageLabel) )

def __init__(self, master=None):
Frame.__init__(self, master)
self.grid(column=6, row=4)
self.createWidgets()

class VerifyProcessor:

def __init__(self, thename, thepass, msg, msglabel):
self.username = thename
self.password = thepass
self.msgVar = msg
self.msgLabel = msglabel

def __call__(self):
import md5
import dictionaryloader
found = 0
theDict = dictionaryloader.loadFrom("Dicttxt")
entries = theDict.items()
for theuser, thepass in entries:
if self.username.get() == theuser and
md5.new(self.password.get()).hexdigest() == thepass:
found=1
from mainmenu import FileManager
app2 = FileManager(self.username.get())
app2.master.title("File Manager")
app2.master.maxsize("400,1500")
app2.mainloop()
================================================== ===================
class FileManager(Frame):

def createWidgets(self, username):
...
def __init__(self, username, master=None):
Frame.__init__(self, master)
self.grid(column=6, row=6)
self.createWidgets(username)
================================================== ====================

 
Reply With Quote
 
 
 
 
Fredrik Lundh
Guest
Posts: n/a
 
      04-24-2005
"Clara" wrote:

> I meant to write an application where there is a button in a window and
> when you click on the button, it will open a new window, but I want the
> first window to close, replaced by the second window.
> I open a login window and start the mainloop, when the user click on
> the login button, the __call__ function of VerifyProcessor is executed
> and it will call the new window which is the file manager window
> The thing is,.. I don't know how to exit the first mainloop and then
> display the second window...I even tried calling the mainloop again but
> a weird thing happens. I really need help because otherwise I'm stuck
> here and I can't complete my assignment. The following is my code:


you don't really have to start a new mainloop to create a new toplevel
window. just call "withdraw" on first window, and create the second
(as a Toplevel), and Tkinter will take care of the rest.

</F>



 
Reply With Quote
 
 
 
 
Clara
Guest
Posts: n/a
 
      04-24-2005
Well, but where do I call withdraw?

 
Reply With Quote
 
Clara
Guest
Posts: n/a
 
      04-24-2005
Forgive my ignorance, but where do I call withdraw?

 
Reply With Quote
 
Fredrik Lundh
Guest
Posts: n/a
 
      04-24-2005
"Clara" wrote:

> Well, but where do I call withdraw?


when you want the new window to appear, and the old one to
go away, of course. something like this, perhaps?

from mainmenu import FileManager
app2 = FileManager(self.username.get())
app2.master.title("File Manager")
app2.master.maxsize("400,1500")
- app2.mainloop()
+ app.master.withdraw()

</F>



 
Reply With Quote
 
Clara
Guest
Posts: n/a
 
      04-24-2005
since the file where i call the first window and the second window is
different,.If I put app.master.withdraw() there,...won't I get error
message that says; app is not defined as global or something like that?

 
Reply With Quote
 
Clara
Guest
Posts: n/a
 
      04-25-2005
I've found the solution!!!!!!!! I must destroy the first window using
self.master.destroy(), but thanks anyway ^_^

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Using property() to extend Tkinter classes but Tkinter classesare old-style classes? Terry Reedy Python 5 11-30-2010 06:49 PM
Closing child window when opening a new Window Patrick Olurotimi Ige ASP .Net 2 12-14-2004 04:59 AM
Re: [Tkinter-discuss] Please help -- Tkinter Scale widget withDoubleVar is acting weird Jeff Epler Python 0 08-23-2004 02:31 PM
Re: [Tkinter-discuss] Please help -- Tkinter Scale widget withDoubleVar is acting weird Jeff Epler Python 0 08-20-2004 12:07 PM
Opening one window while closing the current using JavaScript andPHP... Eric B Venet Javascript 0 07-31-2003 04:45 AM



Advertisments