[Tkinter-discuss] {Possible_Spam} Finding Tkinter widget types
VladPotrosky
greendingbat99 at hotmail.com
Mon Jul 6 17:17:54 CEST 2009
Looks great!
Thanks!
John McMonagle-3 wrote:
>
>
> Use the winfo_class() method (Example below):
>
> from Tkinter import *
> r = Tk()
> b = Button(r, text='test')
> b.pack()
> c = Checkbutton(r)
> c.pack()
> e = Entry(r)
> e.pack()
>
> widgets = [b,c,e]
>
> def widgetMethod(widget):
> if widget.winfo_class() == 'Button':
> print 'A Button widget!'
> elif widget.winfo_class() == 'Checkbutton':
> print 'A Checkbutton widget!'
> elif widget.winfo_class() == 'Entry':
> print 'An Entry widget!'
>
> for widget in widgets:
> widgetMethod(widget)
>
> r.mainloop()
>
>
>
-----
---------------------------------------------------
"I'd like to share a revelation that I've had during my time here. It came
to me when I tried to classify your species and I realized that you're not
actually mammals."
-- Agent Smith
--
View this message in context: http://www.nabble.com/Finding-Tkinter-widget-types-tp24291475p24357016.html
Sent from the Python - tkinter-discuss mailing list archive at Nabble.com.
More information about the Tkinter-discuss
mailing list