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,630 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,590 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: Nov 2006
Posts: 23
Reputation: Haze is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
Haze Haze is offline Offline
Newbie Poster

Re: Python GUI Problem

  #14  
Sep 6th, 2007
ok i understand the first problem now. The second problem i also understand (a bit) but for your example you used a button and what i was planning to use it with was a radiobutton so i tried it.

from Tkinter import *

class abler_radiobutton(Radiobutton):
    def __init__(self, master, target, cnf={}, **kw):
        Radiobutton.__init__(self, master, cnf, **kw)
        self.target = target
        self['command'] = self.disable

    def disable(self):
        self.disable_target['state'] = DISABLED

root = Tk()
root.input_text = Text(root, height = 10, width = 25)
root.input_text.grid(row = 1, column = 1, sticky = N+S+E+W)
root.mainbar_menu = Menu(root)
root.input_menu = Menu(root.mainbar_menu)
root.mainbar_menu.add_cascade(label='Input Options', menu = root.input_menu)
root.input_menu.add_abler_radiobutton(label='Input From File')

root.config(menu=root.mainbar_menu)
root.mainloop()

Obviously this doesnt work because i havent put enough in the .add_abler_radiobutton part. but i dont know exactly what to put in because the creation of this radiobutton was a lot more complicated compared to the creation of a button.

Also another question, why does the disable function have to be indented so that its created along with the class? and why is self.disable not disable(self)? and what exactly does the "button.__init__" line do.

sorry if this is to many questions i just dont like using code when i have no idea what said code actully does.
Reply With Quote  
All times are GMT -4. The time now is 12:35 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC