why an exception

W

wes weston

Group,
When I run the example, do File/New, and double click a line in the
list box; I get:

Exception in Tkinter callback
Traceback (most recent call last):
File "/usr/local/Python/lib/python2.3/lib-tk/Tkinter.py", line 1345, in __call__
return self.func(*args)
File "/home/wes/jbproject/python/bowling/test.py", line 60, in EditSimpleText
str = tkSimpleDialog.askstring('','enter str')
File "/usr/local/Python/lib/python2.3/lib-tk/tkSimpleDialog.py", line 303, in askstring
d = _QueryString(title, prompt, **kw)
File "/usr/local/Python/lib/python2.3/lib-tk/tkSimpleDialog.py", line 281, in __init__
_QueryDialog.__init__(self, *args, **kw)
File "/usr/local/Python/lib/python2.3/lib-tk/tkSimpleDialog.py", line 179, in __init__
Dialog.__init__(self, parent, title)
File "/usr/local/Python/lib/python2.3/lib-tk/tkSimpleDialog.py", line 64, in __init__
self.grab_set()
File "/usr/local/Python/lib/python2.3/lib-tk/Tkinter.py", line 521, in grab_set
self.tk.call('grab', 'set', self._w)
TclError: grab failed: window not viewable


I'm running redhat 9.0 and Python 2.3.3

Another user had a similar problem.
Any ideas?
#-----------------------------------------------------------------------------
from Tkinter import *
import time
import tkSimpleDialog

class MainWindowClass:
def __init__(self):
self.Top = Tk()
self.Top.minsize( 200,200 )

mainmenu = Menu(self.Top)

submenu = Menu( mainmenu, tearoff=0 )

submenu.add_command( label = "New" , command = self.NewB )
mainmenu.add_cascade( label = "File",menu = submenu )

self.Top.config( menu=mainmenu )
self.Top.mainloop()
#--------------------------------------------------------------------
def NewB(self):
ball = Ball(self.Top)
#----------------------------------------------------------
class Ball:
def __init__(self,top,ball=None):
self.Top = Toplevel(top)
self.Top.columnconfigure(0,weight=1)
self.Top.rowconfigure(1 ,weight=1)

self.vscrol = Scrollbar(self.Top,orient="vertical")
self.vscrol.grid(row=1,column=1,sticky="ns")

self.hscrol = Scrollbar(self.Top,orient="horizontal")
self.hscrol.grid(row=2,column=0,sticky="ew")
self.listbox = Listbox( self.Top,
font='system.fixed 12',
width=60,
height=20,
xscrollcommand=self.hscrol.set,
yscrollcommand=self.vscrol.set,
exportselection=0,
selectmode=SINGLE
)
self.listbox.grid(row=1,column=0,sticky="nesw")

self.vscrol.config(command=self.listbox.yview)
self.hscrol.config(command=self.listbox.xview )

label = Label(self.Top,anchor='w',font='system.fixed 12',text='heading')
label.grid(row=0,column=0,sticky="ew")

self.listbox.bind( "<Double-Button-1>",self.EditSimpleText )
self.LabelList = [
( "Last Name :","",self.EditSimpleText),
( "First Name :","",self.EditSimpleText),
]
for x in self.LabelList:
self.listbox.insert(END,x[0]+ " " + x[1])
#--------------------------------------------------------------------
def EditSimpleText( self, event ):
str = tkSimpleDialog.askstring('','enter str')
#----------------------------------------------------------
if __name__ == '__main__':
w = MainWindowClass()
 
W

wes weston

The following change fixes the problem:

def grab_set(self):
"""Set grab for this widget.

A grab directs all events to this and descendant
widgets in the application."""
self.wait_visibility() ###############added#####################3
self.tk.call('grab', 'set', self._w)

This is in:
/usr/local/Python/lib/python2.3/lib-tk/Tkinter.py line 521

'tested only in the case listed previously.
wes
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top