tkinter / gui
inq1ltd at inqvista.com
Sun Feb 24 18:00:09 CET 2013
On Saturday, February 23, 2013 02:50:43 PM Rex Macey wrote:
> Here is one general and one specific question about creating GUIs using
> tkinter from a newbie. I have created a class in which to hold some data.
> I want to create a GUI to get the data from the user and store it in the
> object. Browsing the web I see that a lot of examples on GUIs have the
> forms put into classes. I'm not clear why. Why is that? Second, I've
> created a form with a bunch of widgets on it, one of which is a listbox.
> This is done with a script, not a class. I've defined a method that
> responds to a Button Release event. I know this works because I can print
> the value selected in the listbox while within the method. However, I want
> the value of the listbox after I've closed the form. How do I get that?
There are a few ways to approach this.
without getting to far in depth here,
you can do something like this.
This is not technically correct but a
simple concept of how to.
make a class
lbox = ''
mkLbox = Listbox(masterTK) ## create the listbox in TK
config.mkLbox( stuff, morestuff, ## config it however you want
selectmode = ???)
## you may have to import your class Klbox, here
#depending where you are in your program
then relate Klbox.lbox = (?? something selected from listbox)
# from somewhere else in your program you can
x = Klbox.lbox
Or, you can also learn how to use the
Tkinter StringVar Class, available in Tkinter manual
but you will need to relate the StringVar to an attribute
as I described above so you can get it from another
module or class in your program.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-list