In an application, I try to connect to a telnet server with the telnetlib
module. My ConnectButton is a ToggleButton and all the messages (exceptions,
...) go in a wxTextCtl via a PrintLog method. But if I put :
self.PrintLog(tn.read_all()) for read the socket, the application freeze and
with it all my screens (I work under Linux).
What's wrong with my code :
def OnConnectButton(self, event):
if self.connect.GetValue(): #Le bouton est presse
self.connect.SetLabel('D\xe9connecter')
host = self.srv_adress.GetValue()
user = self.srv_user.GetValue()
pwd = self.srv_pass.GetValue()
if (host != '') and (user != '') and (pwd != ''):
try:
tn = telnetlib.Telnet(host)
self.PrintLog('Attente de login ...')
tn.read_until('login:', 15)
tn.write(user + '\n')
self.PrintLog('Attente d\'authentification ...')
tn.read_until('Password:', 15)
tn.write(pwd + '\n')
self.PrintLog('Connexion r\xe9ussie ...')
#~ tn.read_until('$', 15)
#~ self.PrintLog('Ok')
tn.write('uname -a \n')
tn.write("exit\n")
self.PrintLog(tn.read_all())
tn.close()
self.PrintLog('Ferme')
When you call tn.read_a(), the thread of program control goes into that
method and never returns. This means that the entire wxPython library
is waiting for this method to either return or yeild control back to the
wxPython main loop. You can simulate this effect by sticking
while 1: pass
anywhere in your program. It will cause the wxPython GUI to "lock". It
isn't really locked, of course, just waiting. The net result is the
same, however.
Since read_all() is part of a library, I would suggest putting it in a
thread so that the rest of the application can continue.
···
On Fri, 2003-08-29 at 13:45, Lionel Roubeyrie wrote:
Hi all,
In an application, I try to connect to a telnet server with the telnetlib
module. My ConnectButton is a ToggleButton and all the messages (exceptions,
...) go in a wxTextCtl via a PrintLog method. But if I put :
self.PrintLog(tn.read_all()) for read the socket, the application freeze and
with it all my screens (I work under Linux).
I never use thread, but I think is like :
threading.Thread(target=tn.read_all()).start() isn't it?
But why don't I have the response of 'tn.write('uname -a \n')' ?
Thank's
···
Le Vendredi 29 Août 2003 23:02, Cliff Wells a écrit :
When you call tn.read_a(), the thread of program control goes into that
method and never returns. This means that the entire wxPython library
is waiting for this method to either return or yeild control back to the
wxPython main loop. You can simulate this effect by sticking
while 1: pass
anywhere in your program. It will cause the wxPython GUI to "lock". It
isn't really locked, of course, just waiting. The net result is the
same, however.
Since read_all() is part of a library, I would suggest putting it in a
thread so that the rest of the application can continue.
You need to pass the function that *will* be called, not call it
yourself.
Regards,
···
On Fri, 2003-08-29 at 14:30, Lionel Roubeyrie wrote:
I never use thread, but I think is like :
threading.Thread(target=tn.read_all()).start() isn't it?
But why don't I have the response of 'tn.write('uname -a \n')' ?
The wxDC classes are much lower level than the canvas in tkinter, and are really only for drawing. You would have to work at a similarly low level with the mouse events and calculate the mouse overs yourself.
Another option is to use the wxOGL library which provides a simple shaped object canvas, but it is old a crufty and sometimes difficult to use. There are also some other canvas-like classes available, you can probably find pointers in the mail archives.
···
arnd.baecker@web.de wrote:
Hi,
In Tkinter you can plot a line in a Canvas
and then attach for example a mouseEnter event: