Key Binding Problem

Wildman best_lay at yahoo.com
Wed Mar 23 00:30:09 EDT 2016


On Tue, 22 Mar 2016 23:52:57 -0400, Terry Reedy wrote:

> On 3/22/2016 10:46 PM, Wildman via Python-list wrote:
>> Platform: Linux
>> Python: v.2.7.9
>> Tkinter: v.8.6.2
>>
>> My program has some buttons for file operations, load_image,
>> save_image, and quit.  I would like to bind a key that will
>> execute the procedures for each of the buttons.  The binding
>> for the quit button was easy...
>>
>> root.bind("<q>", quit)
>> root.bind("<Q>", quit)
>>
>> That works but it not executing a quit button procedure.
>> It is merely executing an internal command.  My problem is
>> calling an actual button procedure.  Over the last several
>> hours I have tried many different syntax arrangements and
>> I keep getting "object not defined" errors.  I also tried
>> placing the bind statements into other places in the code.
>> I have run out of ideas.
>>
>> Below is a basic skeleton of my code.  Any help appreciated.
>>
>> #!/usr/bin/env python
>>
>> try:
>>      import Tkinter as tk
>>      from Tkinter import Tk
> 
> The second import is not needed.  tk.Tk is short and should be called 
> just once.
> 
>> except ImportError:
>>      import tkinter as tk
>>      from tkinter import Tk
> 
> ditto.
> 
>> import tkFileDialog, tkMessageBox
> 
> These are 2.x only and should be after the Tkinter import.
> For 3.x, import tk.filedialog, tk.messagebox

Thanks for the info.  Making the changes...

-- 
<Wildman> GNU/Linux user #557453
The cow died so I don't need your bull!



More information about the Python-list mailing list