from Tkinter import *
def disable():# temp
root.input_text['state'] = DISABLED
root = Tk()
root.input_text = Text(root, height = 10, width = 25).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_radiobutton(label='Input From File', command = disable)
root.config(menu=root.mainbar_menu)
root.mainloop()
This code is taken out of part of the larger program im writing so some of the code may seem pointless, im only keeping it their in case i dont realise how much of a effect it has.
error -
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Python25\lib\lib-tk\Tkinter.py", line 1403, in __call__
return self.func(*args)
File "C:/Documents and Settings/Owner/Desktop/ex.py", line 4, in disable
root.input_text['state'] = DISABLED
TypeError: 'NoneType' object does not support item assignment
The error occurs when i click the menu button, not when the program loads. What am i doing wrong when im making this menu?
also your example worked fine, although i tried editing it so i would not have to write a new function for every time i want to disable a diffrent widget by changing these lines.
def disable(widget):
widget["state"] = DISABLED
root.button2 = Button(root, text="Disable the Radiobutton", command=disable(root.button))
this doesnt work as expected because as soon as the gui has loaded the button is allready disabled. sorry i took over a week to get back to you but getting this program to work is not exactly high proiority right now. thanks.