tests/wiimote/wxglade_hmi@wxglade_hmi/pyfile.xml
author Andrey Skvortsov <andrej.skvortzov@gmail.com>
Fri, 15 Sep 2017 19:01:31 +0300
changeset 1807 5562f34f2fc2
parent 1157 72d14a74c643
permissions -rw-r--r--
lazy initialization of highlight pens and brushes for DebugVariableViewer

Constructors wx.Pen() and wx.Brush() require wx.App to exist already.
That causes crash during import of the control,
because import is done before calling main application code.
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<PyFile>
  <variables/>
  <globals>
<![CDATA[
from threading import Thread

def OnConnectButton(self, event):
  def OnWiiConnected(mac_addr):
    self.label_2.SetLabel(
      "Wiimote %s connected"%mac_addr 
      if mac_addr else 
      "Wiimote connection failed !")

  def WiiConnected(mac_addr):
    wx.CallAfter(OnWiiConnected,mac_addr)

  Thread(target = Connect_Wiimote, args = (WiiConnected,)).start()
  self.label_2.SetLabel("Press wiimote 1+2")
  event.Skip()

def OnDisconnectButton(self, event):
  Disconnect_Wiimote()
  self.label_2.SetLabel("Wiimote disconnected")
  event.Skip()

]]>
  </globals>
  <init>
<![CDATA[
]]>
  </init>
  <cleanup>
<![CDATA[
]]>
  </cleanup>
  <start>
<![CDATA[
]]>
  </start>
  <stop>
<![CDATA[
]]>
  </stop>
</PyFile>