| | |
GUI def destroying
![]() |
•
•
Join Date: Jul 2009
Posts: 1
Reputation:
Solved Threads: 0
hey guys im trying to work this out for a school assignment, i cant get the destroy function to work whith the button i created, heres mycode see if you can look at it and tell me whas wrong
python Syntax (Toggle Plain Text)
import Tkinter as tk root = tk.Tk() root.title('background image') def qwerty(): self.destroy(button2) #def qwerty(): image1 = tk.PhotoImage(file="Black.gif") w = image1.width() h = image1.height() panel1.image = image1 root.geometry("%dx%d+0+0" % (w, h)) panel1 = tk.Label(root, image=image1) panel1.pack(side='top', fill='both', expand='yes') self.button2 = tk.Button(panel1, text='Click here to continue', command = qwerty) self.button2.pack(side='bottom') root.mainloop()
•
•
Join Date: May 2008
Posts: 538
Reputation:
Solved Threads: 86
The code you posted wouldn't even compile, let alone run.
Please be specific in the problem you are having.
I think the following is close to what you wanted, but it uses global variables which have their own problems:
Please be specific in the problem you are having.
I think the following is close to what you wanted, but it uses global variables which have their own problems:
Python Syntax (Toggle Plain Text)
import Tkinter as tk root = tk.Tk() root.title('background image') def qwerty(): button2.destroy() #def qwerty(): image1 = tk.PhotoImage(file="Black.gif") w = image1.width() h = image1.height() #panel1.image = image1 root.geometry("%dx%d+0+0" % (w, h)) panel1 = tk.Label(root, image=image1) panel1.pack(side='top', fill='both', expand='yes') button2 = tk.Button(panel1, text='Click here to continue', command = qwerty) button2.pack(side='bottom') root.mainloop()
![]() |
Similar Threads
- Looping action while button is pushed in Glade (Python)
- Python Error (Python)
- Uni Project help (Python)
- Tkinter Addressbook (Python)
- Stuck in GUI (Python)
- Trying to get card images into a GUI (Python)
- Python GUI build: Logic Complications and Mistakes (Python)
- pygtk Glade GUI freezes (Python)
- TURN THIS ASSIGNMENT UserID INTO GUI, CAN YOU HELP ME (Python)
Other Threads in the Python Forum
- Previous Thread: Can I integrate Python and the web?
- Next Thread: Cross-platform console manipulation
| Thread Tools | Search this Thread |
address advanced aliased anydbm bash beginner bits calling casino changecolor clear command conversion convert corners count csv cturtle cursor curves definedlines dictionary digital dynamic dynamically events examples excel external file float format frange function gui handling hints homework i/o iframe import input java line linux list lists loan loop matching mouse multiple number numbers obexftp output parsing path port prime programming projects py py2exe pygame python random rational raw_input recursion recursive return scrolledtext searchingfile signal singleton skinning string strings tails terminal text threading time tkinter tlapse tooltip tuple tutorial type ubuntu unicode urllib urllib2 valueerror variable web-scrape whileloop word wxpython





