Beispiel #1
0
    def buildAudioBar(self):
        """
        Builds the audio bar controls
        """
        audioBarSizer = wx.BoxSizer(wx.HORIZONTAL)
        
        self.buildBtn({'bitmap': 'player_prev.png', 'handler': self.onPrev,
                       'name': 'prev'},
                      audioBarSizer)

        img = wx.Bitmap(os.path.join(bitmapDir, "player_random.png"))
        self.randomBtn = buttons.GenBitmapToggleButton(self, bitmap=img, name="random")
        self.randomBtn.Enable(True)
        self.randomBtn.SetBackgroundColour('white')

        img = wx.Bitmap(os.path.join(bitmapDir, "player_random.png"))
        self.randomBtn.SetBitmapSelected(img)
        self.randomBtn.SetInitialSize()

        self.randomBtn.Bind(wx.EVT_BUTTON, self.onRandomOn)
        audioBarSizer.Add(self.randomBtn, 0, wx.LEFT, 3)

        img = wx.Bitmap(os.path.join(bitmapDir, "player_repeat.png"))
        self.repeatBtn = buttons.GenBitmapToggleButton(self, bitmap=img, name="repeat")
        self.repeatBtn.Enable(True)
        self.repeatBtn.SetBackgroundColour('white')

        img = wx.Bitmap(os.path.join(bitmapDir, "player_repeat.png"))
        self.repeatBtn.SetBitmapSelected(img)
        self.repeatBtn.SetInitialSize()
        audioBarSizer.Add(self.repeatBtn, 0, wx.LEFT, 3)
        
        # create play/pause toggle button
        img = wx.Bitmap(os.path.join(bitmapDir, "player_play.png"))
        self.playPauseBtn = buttons.GenBitmapToggleButton(self, bitmap=img, name="play")
        self.playPauseBtn.Enable(False)
        self.playPauseBtn.SetBackgroundColour('white')

        img = wx.Bitmap(os.path.join(bitmapDir, "player_pause.png"))
        self.playPauseBtn.SetBitmapSelected(img)
        self.playPauseBtn.SetInitialSize()
        
        self.playPauseBtn.Bind(wx.EVT_BUTTON, self.onPlay)
        audioBarSizer.Add(self.playPauseBtn, 0, wx.LEFT, 3)
        
        btnData = [{'bitmap':'player_stop.png',
                    'handler':self.onStop, 'name':'stop'},
                    {'bitmap':'player_next.png',
                     'handler':self.onNext, 'name':'next'}]
        for btn in btnData:
            self.buildBtn(btn, audioBarSizer)
            
        return audioBarSizer
Beispiel #2
0
    def view(self):
        # self.btn_record = wx.Button(self.panel, wx.ID_ANY, "Record", wx.DefaultPosition, wx.Size(50,25), 10)
        # self.sizer.Add(self.btn_record, 2, wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_CENTER_HORIZONTAL,  0)

        img = wx.Bitmap(os.path.join(bitmapDir, "mic_icon.gif"))
        self.btn_record = buttons.GenBitmapToggleButton(self.panel,
                                                        bitmap=img,
                                                        name="play")
        self.btn_record.Enable(True)
        self.btn_record.SetInitialSize()
        # self.btn_record.Bind(wx.EVT_BUTTON, self.record)
        gsizer_db_details = wx.GridSizer(rows=1, cols=1, hgap=0, vgap=5)
        gsizer_db_details.Add(self.btn_record, 1,
                              wx.ALL | wx.ALIGN_CENTER | wx.SHAPED, 0)
        # self.sizer.Add(self.btn_record, 2, wx.ALIGN_CENTER_HORIZONTAL, 50)
        self.sizer.Add(gsizer_db_details, 2, wx.ALIGN_CENTER, 0)
        self.btn_record.Bind(wx.EVT_BUTTON, self.on_record_button)
        self.txt_box = wx.TextCtrl(self.panel,
                                   wx.ID_ANY,
                                   "",
                                   size=wx.DefaultSize,
                                   style=wx.TE_MULTILINE | wx.TE_READONLY)
        self.txt_box.SetFont(
            wx.Font(12, wx.DEFAULT, style=wx.NORMAL, weight=wx.NORMAL))
        self.sizer.Add(self.txt_box, 1, wx.EXPAND | wx.ALIGN_CENTER, 0)
        self.sizer.Layout()
        self.sizer.Fit(self.panel)
        self.panel.SetSizer(self.sizer)
        self.panel.Layout()
        self.Layout()
    def add_controls(self):
        self.build_btn({'bitmap': 'player_prev.png', 'handler': self.on_prev,
                        'name': 'prev'})

        img = wx.Bitmap(os.path.join(bitmapDir, "player_play.png"))
        self.play_pause_btn = buttons.GenBitmapToggleButton(self, bitmap=img, name="play")
        self.play_pause_btn.Enable(False)

        img = wx.Bitmap(os.path.join(bitmapDir, "player_pause.png"))
        self.play_pause_btn.SetBitmapSelected(img)

        self.play_pause_btn.Bind(wx.EVT_BUTTON, self.on_play)
        self.sizer.Add(self.play_pause_btn, 0, wx.LEFT, 0)
        self.sizer.SetSizeHints(self)

        btn_data = [
            {'bitmap': 'player_next.png',
             'handler': self.on_next, 'name': 'next'},
            {'bitmap': 'player_add.png',
             'handler': self.on_add, 'name': 'add'},
            {'bitmap': 'player_album.png',
             'handler': self.on_album_cover, 'name': 'album cover'}
        ]
        for btn in btn_data:
            self.build_btn(btn)
        for btn in self.buttons:
            btn.Enable(False)
    def __init__(self):
        wx.Frame.__init__(self, None, -1, "Generic Button Example",
                            size=(500, 500))
        panel = wx.Panel(self, -1)
        sizer = wx.FlexGridSizer(1, 3, 20, 20)
        b = wx.Button(panel, -1, 'A wx.Button')
        b.SetDefault()
        sizer.Add(b)
        b = wx.Button(panel, -1, 'non-default wx.Button')
        sizer.Add(b)
        sizer.Add((10,10))
        b = buttons.GenButton(panel, -1, 'Genric Button')#基本的通用按钮
        sizer.Add(b)

        b = buttons.GenButton(panel, -1, 'disabled Generic')#无效的通用按钮
        b.Enable(False)
        sizer.Add(b)
        b = buttons.GenButton(panel, -1, 'F')#自定义尺寸和颜色的按钮
        b.SetFont(wx.Font(20, wx.SWISS, wx.NORMAL, wx.BOLD, False))
        b.SetBezelWidth(5)
        b.SetBackgroundColour("Navy")
        b.SetForegroundColour("white")
        b.SetToolTipString("This is a BIG button...")
        sizer.Add(b)
        bmp = wx.Image("Pause.png", wx.BITMAP_TYPE_PNG).ConvertToBitmap()
        b = buttons.GenBitmapButton(panel, -1, bmp)#通用位图按钮
        sizer.Add(b)
        self.btest = buttons.GenBitmapToggleButton(panel, -1, bmp)#通用位图开关按钮
        sizer.Add(self.btest)
        b = buttons.GenBitmapTextButton(panel, -1, bmp, 'Bitmapped Text',size=(375, 75))#位图文本按钮
        b.SetUseFocusIndicator(False)
        sizer.Add(b)
        b = buttons.GenToggleButton(panel, -1, 'Toggle Button')#通用开关按钮
        sizer.Add(b)
        panel.SetSizer(sizer)
Beispiel #5
0
    def addMask(self, mask=None, name="Mask", imagedata=None):
        """
		Add a mask to the tray
		"""
        #		if not mask and (name and imagedata):
        #			m = Mask(name, imagedata.GetDimensions(), imagedata)
        #		elif mask:
        #			m = mask
        #		else:
        #			raise bxdexceptions.MissingParameterException("No mask given")
        #		self.masks.append(m)

        if not mask:
            raise bxdexceptions.MissingParameterException("No mask given")
        elif name and imagedata:
            mask = Mask(name, imagedata.GetDimensions(), imagedata)

        self.masks.append(mask)
        maskBitmap = mask.getAsBitmap(self.GetBackgroundColour())

        genericToggleButton = buttons.GenBitmapToggleButton(
            self.scroll, -1, maskBitmap)
        self.Bind(wx.EVT_BUTTON, self.onToggleButton, genericToggleButton)
        self.buttons.append(genericToggleButton)
        maskAmount = len(self.masks)

        self.scrollSizer.Add(genericToggleButton, (0, maskAmount - 1))
        self.scroll.SetupScrolling()
        self.Layout()
Beispiel #6
0
    def createColorGrid(self, parent):
        buttonSize = (self.BMP_SIZE + 2 * self.BMP_BORDER,
                      self.BMP_SIZE + 2 * self.BMP_BORDER)

        self.label_data = get_label_data()
        self.show_label = self.label_data[0]['cn_name']
        self.curr_label = self.label_data[0]['en_name']
        self.curr_color = self.label_data[0]['color']
        self.colorMap = {}
        self.colorButtons = {}

        colorGrid = wx.GridSizer(cols=self.NUM_COLS, hgap=4, vgap=4)
        for idx, each_label in enumerate(self.label_data):
            color_rgb = tuple(each_label['color'])
            bmp = self._MakeBitmap(color_rgb)
            b = buttons.GenBitmapToggleButton(self, -1, bmp, size=buttonSize)
            b.SetBezelWidth(1)
            b.SetUseFocusIndicator(False)
            b.SetLabel(each_label['en_name'])
            self.Bind(wx.EVT_BUTTON, self.OnSetColour, b)
            colorGrid.Add(b, 0)
            self.colorMap[b.GetId()] = idx
            self.colorButtons[idx] = b
        self.colorButtons[0].SetToggle(True)

        return colorGrid
Beispiel #7
0
    def __init__(self):
        wx.Frame.__init__(self,
                          None,
                          -1,
                          'Generic Button Example',
                          size=(500, 400))
        panel = wx.Panel(self, -1)

        #Can also have rows=x. Can cause errors if set wrongly
        #Don't need the n = ... part, but helped for troubleshooting
        sizer = wx.FlexGridSizer(cols=3, vgap=20, hgap=20)
        b = wx.Button(panel, -1, "A wx.Button")
        b.SetDefault()
        sizer.Add(b)

        #Interesting, can reuse b, now that it is saved to sizer
        b = wx.Button(panel, -1, "non-default wx.Button")
        sizer.Add(b)

        sizer.Add((10, 10))

        b = buttons.GenButton(panel, -1, 'Generic Button')
        sizer.Add(b)

        b = buttons.GenButton(panel, -1, 'disabled Generic')
        b.Enable(False)
        sizer.Add(b)

        b = buttons.GenButton(panel, -1, 'bigger')
        b.SetFont(wx.Font(20, wx.SWISS, wx.NORMAL, wx.BOLD, False))
        b.SetBezelWidth(5)
        #?? Does capitalisation matter
        b.SetBackgroundColour("Navy")
        b.SetForegroundColour("white")
        b.SetToolTipString("This is a BIG button...")
        sizer.Add(b)

        bmp = wx.Image("bitmap.bmp", wx.BITMAP_TYPE_BMP).ConvertToBitmap()
        b = buttons.GenBitmapButton(panel, -1, bmp)
        sizer.Add(b)

        b = buttons.GenBitmapToggleButton(panel, -1, bmp)
        sizer.Add(b)

        b = buttons.GenBitmapTextButton(panel,
                                        -1,
                                        bmp,
                                        "Bitmapped Text",
                                        size=(175, 175))
        #?? What do again
        b.SetUseFocusIndicator(False)
        sizer.Add(b)

        b = buttons.GenToggleButton(panel, -1, "ToggleButton")
        sizer.Add(b)

        panel.SetSizer(sizer)
Beispiel #8
0
    def __init__(self):
        wx.Frame.__init__(self,
                          None,
                          -1,
                          "Generic Button Example",
                          size=(500, 350))
        panel = wx.Panel(self, -1)

        sizer = wx.FlexGridSizer(3, 3, 20, 20)
        b = wx.Button(panel, -1, "A wx.Button")
        b.SetDefault()
        sizer.Add(b)

        b = wx.Button(panel, -1, "non-default wx.Button")
        sizer.Add(b)

        b = buttons.GenButton(panel, -1, "Generic Button")
        sizer.Add(b)

        b = buttons.GenButton(panel, -1, "disabled Generic")
        b.Enable(False)
        sizer.Add(b)

        b = buttons.GenButton(panel, -1, "bigger")
        b.SetFont(wx.Font(20, wx.SWISS, wx.NORMAL, wx.BOLD))
        b.SetBezelWidth(5)
        b.SetBackgroundColour("Navy")
        b.SetForegroundColour("white")
        b.SetToolTip("This is a BIG button!")
        sizer.Add(b)

        bmp = wx.Image("img/button-off.png",
                       wx.BITMAP_TYPE_PNG).ConvertToBitmap()

        b = buttons.GenBitmapButton(panel, -1, bmp)
        sizer.Add(b)

        b = buttons.GenBitmapToggleButton(panel, -1, bmp)
        sizer.Add(b)

        b = buttons.GenBitmapTextButton(panel,
                                        -1,
                                        bmp,
                                        "Bitmap Text",
                                        size=(175, 75))
        b.SetUseFocusIndicator(False)
        sizer.Add(b)

        b = buttons.GenToggleButton(panel, -1, "Toggle Button")
        sizer.Add(b)

        panel.SetSizer(sizer)
Beispiel #9
0
    def addChannel(self, name, color, filename, dims, bmp):
        """
		Add a channel to the tray
		"""
        b = buttons.GenBitmapToggleButton(self.scroll, -1, bmp)
        self.Bind(wx.EVT_BUTTON, self.onToggleButton, b)
        self.buttons.append(b)
        self.units.append((name, filename, color, dims))
        n = len(self.units)

        self.scrollSizer.Add(b, (0, n - 1))
        self.scroll.SetupScrolling()
        self.Layout()
Beispiel #10
0
    def __init__(self, parent, color, thickness):
        """The constructor."""
        wx.Panel.__init__(self, parent, -1, size=(20, 20))

        (self.color, self.thickness) = (color, thickness)

        self.__eventsCallbacks = {}
        self.__eventsCallbacks["EVT_PEN_UPDATE"] = []

        numCols = 8
        spacing = 4

        btnSize = wx.Size(self.BMP_SIZE + 2 * self.BMP_BORDER,
                          self.BMP_SIZE + 2 * self.BMP_BORDER)

        # Make a grid of buttons for each color.  Attach each button
        # event to self.OnSetColor.  The button ID is the same as the
        # key in the color dictionary.
        self.clrBtns = {}

        colorID = 0
        cGrid = wx.GridSizer(cols=numCols, hgap=2, vgap=2)
        for color in menuColors:
            bmp = self.__MakeBitmap(color)
            b = buttons.GenBitmapToggleButton(self, colorID, bmp, size=btnSize)
            b.SetBezelWidth(1)
            b.SetUseFocusIndicator(False)
            self.Bind(wx.EVT_BUTTON, self.__OnSetColor, b)
            cGrid.Add(b, 0)
            self.clrBtns[colorID] = b
            colorID = colorID + 1
        self.clrBtns[0].SetToggle(True)

        # color indicator
        self.__ci = ColorIndicator(self, self.color, self.thickness)

        self.__thicknessSlider = wx.Slider(self, style=wx.SL_AUTOTICKS)
        self.__thicknessSlider.SetRange(1, maxThickness)
        self.Bind(wx.EVT_SLIDER, self.__OnSetThickness, self.__thicknessSlider)

        # Make a box sizer and put the two grids and the indicator
        # window in it.
        box = wx.BoxSizer(wx.VERTICAL)
        box.Add(cGrid, 0, wx.ALL, spacing)
        box.Add(self.__thicknessSlider, 0, wx.EXPAND | wx.ALL, spacing)
        box.Add(self.__ci, 0, wx.EXPAND | wx.ALL, spacing)
        self.SetSizer(box)

        # Resize this window so it is just large enough for the
        # minimum requirements of the sizer.
        box.Fit(self)
    def __init__(self):
        wx.Frame.__init__(self,
                          None,
                          -1,
                          'Generic Button Example',
                          size=(500, 350))
        panel = wx.Panel(self, -1)

        sizer = wx.FlexGridSizer(1, 3, 20, 20)
        b = wx.Button(panel, -1, "A wx.Button")
        b.SetDefault()
        sizer.Add(b)

        b = wx.Button(panel, -1, "non-default wx.Button")
        sizer.Add(b)
        sizer.Add((10, 10))

        b = buttons.GenButton(panel, -1, 'Generic Button')
        sizer.Add(b)

        b = buttons.GenButton(panel, -1, 'disabled Generic')
        b.Enable(False)
        sizer.Add(b)

        b = buttons.GenButton(panel, -1, 'bigger')
        b.SetFont(wx.Font(20, wx.SWISS, wx.NORMAL, wx.BOLD, False))
        b.SetBezelWidth(5)
        b.SetBackgroundColour("Navy")
        b.SetForegroundColour("white")
        b.SetToolTipString("This is a BIG button...")
        sizer.Add(b)

        bmp = wx.Image("bitmap.bmp", wx.BITMAP_TYPE_BMP).ConvertToBitmap()
        b = buttons.GenBitmapButton(panel, -1, bmp)
        sizer.Add(b)

        b = buttons.GenBitmapToggleButton(panel, -1, bmp)
        sizer.Add(b)

        b = buttons.GenBitmapTextButton(panel,
                                        -1,
                                        bmp,
                                        "Bitmapped Text",
                                        size=(175, 75))
        b.SetUseFocusIndicator(False)
        sizer.Add(b)

        b = buttons.GenToggleButton(panel, -1, "Toggle Button")
        sizer.Add(b)

        panel.SetSizer(sizer)
Beispiel #12
0
    def _create_toggle(self):
        img = wx.Bitmap(os.path.join(BIT_MAP_DIR, "play.png"))
        stop_img = wx.Bitmap(os.path.join(BIT_MAP_DIR, 'stop.png'))
        button = buttons.GenBitmapToggleButton(self.player_panel,
                                               bitmap=img,
                                               name="play",
                                               pos=(0, 5),
                                               size=(3, 3))

        button.Enable(False)
        button.SetBitmapSelected(stop_img)
        button.SetInitialSize()
        button.Bind(wx.EVT_BUTTON, self.play)
        return button
Beispiel #13
0
 def createColorGrid(self, parent, buttonSize):
     self.colorMap = {}
     self.colorButtons = {}
     colorGrid = wx.GridSizer(cols=self.NUM_COLS, hgap=2, vgap=2)
     for eachColor in self.colorList:
         bmp = self.MakeBitmap(eachColor)
         b = buttons.GenBitmapToggleButton(self, -1, bmp, size=buttonSize)
         b.SetBezelWidth(1)
         b.SetUseFocusIndicator(False)
         self.Bind(wx.EVT_BUTTON, self.OnSetColour, b)
         colorGrid.Add(b, 0)
         self.colorMap[b.GetId()] = eachColor
         self.colorButtons[eachColor] = b
     self.colorButtons[self.colorList[0]].SetToggle(True)
     return colorGrid
Beispiel #14
0
    def __init__(self):
        wx.Frame.__init__(self,
                          None,
                          -1,
                          'Generic Button Example',
                          size=(500, 350))
        panel = wx.Panel(self, -1)
        sizer = wx.FlexGridSizer(4, 3, 20, 20)
        b = wx.Button(panel, -1, "A wx.Button")
        b.SetDefault()
        sizer.Add(b)
        b = wx.Button(panel, -1, "non-default wx.Button")
        sizer.Add(b)
        sizer.Add((10, 10))

        b = buttons.GenButton(panel, -1,
                              'Generic Button')  # Базовая типовая кнопка
        sizer.Add(b)
        b = buttons.GenButton(
            panel, -1, 'disabled Generic')  # Блокированная типовая кнопка
        b.Enable(False)
        sizer.Add(b)
        b = buttons.GenButton(
            panel, -1,
            'bigger')  # Кнопка с заданным пользователем размером и цветом
        b.SetFont(wx.Font(20, wx.SWISS, wx.NORMAL, wx.BOLD, False))
        b.SetBezelWidth(5)
        b.SetBackgroundColour("Navy")
        b.SetForegroundColour("white")
        b.SetToolTip("This is a BIG button...")
        sizer.Add(b)

        bmp = wx.Image("bird.png", wx.BITMAP_TYPE_PNG).ConvertToBitmap()
        b = buttons.GenBitmapButton(
            panel, -1, bmp)  # Типовая кнопка с битовым изображением
        sizer.Add(b)
        b = buttons.GenBitmapToggleButton(panel, -1, bmp)
        sizer.Add(b)  # Типовая кнопка-переключатель с битовым изображением
        b = buttons.GenBitmapTextButton(
            panel, -1, bmp, "Bitmapped Text",
            size=(175, 75))  # Кнопка с битовым изображением и текстом
        b.SetUseFocusIndicator(False)
        sizer.Add(b)
        b = buttons.GenToggleButton(
            panel, -1, "Toggle Button")  # Типовая кнопка-переключатель
        sizer.Add(b)
        panel.SetSizer(sizer)
Beispiel #15
0
    def addChannelItem(self, name, bitmap, toolid, func):
        """
		Add a channel item
		"""
        icondir = scripting.get_icon_dir()
        btn = buttons.GenBitmapToggleButton(self, toolid, bitmap)
        w, h = bitmap.GetWidth(), bitmap.GetHeight()
        #btn.SetBestSize((w,h))
        btn.SetSize((64, 64))
        btn.SetToolTipString(name)
        btn.Bind(wx.EVT_BUTTON, func)

        self.numberOfChannels += 1
        self.sizer.Add(btn, (self.sizerCount + self.numberOfChannels, 0),
                       span=(1, 2))
        self.channelButtons[toolid] = btn
        self.Layout()
Beispiel #16
0
 def __init__(self):
     wx.Frame.__init__(self,
                       None,
                       -1,
                       "Generic Button Example",
                       size=(500, 350))
     panel = wx.Panel(self, -1)
     sizer = wx.FlexGridSizer(1, 3, 20, 20)
     b = wx.Button(panel, -1, "A wx.Button")
     b.SetDefault()
     b.SetToolTipString("a wx.Button")
     sizer.Add(b)
     b = wx.Button(panel, -1, "non-default wx.Button")
     sizer.Add(b)
     sizer.Add((10, 10))
     b = buttons.GenButton(panel, -1, "Genric Button")
     sizer.Add(b)
     b = buttons.GenButton(panel, -1, "disabled Generic")
     b.Enable(False)
     sizer.Add(b)
     b = buttons.GenButton(panel, -1, 'bigger')
     b.SetFont(wx.Font(20, wx.SWISS, wx.NORMAL, wx.BOLD, False))
     b.SetBezelWidth(5)
     b.SetBackgroundColour("Navy")
     b.SetForegroundColour("white")
     b.SetToolTipString("this is a Big button..")
     sizer.Add(b)
     bmp = wx.Bitmap("img/002.jpg", wx.BITMAP_TYPE_JPEG)
     b = buttons.GenBitmapButton(panel, -1, bmp)
     sizer.Add(b)
     b = buttons.GenBitmapToggleButton(panel, -1, bmp)
     sizer.Add(b)
     b = buttons.GenBitmapTextButton(panel,
                                     -1,
                                     bmp,
                                     "Bitmapped Text",
                                     size=(175, 75))
     self.Bind(wx.EVT_BUTTON, self.OnClick, b)
     b.SetUseFocusIndicator(False)
     sizer.Add(b)
     b = buttons.GenToggleButton(panel, -1, "Toggle Button")
     sizer.Add(b)
     b = wx.ToggleButton(panel, -1, "on/off")
     self.Bind(wx.EVT_TOGGLEBUTTON, self.OnClick, b)
     sizer.Add(b)
     panel.SetSizer(sizer)
Beispiel #17
0
    def __init__(self):
        wx.Frame.__init__(self, None, -1, 'Generic Button Example',
                          size=(500, 350))
        panel = wx.Panel(self, -1)

        sizer = wx.FlexGridSizer(4, 3, 20, 20)
        btn = wx.Button(panel, -1, "A wx.Button")
        btn.SetDefault()
        sizer.Add(btn)

        btn = wx.Button(panel, -1, "Non-default wx.Button")
        sizer.Add(btn)
        sizer.Add((10, 10))

        btn = buttons.GenButton(panel, -1, 'Generic Button')  # 基本的通用按钮
        sizer.Add(btn)

        btn = buttons.GenButton(panel, -1, 'Disabled Generic')  # 无效的通用按钮
        btn.Enable(False)
        sizer.Add(btn)

        btn = buttons.GenButton(panel, -1, 'Bigger')  # 自定义尺寸和颜色的按钮
        btn.SetFont(wx.Font(20, wx.SWISS, wx.NORMAL, wx.BOLD, False))
        btn.SetBezelWidth(5)
        btn.SetBackgroundColour("Navy")
        btn.SetForegroundColour("White")
        btn.SetToolTipString("This is a BIG button...")
        sizer.Add(btn)

        bmp = wx.Image("bitmap.bmp", wx.BITMAP_TYPE_BMP).ConvertToBitmap()
        btn = buttons.GenBitmapButton(panel, -1, bmp)  # 通用位图按钮
        sizer.Add(btn)

        btn = buttons.GenBitmapToggleButton(panel, -1, bmp)  # 通用位图开关按钮
        sizer.Add(btn)

        btn = buttons.GenBitmapTextButton(panel, -1, bmp, "Bitmap Text",
                                          size=(175, 75))  # 位图文本按钮
        btn.SetUseFocusIndicator(False)
        sizer.Add(btn)

        btn = buttons.GenToggleButton(panel, -1, "Toggle Button")  # 通用开关按钮
        sizer.Add(btn)

        panel.SetSizer(sizer)
Beispiel #18
0
    def test_lib_buttons1(self):
        
        btn = buttons.GenButton(self.frame, label='label')
        btn = buttons.GenButton(self.frame, -1, 'label', (10,10), (100,-1), wx.BU_LEFT)
        
        bmp = wx.Bitmap(pngFile)
        btn = buttons.GenBitmapButton(self.frame, bitmap=bmp)
        btn = buttons.GenBitmapTextButton(self.frame, label='label', bitmap=bmp)
        
        btn.SetBitmapFocus(bmp)
        btn.SetBitmapDisabled(bmp)
        btn.SetBitmapSelected(bmp)

        btn = buttons.GenBitmapToggleButton(self.frame, bitmap=bmp)
        btn.SetToggle(True)

        self.assertTrue(btn.GetValue())
        self.assertEqual(btn.GetBitmapLabel(), bmp)
Beispiel #19
0
    def buildAudioBar(self):
        """
        Builds the audio bar controls
        """
        audioBarSizer = wx.BoxSizer(wx.HORIZONTAL)

        self.buildBtn(
            {
                'bitmap': 'player_prev.png',
                'handler': self.onPrev,
                'name': 'prev'
            }, audioBarSizer)

        # create play/pause toggle button
        img = wx.Bitmap(os.path.join(bitmapDir, "player_play.png"))
        self.playPauseBtn = buttons.GenBitmapToggleButton(self,
                                                          bitmap=img,
                                                          name="play")
        self.playPauseBtn.Enable(False)

        img = wx.Bitmap(os.path.join(bitmapDir, "player_pause.png"))
        self.playPauseBtn.SetBitmapSelected(img)
        self.playPauseBtn.SetInitialSize()

        self.playPauseBtn.Bind(wx.EVT_BUTTON, self.onPlay)

        self.Bind(wx.media.EVT_MEDIA_LOADED, self.song_is_loaded)
        self.Bind(wx.media.EVT_MEDIA_FINISHED, self.onSongFinished)
        audioBarSizer.Add(self.playPauseBtn, 0, wx.LEFT, 3)

        btnData = [{
            'bitmap': 'player_stop.png',
            'handler': self.onStop,
            'name': 'stop'
        }, {
            'bitmap': 'player_next.png',
            'handler': self.onNext,
            'name': 'next'
        }]
        for btn in btnData:
            self.buildBtn(btn, audioBarSizer)

        return audioBarSizer
Beispiel #20
0
 def __init__(self):
     wx.Frame.__init__(self,
                       None,
                       -1,
                       'Generic Button Example',
                       size=(500, 350))
     panel = wx.Panel(self, -1)
     sizer = wx.FlexGridSizer(1, 3, 20, 20)
     b = wx.Button(panel, -1, "A wx.Button")
     b.SetDefault()
     sizer.Add(b)
     b = wx.Button(panel, -1, "non-default wx.Button")
     sizer.Add(b)
     sizer.Add((10, 10))
     b = buttons.GenButton(panel, -1, 'Generic Button')
     sizer.Add(b)
     b = buttons.GenButton(panel, -1, 'disabled Generic')
     b.Enable(False)
     sizer.Add(b)
     b = buttons.GenButton(panel, -1, 'bigger')
     b.SetFont(wx.Font(20, wx.SWISS, wx.NORMAL, wx.BOLD, False))
     b.SetBezelWidth(5)
     b.SetBackgroundColour("Navy")
     b.SetForegroundColour("white")
     b.SetToolTipString("This is a BIG button...")
     sizer.Add(b)
     bmp = wx.Image(
         "C:\\Users\\Ashish\\.eclipse\\231700603\\configuration\\org.eclipse.equinox.launcher\\com.jrockit.mc.rcp.application_5.3.0.159881\\splash.bmp",
         wx.BITMAP_TYPE_BMP).ConvertToBitmap()
     b = buttons.GenBitmapButton(panel, -1, bmp)
     sizer.Add(b)
     b = buttons.GenBitmapToggleButton(panel, -1, bmp)
     sizer.Add(b)
     b = buttons.GenBitmapTextButton(panel,
                                     -1,
                                     bmp,
                                     "Bitmapped Text",
                                     size=(175, 75))
     b.SetUseFocusIndicator(False)
     sizer.Add(b)
     b = buttons.GenToggleButton(panel, -1, "Toggle Button")
     sizer.Add(b)
     panel.SetSizer(sizer)
Beispiel #21
0
    def __init__(self, parent):
        wx.Panel.__init__(self, parent, -1, style=wx.RAISED_BORDER)

        global control_panel_model
        control_panel_model = Control_panel_model()

        button_size = wx.Size(32 + 2 * 3, 32 + 2 * 3)

        c_grid = wx.GridSizer(cols=3, hgap=2, vgap=2)
        self.terrain_buttons = {}

        for i in range(len(terrain_types)):
            tile = terrain_types[i]
            bmp = wx.EmptyBitmap(32, 32)
            bmp_dc = wx.MemoryDC()
            bmp_dc.SelectObject(bmp)

            xsrc = mtctl_terrain[tile][0] * 32
            ysrc = mtctl_terrain[tile][1] * 32
            bmp_dc.Blit(0, 0, 32, 32, terrain_dc, xsrc, ysrc)

            b = buttons.GenBitmapToggleButton(self, i, bmp, size=button_size)
            b.SetBezelWidth(1)
            b.SetUseFocusIndicator(False)
            self.Bind(wx.EVT_BUTTON, self.OnSetTerrain, b)
            c_grid.Add(b, 0)
            self.terrain_buttons[terrain_types[i]] = b

        self.terrain_buttons[control_panel_model.selected_terrain].SetToggle(
            True)

        # Make a box sizer and put the two grids and the indicator
        # window in it.
        box = wx.BoxSizer(wx.VERTICAL)
        box.Add(c_grid, 0, wx.ALL, 4)
        self.SetSizer(box)
        self.SetAutoLayout(True)

        # Resize this window so it is just large enough for the
        # minimum requirements of the sizer.
        box.Fit(self)
  def __init__(self, parent):
    wx.Panel.__init__(self, parent=parent, id=wx.ID_ANY)

    self.index = None
    self.btn_box = wx.BoxSizer(wx.HORIZONTAL)
    view_bmp = bitmaps.fetch_custom_icon_bitmap('image_viewer16')
    self.btn_viewer = btn.GenBitmapButton(self, bitmap=view_bmp)
    viewmag_bmp = bitmaps.fetch_icon_bitmap('actions', 'viewmag', size=16)
    self.btn_mag = btn.GenBitmapButton(self, bitmap=viewmag_bmp)
    star_on_bmp = bitmaps.fetch_icon_bitmap('actions', 'bookmark_gold',
                                            size=16)
    star_off_bmp = bitmaps.fetch_icon_bitmap('actions', 'bookmark_silver',
                                             size=16)
    self.btn_flag = btn.GenBitmapToggleButton(self, bitmap=star_off_bmp)
    self.btn_flag.SetBitmapSelected(star_on_bmp)
    self.btn_box.Add(self.btn_mag)
    self.btn_box.Add(self.btn_viewer, flag=wx.LEFT, border=5)
    self.btn_box.Add(self.btn_flag, flag=wx.LEFT, border=5)
    self.SetSizer(self.btn_box)
    self.SetBackgroundColour('white')
    self.Fit()
Beispiel #23
0
 def createMainTool(self):
     self.toolIdMap = {}
     self.maintoolButtons = {}
     compGrid = wx.GridSizer(cols=2, hgap=0, vgap=0)
     self.panel = wx.Panel(self, style=wx.SUNKEN_BORDER)
     for eachtool in self.maintool:
         bmp = wx.Bitmap(eachtool, type=wx.BITMAP_TYPE_PNG)
         b = buttons.GenBitmapToggleButton(self.panel,
                                           -1,
                                           bmp,
                                           size=(35, 35))
         b.SetBezelWidth(1)
         b.SetUseFocusIndicator(False)
         self.Bind(wx.EVT_BUTTON, self.OnSetTool, b)
         self.Bind(wx.EVT_ENTER_WINDOW, self.OnEnter, b)
         compGrid.Add(b, 0)
         self.toolIdMap[b.GetId()] = eachtool
         self.maintoolButtons[eachtool] = b
     self.maintoolButtons[self.maintool[0]].SetToggle(True)
     self.toolselected = self.maintoolButtons[self.maintool[0]].GetId()
     self.GetParent().toolSelect = self.maintool[0]
     self.panel.SetSizer(compGrid)
     return self.panel
Beispiel #24
0
    def createColorGrid(self, parent, buttonSize):
        #interesting, using {}
        self.colorMap = {}
        self.colorButtons = {}
        colorGrid = wx.GridSizer(cols=self.NUM_COLS, hgap=2, vgap=2)

        for eachColor in self.colorList:
            #create coloured square, bind colour to, add to grid
            bmp = parent.MakeBitmap(eachColor)
            b = buttons.GenBitmapToggleButton(self, -1, bmp, size=buttonSize)
            b.SetBezelWidth(1)
            b.SetUseFocusIndicator(False)
            self.Bind(wx.EVT_BUTTON, self.OnSetColour, b)
            colorGrid.Add(b, 0)

            #map back the buttons and color, for easier access later
            self.colorMap[b.GetId()] = eachColor
            self.colorButtons[eachColor] = b

        #set first button to be switched on
        self.colorButtons[self.colorList[0]].SetToggle(True)

        return colorGrid
Beispiel #25
0
    def set_audio_bar_panel(self):
        audio_bar_sizer = wx.BoxSizer(wx.HORIZONTAL)

        self.prev_btn = self.add_button('player_prev.png',
                                        self.on_prev_recording, 'prev',
                                        audio_bar_sizer)

        img = wx.Bitmap(os.path.join(bitmap_dir, "player_play.png"))
        self.play_pause_btn = buttons.GenBitmapToggleButton(self.panel,
                                                            bitmap=img,
                                                            name="play")
        self.play_pause_btn.Enable(False)

        img = wx.Bitmap(os.path.join(bitmap_dir, "player_pause.png"))
        self.play_pause_btn.SetBitmapSelected(img)
        self.play_pause_btn.SetInitialSize()

        self.play_pause_btn.Bind(wx.EVT_BUTTON, self.on_play_recording)
        audio_bar_sizer.Add(self.play_pause_btn, 0, wx.ALL, 1)

        self.next_btn = self.add_button("player_next.png",
                                        self.on_next_recording, 'next',
                                        audio_bar_sizer)
        return audio_bar_sizer
Beispiel #26
0
    def __init__(self, parent, log):
        wx.Panel.__init__(self, parent, -1)
        self.log = log
        ##self.SetBackgroundColour("sky blue")

        sizer = wx.FlexGridSizer(1, 3, 20, 20)

        # A regular button, selected as the default button
        b = wx.Button(self, -1, "A real button")
        b.SetDefault()
        self.Bind(wx.EVT_BUTTON, self.OnButton, b)
        sizer.Add(b)

        # Same thing, but NOT set as the default button
        b = wx.Button(self, -1, "non-default")
        self.Bind(wx.EVT_BUTTON, self.OnButton, b)
        sizer.Add(b)
        sizer.Add((10, 10))

        # Plain old text button based off GenButton()
        b = buttons.GenButton(self, -1, 'Hello')
        self.Bind(wx.EVT_BUTTON, self.OnButton, b)
        sizer.Add(b)

        # Plain old text button, disabled.
        b = buttons.GenButton(self, -1, 'disabled')
        self.Bind(wx.EVT_BUTTON, self.OnButton, b)
        b.Enable(False)
        sizer.Add(b)

        # This time, we let the botton be as big as it can be.
        # Also, this one is fancier, with custom colors and bezel size.
        b = buttons.GenButton(self, -1, 'bigger')
        self.Bind(wx.EVT_BUTTON, self.OnBiggerButton, b)
        b.SetFont(wx.Font(20, wx.SWISS, wx.NORMAL, wx.BOLD, False))
        b.SetBezelWidth(5)
        b.SetMinSize(wx.DefaultSize)
        b.SetBackgroundColour("Navy")
        b.SetForegroundColour(wx.WHITE)
        b.SetToolTipString("This is a BIG button...")
        # let the sizer set best size
        sizer.Add(b, flag=wx.ADJUST_MINSIZE)

        # An image button
        bmp = images.Test2.GetBitmap()
        b = buttons.GenBitmapButton(self, -1, bmp)
        self.Bind(wx.EVT_BUTTON, self.OnButton, b)
        sizer.Add(b)

        # An image button, disabled.
        bmp = images.Test2.GetBitmap()
        b = buttons.GenBitmapButton(self, -1, bmp)
        self.Bind(wx.EVT_BUTTON, self.OnButton, b)
        sizer.Add(b)
        b.Enable(False)

        # An image button, using a mask to get rid of the
        # undesireable part of the image
        b = buttons.GenBitmapButton(self, -1, None)
        self.Bind(wx.EVT_BUTTON, self.OnButton, b)
        bmp = images.Bulb1.GetBitmap()
        mask = wx.Mask(bmp, wx.BLUE)
        bmp.SetMask(mask)
        b.SetBitmapLabel(bmp)
        bmp = images.Bulb2.GetBitmap()
        mask = wx.Mask(bmp, wx.BLUE)
        bmp.SetMask(mask)
        b.SetBitmapSelected(bmp)
        b.SetInitialSize()
        sizer.Add(b)

        # A toggle button
        b = buttons.GenToggleButton(self, -1, "Toggle Button")
        self.Bind(wx.EVT_BUTTON, self.OnToggleButton, b)
        sizer.Add(b)

        # An image toggle button
        b = buttons.GenBitmapToggleButton(self, -1, None)
        self.Bind(wx.EVT_BUTTON, self.OnToggleButton, b)
        bmp = images.Bulb1.GetBitmap()
        mask = wx.Mask(bmp, wx.BLUE)
        bmp.SetMask(mask)
        b.SetBitmapLabel(bmp)
        bmp = images.Bulb2.GetBitmap()
        mask = wx.Mask(bmp, wx.BLUE)
        bmp.SetMask(mask)
        b.SetBitmapSelected(bmp)
        b.SetToggle(True)
        b.SetInitialSize()
        sizer.Add(b)

        # A bitmap button with text.
        b = buttons.GenBitmapTextButton(self,
                                        -1,
                                        None,
                                        "Bitmapped Text",
                                        size=(200, 45))
        self.Bind(wx.EVT_BUTTON, self.OnButton, b)
        bmp = images.Bulb1.GetBitmap()
        mask = wx.Mask(bmp, wx.BLUE)
        bmp.SetMask(mask)
        b.SetBitmapLabel(bmp)
        bmp = images.Bulb2.GetBitmap()
        mask = wx.Mask(bmp, wx.BLUE)
        bmp.SetMask(mask)
        b.SetBitmapSelected(bmp)
        b.SetUseFocusIndicator(False)
        b.SetInitialSize()
        sizer.Add(b)

        # a flat text button
        b = buttons.GenButton(self,
                              -1,
                              'Flat buttons too!',
                              style=wx.BORDER_NONE)
        self.Bind(wx.EVT_BUTTON, self.OnButton, b)
        sizer.Add(b, flag=wx.ALIGN_CENTER_VERTICAL)

        # A flat image button
        bmp = images.Test2.GetBitmap()
        bmp.SetMaskColour("blue")
        b = buttons.GenBitmapButton(self, -1, bmp, style=wx.BORDER_NONE)
        self.Bind(wx.EVT_BUTTON, self.OnButton, b)
        sizer.Add(b)
        ##b.SetBackgroundColour("sky blue")
        ##b.SetBackgroundColour("pink")

        b = buttons.ThemedGenButton(self, -1, 'Drawn with native renderer')
        self.Bind(wx.EVT_BUTTON, self.OnButton, b)
        sizer.Add(b)

        border = wx.BoxSizer(wx.VERTICAL)
        border.Add(sizer, 0, wx.ALL, 25)
        self.SetSizer(border)
Beispiel #27
0
    def __init__(self, parent, ID, doodle):
        wx.Panel.__init__(self, parent, ID, style=wx.RAISED_BORDER)

        numCols = 4
        spacing = 4

        btnSize = wx.Size(self.BMP_SIZE + 2 * self.BMP_BORDER,
                          self.BMP_SIZE + 2 * self.BMP_BORDER)

        # Make a grid of buttons for each colour.  Attach each button
        # event to self.OnSetColour.  The button ID is the same as the
        # key in the colour dictionary.
        self.clrBtns = {}
        colours = doodle.menuColours
        keys = colours.keys()
        keys.sort()
        cGrid = wx.GridSizer(cols=numCols, hgap=2, vgap=2)
        for k in keys:
            bmp = self.MakeBitmap(colours[k])
            b = buttons.GenBitmapToggleButton(self, k, bmp, size=btnSize)
            b.SetBezelWidth(1)
            b.SetUseFocusIndicator(False)
            wx.EVT_BUTTON(self, k, self.OnSetColour)
            cGrid.Add(b, 0)
            self.clrBtns[colours[k]] = b
        self.clrBtns[colours[keys[0]]].SetToggle(True)

        # Make a grid of buttons for the thicknesses.  Attach each button
        # event to self.OnSetThickness.  The button ID is the same as the
        # thickness value.
        self.thknsBtns = {}
        tGrid = wx.GridSizer(cols=numCols, hgap=2, vgap=2)
        for x in range(1, doodle.maxThickness + 1):
            b = buttons.GenToggleButton(self, x, str(x), size=btnSize)
            b.SetBezelWidth(1)
            b.SetUseFocusIndicator(False)
            wx.EVT_BUTTON(self, x, self.OnSetThickness)
            tGrid.Add(b, 0)
            self.thknsBtns[x] = b
        self.thknsBtns[1].SetToggle(True)

        # Make a colour indicator window, it is registerd as a listener
        # with the doodle window so it will be notified when the settings
        # change
        ci = ColourIndicator(self)
        doodle.AddListener(ci)
        doodle.Notify()
        self.doodle = doodle

        # Make a box sizer and put the two grids and the indicator
        # window in it.
        box = wx.BoxSizer(wx.VERTICAL)
        box.Add(cGrid, 0, wx.ALL, spacing)
        box.Add(tGrid, 0, wx.ALL, spacing)
        box.Add(ci, 0, wx.EXPAND | wx.ALL, spacing)
        self.SetSizer(box)
        self.SetAutoLayout(True)

        # Resize this window so it is just large enough for the
        # minimum requirements of the sizer.
        box.Fit(self)
Beispiel #28
0
    def __init__(self, parent, **kws):
        """
		Initialization
		"""
        self.parent = parent
        self.selectedPoint = None
        self.hasPainted = 0
        wx.Panel.__init__(self, parent, -1)
        self.updateT = 0
        if kws.has_key("alpha"):
            self.alpha = kws["alpha"]
        self.updateCallback = 0
        self.ctf = vtk.vtkColorTransferFunction()
        self.doyield = 1
        self.calling = 0
        self.guiupdate = 0
        self.freeMode = 0
        self.selectThreshold = 35.0
        self.ptThreshold = 0.1
        self.color = 0
        self.modCount = 0
        self.minval = 0
        self.maxval = 255
        self.otf = vtk.vtkPiecewiseFunction()
        self.restoreDefaults()
        self.mainsizer = wx.BoxSizer(wx.VERTICAL)

        self.canvasBox = wx.BoxSizer(wx.VERTICAL)

        self.value = CTFValuePanel(self)
        self.canvasBox.Add(self.value, 0, wx.EXPAND | wx.LEFT | wx.RIGHT, 10)

        self.canvas = CTFPaintPanel(self)
        self.canvasBox.Add(self.canvas, 1, wx.ALL | wx.EXPAND, 10)

        self.mainsizer.Add(self.canvasBox)

        self.itemBox = wx.BoxSizer(wx.HORIZONTAL)

        self.alphaMode = 0

        iconpath = scripting.get_icon_dir()
        redbmp = wx.Image(os.path.join(iconpath, "CTF_Red.png"),
                          wx.BITMAP_TYPE_PNG).ConvertToBitmap()
        self.redBtn = buttons.GenBitmapToggleButton(self, -1, None)
        self.redBtn.SetBestSize((32, 32))
        self.redBtn.SetValue(1)
        self.redBtn.SetBitmapLabel(redbmp)

        greenbmp = wx.Image(os.path.join(iconpath, "CTF_Green.png"),
                            wx.BITMAP_TYPE_PNG).ConvertToBitmap()
        self.greenBtn = buttons.GenBitmapToggleButton(self, -1, None)
        self.greenBtn.SetBestSize((32, 32))
        self.greenBtn.SetBitmapLabel(greenbmp)

        bluebmp = wx.Image(os.path.join(iconpath, "CTF_Blue.png"),
                           wx.BITMAP_TYPE_PNG).ConvertToBitmap()
        self.blueBtn = buttons.GenBitmapToggleButton(self, -1, None)
        self.blueBtn.SetBestSize((32, 32))
        self.blueBtn.SetBitmapLabel(bluebmp)

        if self.alpha:
            alphabmp = wx.Image(os.path.join(iconpath, "CTF_Alpha.png"),
                                wx.BITMAP_TYPE_PNG).ConvertToBitmap()
            self.alphaBtn = buttons.GenBitmapToggleButton(self, -1, None)
            self.alphaBtn.SetBestSize((32, 32))
            self.alphaBtn.Bind(wx.EVT_BUTTON, self.onEditAlpha)
            self.alphaBtn.SetBitmapLabel(alphabmp)

        self.freeBtn = buttons.GenBitmapToggleButton(self, -1, None)
        self.freeBtn.SetBestSize((32, 32))
        bmp = wx.Image(os.path.join(iconpath, "CTF_Freehand.png"),
                       wx.BITMAP_TYPE_PNG).ConvertToBitmap()
        self.freeBtn.SetBitmapLabel(bmp)
        self.colorBtn = csel.ColourSelect(self, -1, "", size=(32, 32))
        self.colorBtn.Bind(csel.EVT_COLOURSELECT, self.onSetToColor)

        openbmp = wx.Image(os.path.join(iconpath, "CTF_OpenPalette.png"),
                           wx.BITMAP_TYPE_PNG).ConvertToBitmap()
        self.openBtn = buttons.GenBitmapButton(self, -1, None)
        self.openBtn.SetBestSize((32, 32))
        self.openBtn.SetBitmapLabel(openbmp)

        savebmp = wx.Image(os.path.join(iconpath, "CTF_SavePalette.png"),
                           wx.BITMAP_TYPE_PNG).ConvertToBitmap()
        self.saveBtn = buttons.GenBitmapButton(self, -1, None)
        self.saveBtn.SetBestSize((32, 32))
        self.saveBtn.SetBitmapLabel(savebmp)

        self.maxNodes = wx.SpinCtrl(self,
                                    -1,
                                    "20",
                                    min=2,
                                    max=9999,
                                    size=(54, -1),
                                    style=wx.TE_PROCESS_ENTER)
        self.maxNodes.SetToolTip(
            wx.ToolTip("Set the maximum number of nodes in the graph."))
        self.maxNodes.SetHelpText(
            "Use this control to set the maximum number of nodes in the graph. This is useful if you have a hand drawn palette that you wish to edit by dragging the nodes."
        )
        self.maxNodes.Bind(wx.EVT_SPINCTRL, self.onSetMaxNodes)
        self.maxNodes.Bind(wx.EVT_TEXT_ENTER, self.onSetMaxNodes)

        self.itemBox.Add(self.redBtn)
        self.itemBox.Add(self.greenBtn)
        self.itemBox.Add(self.blueBtn)
        if self.alpha:
            self.itemBox.Add(self.alphaBtn)

        self.itemBox.Add(self.freeBtn)
        self.itemBox.Add(self.colorBtn)
        self.itemBox.Add(self.openBtn)
        self.itemBox.Add(self.saveBtn)
        self.itemBox.Add(self.maxNodes)

        self.redBtn.Bind(wx.EVT_BUTTON, self.onEditRed)
        self.greenBtn.Bind(wx.EVT_BUTTON, self.onEditGreen)
        self.blueBtn.Bind(wx.EVT_BUTTON, self.onEditBlue)

        self.freeBtn.Bind(wx.EVT_BUTTON, self.onFreeMode)

        self.openBtn.Bind(wx.EVT_BUTTON, self.onOpenLut)
        self.saveBtn.Bind(wx.EVT_BUTTON, self.onSaveLut)

        self.mainsizer.Add(self.itemBox)

        self.SetAutoLayout(True)
        self.SetSizer(self.mainsizer)
        self.mainsizer.SetSizeHints(self)

        self.upToDate = 0
        self.canvas.Bind(wx.EVT_LEFT_DOWN, self.onEditFunction)
        self.canvas.Bind(wx.EVT_LEFT_UP, self.updateCTFView)
        self.canvas.Bind(wx.EVT_LEFT_DCLICK, self.onDeletePoint)

        self.canvas.Bind(wx.EVT_RIGHT_DOWN, self.onCreatePoint)
        self.canvas.Bind(wx.EVT_MOTION, self.onDrawFunction)

        self.pos = (0, 0)
Beispiel #29
0
def make_btn(id, parent):
    bmp = wx.ArtProvider.GetBitmap(getattr(wx, id), wx.ART_OTHER, (16, 16))
    btn = buttons.GenBitmapToggleButton(parent, -1, bmp)
    print("icon %s ok" % id)
    return btn
Beispiel #30
0
    def __init__(self, parent):
        wx.Panel.__init__(self, parent)

        # Set common sizes
        params.InitParams(self)

        topSizer = wx.BoxSizer(wx.VERTICAL)
        pinSizer = wx.BoxSizer(wx.HORIZONTAL)
        sizer = wx.FlexGridSizer(2, 2, 1, 5)
        self.labelRef = wx.StaticText(self, -1, 'ref:')
        self.textRef = params.ParamText(self, 'ref', textWidth=200)
        sizer.AddMany([(self.labelRef, 0, wx.ALIGN_CENTER_VERTICAL),
                       (self.textRef, 0, wx.LEFT, 5)])
        self.labelClass = wx.StaticText(self, -1, 'class:')
        self.textClass = params.ParamText(self, 'class', textWidth=200)
        sizer.AddMany([(self.labelClass, 0, wx.ALIGN_CENTER_VERTICAL),
                       (self.textClass, 0, wx.LEFT, 5)])
        self.labelName = wx.StaticText(self, -1, 'name:')
        self.textName = params.ParamText(self, 'name', textWidth=200)
        sizer.AddMany([(self.labelName, 0, wx.ALIGN_CENTER_VERTICAL),
                       (self.textName, 0, wx.LEFT, 5)])
        pinSizer.Add(sizer, 0, wx.ALL, 5)
        pinSizer.Add((0, 0), 1)
        self.pinButton = buttons.GenBitmapToggleButton(
            self, bitmap=images.getToolPinBitmap(), style=wx.BORDER_NONE)
        self.pinButton.SetBitmapSelected(images.getToolPinDownBitmap())
        self.pinButton.SetToggle(g.conf.panelPinState)
        self.pinButton.SetToolTipString('Sticky page selection')
        # No highlighting please
        self.pinButton.GetBackgroundBrush = lambda dc: None
        pinSizer.Add(self.pinButton)
        topSizer.Add(pinSizer, 0, wx.EXPAND)
        self.sizer = sizer

        self.nb = wx.Notebook(self, -1)
        if wx.Platform == '__WXGTK__':
            # Redefine AddPage on GTK to fix when page added is not shown
            _oldAddPage = wx.Notebook.AddPage

            def _newAddPage(self, page, label):
                _oldAddPage(self, page, label)
                page.Show(True)

            wx.Notebook.AddPage = _newAddPage

        # Create scrolled windows for panels
        self.pageA = ScrolledPage(self.nb)
        self.nb.AddPage(self.pageA, 'Attributes')
        # Style page
        self.pageStyle = ScrolledPage(self.nb)
        self.pageStyle.Hide()
        # Extra style page
        self.pageExStyle = ScrolledPage(self.nb)
        self.pageExStyle.Hide()
        # Window attributes page
        self.pageWA = ScrolledPage(self.nb)
        self.pageWA.Hide()
        # Implicit attributes page
        self.pageIA = ScrolledPage(self.nb)
        self.pageIA.Hide()
        # Code page
        self.pageCode = ScrolledPage(self.nb)
        self.pageCode.Hide()

        topSizer.Add(self.nb, 1, wx.EXPAND)
        self.SetSizer(topSizer)

        self.undo = None  # pending undo object