mouse-over ignores grid

  • lxpypg

    lxpypg - 2009-08-23

    XP, Python 2.6.2, wxPython, wxPropGrid 1.4.5

    Trying to implement mouse-over event as user moves the mouse over properties.

    I am using propertygrid manager with toolbar and description box.

    Self is a sub-class of wx.propgrid.PropertyGridManager

    Event binding code is:
    grid = self.GetGrid()
    grid.Bind(wx.EVT_MOTION, self.on_mouse)
    Also tried:
    self.Bind(wx.EVT_MOTION, self.on_mouse)

    The result is:  When the user moves the mouse in an area of the grid that is empty, the method, on_mouse, is called.  If the mouse is moving over a property/value item, on_mouse is not called.

    The behaviour I am trying to achieve is to display the property name in the status bar as the user moves the mouse over a property.

    I tried it with wx.propgrid 1.2.11 and it works.

    Do you have any suggestions?

    • Jaakko Salli

      Jaakko Salli - 2009-08-23

      Try binding to self.GetGrid().GetPanel(). Unlike in 1.2, version 1.4 has an intermediate panel between the property grid and properties (this is done to get cleaner behavior with wx.ScrolledWindow from which PG is derived from).

      Also, you could use wx.propgrid.EVT_PG_HIGHLIGHTED, which is generated each time mouse hovers over another property.


    • lxpypg

      lxpypg - 2009-08-23

      Thanks Jaakko, that worked!

      EVT_PG_HIGHLIGHTED is a better solution for displaying the property name in the status bar.  Thank you for that suggestion.

      I am also using wx.propgrid in a drag and drop operation.  Here is my experience so far...

      wxPropertyGrid::HitTest() is generating an error message:
      swig/python detected a memory leak of type 'wx.PropertyGridHitTestResult *', no destructor found.

      splitterHitOffset is missing from the documentation page.

      Here is a code snippet:
      grid = self.GetGrid()
      pg_hit_test_obj = grid.HitTest(position)
      column_index = pg_hit_test_obj.column
      splitter_index = pg_hit_test_obj.splitter
      splitter_offset = pg_hit_test_obj.splitterHitOffset
      pg_property = pg_hit_test_obj.GetProperty()

      Also, I tried:
      pg_hit_test_obj = self.HitTest(position)

      It returned: -10
      I expected it to return: None
      or not work at all.

      Another observation about HitTest()...
      I am using the Toolbar in propgridmanager.

      wx.PyDropTarget:OnDragOver gives me three parameters to work with:
      dnd_x, dnd_y, dnd_status_code.
      I use the x, y coordinates in a HitTest like this: self.hit_test_result(dnd_x, dnd_y)
      Because of the toolbar, I have to add 25 pixels to the dnd_y coordinate to have the HitTest return results for what the mouse is actually pointing to.

      HitTest is working for me and I like the OOP implementation: wxPropertyGridHitTestResult.
      I wish the Tree control HitTest returned an object like that.

      Thanks to your help, everything is working good!
      Thank you for wxPropertyGrid!

      • Jaakko Salli

        Jaakko Salli - 2009-08-23

        Right, SWIG seems to have trouble with structs/classes without explicit destructor. I've now converted wxPropertyGridHitTestResult into a real class, and for me it doesn't show the memory leak error.

        Thanks for reporting this!



Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks