Having a strange issue, new to wxForms.
I’m using wxFormBuilder to create a test form. Using visual studio to write the code.
Have a simple button, check, slider and gauge. Everything i have here works, however if i double click the button accidentally. (With or without a handler for double click) the button “Locks Up” and I can no longer push it, or move the slider. The gauge and check update fine however,
Any ideas???
Gui File
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()