import time import wx import wx.gizmos as gizmos import config #---------------------------------------------------------------------- from ctypes import * # load BCA_Lib.dll bca = cdll.LoadLibrary("BCA_Lib.dll") # function CMPFUNC = CFUNCTYPE(None, c_void_p, c_ubyte, c_ubyte, c_void_p, c_uint, c_void_p) # show_alc = 1 # verbose = 0 # receive function def recv_func(contx, channel, event, data, length, cookie): dat = cast(data, POINTER(c_ubyte)) config.alc = dat[1] if verbose: print "recv_func:", config.alc # time.sleep(0) return # class TestPanel(wx.Panel): def __init__(self, parent, log): wx.Panel.__init__(self, parent, -1) self.log = log self.sizer = wx.BoxSizer(wx.VERTICAL) # self.text_alc = wx.StaticText(self, label="alc") # img_temp = wx.Image("hare.jpg", wx.BITMAP_TYPE_JPEG).ConvertToBitmap() # button_temp = wx.BitmapButton(self, -1, img_temp, (0,0), (100,100)) # alc led = gizmos.LEDNumberCtrl(self, -1) #, (0,0), (320, 240), # gizmos.LED_ALIGN_CENTER | gizmos.LED_DRAW_FADED) self.led_alc = led self.sizer.Add(self.led_alc, 1, wx.EXPAND) self.SetSizer(self.sizer) self.SetAutoLayout(1) self.sizer.Fit(self) # self.OnTimer(None) self.timer = wx.Timer(self) self.timer.Start(5000) self.Bind(wx.EVT_TIMER, self.OnTimer) def OnTimer(self, evt): if show_alc == 1: st = "%d" % config.alc # print "alc",st self.led_alc.SetValue(st) # time.sleep(0) def OnPaint(self, evt): print ("OnPaint evt") def ShutdownDemo(self): self.timer.Stop() del self.timer #---------------------------------------------------------------------- def runTest(frame, nb, log): win = TestPanel(nb, log) return win #---------------------------------------------------------------------- overview = """\ The following was gleaned as best I could from the wxWindows source, which was a bit reluctant to reveal its secrets. My appologies if I missed anything - jmg

LEDNumberCtrl( parent, id=-1, pos=wx.DefaultPosition, size=wx.DefaultSize, style=LED_ALIGN_LEFT | LED_DRAW_FADED)

This is a control that simulates an LED clock display. It only accepts numeric input.

Styles

LED_ALIGN_LEFT
Align to the left.
LED_ALIGN_RIGHT
Align to the right.
LED_ALIGN_CENTER
Center on display.
LED_DRAW_FADED
Not implemented.

Methods (and best guesses at what they do)

GetAlignment()
Returns the alignment attribute for the control.
GetDrawFaded()
Returns the DrawFaded attribute for the control.
GetValue()
Returns the current value of the control.
SetAlignment(alignment)
Set the alignment attribute for the control.
SetDrawFaded(value)
Set the DrawFaded attribute for the control.
SetValue(number)
Set the value for the control. Only numeric values are accepted.

Additionally, several methods of wx.Window are available as well. """ func = CMPFUNC(recv_func) if __name__ == '__main__': import sys,os import run # open device print "OpenDevice" context = bca.BCA_OpenDevice(0) # regist callback function print "RegisterReceiveFunc" bca.BCA_RegisterReceiveFunc(context, func, context) # open channel if show_alc == 1: print "OpenChannel for alc" res = bca.BCA_OpenChannel(context,\ 3,\ 16,\ 0,\ 36,\ 0,\ 0,\ 69,\ c_double(1.0)) # run.main(['', os.path.basename(sys.argv[0])] + sys.argv[1:])