why an exception

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • wes weston

    why an exception

    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('','e nter str')
    File "/usr/local/Python/lib/python2.3/lib-tk/tkSimpleDialog. py", line 303, in askstring
    d = _QueryString(ti tle, 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('g rab', '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.minsiz e( 200,200 )

    mainmenu = Menu(self.Top)

    submenu = Menu( mainmenu, tearoff=0 )

    submenu.add_com mand( label = "New" , command = self.NewB )
    mainmenu.add_ca scade( label = "File",menu = submenu )

    self.Top.config ( menu=mainmenu )
    self.Top.mainlo op()
    #--------------------------------------------------------------------
    def NewB(self):
    ball = Ball(self.Top)
    #----------------------------------------------------------
    class Ball:
    def __init__(self,t op,ball=None):
    self.Top = Toplevel(top)
    self.Top.column configure(0,wei ght=1)
    self.Top.rowcon figure(1 ,weight=1)

    self.vscrol = Scrollbar(self. Top,orient="ver tical")
    self.vscrol.gri d(row=1,column= 1,sticky="ns")

    self.hscrol = Scrollbar(self. Top,orient="hor izontal")
    self.hscrol.gri d(row=2,column= 0,sticky="ew")
    self.listbox = Listbox( self.Top,
    font='system.fi xed 12',
    width=60,
    height=20,
    xscrollcommand= self.hscrol.set ,
    yscrollcommand= self.vscrol.set ,
    exportselection =0,
    selectmode=SING LE
    )
    self.listbox.gr id(row=1,column =0,sticky="nesw ")

    self.vscrol.con fig(command=sel f.listbox.yview )
    self.hscrol.con fig(command=sel f.listbox.xview )

    label = Label(self.Top, anchor='w',font ='system.fixed 12',text='headi ng')
    label.grid(row= 0,column=0,stic ky="ew")

    self.listbox.bi nd( "<Double-Button-1>",self.EditSi mpleText )
    self.LabelList = [
    ( "Last Name :","",self.Edit SimpleText),
    ( "First Name :","",self.Edit SimpleText),
    ]
    for x in self.LabelList:
    self.listbox.in sert(END,x[0]+ " " + x[1])
    #--------------------------------------------------------------------
    def EditSimpleText( self, event ):
    str = tkSimpleDialog. askstring('','e nter str')
    #----------------------------------------------------------
    if __name__ == '__main__':
    w = MainWindowClass ()

  • wes weston

    #2
    Re: why an exception

    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_visib ility() ############### added########## ###########3
    self.tk.call('g rab', '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

    Comment

    • wes weston

      #3
      Re: why an exception

      Patch submitted.
      wes

      Comment

      Working...