473,387 Members | 3,820 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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

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)
================================================== ====================

Jul 19 '05 #1
6 6913
"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>

Jul 19 '05 #2
Well, but where do I call withdraw?

Jul 19 '05 #3
Forgive my ignorance, but where do I call withdraw?

Jul 19 '05 #4
"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>

Jul 19 '05 #5
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?

Jul 19 '05 #6
I've found the solution!!!!!!!! I must destroy the first window using
self.master.destroy(), but thanks anyway ^_^

Jul 19 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Fuzzyman | last post by:
I'm having trouble implementing my GUI using Tkinter...... I've been working through the Tkinter tutorials from 'Programming Python' and am generally happy enough with the functionality and feel...
5
by: Peter Moscatt | last post by:
Ok.... I am pretty new to Python (as you may have gathered from previous posts). So now it time for another one of my ridiculous questions.... :-) When using 'Tkinter', what is used as the...
0
by: Richard Townsend | last post by:
I've been experimenting with passing a window handle from a wxPython app to a Tkinter app. The Tkinter app should embed a Toplevel window containing a Canvas widget in the wxPython app's Frame (see...
6
by: William Gill | last post by:
A short while ago someone posted that(unlike the examples) you should use Tk as the base for your main window in tkinter apps, not Frame. Thus : class MyMain(Frame): def __init__(self,...
0
by: syed_saqib_ali | last post by:
Below is a simple code snippet showing a Tkinter Window bearing a canvas and 2 connected scrollbars (Vertical & Horizontal). Works fine. When you shrink/resize the window the scrollbars adjust...
1
by: syed_saqib_ali | last post by:
Below is a simple code snippet showing a Tkinter Window bearing a canvas and 2 connected scrollbars (Vertical & Horizontal). Works fine. When you shrink/resize the window the scrollbars adjust...
34
by: Alexnb | last post by:
Gerhard Häring wrote: No, it didn't work, but it gave me some interesting feedback when I ran it in the shell. Heres what it told me: Traceback (most recent call last): File...
1
by: varun chadha | last post by:
i am trying to develop a application using Tkinter in which a new window pops out on a particular button press.though i can pass control automatically to that window using .force_focus() method and...
0
by: Guilherme Polo | last post by:
On Thu, Aug 28, 2008 at 10:29 AM, <dudeja.rajat@gmail.comwrote: It is good to post a short code sample that demonstrates the problem, but it has to run by itself at least. tkMessageBox...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.