Beispiel #1
0
    def DoCreateResource(self):
        assert self.GetInstance() is None

        bmp = wx.NullBitmap
        if self.GetParamNode("bitmap"):
            bmp = self.GetBitmap("bitmap")

        w = btns.PopupImageButton(self.GetParentAsWindow(),
                                  self.GetID(),
                                  bmp,
                                  pos=self.GetPosition(),
                                  size=self.GetSize(),
                                  style=self.GetStyle())

        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 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)
Beispiel #3
0
    def test_popup_button(self):
        btn = buttons.PopupImageButton(self.panel, label="Drop it!", style=wx.ALIGN_CENTER)
        self.add_control(btn, wx.ALL | wx.ALIGN_CENTER_HORIZONTAL)

        nb_options = 5
        for i in range(nb_options):
            def tmp(option=i):
                print "option %s chosen" % option

            btn.add_choice("option %s" % i, tmp)

        test.gui_loop()
        self.assertEqual(len(btn.choices), nb_options)
        self.assertEqual(btn.menu.MenuItemCount, nb_options)
        btn.remove_choice("option 0")
        test.gui_loop()
        self.assertEqual(len(btn.choices), nb_options - 1)
        self.assertEqual(btn.menu.MenuItemCount, nb_options - 1)
        test.gui_loop()