Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Problem (or even bug?) with Tkinter

Reply
Thread Tools

Problem (or even bug?) with Tkinter

 
 
Matt Hammond
Guest
Posts: n/a
 
      08-19-2005
Here's a strange one in Tkinter that has me stumped:
(I'm running python 2.4 on Suse Linux 9.3 64bit)

I'm trying to make a set of Entry widgets with Label widgets to the left
of each one, using the grid layout. If I make and grid the Label *before*
the Entry then the Entry widget doesn't seem to work - it lets me put the
cursor in it, but I can't type! See example code below.

Is this just me doing something really really silly, or is there a bug
here?

I'm inclined to think the latter. I've been developing with python 2.4 on
Suse Linux 9.3 64bit. I've just tested it on a Win2k machine witih python
2.3 and can type into both Entry widgets.

regards


Matt
-------

#!/usr/bin/env python

import Tkinter

class ProblemGUI(object):

def __init__(self):
super(ProblemGUI, self).__init__()
self.window = Tkinter.Tk()

self.window.title("Try typing into both Entry widgets")

# declare and grid Entry widget before Label widget
self.entry1 = Tkinter.Entry(self.window)
self.entry1.grid(row=0, column=1)

self.label1 = Tkinter.Label(self.window, text="CAN WRITE ->")
self.label1.grid(row=0,column=0)

# declare and grid Label widget before Entry widget
self.label2 = Tkinter.Label(self.window, text="CAN'T WRITE ->")
self.label2.grid(row=1,column=0)

self.entry2 = Tkinter.Entry(self.window)
self.entry2.grid(row=1, column=1)


x=ProblemGUI()
x.window.mainloop()


--

| Matt Hammond
| R&D Engineer, BBC Research and Development, Tadworth, Surrey, UK.
 
Reply With Quote
 
 
 
 
Eric Brunel
Guest
Posts: n/a
 
      08-19-2005
On Fri, 19 Aug 2005 09:53:20 +0100, Matt Hammond <> wrote:

> Here's a strange one in Tkinter that has me stumped:
> (I'm running python 2.4 on Suse Linux 9.3 64bit)
>
> I'm trying to make a set of Entry widgets with Label widgets to the left
> of each one, using the grid layout. If I make and grid the Label *before*
> the Entry then the Entry widget doesn't seem to work - it lets me put the
> cursor in it, but I can't type! See example code below.
>
> Is this just me doing something really really silly, or is there a bug
> here?


I tested with Python 2.1 on Mandrake Linux 8.0 and it works fine. My tcl/tk version is 8.3.4

Do you know the tcl/tk version you have? If you don't, you can get it via:

from Tkinter import Tk()
root = Tk()
root.tk.eval('puts $tk_patchLevel')

I suspect a bug at tcl level. So can you execute the following tcl script:

-------
entry .en1
grid .en1 -row 0 -column 1

label .lb1 -text "CAN WRITE ->"
grid .lb1 -row 0 -column 0


label .lb2 -text "CAN'T WRITE ->"
grid .lb2 -row 1 -column 0

entry .en2
grid .en2 -row 1 -column 1
-------

It is exactly the same as yours in tcl syntax. To execute it, just save it to the file script.tcl and type in a shell:
wish script.tcl

(The "wish" command may include a version number, such as "wish8.4")

If the script above shows the same behaviour as your Python script, then it's not Tkinter's fault, but tk's. You should then report the bug to comp.lang.tcl.

HTH
--
python -c "print ''.join([chr(154 - ord(c)) for c in 'U(17zX(%,5.zmz5(17;8(%,5.Z65\'*9--56l7+-'])"
 
Reply With Quote
 
 
 
 
Matt Hammond
Guest
Posts: n/a
 
      08-19-2005
Thanks for that. I've tested your script and it seems to have the same
problem, so I'll post your example across in comp.lang.tcl as you suggest.

Seems I'm running tcl/tk 8.4.9, and wish 8.4

cheers


Matt

> I suspect a bug at tcl level. So can you execute the following tcl
> script:
>
> -------
> entry .en1
> grid .en1 -row 0 -column 1
>
> label .lb1 -text "CAN WRITE ->"
> grid .lb1 -row 0 -column 0
>
>
> label .lb2 -text "CAN'T WRITE ->"
> grid .lb2 -row 1 -column 0
>
> entry .en2
> grid .en2 -row 1 -column 1
> -------
>
> It is exactly the same as yours in tcl syntax. To execute it, just save
> it to the file script.tcl and type in a shell:
> wish script.tcl




--

| Matt Hammond
| R&D Engineer, BBC Research and Development, Tadworth, Surrey, UK.
 
Reply With Quote
 
Matt Hammond
Guest
Posts: n/a
 
      08-22-2005
A fix for this has just been pointed out to me (by Reinhard Max):

<quote>
I've seen problems with non-working entry and text widgets on SUSE Linux
when Tk is used with the SCIM input manager. Could you please check
whether the XMODIFIERS variable exists in the environment of your Tk
process? If exists and has the value "@im=SCIM", you could try as
aworkaround to set it to "@im=local", or just unset it before starting Tk.
If that fixes your problem, and you don't otherwise make use of SCIM, you
can just deinstall the scim package.

Unfortunately I haven't yet found a way to make Tk cooperate better with
SCIM. As a workaround for SUSE Linux 10.0 I might just unset XMODIFIERS
during Tk's startup, so that at least typing ASCII will work.
</quote>

Altering the XMODIFIERS environment variable as he suggested solved the
problem.


--

| Matt Hammond
| R&D Engineer, BBC Research and Development, Tadworth, Surrey, UK.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
CPU Usage frequently 100% even though it seems not even close tototal memory Newcomer Computer Support 3 11-15-2009 06:51 AM
CPU Usage frequently 100% even though it seems not even close tototal memory Newcomer Computer Support 0 11-14-2009 11:21 PM
Why my working ps/2 mouse freezes and even don't even get recon.after reboot ? demi General Computer Support 0 08-03-2007 05:30 AM
Why my working ps/2 mouse freezes and even don't even get recon.after reboot ? demi General Computer Support 0 08-03-2007 05:28 AM
Even older fart, even newer newbie Stan Goodman Java 11 07-04-2003 07:32 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57