示例#1
0
    def __init__(self, parent, id, bridge=None):

        # baseclass constructor
        DevicePanel.__init__(self, parent, id, bridge)

        self.parameter = wx.TextCtrl(self, -1, "0", size=(125, -1))
        #em.eventManager.Register(self.setParameter, wx.EVT_TEXT, self.parameter)

        self.delay = wx.TextCtrl(self, -1, "1", size=(125, -1))

        self.b = wx.Button(self, -1, 'Go!', size=(125, -1))
        em.eventManager.Register(self.setParameter, wx.EVT_BUTTON, self.b)

        # labels
        label_parameter = wx.StaticText(self, -1, 'Parameter:', style=wx.ALIGN_RIGHT)
        label_delay = wx.StaticText(self, -1, 'Delay:', style=wx.ALIGN_RIGHT)

        # variable size n x 2 grid for overall alignment
        flexgridsizer = wx.FlexGridSizer(rows=3, cols=3, vgap=10, hgap=25)
        flexgridsizer.AddMany( [label_parameter, self.parameter, self.b,
                                label_delay, self.delay] )

        # how to do this automatically?
        self._sizer.Add(flexgridsizer)
        self._sizer.Fit(self)
示例#2
0
    def __init__(self, parent, id, callback=defaultaction):

        # adjustables
        width = 600
        height = 600

        # baseclass constructor
        DevicePanel.__init__(self, parent, id, callback)

        # control window
        panelid = wx.NewId()
        self.panel = wx.Panel(self, panelid, size=(width,height), style=wx.SIMPLE_BORDER)

        # status
        self.text = wx.StaticText(self, -1, "", (width, 100), (width, -1), wx.ALIGN_CENTER)
        font = wx.Font(18, wx.SWISS, wx.NORMAL, wx.NORMAL)
        self.text.SetFont(font)

        # event handler callbacks
        em.eventManager.Register(self.onMouseClick, wx.EVT_LEFT_DOWN, self.panel)
        em.eventManager.Register(self.onMouseRelease, wx.EVT_LEFT_UP, self.panel)
        em.eventManager.Register(self.onMouseClick, wx.EVT_RIGHT_DOWN, self.panel)
        em.eventManager.Register(self.onMouseRelease, wx.EVT_RIGHT_UP, self.panel)
        em.eventManager.Register(self.OnPaint, wx.EVT_PAINT, self.panel)
        em.eventManager.Register(self.onMove, wx.EVT_MOTION, self.panel)
        em.eventManager.Register(self.onLeavePanel, wx.EVT_LEAVE_WINDOW, self.panel)
        em.eventManager.Register(self.onEnterPanel, wx.EVT_ENTER_WINDOW, self.panel)
        wx.EVT_TIMER(self,-1, self.onTimer)


        # device context isn't available until window is actually drawn
        self.dc = None

        # rather than reacting to all mouse movements, we accumulate
        # and send updates at fixed intervals
        self.interval = 100
        self.timer = None

        # number of pixels mouse has to move in a polling period to register
        self.xsensitivity = 3
        self.ysensitivity = 3

        # set up finite state machine transitions
        self.configureFSM(self.onTransition)

        # how to do this automatically?
        self._sizer.Add(self.panel)
        self._sizer.Add(self.text)
        self._sizer.Fit(self)
示例#3
0
    def __init__(self, parent, id, bridge=None):

        # baseclass constructor
        DevicePanel.__init__(self, parent, id, bridge)

        # images in agdevicecontrol/clients/images directory, need fully qualified paths
        images = resource.globdict("agdevicecontrol.gui", subdir="images", filter='*.png')

        # movement buttons numbered like telephone dialpad, 1-9 from bottom left
        bitmaps_normal = [ images['img%dn.png' % (i+1)] for i in range(9) ]
        bitmaps_pressed = [ images['img%dp.png' % (i+1)] for i in range(9) ]

        # actions on button press
        self.onpress_actions = { 1:'PanLeftTiltDown', 2:'TiltDown', 3:'PanRightTiltDown',
                                 4:'PanLeft', 5:'MoveHome', 6:'PanRight',
                                 7:'PanLeftTiltUp', 8:'TiltUp', 9:'PanRightTiltUp' }


        # populate a 3x3 grid for movement buttons
        grid_sizer = wx.GridSizer(3,3,0,0)
        for mid in [7,8,9,4,5,6,1,2,3]:
            button = BitmapButton(self, mid, self.movePress, self.moveRelease,
                                  bitmaps_normal[mid-1], bitmaps_pressed[mid-1])  # images start at 1
            grid_sizer.Add(button, 0, wx.EXPAND)
        grid_sizer.Fit(self)


        # (continuous|quantised) movement checkbox.  Default is quantised, press
        # movement button and camera moves fixed (hopefully zoom dependent) amount
        self.continuous = ParameterSwitch(self, -1, 'Continuous Movement', callback=self.continuousMove)
        self.continuous_move = False

        # zoom buttons
        self.zoom = wx.BoxSizer(wx.HORIZONTAL)
        zoominbutton = BitmapButton(self, id, self.zoomInPress, self.zoomRelease,
                                    images['zoomin0.png'], images['zoomin1.png'])
        self.zoom.Add(zoominbutton)
        zoomoutbutton = BitmapButton(self, id, self.zoomOutPress, self.zoomRelease,
                                    images['zoomout0.png'], images['zoomout1.png'])
        self.zoom.Add(zoomoutbutton)

        
        # power toggle
        self.power = wx.RadioBox(self, -1, '', wx.DefaultPosition, wx.DefaultSize,
                             ['Off','On'], 2, wx.RA_SPECIFY_COLS | wx.NO_BORDER)
        em.eventManager.Register(self.setPower, wx.EVT_RADIOBOX, self.power)



        # labels
        label_movement = wx.StaticText(self, -1, 'Movement:', style=wx.ALIGN_RIGHT)
        label_zoom = wx.StaticText(self, -1, 'Zoom:', style=wx.ALIGN_RIGHT)
        label_power = wx.StaticText(self, -1, 'Power:', style=wx.ALIGN_RIGHT)


        # variable size n x 2 grid for overall alignment
        flexgridsizer = wx.FlexGridSizer(rows=4, cols=2, vgap=10, hgap=25)
        flexgridsizer.AddMany( [label_movement, grid_sizer,
                                (0,0), self.continuous,
                                label_zoom, self.zoom,
                                label_power, self.power] )

        # how to do this automatically?
        self._sizer.Add(flexgridsizer)
        self._sizer.Fit(self)