Seite 1 von 1

checkbutton mit select() vor-wählen: 'NoneType' has no attr

Verfasst: Dienstag 31. März 2009, 18:41
von egerlach
Hallo,
warum kommt bei dem Versuch eines select() die Fehlermeldung:
Traceback (most recent call last):
File "aa.py", line 7, in <module>
Bc.select()
AttributeError: 'NoneType' object has no attribute 'select'

Code: Alles auswählen

import Tkinter as tk
root=tk.Tk()
b=tk.StringVar()
Bc=tk.Checkbutton(root, text="ddddddd", variable=b).grid()
Bc.select()
tk.mainloop()
Zur Info:
http://effbot.org/tkinterbook/radiobutt ... ect-method
deselect() Deselects the button.
flash() Redraws the button a couple of times, alternating between active and normal appearance. This can be useful when debugging, or to indicate when some other user action has activate the button.
invoke() Calls the command associated with the button.
select() Selects the button.

Verfasst: Dienstag 31. März 2009, 19:17
von yipyip
Bc ist None, weil das der Rückgabewert von grid() ist.
Was Du schreiben willst ist:

Code: Alles auswählen

...
Bc=tk.Checkbutton(root, text="ddddddd", variable=b)
Bc.grid()
Bc.select()
...
:wink:
yipyip