Hello,

I'm trying to detect when the pointer enters or leaves the area of a drawing
area, so I did the obvious thing of putting the drawing area in an event box
and hooking callbacks up to its enter_notify_event and leave_notify_events.

This works fine, but I'm also getting enter and leave notifications when the
mouse gets clicked inside the drawing area. Why does this happen, and what do I
do to stop it?

Following is the glade file and python code for the test script.
Thanks in advance!
-lars

------------------------------------
test.glade
------------------------------------

<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*-->
<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd";>

<glade-interface>

<widget class="GtkWindow" id="window1">
  <property name="visible">True</property>
  <property name="title" translatable="yes">window1</property>
  <property name="type">GTK_WINDOW_TOPLEVEL</property>
  <property name="window_position">GTK_WIN_POS_NONE</property>
  <property name="modal">False</property>
  <property name="resizable">True</property>
  <property name="destroy_with_parent">False</property>

  <child>
    <widget class="GtkFrame" id="frame1">
      <property name="border_width">42</property>
      <property name="visible">True</property>
      <property name="label_xalign">0</property>
      <property name="label_yalign">0.5</property>
      <property name="shadow_type">GTK_SHADOW_ETCHED_IN</property>

      <child>
        <widget class="GtkEventBox" id="eventbox1">
          <property name="visible">True</property>
          <signal name="enter_notify_event" handler="on_eventbox1_enter_notify_event" 
last_modification_time="Fri, 13 Jun 2003 20:49:46 GMT"/>
          <signal name="leave_notify_event" handler="on_eventbox1_leave_notify_event" 
last_modification_time="Fri, 13 Jun 2003 20:49:53 GMT"/>

          <child>
            <widget class="GtkDrawingArea" id="drawingarea1">
              <property name="width_request">20</property>
              <property name="height_request">55</property>
              <property name="visible">True</property>
            </widget>
          </child>
        </widget>
      </child>

      <child>
        <widget class="GtkLabel" id="label1">
          <property name="visible">True</property>
          <property name="label" translatable="yes">event box</property>
          <property name="use_underline">False</property>
          <property name="use_markup">False</property>
          <property name="justify">GTK_JUSTIFY_LEFT</property>
          <property name="wrap">False</property>
          <property name="selectable">False</property>
          <property name="xalign">0.5</property>
          <property name="yalign">0.5</property>
          <property name="xpad">0</property>
          <property name="ypad">0</property>
        </widget>
        <packing>
          <property name="type">label_item</property>
        </packing>
      </child>
    </widget>
  </child>
</widget>

</glade-interface>

---------------------------------
test.py
---------------------------------
#!/usr/bin/env python2

import gtk
from gtk import glade

def enter(widget, event):
    print "enter"

def leave(widget, event):
    print "leave"

x = glade.XML('test.glade')
x.signal_autoconnect({"on_eventbox1_enter_notify_event": enter,
                      "on_eventbox1_leave_notify_event": leave})
x.get_widget('window1').connect('destroy', gtk.mainquit)
gtk.mainloop()

___________________________________________________________
lars damerow
button pusher
pixar animation studios
[EMAIL PROTECTED]

I'm your only friend, I'm not your only friend, but I'm a little glowing
friend, but really I'm not actually your friend, but I am...
_______________________________________________
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/

Reply via email to