Strange Tkinter Grid behaviour Problem

H J van Rooyen mail at microcorp.co.za
Tue Aug 1 08:14:51 EDT 2006


Hi,

Still struggling with my GUI exercise -

I have the following lines of code in a routine that is bound at <Key-Return> to
an instance of Entry :

        self.disp.Amount_des = Label(self.disp, text = self.dis_string, fg =
'black', bg = 'yellow')
        self.disp.Amount_des.grid(row = self.rownum, column=0, sticky = 'nesw')

        self.disp.Amount = Label(self.disp, text = self.retstring, fg = 'black',
bg = 'green')
        self.disp.Amount.grid(row = self.rownum, column=1, sticky = N+S+E+W)

The second call to the grid method fails as follows:

Exception in Tkinter callback
Traceback (most recent call last):
  File "E:\PYTHON24\lib\lib-tk\Tkinter.py", line 1345, in __call__
    return self.func(*args)
  File "C:\WINDOWS\DESKTOP\Entry1.py", line 243, in entryend
    self.disp.Amount.grid(row = self.rownum, column=1, sticky = N+S+E+W)
TypeError: cannot concatenate 'str' and 'instance' objects

If I change the N+S+E+W to the 'nsew' form, it works no problem...

Weird - at other places in the program the form:  sticky = N+S+E+W works without
a problem.
I found the 'nsew' form by trial and error...

self.disp is a window different from the current one - it is used to display a
record entry as it is built up field by field. - the code fragment above is what
inserts the description of the entry and the entered data in a row in the window
used for displaying, when the user hits the enter key.

Is this a bug, or am I still doing something wrong?

- Hendrik




More information about the Python-list mailing list