Hello
I am currently designing my first GUI and am having difficulties opening and closing new windows. I have been looking for ideas for sometime now, however when ever I fit them into my code it does not seem to work.
What I am trying to do is open up a fresh window when a button is clicked and closing or hiding the master window.
I've attached my code and any assistance would be appriciated.
B
3 2436
You can use withdraw and deiconify on a frame. A simple example that will close and open a Frame or a top level/root ("window" is a generic term and not specific enough for your question). You can also create an entirely new frame within Toplevel with a button click's callback. - import Tkinter
-
-
class TestClass():
-
-
def __init__(self):
-
self.top = Tkinter.Tk()
-
self.top.title("Test")
-
self.top.geometry("200x150+500+5")
-
-
frame_1 = Tkinter.Toplevel()
-
frame_1.title("frame 1")
-
-
but_1 = Tkinter.Button(self.top, text='DeIconify',
-
command=frame_1.deiconify)
-
but_1.pack(side="bottom", fill=Tkinter.X, expand=1)
-
-
but_2 = Tkinter.Button(self.top, text='Quit',
-
command=self.top.quit, bg='blue', fg='yellow')
-
but_2.pack(side="bottom", fill=Tkinter.X, expand=1)
-
-
can_1 = Tkinter.Canvas(frame_1)
-
can_1.pack()
-
can_1.create_rectangle(50,50,100,100, outline='white', fill='black')
-
-
cont = Tkinter.Button(frame_1, text='Withdraw',
-
command=frame_1.withdraw, bg='red', fg='white' )
-
cont.pack(side="bottom", fill=Tkinter.X, expand=1)
-
-
-
self.top.mainloop()
-
-
##====================================================================
-
if __name__ == '__main__':
-
CT=TestClass()
Hi dwblas
Many thanks for taking the time to reply. I'm not sure if the code you have sent will do what I intend it to.
Effectivley, upon the click of a button I would like one frame to close and also another frame to open a bit like a 'next' button.
Kind regards
B
Use deiconify (or destroy) to close one frame, and add a new Frame class for the new window.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Ali |
last post by:
When I open a window using the Tkinter GUI thing the title bar always
says "Tk". I would like to know how to change this. I would also like
to know how to cjange it on any other popup windows I may...
|
by: Pekka Niiranen |
last post by:
Hi there,
after reading TkInter/thread -recipe:
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/82965
I wondered if it was possible to avoid using threads
for the following problem:
...
|
by: Blair Hall |
last post by:
I have a requirement to prevent 'accidental' tampering
with some software written in Python. If I ensure that all
of the modules concerned are compiled into .pyc's, and remove
the .py's to another...
|
by: ³Â Ñô |
last post by:
I write a program with Python 2.4 + Tkinter
Execute it, there will be a window show something.
If I minimize it, it will be minimized to the taskbar. But I would like
it to miniminze to the System...
|
by: Simon Harvey |
last post by:
Hi everyone,
I need to make a service that monitors a directory for changes in the files
contained within it. I have two questions:
1. I'm going to be using a FileSystemWatcher object to do...
|
by: Carl Fenley |
last post by:
I believe I have almost successfully created a custom datagrid control. The
new class builds without error. I have added it as reference to the main
Windows Application project. It appears on...
|
by: Sabin Finateanu |
last post by:
Hi! Can anyone tell me where can I find a complete Windows Versions
List. I want to make a program that will identify the Windows Service
Pack based on the build and revision number. Can anyone...
|
by: Hank |
last post by:
I am writing a windows service in C#.NET which will manage image capturing
devices, when client connects to the service, at some point the service need
to expose a device dialog to the client for...
|
by: Protected |
last post by:
Hello. I'm a complete newbie trying to learn Python. I decided to try
some Tkinter examples, including the one from the library reference,
but they don't seem to do anything! Shouldn't there be,...
|
by: William McBrine |
last post by:
So, basically what I'm doing is this:
window1 = Tkinter.Tk()
....
window1.destroy()
....
window2 = Tkinter.Tk()
This works well in Linux and Mac OS X (and the PyGtk equivalent works on
all...
|
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,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
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...
|
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...
|
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,...
|
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...
| |