[Tutor] ComboBox with Tkinter

Michael Lange klappnase at freenet.de
Sat Jul 17 17:18:47 CEST 2004


On Fri, 16 Jul 2004 20:50:45 -0700
Dick Moores <rdm at rcblue.com> wrote:


> "last update: Dec 10, 1999"
> 
> No problem?
> 

I know, it's a little outdated, but for the most part it's still o.k.
The parts that have changed since 1999 mostly affect a couple of new widgets
in the standard library (LabelFrame, PanedWidget, OptionMenu...) and some new options
that were added (like the "compound" option for labels and buttons) but everything (or at least almost
everything) from this book should still work.
Frederic Lundh is currently working on  an updated version of this document:

<http://effbot.org/books/tkinterbook/>

but it's not yet as complete as the old version.

> For example, I just ran his hello2.py. The Hello button works, but the 
> Quit button doesn't quit. Or maybe I don't understand even enough to run 
> these things. I have Python 2.3.4.
> 
> ===================================
> # File: 
> hello2.py 
> #<http://www.pythonware.com/library/tkinter/introduction/hello-again.htm>
> 
> from Tkinter import *
> 
> class App:
> 
>      def __init__(self, master):
> 
>          frame = Frame(master)
>          frame.pack()
> 
>          self.button = Button(frame, text="QUIT", fg="red", 
> command=frame.quit)
>          self.button.pack(side=LEFT)
> 
>          self.hi_there = Button(frame, text="Hello", command=self.say_hi)
>          self.hi_there.pack(side=LEFT)
> 
>      def say_hi(self):
>          print "hi there, everyone!"
> 
> root = Tk()
> 
> app = App(root)
> 
> root.mainloop()
> =========================================
> 

This works fine for me; maybe you tried to run it from within IDLE? It's a special IDLE issue
that using the quit() method does not work; quit() exits Tk's mainloop, and the problem is that
IDLE runs inside the mainloop itself.

Best regards

Michael



More information about the Tutor mailing list