Tkinter interactive

James Stroud jstroud at ucla.edu
Sat Dec 17 17:01:03 EST 2005


cm012b5105 wrote:
> Hello i am fairly new to python,
> I have written an interactive programme a small example of it is here.
> s = raw_input ("Do you have any children? ")
> if s== 'yes':
>    print "Thats great"
> elif s=='no':
>    print "Well my boss has 2"
> 
> 
> Now i have also been looking at Tkinter if we take the basic "hello, world" 
> programme which is like this.
> 
> # File: hello1.py
> 
> from Tkinter import *
> 
> root = Tk()
> 
> w = Label(root, text="Hello,!")
> w.pack()
> 
> root.mainloop()
> 
> What i want is to incorporate this in to my programme so when i start my 
> programme a little box appears saying hello then my interactive programme 
> runs within the box
> This it what it looks like
> 
> from Tkinter import *
> 
> root = Tk()
> 
> w = Label(root, text="Hello,!")
> w.pack()
> s = raw_input ("Do you have any children? ")
> if s== 'yes':
>    print "Thats great"
> elif s=='no':
>    print "Well my boss has 2"
> 
> The result of that is i just get another box open and start to run my 
> interactive programme as though it ignores the Tk box which says hello hope 
> this makes sense any advise on this please.
> thanks nige

GUI programming is kind of advanced. It is tough to make a leap from the 
hello world program of a new language to an interactive gui interface. I 
think you can save yourself a lot of frustration and confusion by first 
working throught the python tutorial:

   http://docs.python.org/tut/tut.html

Then working throught the "Tkinter tutorial":

   http://www.python.org/doc/life-preserver/

Pound these out over the course of a few weekends and you will be leaps 
and bounds further in your understanding than if you attempted to learn 
through unguided exploration (though the latter may be more fun sometimes).

James



More information about the Python-list mailing list