473,406 Members | 2,312 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

[Tkinter] event problem

I have just tried this code..

Tkinter import *

root = Tk()

def callback(event):
print "clicked at", event.x, event.y

frame = Frame(root, width=100, height=100)
frame.bind("<Button-1>", callback)
frame.pack()
root.mainloop()

... on my SuSE Linux 8.2, Python 2.2.2, python-tk 2.2.2.

This opens a new window, but there is a problem when I click on it. I
tried similar code where clicking on a button does the same. Can anyone
help?

Here is the error:

Exception in Tkinter callback
Traceback (most recent call last):
File
"/var/tmp/python-2.2.2-build//usr/lib/python2.2/lib-tk/Tkinter.py", line
1299, in __call__
args = apply(self.subst, args)
File
"/var/tmp/python-2.2.2-build//usr/lib/python2.2/lib-tk/Tkinter.py", line
1035, in _substitute
e.height = getint(h)
ValueError: invalid literal for int(): ??

Jul 18 '05 #1
3 2406
Ivan Letal wrote:
I have just tried this code..

Tkinter import *

root = Tk()

def callback(event):
print "clicked at", event.x, event.y

frame = Frame(root, width=100, height=100)
frame.bind("<Button-1>", callback)
frame.pack()
root.mainloop()

.. on my SuSE Linux 8.2, Python 2.2.2, python-tk 2.2.2.

This opens a new window, but there is a problem when I click on it. I
tried similar code where clicking on a button does the same. Can anyone
help?

Here is the error:

Exception in Tkinter callback
Traceback (most recent call last):
File
"/var/tmp/python-2.2.2-build//usr/lib/python2.2/lib-tk/Tkinter.py", line
1299, in __call__
args = apply(self.subst, args)
File
"/var/tmp/python-2.2.2-build//usr/lib/python2.2/lib-tk/Tkinter.py", line
1035, in _substitute
e.height = getint(h)
ValueError: invalid literal for int(): ??

No problems with your code here (Suse 8.1, Python 2.3).

The relevant portion of 2.3's Tkinter.py has an interesting comment together
with what seems to be a Tk workaround:

[...]
def _substitute(self, *args):
"""Internal function."""
if len(args) != len(self._subst_format): return args
getboolean = self.tk.getboolean

getint = int
def getint_event(s):
"""Tk changed behavior in 8.4.2, returning "??" rather more
often."""
try:
return int(s)
except ValueError:
return s
[...]

So, if that's an option, upgrading to 2.3 should solve your problem.

Peter
Jul 18 '05 #2
Ivan Letal wrote:
I have just tried this code..

Tkinter import *

root = Tk()

def callback(event):
print "clicked at", event.x, event.y

frame = Frame(root, width=100, height=100)
frame.bind("<Button-1>", callback)
frame.pack()
root.mainloop()

.. on my SuSE Linux 8.2, Python 2.2.2, python-tk 2.2.2.

This opens a new window, but there is a problem when I click on it. I
tried similar code where clicking on a button does the same. Can anyone
help?

Here is the error:

Exception in Tkinter callback
Traceback (most recent call last):
File
"/var/tmp/python-2.2.2-build//usr/lib/python2.2/lib-tk/Tkinter.py", line
1299, in __call__
args = apply(self.subst, args)
File
"/var/tmp/python-2.2.2-build//usr/lib/python2.2/lib-tk/Tkinter.py", line
1035, in _substitute
e.height = getint(h)
ValueError: invalid literal for int(): ??

No problems with your code here (Suse 8.1, Python 2.3).

The relevant portion of 2.3's Tkinter.py has an interesting comment together
with what seems to be a Tk workaround:

[...]
def _substitute(self, *args):
"""Internal function."""
if len(args) != len(self._subst_format): return args
getboolean = self.tk.getboolean

getint = int
def getint_event(s):
"""Tk changed behavior in 8.4.2, returning "??" rather more
often."""
try:
return int(s)
except ValueError:
return s
[...]

So, if that's an option, upgrading to 2.3 should solve your problem.

Peter
Jul 18 '05 #3
In article <bk**********@ns.felk.cvut.cz>,
Ivan Letal <ad*******@centrum.cz> wrote:
I have just tried this code....
Here is the error:

Exception in Tkinter callback
Traceback (most recent call last):
File
"/var/tmp/python-2.2.2-build//usr/lib/python2.2/lib-tk/Tkinter.py", line
1299, in __call__
args = apply(self.subst, args)
File
"/var/tmp/python-2.2.2-build//usr/lib/python2.2/lib-tk/Tkinter.py", line
1035, in _substitute
e.height = getint(h)
ValueError: invalid literal for int(): ??


I think you are running mutually incompatible versions of Python and Tk.
Python 2.2.2 and earlier need Tk 8.4.1 or earlier. Python 2.3 is
compatible with later versions of Tk.

-- Russell
Jul 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: wang xiaoyu | last post by:
Hello,everyone. my program runs well in windows,i use tkSimpleDialog to receive some input,but when i copy my program into Linux RH8.0,entrys in my tkSimpleDialog derived Dialog have a vital...
3
by: Gary Richardson | last post by:
I've just switched to Python 2.3.2 and have encountered a problem that causes a program to crash. The program was working with Python 2.2. The code below will illustrate the problem. A listbox is...
2
by: Russell E. Owen | last post by:
I want to support execution of simple user-written scripts in a Tkinter application. The scripts should be able to wait for data and such without hanging the GUI (and without having to write the...
2
by: Michael Zhang | last post by:
My project uses Python-2.3.4 + Tkinter + PIL-1.1.4 to retrieve images from server and display those images. I created a thread (also a separate toplevel window) for displaying images and another...
2
by: Grooooops | last post by:
I've been hacking around this for a few days and have gotten close to what I want... but not quite... The TKinter Docs provide this example: # configure text tag text.tag_config("a",...
1
by: vigacmoe | last post by:
Hi all, I'm trying to write a simple tkinter program, then this problem popped up. The followin code will describe the problem. ------------------------------------------ import Tkinter ...
0
by: Helmut Jarausch | last post by:
Hi, I'd like to bind the '<Return>' event to a function which does some calculations (like a database lookup) and then invoke tk_focusNext. I get an exception as many others have reported...
0
by: Guilherme Polo | last post by:
On Wed, Sep 3, 2008 at 8:57 PM, Kevin McKinley <kem1723@yahoo.comwrote: Come on.. "help on lines 384-403", that is not a good way to look for help. You are supposed to post some minimal code that...
4
by: Mudcat | last post by:
I've tried quite a few things to get this correct but have hit a couple of sticking points that I can't figure out. I need to ge the Text box to function like the 'wraplength' option in a Label. ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.