Tkinter problem

62 views
Skip to first unread message

Eric

unread,
Aug 27, 2012, 3:32:06 AM8/27/12
to pypu...@googlegroups.com
Hi all,
I am running into a problem where Tkinter is crashing if I send a message but it is fine if I comment out sendMessage.  I put in print stmts to show the internal id for the problem control (self.msg_ctrl_login._w) and it is somehow reverting to an earlier control reference when sendMessage is used. 

The sequence is to start a main dialog, click a Login button to bring up a Login dialog, fill in the login info and click connect.  If the login fails, a message is published, pub.sendMessage("agile.fail.connect", msg=Config.MSG_AGILE_CONN_TIMEOUT) to change a message and background color of a label on the Login diaglog.

I ran a sequence of launching the Login dialog, print the control ID at the end of the init routine; click Login and print the ID again, after a timeout failure the Login function exits and prints again.  I cancel out of the dialog (destroy it) and get another print.

Here is the debug output:

(sendMessage commented out, you can see the designator change when Login launches a second time)
Init done   .51829376.51860184.51860384
Login entry .51829376.51860184.51860384
Login exit  .51829376.51860184.51860384
Cancel      .51829376.51860184.51860384

Init done   .51850896.51863064.53428392 << New designator
Login entry .51850896.51863064.53428392
Login exit  .51850896.51863064.53428392
Cancel      .51850896.51863064.53428392

=========================================
2nd try
pub.sendMessage enabled, prints the msg and the control ID ("Failed...") in the subscribed function

Init done   .52750976.52766760.52766960
Login entry .52750976.52766760.52766960
Msg         Connection Timeout
Failed      .52750976.52766760.52766960
Login exit  .52750976.52766760.52766960
Cancel      .52750976.52766760.52766960

Init done   .52766320.52787240.52786880
Login entry .52766320.52787240.52786880
Msg         Connection Timeout
Failed      .52750976.52766760.52766960 << reference reverted???

Exception in Tkinter callback
Traceback (most recent call last):
  File "D:\Python27\Lib\lib-tk\Tkinter.py", line 1410, in __call__
    return self.func(*args)
  File "D:\SVNRepo\projects-sw\ISIApps\trunk\src\virtenv\src\agile_revision_check.py", line 640, in login
    if connection_agile.login(self.txtUser_name.get(), self.txtPassword.get()):
  File "D:\SVNRepo\projects-sw\ISIApps\trunk\src\virtenv\src\agile_revision_check.py", line 412, in login
    if not self.connect():
  File "D:\SVNRepo\projects-sw\ISIApps\trunk\src\virtenv\src\agile_revision_check.py", line 405, in connect
    pub.sendMessage("agile.fail.connect", msg=Config.MSG_AGILE_CONN_TIMEOUT)
  File "d:\SVNRepo\projects-sw\ISIApps\trunk\src\virtenv\lib\site-packages\pubsub\core\kwargs\publisher.py", line 30, in sendMessage
    topicObj.publish(**kwargs)
  File "d:\SVNRepo\projects-sw\ISIApps\trunk\src\virtenv\lib\site-packages\pubsub\core\kwargs\publishermixin.py", line 24, in publish
    self._publish(msgKwargs)
  File "d:\SVNRepo\projects-sw\ISIApps\trunk\src\virtenv\lib\site-packages\pubsub\core\topicobj.py", line 340, in _publish
    self.__sendMessage(data, self, iterState)
  File "d:\SVNRepo\projects-sw\ISIApps\trunk\src\virtenv\lib\site-packages\pubsub\core\topicobj.py", line 359, in __sendMessage
    self._mix_callListener(listener, data, iterState)
  File "d:\SVNRepo\projects-sw\ISIApps\trunk\src\virtenv\lib\site-packages\pubsub\core\kwargs\publishermixin.py", line 64, in _mix_callListener
    listener(iterState.filteredArgs, self, msgKwargs)
  File "d:\SVNRepo\projects-sw\ISIApps\trunk\src\virtenv\lib\site-packages\pubsub\core\kwargs\listenerimpl.py", line 27, in __call__
    cb(**kwargs)
  File "D:\SVNRepo\projects-sw\ISIApps\trunk\src\virtenv\src\agile_revision_check.py", line 673, in logon_failure
    self.msg_ctrl_login.configure(bg=Config.CTRL_COLOR_LOGIN_FAIL)
  File "D:\Python27\Lib\lib-tk\Tkinter.py", line 1202, in configure
    return self._configure('configure', cnf, kw)
  File "D:\Python27\Lib\lib-tk\Tkinter.py", line 1193, in _configure
    self.tk.call(_flatten((self._w, cmd)) + self._options(cnf))
TclError: invalid command name ".52750976.52766760.52766960"

This is with PyPubSub 3.1.2, Python 2.7 on Windows 7.

I'd appreciate any pointers on how to troubleshoot this further.

Thanks,
Eric

oliver

unread,
Aug 27, 2012, 7:17:02 AM8/27/12
to pypu...@googlegroups.com
Eric, 
This error appears to be in the listener body, ie it is not a pubsub error (pubsub isn't complaining of incompatible listener signature, or missing message data etc). Looks like TkInter is choking when it uses the dialog box text field contents. Is the dialog box instance still existing at that point? Why not pass the contents needed as part of the message data: 

pub.sendMessage("agile.fail.connect", 
    msg  = Config.MSG_AGILE_CONN_TIMEOUT, 
    user = self.txtUser_name.get(), 
    pwd  = self.txtPassword.get())

After all, the dialog box is just a means of getting the data, but the listener should probably not care about this, it just wants the data. 

Oliver

Eric

unread,
Nov 5, 2012, 1:51:44 AM11/5/12
to pypu...@googlegroups.com
Hi Oliver,

You were right, the dialog box instance was destroyed and then I tried to set the cursor back to the normal cursor, reversed the order of the two statements and life was good...
Thanks,
Eric
 

oliver

unread,
Nov 5, 2012, 7:17:56 AM11/5/12
to PyPubSub
Awesome to hear, thanks for the update!


 

--
You received this message because you are subscribed to the Google Groups "pypubsub" group.
To view this discussion on the web visit https://groups.google.com/d/msg/pypubsub/-/91zH64dJkzQJ.
To post to this group, send email to pypu...@googlegroups.com.
To unsubscribe from this group, send email to pypubsub+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/pypubsub?hl=en.

Reply all
Reply to author
Forward
0 new messages