Exemplo n.º 1
0
    def test_globdict(self):
        """Dictionary of fully qualified paths keyed by filename for package directory"""

        base_path = agdevicecontrol.__path__[0]

        # fully qualified paths to images
        fqfiles = map(os.path.abspath, pyglob(base_path + "/gui/images/*.png"))
        fqfiles.sort()
        
        dict = resource.globdict("agdevicecontrol.gui", subdir="images", filter='*.png')

        assert len(dict) == len(fqfiles)
        for fqfile in fqfiles:
            file = os.path.split(fqfile)[1]
            assert file in dict
            assert dict[file] == fqfile
Exemplo n.º 2
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)