[New-bugs-announce] [issue11387] Tkinter, callback functions

Nikolay Fomichev report at bugs.python.org
Thu Mar 3 19:30:14 CET 2011


New submission from Nikolay Fomichev <morphsandn at gmail.com>:

A simple code:

class App():  
    def __init__(self):
        self.root = tk.Tk()
        
        self.btn = tk.Button(self.root, text='Click me')
        self.btn.pack()
        self.btn.bind('<Button-1>', self.click)

        self.root.mainloop()
        
    def click(self, event):
        # Messagebox or filedialog
        pass


When the button is clicked, it calls the function where a filedialog or messagebox is called. After the function is done the button changes - it looks like it's pressed. Its relief is sunken. Something like "self.btn.config(relief=tk.RAISED)" has no effect - relief is raised, but the button still looks pressed.
If no dialogs are called, all is fine.

But... if instead of "bind" I use config option "command", it works - the function goes well with dialogs, etc and the button is really raised.

I checked this in 2.6.6, 2.7, 3.1.2 and 3.2 on Linux and Win, everywhere is the same tune.

----------
components: Tkinter
messages: 129990
nosy: Nikolay.Fomichev
priority: normal
severity: normal
status: open
title: Tkinter, callback functions
versions: Python 2.6, Python 2.7, Python 3.1, Python 3.2

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue11387>
_______________________________________


More information about the New-bugs-announce mailing list