GUI def destroying

Reply

Join Date: Jul 2009
Posts: 1
Reputation: TubbyT is an unknown quantity at this point 
Solved Threads: 0
TubbyT TubbyT is offline Offline
Newbie Poster

GUI def destroying

 
0
  #1
Jul 28th, 2009
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
  
  1. import Tkinter as tk
  2.  
  3. root = tk.Tk()
  4. root.title('background image')
  5.  
  6. def qwerty():
  7. self.destroy(button2)
  8.  
  9. #def qwerty():
  10. image1 = tk.PhotoImage(file="Black.gif")
  11. w = image1.width()
  12. h = image1.height()
  13. panel1.image = image1
  14. root.geometry("%dx%d+0+0" % (w, h))
  15.  
  16. panel1 = tk.Label(root, image=image1)
  17. panel1.pack(side='top', fill='both', expand='yes')
  18.  
  19. self.button2 = tk.Button(panel1, text='Click here to continue', command = qwerty)
  20. self.button2.pack(side='bottom')
  21.  
  22.  
  23.  
  24.  
  25. root.mainloop()
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 538
Reputation: Murtan is a jewel in the rough Murtan is a jewel in the rough Murtan is a jewel in the rough Murtan is a jewel in the rough 
Solved Threads: 86
Murtan Murtan is offline Offline
Posting Pro

Re: GUI def destroying

 
0
  #2
Jul 29th, 2009
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:

  1. import Tkinter as tk
  2.  
  3. root = tk.Tk()
  4. root.title('background image')
  5.  
  6. def qwerty():
  7. button2.destroy()
  8.  
  9. #def qwerty():
  10. image1 = tk.PhotoImage(file="Black.gif")
  11.  
  12. w = image1.width()
  13. h = image1.height()
  14. #panel1.image = image1
  15. root.geometry("%dx%d+0+0" % (w, h))
  16.  
  17. panel1 = tk.Label(root, image=image1)
  18. panel1.pack(side='top', fill='both', expand='yes')
  19.  
  20. button2 = tk.Button(panel1, text='Click here to continue', command = qwerty)
  21. button2.pack(side='bottom')
  22.  
  23. root.mainloop()
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC