Hi,
I was playing with tkinter, at the same time enjoying the olympics. I
thought I'd try to create a program for keeping scores of the
speed-skating. However, under windows I got into a crash, with the helpful
"Send crash-report". I tried to change this into a smaller program that
still crashes, but whatever I change, it stops crashing.
Under linux it also coredumps, but then when you close the window.
Since it's python, and crashes shouldn't happen, I thought I'd attach the
whole program (it's 82 lines). The strange thing is, if the 'SkateWindow'
is started with a distance < 10000, it runs allright.
With 10km, the window is wider than my screen, but changing line 29
self.distances = range(start,distance+1, 400)
into
self.distances = range(start,distance+1, 800)
reduces the number of columns, but not the crash.
Any ideas?
Regards,
Chris Niekel
--
I've been down so long, if I'd cheer up, I'd still be depressed.
- Lisa Simpson, Moanin' Lisa Blues.
import Tkinter
import os
evs=[]
startlist = {
'Bart veldkamp': '6.32.02',
'Groydum':'6.24.21',
'Saetre': '6.25.15',
'Carl Verheijen':'',
'Sven Kramer':'',
'Skobrev':'6.27.02',
}
players = map(lambda x: 'player%02d' % x, range(10))
startlist = {}
for p in players:
startlist[p] = ''
class SkateWindow:
def __init__(self, distance, contest):
self.length=distance
start = distance % 400
if start == 0:
start = 400
self.distances = range(start,distance+1, 400)
print self.distances
self.contest = contest
self.create_window()
def destroy(self):
print 'window destroyed'
self.win.destroy()
self.win = None
def create_window(self):
rowcount = 0
win = Tkinter.Tk()#width=800,height=600)
win.tk.call('encoding','system', 'utf-8')
frame = Tkinter.Frame(win,bd=2,relief=Tkinter.SUNKEN)
self.win = win
self.frame = frame
win.protocol("WM_DELETE_WINDOW", self.destroy)
l = Tkinter.Label(frame, text='Naam')
l.grid(row=0,column=0, sticky=Tkinter.W)
for d in self.distances:
l = Tkinter.Label(frame, text=str(d))
l.grid(row=0,column=d)
l.configure(bg='black', fg='white')
for s in self.contest.contestants:
rowcount+=1
l = Tkinter.Label(frame, text=unicode(s))
l.grid(row=rowcount,column=0,sticky=Tkinter.W)
for d in self.distances:
e = Tkinter.Entry(frame,width='8')
e.grid(row=rowcount, column=d)
def setdata(event,s=s,d=d,widget=e):
return self.dataset(event, s, d,widget)
e.bind('<Return>', setdata)
#if startlist[s]:
#print s, 'scores', startlist[s]
#e.insert(Tkinter.INSERT, startlist[s])
#e.configure(bg='grey90')
#frame.grid(padx=10,pady=10)
frame.grid()
def dataset(self,event, s,d, widget):
print `event`, `s`, `d`,widget.get()
evs.append(event)
if __name__ == '__main__':
class X: pass
x = X()
x.contestants = players
#w = SkateWindow(3000, x)
w = SkateWindow(10000,x)
Tkinter.mainloop()
_______________________________________________
Tkinter-discuss mailing list
[email protected]
http://mail.python.org/mailman/listinfo/tkinter-discuss