[Python-bugs-list] [Bug #114424] Tkinter/Canvas drawing causes interpreter to crash.

noreply@sourceforge.net noreply@sourceforge.net
Fri, 15 Sep 2000 00:09:09 -0700


Bug #114424, was updated on 2000-Sep-14 06:32
Here is a current snapshot of the bug.

Project: Python
Category: Tkinter
Status: Closed
Resolution: Fixed
Bug Group: None
Priority: 9
Summary: Tkinter/Canvas drawing causes interpreter to crash.

Details: 
 14 September 2000

 Please find my original query below with regard to Tkinter and Python2.0beta1.
 Also find the Python help desk response.

 I had not mentioned in my original query that I am running on a 
 Sun Ultra 10 with the Solaris 5.5.1 operating system. 

 Best,
 Michele

 ---------------------------------------------------------------------------
 ---------------------------------------------------------------------------


 13 September 2000

 HI Python Folks,

 I am trying to evaluate the new "flatten" functionality written for 
 Tkinter to determine if it generates a scientific plot with many data
 points in a reasonable time. I am using the Python2.0beta1.  I should
 admit to being a bit of a newbie with Python.

 For this test, I am using some very simple code that is from the "Python 
 and Tkinter Programming" book by John Grayson.  I will append the simple 
 program to the bottom of this note.  I will mention I did modify the 
 code in the following manner:
  
   1) scaled.append(x,y) to scaled.append((x,y)).
   2) commented out some stuff I did not care about
   3) added code to be able to generate as many data points as I want for
      testing

 If I run the very code attached to this note, I get:

enkidu> /usr/local/bin/python2.0 simpleplot2.py
Traceback (most recent call last):
  File "simpleplot2.py", line 39, in ?
    canvas.create_line(scaled, fill='royalblue')
  File "/usr/local/Python-2.0b1/lib/python2.0/lib-tk/Tkinter.py", line 1955, in create_line
    return self._create('line', args, kw)
  File "/usr/local/Python-2.0b1/lib/python2.0/lib-tk/Tkinter.py", line 1942, in _create
    (self._w, 'create', itemType)
TypeError: can only concatenate tuple (not "dictionary") to tuple
Bus error (core dumped)

 I changed the scaled.append((x,y)) to two lines where I append x and y
 separately; this got rid of the TypeError, but I still got the core dump.
 I have done many experiments where I can sometimes get the code to work in
 interactive mode, but if I decide to draw the line in color, I get a bus 
 error.  I can sometimes draw lines with only a few data points, but I
 bomb on lines with many points.

 I tell you all of this to find out if Tkinter has been tested for drawing
 lines and such on a canvas under Python2.0?  I am suspicious of either 
 memory problems or newbie problems.  I have tried some demos of Tkinter, as 
 well as some GUIs I have made using Tkinter which employ lots of widgets 
 (i.e., scrollbars, text, label, entry) and these seem to work just fine.
 I am not very experienced with drawing stuff on the canvas.

 I do not expect you to debug this code for me, but rather to tell me how
 well Tkinter has been tested under Python2.0.  I know you probably have 
 lots o'stuff to do.

 Best,
 Michele

 -------------------------------------------------------------------------
 Michele D. De La Pena                        email: delapena@stsci.edu
 Senior Scientific Programmer                 phone: 410-338-4713
 Space Telescope Science Institute            fax:   410-338-4767
 3700 San Martin Drive
 Baltimore, MD  21218

 "The nice thing about standards is there are so many to choose from."
 -------------------------------------------------------------------------


 ****************************************************************************

from Tkinter import *

root = Tk()
root.title('Simple Plot - Version 2')
canvas = Canvas(root, width=450, height=300, bg = 'white')
canvas.pack()
Button(root, text='Quit', command=root.quit).pack()

canvas.create_line(100,250,400,250, width=2)
canvas.create_line(100,250,100,50,  width=2)

for i in range(11):
    x = 100 + (i * 30)
    canvas.create_line(x,250,x,245, width=2)
    canvas.create_text(x,254, text='%d'% (10*i), anchor=N)

for i in range(6):
    y = 250 - (i * 40)
    canvas.create_line(100,y,105,y, width=2)
    canvas.create_text(96,y, text='%5.1f'% (50.*i), anchor=E)

scaled = []

# MDD Added this code to generate potentially lots of data points
for i in range(10):
    x, y = i, i
    x = x + 100
    y = 50 + y
    scaled.append((x,y))

"""  I am not interested in this.
scaled = []
for x,y in [(12, 56), (20, 94), (33, 98), (45, 120), (61, 180),
            (75, 160), (98, 223)]:
    scaled.append((100 + 3*x, 250 - (4*y)/5))
"""

canvas.create_line(scaled, fill='royalblue')

"""  I am not interested in this.
for x,y in scaled:
    canvas.create_oval(x-6,y-6,x+6,y+6, width=1,
                       outline='black', fill='SkyBlue2')
"""

root.mainloop()

 ---------------------------------------------------------------------------
 ---------------------------------------------------------------------------