Re: Button drag
philippe DALET <[email protected]> Sat, 15 Jun 2019 07:06:52 -0700 (PDT)
| Newsgroups | gmane.comp.python.wxpython.devel |
|---|---|
| Message-ID | <[email protected]> |
------=_Part_1204_1153280170.1560607612490 Content-Type: multipart/alternative; boundary="----=_Part_1205_2146789089.1560607612490" ------=_Part_1205_2146789089.1560607612490 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hello, I have the same problem when I drag with this widgets like button checkbox choice=20 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 Le samedi 8 juin 2019 11:28:35 UTC+2, philippe DALET a =C3=A9crit : > > 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= ,=20 > 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 > --=20 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 e= mail to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/= wxPython-dev/b48a0a98-4430-459f-bd5d-bf0b949513b9%40googlegroups.com. For more options, visit https://groups.google.com/d/optout. ------=_Part_1205_2146789089.1560607612490 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable <div dir=3D"ltr">Hello,<div><br></div><div>I have the same problem when I d= rag with this widgets like button</div><div><div>checkbox</div><div>choice= =C2=A0</div><div>combobox</div><div>Floatcanvas</div><div>stc.StyledTextCtr= l)<br></div><div>imagebutton</div><div>listbox</div><div>notebook</div><div= >texctrl</div><div><br></div><div>but no problems with this widgets</div><d= iv>bitmapconvas</div><div>calendar</div><div><br></div><div>The file joined= (checkbox.py)=C2=A0 works fine on win7 64bits and wxpython 4.0.6.</div><di= v>I have not seen a generic Checkbox.</div><div><br></div><div>Philippe</di= v><div><br></div><div><br></div><br><br><br><br>Le samedi 8 juin 2019 11:28= :35 UTC+2, philippe DALET a =C3=A9crit=C2=A0:<blockquote class=3D"gmail_quo= te" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;paddi= ng-left: 1ex;"><div dir=3D"ltr"><div>Hello</div><div><br></div><div>I try t= o drag a button with the mouse on a panel.</div><div><br></div><div>It work= s fine on win7 (64bits) with wxpython 4.0.6.=C2=A0 py3.7.3</div><div><br></= div><div>On Ubuntu 18.04--16.04=C2=A0 (64bits) with wxpython 4.0.6. GTK2 = py3.5 or py3.6, a capturelost event appears, and after my script is out of = control.</div><div>Only alt+F4 can stop the script.<br></div><div><br></div= ><div>if I change the code like this</div><div>=C2=A0=C2=A0=C2=A0 def OnMou= seDown(self, event):<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 self.btn= .CaptureMouse()</div><div>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 self.b= tn.ReleaseMouse()<br></div><div></div><div></div><div>it works fine.</div><= div><br></div><div>How to avert this event ?<br></div><div><br></div><div>T= hanks for your reply.<br></div><div><br></div><div></div><div>Ph.DALET<br><= /div></div></blockquote></div></div> <p></p> -- <br /> You received this message because you are subscribed to the Google Groups &= quot;wxPython-dev" group.<br /> To unsubscribe from this group and stop receiving emails from it, send an e= mail to <a href=3D"mailto:[email protected]">wxPyth= [email protected]</a>.<br /> To view this discussion on the web visit <a href=3D"https://groups.google.c= om/d/msgid/wxPython-dev/b48a0a98-4430-459f-bd5d-bf0b949513b9%40googlegroups= .com?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.com/d/ms= gid/wxPython-dev/b48a0a98-4430-459f-bd5d-bf0b949513b9%40googlegroups.com</a= >.<br /> For more options, visit <a href=3D"https://groups.google.com/d/optout">http= s://groups.google.com/d/optout</a>.<br /> ------=_Part_1205_2146789089.1560607612490-- ------=_Part_1204_1153280170.1560607612490 Content-Type: text/x-python; charset=US-ASCII; name=checkbox.py Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=checkbox.py X-Attachment-Id: a75ff4e0-04b0-4408-839c-cc9eb86b4836 Content-ID: <a75ff4e0-04b0-4408-839c-cc9eb86b4836> import wx import time class Mywin(wx.Frame): def __init__(self, parent, title): super(Mywin, self).__init__(parent, title = title,size = (400,200)) self.InitUI() self.Centre() def InitUI(self): self.panel = wx.Panel(self) vbox = wx.BoxSizer(wx.VERTICAL) self.chk = wx.CheckBox(self.panel,-1,"click Me",pos=(10, 10)) vbox.Add(self.chk,0,wx.ALIGN_CENTER) self.chk.Bind(wx.EVT_LEFT_DOWN, self.OnMouseDown) self.chk.Bind(wx.EVT_MOTION, self.OnMouseMove) self.chk.Bind(wx.EVT_LEFT_UP, self.OnMouseUp) self.chk.Bind(wx.EVT_MOUSE_CAPTURE_LOST, self.OnCaptureLost) print ("Init pos:",self.chk.GetPosition()) def OnMouseDown(self, event): self.chk.CaptureMouse() print ("Left Down") sx,sy = self.panel.ScreenToClient(self.chk.GetPosition()) dx,dy = self.panel.ScreenToClient(wx.GetMousePosition()) self.chk._x,self.chk._y = (sx-dx, sy-dy) def OnMouseMove(self, event): if event.Dragging() and event.LeftIsDown(): x, y = wx.GetMousePosition() self.chk.SetPosition(wx.Point(x+self.chk._x,y+self.chk._y)) print(self.chk.GetPosition()) def OnMouseUp(self, event): if (self.chk.HasCapture()): self.chk.ReleaseMouse() print ("Final pos:",self.chk.GetPosition()) def OnCaptureLost(self, event): print ("Err") print(self.chk.GetCapture()) def main(): app = wx.App() w = Mywin(None, title='Checkbox drag demo') w.Show() app.MainLoop() if __name__ == '__main__': main() ------=_Part_1204_1153280170.1560607612490--