FAQ
I am trying to do the following using Python and Tkinter:

1) Display a window with 1 button
2) When user clicks the button, Python attempts to call a function
that opens a socket and listens for a connection - what I want to do
is, if the socket has been successfully opened and the system is
waiting for a connection, to turn the button green.

The problem I'm having is when the button is clicked, the color never
changes and the application "locks up" until the remote end connects
and disconnects. Where can I put the button configuration statement so
that it will turn green to indicate the socket was opened successfully?
Thanks!

Search Discussions

  • Kent Johnson at Feb 27, 2006 at 4:51 pm

    D wrote:
    I am trying to do the following using Python and Tkinter:

    1) Display a window with 1 button
    2) When user clicks the button, Python attempts to call a function
    that opens a socket and listens for a connection - what I want to do
    is, if the socket has been successfully opened and the system is
    waiting for a connection, to turn the button green.

    The problem I'm having is when the button is clicked, the color never
    changes and the application "locks up" until the remote end connects
    and disconnects. Where can I put the button configuration statement so
    that it will turn green to indicate the socket was opened successfully?
    You need to give some time to the GUI so it can draw. A minimal solution
    is to call root.update_idletasks() after you set the button to green. If
    you want the GUI to be responsive you have to run the socket in a
    separate thread; this recipe may give you some help though it may be
    more complex than you need:
    http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/82965

    Kent
  • D at Feb 27, 2006 at 7:21 pm
    Thanks Kent! update_idletasks() does exactly what I needed, which as
    you mentioned was just to give it enough time to reconfigure the
    button.

    Doug

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppython-list @
categoriespython
postedFeb 27, '06 at 3:44p
activeFeb 27, '06 at 7:21p
posts3
users2
websitepython.org

2 users in discussion

D: 2 posts Kent Johnson: 1 post

People

Translate

site design / logo © 2022 Grokbase