User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Python section within the Software Development category of DaniWeb, a massive community of 426,634 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 1,595 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Python advertiser: Programming Forums

Python GUI Problem

Join Date: Jul 2006
Posts: 562
Reputation: jrcagle is on a distinguished road 
Rep Power: 4
Solved Threads: 72
jrcagle jrcagle is offline Offline
Posting Pro

Re: Python GUI Problem

  #19  
Sep 11th, 2007
This is a first draft of what you might want. The radiobutton has a 'command' feature that allows you to supply a callback when it is activated, so I eliminated the need for a separate class. The only problem with this so far is that you can't supply a target, but I know how to fix that. See if you understand this first and whether it's along the lines of what you are trying for:

  1. from Tkinter import *
  2.  
  3. def disable():
  4. print "disabling"
  5. root.button['state'] = DISABLED
  6.  
  7. def enable():
  8. print "enabling"
  9. root.button['state'] = ACTIVE
  10.  
  11. def button_com():
  12. print "hi"
  13.  
  14. root = Tk()
  15. root.input_text = Text(root, height = 10, width = 25)
  16. root.input_text.grid(row = 1, column = 1, sticky = N+S+E+W)
  17. root.mainbar_menu = Menu(root)
  18. root.input_menu = Menu(root.mainbar_menu)
  19. root.mainbar_menu.add_cascade(label='Input Options', menu = root.input_menu)
  20. root.button = Button(root, text="Swill", command = button_com)
  21. root.button.grid()
  22. root.input_menu.add_radiobutton(label='Input From File', command=disable)
  23. root.input_menu.add_radiobutton(label='Input from Pipe', command=enable)
  24. root.input_menu.add_radiobutton(label='Input from Stream', command=enable)
  25. root.config(menu=root.mainbar_menu)
  26. root.mainloop()
Last edited by jrcagle : Sep 11th, 2007 at 9:49 pm.
Reply With Quote  
All times are GMT -4. The time now is 12:44 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC