def test_text_buttons(self): self.assertRaises(ValueError, buttons.ImageTextButton, self.panel, {'label': "blah"}) btn = buttons.ImageTextButton(self.panel, height=32) self.add_control(btn, wx.ALL | wx.ALIGN_CENTER_HORIZONTAL) btn = buttons.ImageTextToggleButton(self.panel, height=32, label="Toggle") self.add_control(btn, wx.ALL | wx.ALIGN_CENTER_HORIZONTAL) btn = buttons.ImageTextButton(self.panel, size=(300, -1), face_colour='blue', height=32, label="Wider!") btn.Disable() self.add_control(btn, wx.ALL | wx.ALIGN_CENTER_HORIZONTAL) btn = buttons.ImageTextButton(self.panel, size=(300, -1), height=32, label="Icon!") btn.SetIcon(img.getBitmap("icon/ico_ang.png")) btn.Disable() self.add_control(btn, wx.ALL | wx.ALIGN_CENTER_HORIZONTAL) test.gui_loop()
def DoCreateResource(self): assert self.GetInstance() is None bmp = wx.NullBitmap if self.GetParamNode("bitmap"): bmp = self.GetBitmap("bitmap") w = btns.ImageTextButton(self.GetParentAsWindow(), self.GetID(), bmp, pos=self.GetPosition(), size=self.GetSize(), style=self.GetStyle(), label=self.GetText('label'), label_delta=self.GetLong('delta')) if self.GetParamNode("selected"): bmp = self.GetBitmap("selected") w.SetBitmapSelected(bmp) if self.GetParamNode("hover"): bmp = self.GetBitmap("hover") w.SetBitmapHover(bmp) if self.GetParamNode("focus"): bmp = self.GetBitmap("focus") w.SetBitmapFocus(bmp) if self.GetParamNode("disabled"): bmp = self.GetBitmap("disabled") w.SetBitmapDisabled(bmp) self.SetupWindow(w) return w
def test_image_button_font(self): for height in (16, 24, 32, 48): btn = buttons.ImageTextButton(self.panel, height=height, label="Big brown fox") self.add_control(btn, wx.ALL | wx.ALIGN_CENTER_HORIZONTAL) test.gui_loop()
def setUpClass(cls): super(ButtonsTestCase, cls).setUpClass() cls.buttons = OrderedDict() panel = cls.app.panel_finder() cls.buttons['ImageButton'] = buttons.ImageButton( panel, -1, data.getbtn_128x24Bitmap()) cls.buttons['ImageButton'].SetBitmaps(data.getbtn_128x24_hBitmap()) cls.buttons['ImageTextButton'] = buttons.ImageTextButton( panel, -1, data.getbtn_128x24Bitmap(), "ImageTextButton", label_delta=1) cls.buttons['ImageTextButton'].SetBitmaps(data.getbtn_128x24_hBitmap(), data.getbtn_128x24_aBitmap()) cls.buttons['ImageToggleButton'] = buttons.ImageToggleButton( panel, -1, data.getbtn_128x24Bitmap(), label_delta=10) cls.buttons['ImageToggleButton'].SetBitmaps( data.getbtn_128x24_hBitmap(), data.getbtn_128x24_aBitmap()) cls.buttons['ImageTextToggleButton'] = buttons.ImageTextToggleButton( panel, -1, data.getbtn_256x24_hBitmap(), "ImageTextToggleButton", label_delta=1, style=wx.ALIGN_CENTER) cls.buttons['ImageTextToggleButton'].SetBitmaps( data.getbtn_256x24_hBitmap(), data.getbtn_256x24_aBitmap()) cls.buttons['ViewButton'] = buttons.ViewButton( panel, -1, data.getpreview_blockBitmap(), label_delta=1, style=wx.ALIGN_CENTER) cls.buttons['ViewButton'].set_overlay_image(data.geticon128Image()) cls.buttons['ViewButton'].SetBitmaps(data.getpreview_block_aBitmap()) cls.buttons['ColourButton'] = buttons.ColourButton( panel, -1, data.getbtn_128x24Bitmap()) cls.buttons['PopupImageButton'] = buttons.PopupImageButton( panel, -1, data.getbtn_128x24Bitmap(), r"\/", style=wx.ALIGN_CENTER) cls.buttons['PopupImageButton'].SetBitmaps( data.getbtn_128x24_hBitmap()) for btn in cls.buttons.values(): cls.add_control(btn, wx.ALL | wx.ALIGN_CENTER_HORIZONTAL)
def test_image_text_button(self): # No icon self.add_control(wx.StaticText(self.panel, label="No icon, no alignment"), flags=wx.ALL | wx.EXPAND, border=2) for i, h in enumerate(BTN_SIZES): row_sizer = wx.BoxSizer(wx.HORIZONTAL) # Without explicit size btn = buttons.ImageTextButton(self.panel, label="Hoger", height=h) btn.SetToolTip("No width defined") row_sizer.Add(btn, flag=wx.LEFT | wx.RIGHT, border=2) for w in BTN_WIDTHS: btn = buttons.ImageTextButton(self.panel, label="Hoger", height=h, size=(w, -1)) btn.SetToolTip("Width set to %d" % w) row_sizer.Add(btn, flag=wx.LEFT | wx.RIGHT, border=2) self.add_control(row_sizer, flags=wx.ALL | wx.EXPAND, border=2) btn = buttons.ImageTextButton(self.panel, label="Hoger", height=h, size=(w, -1)) btn.SetToolTip("Expand") self.add_control(btn, flags=wx.ALL | wx.EXPAND, border=2) # With icon self.add_control(wx.StaticText(self.panel, label="With icon, no alignment"), flags=wx.ALL | wx.EXPAND, border=2) for i, h in enumerate(BTN_SIZES): row_sizer = wx.BoxSizer(wx.HORIZONTAL) # Without explicit size btn = buttons.ImageTextButton( self.panel, label="Hoger", height=h, icon=img.getBitmap("icon/ico_chevron_down.png")) btn.SetToolTip("No width defined") row_sizer.Add(btn, flag=wx.LEFT | wx.RIGHT, border=2) for w in BTN_WIDTHS: btn = buttons.ImageTextButton( self.panel, label="Hoger", height=h, size=(w, -1), icon=img.getBitmap("icon/ico_chevron_down.png")) btn.SetToolTip("Width set to %d" % w) row_sizer.Add(btn, flag=wx.LEFT | wx.RIGHT, border=2) self.add_control(row_sizer, flags=wx.ALL | wx.EXPAND, border=2) btn = buttons.ImageTextButton( self.panel, label="Hoger", height=h, size=(w, -1), icon=img.getBitmap("icon/ico_chevron_down.png")) btn.SetToolTip("Expand") self.add_control(btn, flags=wx.ALL | wx.EXPAND, border=2) # With icon, CENTER ALIGNED self.add_control(wx.StaticText(self.panel, label="With icon, center alignment"), flags=wx.ALL | wx.EXPAND, border=2) for i, h in enumerate(BTN_SIZES): row_sizer = wx.BoxSizer(wx.HORIZONTAL) # Without explicit size btn = buttons.ImageTextButton( self.panel, label="Hoger", height=h, icon=img.getBitmap("icon/ico_chevron_down.png"), style=wx.ALIGN_CENTER) btn.SetToolTip("No width defined") btn.SetIcon(img.getBitmap("icon/ico_chevron_down.png")) row_sizer.Add(btn, flag=wx.LEFT | wx.RIGHT, border=2) for w in BTN_WIDTHS: btn = buttons.ImageTextButton( self.panel, label="Hoger", height=h, size=(w, -1), icon=img.getBitmap("icon/ico_chevron_down.png"), style=wx.ALIGN_CENTER) btn.SetToolTip("Width set to %d" % w) row_sizer.Add(btn, flag=wx.LEFT | wx.RIGHT, border=2) self.add_control(row_sizer, flags=wx.ALL | wx.EXPAND, border=2) btn = buttons.ImageTextButton( self.panel, label="Hoger", height=h, size=(w, -1), icon=img.getBitmap("icon/ico_chevron_down.png"), style=wx.ALIGN_CENTER) btn.SetToolTip("Expand") self.add_control(btn, flags=wx.ALL | wx.EXPAND, border=2) # With icon, RIGHT ALIGNED self.add_control(wx.StaticText(self.panel, label="With icon, right alignment"), flags=wx.ALL | wx.EXPAND, border=2) for i, h in enumerate(BTN_SIZES): row_sizer = wx.BoxSizer(wx.HORIZONTAL) # Without explicit size btn = buttons.ImageTextButton( self.panel, label="Hoger", height=h, icon=img.getBitmap("icon/ico_chevron_down.png"), style=wx.ALIGN_RIGHT) btn.SetToolTip("No width defined") btn.SetIcon(img.getBitmap("icon/ico_chevron_down.png")) row_sizer.Add(btn, flag=wx.LEFT | wx.RIGHT, border=2) for w in BTN_WIDTHS: btn = buttons.ImageTextButton( self.panel, label="Hoger", height=h, size=(w, -1), icon=img.getBitmap("icon/ico_chevron_down.png"), style=wx.ALIGN_RIGHT) btn.SetToolTip("Width set to %d" % w) row_sizer.Add(btn, flag=wx.LEFT | wx.RIGHT, border=2) self.add_control(row_sizer, flags=wx.ALL | wx.EXPAND, border=2) btn = buttons.ImageTextButton( self.panel, label="Hoger", height=h, size=(w, -1), icon=img.getBitmap("icon/ico_chevron_down.png"), style=wx.ALIGN_RIGHT) btn.SetToolTip("Expand") self.add_control(btn, flags=wx.ALL | wx.EXPAND, border=2)