I’d like to be able to drag a button around on a panel and drop it wherever I like, but the problem I’m having is that the dragging of my button is incongruent with the motion of the mouse; it’s not a 1:1 ratio, the mouse moves faster than the control gets moved.
Additionally, the control doesn’t drag smoothly; it “jitters” as it moves along.
Any ideas?
Take a look at the mouse event handlers in the ShapedWindow sample in the demo. It has some basic code for dragging the window around the screen that should be able to be easily adapted to your needs. Since it is handling dragging of a top level window it is using screen coordinates, so you'll probably want to use coordinates relative to the button's parent window instead.
···
On 1/26/11 12:58 PM, mw wrote:
I'd like to be able to drag a button around on a panel and drop it
wherever I like, but the problem I'm having is that the dragging of my
button is incongruent with the motion of the mouse; it's not a 1:1
ratio, the mouse moves faster than the control gets moved.
Additionally, the control doesn't drag smoothly; it "jitters" as it
moves along.
Any ideas?
On Wed, Jan 26, 2011 at 1:34 PM, Robin Dunn robin@alldunn.com wrote:
On 1/26/11 12:58 PM, mw wrote:
I’d like to be able to drag a button around on a panel and drop it
wherever I like, but the problem I’m having is that the dragging of my
button is incongruent with the motion of the mouse; it’s not a 1:1
ratio, the mouse moves faster than the control gets moved.
Additionally, the control doesn’t drag smoothly; it “jitters” as it
moves along.
Any ideas?
Take a look at the mouse event handlers in the ShapedWindow sample in the demo. It has some basic code for dragging the window around the screen that should be able to be easily adapted to your needs. Since it is handling dragging of a top level window it is using screen coordinates, so you’ll probably want to use coordinates relative to the button’s parent window instead.
On Wed, Jan 26, 2011 at 1:34 PM, Robin Dunn robin@alldunn.com wrote:
On 1/26/11 12:58 PM, mw wrote:
I’d like to be able to drag a button around on a panel and drop it
wherever I like, but the problem I’m having is that the dragging of my
button is incongruent with the motion of the mouse; it’s not a 1:1
ratio, the mouse moves faster than the control gets moved.
Additionally, the control doesn’t drag smoothly; it “jitters” as it
moves along.
Any ideas?
Take a look at the mouse event handlers in the ShapedWindow sample in the demo. It has some basic code for dragging the window around the screen that should be able to be easily adapted to your needs. Since it is handling dragging of a top level window it is using screen coordinates, so you’ll probably want to use coordinates relative to the button’s parent window instead.
You were still mixing coordinates relative to the frame and relative to the button. Switching to do everything relative to the frame takes care of the problem. Oh and you really do need to capture the mouse.
I know I am pointing to a very old post. I recently came across this post and tried out the attached code in Windows/Python2.7/wxpython 3.0
It worked as expected.
But when I tried the same code in Ubuntu 14.04/ Python 2.7 and python-wxgtk2.8 , I am not able to drag the button at all.
What I noticed is mouse motion events are not triggered when mouse left button is down for a wx.button.
Is there any workaround to fix this issue?
Thank you in advance
TSCOM
···
On Thursday, 27 January 2011 05:35:56 UTC+5:30, Robin Dunn wrote:
On 1/26/11 3:34 PM, mw wrote:
Same weirdness; the mouse movement greatly outpaces the drag of the
control across the face of the frame or a panel.
You were still mixing coordinates relative to the frame and relative to
the button. Switching to do everything relative to the frame takes care
of the problem. Oh and you really do need to capture the mouse.
Interesting. It works if you make it a panel instead of a button.
That doesn’t make much sense. I don’t know who is eating the
mouse-move and mouse-up events. You’re not propagating the
mouse-down event to the button, so it shouldn’t be doing any special
handling.
That does bring up a question. If you’re capturing the mouse-down
event, how will the button ever be able to behave like a button?
When I try it, it also misses the mouse-up event. The only way to
bring the mouse back is to alt-tab to a command shell and kill the
app.
By default the button expands to fill the frame. You can avoid that
by creating a panel, then adding the button to the panel.
···
TSCOM wrote:
I know I am pointing to a very old post. I recently came
across this post and tried out the attached code in
Windows/Python2.7/wxpython 3.0
It worked as expected.
But when I tried the same code in Ubuntu 14.04/ Python 2.7
and python-wxgtk2.8 , I am not able to drag the button at
all.
What I noticed is mouse motion events are not triggered
Like you said,I created a panel and added button to the panel…still it shows the same behavior…I commented out the **self.btn.CaptureMouse() in **
**onButton()** and this change helped the button to detect mouse up event, but still not detecting the mouse motion with left down...
Regarding your question about actual button behavior, my goal is to change the mouse left down handler of the button depending on a particular flag.
In one case, I should be able to drag the button (left down and motion / drag) for rearranging it and in the other case, I use the left down for actual button activation.
This idea worked perfectly in Windows..and **that is why I moved on to Ubuntu/ Raspberry Pi and noticed this issue.**
Hope you understand my problem. Any workaround?
Thank you once again,
TSCOM
···
On Thu, Apr 26, 2018 at 11:24 PM, Tim Roberts timr@probo.com wrote:
TSCOM wrote:
I know I am pointing to a very old post. I recently came
across this post and tried out the attached code in
Windows/Python2.7/wxpython 3.0
It worked as expected.
But when I tried the same code in Ubuntu 14.04/ Python 2.7
and python-wxgtk2.8 , I am not able to drag the button at
all.
What I noticed is mouse motion events are not triggered
when mouse left button is down for a wx.button.
-- Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.
Interesting. It works if you make it a panel instead of a button.
That doesn’t make much sense. I don’t know who is eating the
mouse-move and mouse-up events. You’re not propagating the
mouse-down event to the button, so it shouldn’t be doing any special
handling.
That does bring up a question. If you're capturing the mouse-down
event, how will the button ever be able to behave like a button?
When I try it, it also misses the mouse-up event. The only way to
bring the mouse back is to alt-tab to a command shell and kill the
app.
By default the button expands to fill the frame. You can avoid that
by creating a panel, then adding the button to the panel.
–
You received this message because you are subscribed to the Google Groups “wxPython-users” group.
Right, I understood your problem from the beginning. I was easily
able to duplicate the problem on my Ubuntu setup. I can’t explain
it. I believe it’s something inside GTK.
Here’s an interesting tidbit. If you add “event.Skip()” to your
onMove handler, the dragging works – every other time. That tells
me the problem MUST be related to the button’s own mouse capture
handling. Buttons capture the mouse when you click them so they can
change their color when you move the mouse away.
···
Abi wrote:
Like you said,I created a panel and added button to the
panel…still it shows the same behavior…I commented out the **self.btn.CaptureMouse() in **
**onButton()** and this change helped the button to detect mouse up event, but still not detecting the mouse motion with left down...
Regarding your question about actual button behavior, my goal is to change the mouse left down handler of the button depending on a particular flag.
In one case, I should be able to drag the button (left down and motion / drag) for rearranging it and in the other case, I use the left down for actual button activation.
This idea worked perfectly in Windows..and **that is why I moved on to Ubuntu/ Raspberry Pi and noticed this issue.**