button double click causes freeze of GUI

Sean Carter <[email protected]> Tue, 15 Nov 2022 08:47:23 -0800 (PST)
Newsgroups gmane.comp.python.wxpython
Message-ID <[email protected]>
------=_Part_1976_149195367.1668530843276
Content-Type: multipart/alternative; 
	boundary="----=_Part_1977_1666448961.1668530843276"

------=_Part_1977_1666448961.1668530843276
Content-Type: text/plain; charset="UTF-8"

Hey everyone, just started playing with wxPython. Im using wxFormBuilder 
and visual studio for the code.

Got a little Gui working great, a button with up and down events, a slider 
, a check and a gauge.

But everytime i double click the button, it's likethe whole frame freezes, 
i can no long push the button, or move the slider. The gauge and check 
still update however

2 files - wxForm Gui (minus bind and code)

# -*- coding: utf-8 -*-

###########################################################################
## Python code generated with wxFormBuilder (version 3.10.1-0-g8feb16b3)
## http://www.wxformbuilder.org/
##
## PLEASE DO *NOT* EDIT THIS FILE!
###########################################################################

import wx
import wx.xrc

###########################################################################
## Class MyFrame1
###########################################################################

class MyFrame1 ( wx.Frame ):

    def __init__( self, parent ):
        wx.Frame.__init__ ( self, parent, id = wx.ID_ANY, title = 
wx.EmptyString, pos = wx.DefaultPosition, size = wx.Size( 500,300 ), style 
= wx.DEFAULT_FRAME_STYLE|wx.TAB_TRAVERSAL )

        self.SetSizeHints( wx.DefaultSize, wx.DefaultSize )

        gSizer1 = wx.GridSizer( 0, 2, 0, 0 )

        bSizer3 = wx.BoxSizer( wx.VERTICAL )

        self.m_button2 = wx.Button( self, wx.ID_ANY, u"Button", 
wx.DefaultPosition, wx.DefaultSize, 0 )
        bSizer3.Add( self.m_button2, 0, wx.ALL, 5 )

        self.m_slider2 = wx.Slider( self, wx.ID_ANY, 0, 0, 100, 
wx.DefaultPosition, wx.DefaultSize, wx.SL_HORIZONTAL )
        bSizer3.Add( self.m_slider2, 0, wx.ALL, 5 )


        gSizer1.Add( bSizer3, 1, wx.EXPAND, 5 )

        bSizer4 = wx.BoxSizer( wx.VERTICAL )

        self.m_radioBtn2 = wx.RadioButton( self, wx.ID_ANY, u"Light", 
wx.DefaultPosition, wx.DefaultSize, 0 )
        self.m_radioBtn2.SetValue( True )
        bSizer4.Add( self.m_radioBtn2, 0, wx.ALL, 5 )

        self.m_gauge1 = wx.Gauge( self, wx.ID_ANY, 100, wx.DefaultPosition, 
wx.DefaultSize, wx.GA_HORIZONTAL )
        self.m_gauge1.SetValue( 0 )
        bSizer4.Add( self.m_gauge1, 0, wx.ALL, 5 )


        gSizer1.Add( bSizer4, 1, wx.EXPAND, 5 )


        self.SetSizer( gSizer1 )
        self.Layout()

        self.Centre( wx.BOTH )

        # Connect Events
        self.m_button2.Bind( wx.EVT_LEFT_DCLICK, self.PB0_DC )

    def __del__( self ):
        pass


    # Virtual event handlers, override them in your derived class
    def PB0_DC( self, event ):
        event.Skip()

    def PB0_D( self, event ):
        event.Skip()

    def PB0_U( self, event ):
        event.Skip()

    def m_slider2OnSlider( self, event ):
        event.Skip()




Main file



from Gui import MyFrame1
import sys
import wx
import os
from pylogix import PLC

class f(MyFrame1):
    def __init__(self, parent):
        MyFrame1.__init__(self, parent)

       # Connect Event
        self.m_button2.Bind( wx.EVT_LEFT_DOWN, self.PB0_D )
        self.m_button2.Bind( wx.EVT_LEFT_UP, self.PB0_U )
        self.m_slider2.Bind( wx.EVT_SLIDER, self.m_slider2OnSlider )
        self.timer = wx.Timer(self)
        self.timer.Start(250)
        self.Bind(wx.EVT_TIMER, self.update, self.timer)
    
    def PB0_D( self, event ):
        clx.Write('buttons.0',1)
        
    def PB0_U( self, event ):
        clx.Write('buttons.0',0)

    def m_slider2OnSlider( self, event ):
        clx.Write('HMI_ANALOG_INPUT_CH1',self.m_slider2.Value)

    def update(self,event):
        IND0 = clx.Read('IND0')
        self.m_radioBtn2.SetValue(IND0.Value)
        CH1OUT = clx.Read('HMI_ANALOG_OUTPUT_CH1')
        self.m_gauge1.Value = int(CH1OUT.Value)
        self.Layout()
        self.Update()

def main():
    global clx
    clx = PLC('192.168.2.190',2)
    app = wx.App()
    frame = f(None)
    frame.Show()
    app.MainLoop()

if __name__ == '__main__':
    main()


ideas?

-- 
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/wxpython-users/5480905c-0839-4fe4-a4f9-1c24692a36fbn%40googlegroups.com.

------=_Part_1977_1666448961.1668530843276
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

Hey everyone, just started playing with wxPython. Im using wxFormBuilder an=
d visual studio for the code.<div><br></div><div>Got a little Gui working g=
reat, a button with up and down events, a slider , a check and a gauge.</di=
v><div><br></div><div>But everytime i double click the button, it's likethe=
 whole frame freezes, i can no long push the button, or move the slider. Th=
e gauge and check still update however<br><div><br></div><div>2 files - wxF=
orm Gui (minus bind and code)</div><div><br></div><div># -*- coding: utf-8 =
-*-<br><br>################################################################=
###########<br>## Python code generated with wxFormBuilder (version 3.10.1-=
0-g8feb16b3)<br>## http://www.wxformbuilder.org/<br>##<br>## PLEASE DO *NOT=
* EDIT THIS FILE!<br>######################################################=
#####################<br><br>import wx<br>import wx.xrc<br><br>############=
###############################################################<br>## Class=
 MyFrame1<br>##############################################################=
#############<br><br>class MyFrame1 ( wx.Frame ):<br><br>&nbsp; &nbsp; def =
__init__( self, parent ):<br>&nbsp; &nbsp; &nbsp; &nbsp; wx.Frame.__init__ =
( self, parent, id =3D wx.ID_ANY, title =3D wx.EmptyString, pos =3D wx.Defa=
ultPosition, size =3D wx.Size( 500,300 ), style =3D wx.DEFAULT_FRAME_STYLE|=
wx.TAB_TRAVERSAL )<br><br>&nbsp; &nbsp; &nbsp; &nbsp; self.SetSizeHints( wx=
.DefaultSize, wx.DefaultSize )<br><br>&nbsp; &nbsp; &nbsp; &nbsp; gSizer1 =
=3D wx.GridSizer( 0, 2, 0, 0 )<br><br>&nbsp; &nbsp; &nbsp; &nbsp; bSizer3 =
=3D wx.BoxSizer( wx.VERTICAL )<br><br>&nbsp; &nbsp; &nbsp; &nbsp; self.m_bu=
tton2 =3D wx.Button( self, wx.ID_ANY, u"Button", wx.DefaultPosition, wx.Def=
aultSize, 0 )<br>&nbsp; &nbsp; &nbsp; &nbsp; bSizer3.Add( self.m_button2, 0=
, wx.ALL, 5 )<br><br>&nbsp; &nbsp; &nbsp; &nbsp; self.m_slider2 =3D wx.Slid=
er( self, wx.ID_ANY, 0, 0, 100, wx.DefaultPosition, wx.DefaultSize, wx.SL_H=
ORIZONTAL )<br>&nbsp; &nbsp; &nbsp; &nbsp; bSizer3.Add( self.m_slider2, 0, =
wx.ALL, 5 )<br><br><br>&nbsp; &nbsp; &nbsp; &nbsp; gSizer1.Add( bSizer3, 1,=
 wx.EXPAND, 5 )<br><br>&nbsp; &nbsp; &nbsp; &nbsp; bSizer4 =3D wx.BoxSizer(=
 wx.VERTICAL )<br><br>&nbsp; &nbsp; &nbsp; &nbsp; self.m_radioBtn2 =3D wx.R=
adioButton( self, wx.ID_ANY, u"Light", wx.DefaultPosition, wx.DefaultSize, =
0 )<br>&nbsp; &nbsp; &nbsp; &nbsp; self.m_radioBtn2.SetValue( True )<br>&nb=
sp; &nbsp; &nbsp; &nbsp; bSizer4.Add( self.m_radioBtn2, 0, wx.ALL, 5 )<br><=
br>&nbsp; &nbsp; &nbsp; &nbsp; self.m_gauge1 =3D wx.Gauge( self, wx.ID_ANY,=
 100, wx.DefaultPosition, wx.DefaultSize, wx.GA_HORIZONTAL )<br>&nbsp; &nbs=
p; &nbsp; &nbsp; self.m_gauge1.SetValue( 0 )<br>&nbsp; &nbsp; &nbsp; &nbsp;=
 bSizer4.Add( self.m_gauge1, 0, wx.ALL, 5 )<br><br><br>&nbsp; &nbsp; &nbsp;=
 &nbsp; gSizer1.Add( bSizer4, 1, wx.EXPAND, 5 )<br><br><br>&nbsp; &nbsp; &n=
bsp; &nbsp; self.SetSizer( gSizer1 )<br>&nbsp; &nbsp; &nbsp; &nbsp; self.La=
yout()<br><br>&nbsp; &nbsp; &nbsp; &nbsp; self.Centre( wx.BOTH )<br><br>&nb=
sp; &nbsp; &nbsp; &nbsp; # Connect Events<br>&nbsp; &nbsp; &nbsp; &nbsp; se=
lf.m_button2.Bind( wx.EVT_LEFT_DCLICK, self.PB0_DC )<br><br>&nbsp; &nbsp; d=
ef __del__( self ):<br>&nbsp; &nbsp; &nbsp; &nbsp; pass<br><br><br>&nbsp; &=
nbsp; # Virtual event handlers, override them in your derived class<br>&nbs=
p; &nbsp; def PB0_DC( self, event ):<br>&nbsp; &nbsp; &nbsp; &nbsp; event.S=
kip()<br><br>&nbsp; &nbsp; def PB0_D( self, event ):<br>&nbsp; &nbsp; &nbsp=
; &nbsp; event.Skip()<br><br>&nbsp; &nbsp; def PB0_U( self, event ):<br>&nb=
sp; &nbsp; &nbsp; &nbsp; event.Skip()<br><br>&nbsp; &nbsp; def m_slider2OnS=
lider( self, event ):<br>&nbsp; &nbsp; &nbsp; &nbsp; event.Skip()<br><br><b=
r><div><br></div><div><br></div><div>Main file</div><div><br></div><div><br=
></div><div><br></div><div>from Gui import MyFrame1<br>import sys<br>import=
 wx<br>import os<br>from pylogix import PLC<br><br>class f(MyFrame1):<br>&n=
bsp; &nbsp; def __init__(self, parent):<br>&nbsp; &nbsp; &nbsp; &nbsp; MyFr=
ame1.__init__(self, parent)<br><br>&nbsp; &nbsp; &nbsp; &nbsp;# Connect Eve=
nt<br>&nbsp; &nbsp; &nbsp; &nbsp; self.m_button2.Bind( wx.EVT_LEFT_DOWN, se=
lf.PB0_D )<br>&nbsp; &nbsp; &nbsp; &nbsp; self.m_button2.Bind( wx.EVT_LEFT_=
UP, self.PB0_U )<br>&nbsp; &nbsp; &nbsp; &nbsp; self.m_slider2.Bind( wx.EVT=
_SLIDER, self.m_slider2OnSlider )<br>&nbsp; &nbsp; &nbsp; &nbsp; self.timer=
 =3D wx.Timer(self)<br>&nbsp; &nbsp; &nbsp; &nbsp; self.timer.Start(250)<br=
>&nbsp; &nbsp; &nbsp; &nbsp; self.Bind(wx.EVT_TIMER, self.update, self.time=
r)<br>&nbsp; &nbsp; <br>&nbsp; &nbsp; def PB0_D( self, event ):<br>&nbsp; &=
nbsp; &nbsp; &nbsp; clx.Write('buttons.0',1)<br>&nbsp; &nbsp; &nbsp; &nbsp;=
 <br>&nbsp; &nbsp; def PB0_U( self, event ):<br>&nbsp; &nbsp; &nbsp; &nbsp;=
 clx.Write('buttons.0',0)<br><br>&nbsp; &nbsp; def m_slider2OnSlider( self,=
 event ):<br>&nbsp; &nbsp; &nbsp; &nbsp; clx.Write('HMI_ANALOG_INPUT_CH1',s=
elf.m_slider2.Value)<br><br>&nbsp; &nbsp; def update(self,event):<br>&nbsp;=
 &nbsp; &nbsp; &nbsp; IND0 =3D clx.Read('IND0')<br>&nbsp; &nbsp; &nbsp; &nb=
sp; self.m_radioBtn2.SetValue(IND0.Value)<br>&nbsp; &nbsp; &nbsp; &nbsp; CH=
1OUT =3D clx.Read('HMI_ANALOG_OUTPUT_CH1')<br>&nbsp; &nbsp; &nbsp; &nbsp; s=
elf.m_gauge1.Value =3D int(CH1OUT.Value)<br>&nbsp; &nbsp; &nbsp; &nbsp; sel=
f.Layout()<br>&nbsp; &nbsp; &nbsp; &nbsp; self.Update()<br><br>def main():<=
br>&nbsp; &nbsp; global clx<br>&nbsp; &nbsp; clx =3D PLC('192.168.2.190',2)=
<br>&nbsp; &nbsp; app =3D wx.App()<br>&nbsp; &nbsp; frame =3D f(None)<br>&n=
bsp; &nbsp; frame.Show()<br>&nbsp; &nbsp; app.MainLoop()<br><br>if __name__=
 =3D=3D '__main__':<br>&nbsp; &nbsp; main()<br><br><br>ideas?</div><div><br=
></div></div></div>

<p></p>

-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;wxPython-users&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:[email protected]">wxpy=
[email protected]</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/d/msgid/wxpython-users/5480905c-0839-4fe4-a4f9-1c24692a36fbn%40googlegro=
ups.com?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.com/d=
/msgid/wxpython-users/5480905c-0839-4fe4-a4f9-1c24692a36fbn%40googlegroups.=
com</a>.<br />

------=_Part_1977_1666448961.1668530843276--

------=_Part_1976_149195367.1668530843276--