mouse-overs with graphical objects

Hi,

In Tkinter you can plot a line in a Canvas
and then attach for example a mouseEnter event:

self.mycurve=self.MyCanvas.create_line(liste,width=3,fill="blue")

self.MyCanvas.tag_bind(mycurve, "<Enter>", self.mouseEnter)

How could one achieve something similar with wxPython
(eg. for a wxClientDC and a line created by dc.DrawLineList)?

Many thanks,

Arnd

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).
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')
                
        except EOFError:
          self.PrintLog('Connection perdue')
          self.connect.SetValue(0)
          self.connect.SetLabel('Connecter')
        
        except Exception, detail:
          self.PrintLog(detail)
          self.connect.SetValue(0)
          self.connect.SetLabel('Connecter')
      else :
        self.PrintLog('Connection impossible : vous devez renseigner tous les
champs !')
        self.connect.SetValue(0)
        self.connect.SetLabel('Connecter')
    else:
      try:
        tn.write("exit\n")
        tn.close()
      except:
        pass
      self.PrintLog('Connexion au serveur ferm\xe9e')
      self.connect.SetLabel('Connecter')
      
Thank's for your help.

···

--
Lionel Roubeyrie
lionel.roubeyrie@chello.fr

Sorry Arnd for my false reply !

···

--
Lionel Roubeyrie
lionel.roubeyrie@chello.fr

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).

--
Cliff Wells, Software Engineer
Logiplex Corporation (www.logiplex.net)
(503) 978-6726 (800) 735-0555

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.

--
Lionel Roubeyrie
lionel.roubeyrie@chello.fr

Close, try:

threading.Thread(target = tn.read_all).start()

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')' ?

--
Cliff Wells, Software Engineer
Logiplex Corporation (www.logiplex.net)
(503) 978-6726 (800) 735-0555

Thank's for your help, I'll try it tomorrow.

···

Le Vendredi 29 Août 2003 23:51, Cliff Wells a écrit :

Close, try:

threading.Thread(target = tn.read_all).start()

You need to pass the function that *will* be called, not call it
yourself.

Regards,

--
Lionel Roubeyrie
lionel.roubeyrie@chello.fr

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:

self.mycurve=self.MyCanvas.create_line(liste,width=3,fill="blue")

self.MyCanvas.tag_bind(mycurve, "<Enter>", self.mouseEnter)

How could one achieve something similar with wxPython
(eg. for a wxClientDC and a line created by dc.DrawLineList)?

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!