By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,199 Members | 1,064 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,199 IT Pros & Developers. It's quick & easy.

why an exception

P: n/a
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()

Jul 18 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
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

Jul 18 '05 #2

P: n/a
Patch submitted.
wes

Jul 18 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.