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 397,569 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 3,518 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:

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

  #10  
Aug 29th, 2007
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.
Reply With Quote  
All times are GMT -4. The time now is 4:22 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC