Beispiel #1
0
    def test_image_button_align(self):
        # btn = buttons.ImageButton(self.panel, height=16, size=(100, -1),
        #                           icon=img.getBitmap("icon/ico_chevron_down.png"))
        # self.add_control(btn, wx.ALL | wx.ALIGN_CENTER_HORIZONTAL)

        btn = buttons.ImageButton(self.panel,
                                  height=32,
                                  size=(100, -1),
                                  icon=img.getBitmap("icon/ico_acqui.png"),
                                  style=wx.ALIGN_LEFT)
        self.add_control(btn, wx.ALL | wx.ALIGN_CENTER_HORIZONTAL)

        btn = buttons.ImageButton(self.panel,
                                  height=32,
                                  size=(100, -1),
                                  icon=img.getBitmap("icon/ico_acqui.png"),
                                  style=wx.ALIGN_CENTER)
        self.add_control(btn, wx.ALL | wx.ALIGN_CENTER_HORIZONTAL)

        btn = buttons.ImageButton(self.panel,
                                  height=32,
                                  size=(100, -1),
                                  icon=img.getBitmap("icon/ico_acqui.png"),
                                  style=wx.ALIGN_RIGHT)
        self.add_control(btn, wx.ALL | wx.ALIGN_CENTER_HORIZONTAL)
Beispiel #2
0
    def DoCreateResource(self):
        assert self.GetInstance() is None

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

        w = btns.ImageButton(self.GetParentAsWindow(),
                            self.GetID(),
                            bmp,
                            pos=self.GetPosition(),
                            size=self.GetSize(),
                            style=self.GetStyle(),
                            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 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 #4
0
    def test_image_button(self):

        # No icon

        for i, h in enumerate(BTN_SIZES):

            row_sizer = wx.BoxSizer(wx.HORIZONTAL)

            # Without explicit size

            btn = buttons.ImageButton(self.panel, 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.ImageButton(self.panel, 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.ImageButton(self.panel, height=h)
        btn.SetToolTip("Expand")
        self.add_control(btn, flags=wx.ALL | wx.EXPAND, border=2)

        # With icon

        for i, h in enumerate(BTN_SIZES):

            row_sizer = wx.BoxSizer(wx.HORIZONTAL)

            # Without explicit size

            btn = buttons.ImageButton(
                self.panel,
                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.ImageButton(
                    self.panel,
                    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.ImageButton(
            self.panel,
            height=h,
            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

        for i, h in enumerate(BTN_SIZES):

            row_sizer = wx.BoxSizer(wx.HORIZONTAL)

            # Without explicit size

            btn = buttons.ImageButton(
                self.panel,
                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.ImageButton(
                    self.panel,
                    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.ImageButton(
            self.panel,
            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

        for i, h in enumerate(BTN_SIZES):

            row_sizer = wx.BoxSizer(wx.HORIZONTAL)

            # Without explicit size

            btn = buttons.ImageButton(
                self.panel,
                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.ImageButton(
                    self.panel,
                    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.ImageButton(
            self.panel,
            height=h,
            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)