473,396 Members | 1,689 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,396 software developers and data experts.

Problem (or even bug?) with Tkinter

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.
Aug 19 '05 #1
3 2122
On Fri, 19 Aug 2005 09:53:20 +0100, Matt Hammond <ma**********@rd.bbc.co.uk> 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+-'])"
Aug 19 '05 #2
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.
Aug 19 '05 #3
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.
Aug 22 '05 #4

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

Similar topics

5
by: Andrew Gregory | last post by:
Could someone help me out with these few lines of code: I would like to know why the Quit button in this application removes the buttons and causes "Quitting" to be printed, but does not close the...
2
by: Marc | last post by:
Hi all, I was using Tkinter.IntVar() to store values from a large list of parts that I pulled from a list. This is the code to initialize the instances: def initVariables(self): self.e =...
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: Martin Jensen | last post by:
Hi I have a problem with Qt. My class definition is this: class Button : public QObject, public Tk_Object { Q_OBJECT public: Button() {} Button(Tk_Object &p); ~Button();
0
by: syed_saqib_ali | last post by:
Below is a simple code snippet showing a Tkinter Window bearing a canvas and 2 connected scrollbars (Vertical & Horizontal). Works fine. When you shrink/resize the window the scrollbars adjust...
2
by: Stewart Midwinter | last post by:
this has me puzzled; I've created a small test app to show the problem I'm having. I want to use subprocess to execute system commands from inside a Tkinter app running under Cygwin. When I...
2
by: stknightmare | last post by:
Hi i have a program written in python which uses very big loops and i am trying to get some output by using the text widget of tkinter,the problem is that tkinter waits for the function to finish the...
1
by: chewinggumking | last post by:
I need help with this problem I'm facing when I use Tkinter to make a GUI. The app window is the correct sige h = 200, w = 400 if I don't add a button to the script. The weird thing is, the minute...
2
by: skanemupp | last post by:
so my little calculator works perfectly now. just having some trouble with the layout. this whole tkinter-thing seems to be more tricky than it should be. how can i make the 4 column of buttons...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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...

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.