Button drag

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 (1.64 KB)

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.

···

On Saturday, June 8, 2019 at 2:28:35 AM UTC-7, philippe DALET wrote:

Robin

Thanks a lot. It works fine with this generic button.
Philippe

Le lun. 10 juin 2019 à 20:42, Robin Dunn robin@alldunn.com a écrit :

···

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

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+unsubscribe@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.

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 (1.65 KB)

···

Le samedi 8 juin 2019 11:28:35 UTC+2, philippe DALET a écrit :

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

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.

···

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.

Robin

Philippe

Le samedi 8 juin 2019 11:28:35 UTC+2, philippe DALET a écrit :

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