Button drag

1 view
Skip to first unread message

philippe DALET

unread,
Jun 8, 2019, 5:28:35 AM6/8/19
to wxPython-dev
Hello

I try to drag a button with the mouse on a panel.

It works fine on win7 (64bits) with wxpython 4.0.6.  py3.7.3

On Ubuntu 18.04--16.04  (64bits) with wxpython 4.0.6. GTK2 py3.5 or py3.6, a capturelost event appears, and after my script is out of control.
Only alt+F4 can stop the script.

if I change the code like this
    def OnMouseDown(self, event):
        self.btn.CaptureMouse()
        self.btn.ReleaseMouse()
it works fine.

How to avert this event ?

Thanks for your reply.

Ph.DALET
buttonDrag.py

Robin Dunn

unread,
Jun 10, 2019, 2:42:40 PM6/10/19
to wxPython-dev
On Saturday, June 8, 2019 at 2:28:35 AM UTC-7, philippe DALET wrote:
Hello

I try to drag a button with the mouse on a panel.

It works fine on win7 (64bits) with wxpython 4.0.6.  py3.7.3

On Ubuntu 18.04--16.04  (64bits) with wxpython 4.0.6. GTK2 py3.5 or py3.6, a capturelost event appears, and after my script is out of control.
Only alt+F4 can stop the script.

On X this usually means that something has the mouse captured but doesn't release it.

 
if I change the code like this
    def OnMouseDown(self, event):
        self.btn.CaptureMouse()
        self.btn.ReleaseMouse()
it works fine.

How to avert this event ?


It's probable that the native widget itself is doing something with the capture, or even that the parent or some other window is stealing the capture. I noticed that if I change your sample to use a generic widget like wx.lib.buttons.ThemedGenButton that it didn't have any problems.

 
--
Robin

philippe DALET

unread,
Jun 12, 2019, 2:38:30 PM6/12/19
to wxPyth...@googlegroups.com
Thanks a lot. It works fine with this generic button.
Philippe

--
You received this message because you are subscribed to the Google Groups "wxPython-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wxPython-dev...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/wxPython-dev/b15a48f5-1eed-4d86-b959-c1c0b7f7b259%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

philippe DALET

unread,
Jun 15, 2019, 10:06:52 AM6/15/19
to wxPython-dev
Hello,

I have the same problem when I drag with this widgets like button
checkbox
choice 
combobox
Floatcanvas
stc.StyledTextCtrl)
imagebutton
listbox
notebook
texctrl

but no problems with this widgets
bitmapconvas
calendar

The file joined (checkbox.py)  works fine on win7 64bits and wxpython 4.0.6.
I have not seen a generic Checkbox.

Philippe
checkbox.py

Robin Dunn

unread,
Jun 19, 2019, 5:19:15 PM6/19/19
to wxPython-dev
On Saturday, June 15, 2019 at 7:06:52 AM UTC-7, philippe DALET wrote:
Hello,

I have the same problem when I drag with this widgets like button
checkbox
choice 
combobox
Floatcanvas
stc.StyledTextCtrl)
imagebutton
listbox
notebook
texctrl

but no problems with this widgets
bitmapconvas
calendar

The file joined (checkbox.py)  works fine on win7 64bits and wxpython 4.0.6.
I have not seen a generic Checkbox.

One way to work around things like this is to create an image to represent the widget while dragging, and hide the real widget when the drag starts and show the image instead. Then when the drag is done you can move the real widget and then show it. The wx.DragImage class can help you with the dragging part.

--
Robin
Reply all
Reply to author
Forward
0 new messages