Example #1
0
    def __init__(self, name, parent, index, label):
        # Initialise parent classes
        ManagedBase.__init__(self, name, parent, index)
        EditStylesMixin.__init__(self)
        BitmapMixin.__init__(self)

        # initialise instance properties
        self.label = np.TextProperty(label, default_value="", multiline="grow")
        self.default = np.CheckBoxProperty(False, default_value=False)
        self.stockitem = np.ListBoxPropertyD(self.STOCKITEMS[0],
                                             choices=self.STOCKITEMS)

        self.bitmap = np.BitmapPropertyD(min_version=(3, 0))
        self.disabled_bitmap = np.BitmapPropertyD(min_version=(3, 0))
        self.pressed_bitmap = np.BitmapPropertyD(min_version=(3, 0))
        self.current_bitmap = np.BitmapPropertyD(min_version=(3, 0))
        self.focus_bitmap = np.BitmapPropertyD(min_version=(3, 0))

        values = [wx.LEFT, wx.RIGHT, wx.TOP, wx.BOTTOM]
        aliases = ["wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM"]
        p = self.bitmap_dir = np.RadioProperty(wx.LEFT,
                                               values,
                                               columns=4,
                                               aliases=aliases,
                                               default_value=wx.LEFT)
        p.min_version = (3, 0)
        p.blocked = True
Example #2
0
    def properties_changed(self, modified=None):
        "update label (and size if label/stockitem have changed)"

        label_modified = not modified or "label" in modified

        if not modified or "stockitem" in modified:
            # if stockitem is set, label needs to be deactivated and window id is wxID_...
            if self.properties["stockitem"].is_active():
                self.properties["label"].set_blocked(True)
                new_id = "wxID_" + self.stockitem
                self.properties["id"].set(new_id, deactivate=True)
                #self.properties["id"].default_value = new_id  # avoid this value to be written to XML

                l = ButtonStockItems.stock_ids[self.stockitem]
                if self.widget:
                    self.widget.SetLabel(l)
            else:
                self.properties["label"].set_blocked(False)
                #self.properties["id"].default_value = "wxID_ANY"
                label_modified = True

        if label_modified and self.properties["label"].is_active():
            if self.widget:
                self.widget.SetLabel(self.label)

        if (label_modified or "name" in modified) and common.app_tree:
            common.app_tree.refresh(self,
                                    refresh_label=True,
                                    refresh_image=False)

        BitmapMixin._properties_changed(self, modified)
        self._set_widget_best_size()
        EditStylesMixin.properties_changed(self, modified)
        ManagedBase.properties_changed(self, modified)
Example #3
0
 def create_widget(self):
     self.widget = wx.ToggleButton(self.parent_window.widget,
                                   wx.ID_ANY,
                                   self.label,
                                   style=self.style)
     self.widget.SetValue(self.value)
     self.widget.Bind(wx.EVT_TOGGLEBUTTON,
                      self.on_set_focus,
                      id=self.widget.GetId())
     BitmapMixin._set_preview_bitmaps(self)
Example #4
0
    def __init__(self, name, parent, bmp_file, pos):
        ManagedBase.__init__(self, name, 'wxBitmapButton', parent, pos)
        EditStylesMixin.__init__(self)
        BitmapMixin.__init__(self)

        # initialise instance properties
        self.bitmap = np.BitmapProperty(bmp_file)
        self.disabled_bitmap = np.BitmapPropertyD("")
        self.pressed_bitmap = np.BitmapPropertyD(min_version=(3, 0))
        self.current_bitmap = np.BitmapPropertyD(min_version=(3, 0))
        self.focus_bitmap = np.BitmapPropertyD(min_version=(3, 0))
        self.default = np.CheckBoxProperty(False, default_value=False)
Example #5
0
    def _properties_changed(self, modified, actions):
        if not modified or "value" in modified and self.widget:
            self.widget.SetValue(self.value)

        if not modified or "label" in modified:
            if self.widget:
                self.widget.SetLabel(self.label)
            if modified: actions.update(("layout", "label"))

        BitmapMixin._properties_changed(self, modified, actions)
        EditStylesMixin._properties_changed(self, modified, actions)
        ManagedBase._properties_changed(self, modified, actions)
Example #6
0
    def __init__(self, name, parent, id, bmp_file, sizer, pos):
        ManagedBase.__init__(self, name, 'wxBitmapButton', parent, id, sizer,
                             pos)
        EditStylesMixin.__init__(self)
        BitmapMixin.__init__(self)

        # initialise instance properties
        filedialog_style = wx.FD_OPEN | wx.FD_FILE_MUST_EXIST  # for the following two properties
        self.bitmap = np.BitmapProperty(bmp_file, style=filedialog_style)
        self.disabled_bitmap = np.BitmapPropertyD("",
                                                  default_value="",
                                                  style=filedialog_style)
        self.default = np.CheckBoxProperty(False, default_value=False)
Example #7
0
    def properties_changed(self, modified):
        if not modified or "value" in modified and self.widget:
            self.widget.SetValue(self.value)

        if not modified or "label" in modified:
            if self.widget:
                self.widget.SetLabel(self.label)
                self._set_widget_best_size()
            common.app_tree.refresh(self, refresh_label=True, refresh_image=False)

        BitmapMixin._properties_changed(self, modified)
        self._set_widget_best_size()
        EditStylesMixin.properties_changed(self, modified)
        ManagedBase.properties_changed(self, modified)
Example #8
0
    def _properties_changed(self, modified, actions):
        "update label (and size if label/stockitem have changed)"

        if "bitmap" in modified:
            self.properties["bitmap_dir"].set_blocked(
                not self.check_prop_truth("bitmap"))

        label_modified = not modified or ("label" in modified
                                          or "font" in modified)

        if not modified or "stockitem" in modified:
            # if stockitem is set, label needs to be deactivated and window id is wxID_...
            if self.properties["stockitem"].is_active():
                self.properties["label"].set_blocked(True)
                new_id = "wxID_" + self.stockitem
                if common.history:
                    common.history.monitor_property(self.properties["id"])
                self.properties["id"].set(new_id, deactivate=True)
                #self.properties["id"].default_value = new_id  # avoid this value to be written to XML

                l = ButtonStockItems.stock_ids[self.stockitem]
                if self.widget: self.widget.SetLabel(l)
            else:
                self.properties["label"].set_blocked(False)
                label_modified = True

        if modified and "font" in modified and wx.Platform == '__WXGTK__':
            # on GTK setting a smaller font would fail
            actions.update(("recreate2", "label", "sizeevent"))
            return

        if label_modified and self.properties["label"].is_active(
        ) and self.widget:
            self.widget.SetLabel(self.label)
            label_modified = True

        if label_modified or (modified and "stockitem" in modified):
            actions.update(("layout", "label", "sizeevent"))

        if modified and ("label" in modified or "stockitem" in modified):
            actions.add("label")

        if "bitmap_dir" in modified and self.widget:
            self.widget.SetBitmapPosition(self.bitmap_dir)

        BitmapMixin._properties_changed(self, modified, actions)
        EditStylesMixin._properties_changed(self, modified, actions)
        ManagedBase._properties_changed(self, modified, actions)
Example #9
0
    def __init__(self, name, parent, label, pos):
        # Initialise parent classes
        ManagedBase.__init__(self, name, 'wxButton', parent, pos)
        EditStylesMixin.__init__(self)
        BitmapMixin.__init__(self)

        # initialise instance properties
        self.label     = np.TextProperty(label, default_value="", multiline="grow")
        self.default   = np.CheckBoxProperty(False, default_value=False)
        self.stockitem = np.ListBoxPropertyD(self.STOCKITEMS[0], choices=self.STOCKITEMS)

        self.bitmap          = np.BitmapPropertyD(min_version=(3,0))
        self.disabled_bitmap = np.BitmapPropertyD(min_version=(3,0))
        self.pressed_bitmap  = np.BitmapPropertyD(min_version=(3,0))
        self.current_bitmap  = np.BitmapPropertyD(min_version=(3,0))
        self.focus_bitmap    = np.BitmapPropertyD(min_version=(3,0))
    def __init__(self, name, parent, id, bmp_file, sizer, pos):
        ManagedBase.__init__(self, name, 'wxBitmapButton', parent, id, sizer,
                             pos)
        EditStylesMixin.__init__(self)
        BitmapMixin.__init__(self)

        # initialise instance properties
        filedialog_style = wx.FD_OPEN | wx.FD_FILE_MUST_EXIST  # for the following two properties
        self.bitmap = np.FileNameProperty(bmp_file, style=filedialog_style)
        self.disabled_bitmap = np.FileNamePropertyD("",
                                                    default_value="",
                                                    style=filedialog_style)
        self.default = np.CheckBoxProperty(False)

        if config.preferences.default_border:
            self.border.set(config.preferences.default_border_size)
            self.flag.set(wx.ALL)
Example #11
0
 def properties_changed(self, modified=None):
     "update label (and size if label/stockitem have changed)"
     BitmapMixin._properties_changed(self, modified)
     EditStylesMixin.properties_changed(self, modified)
     ManagedBase.properties_changed(self, modified)
Example #12
0
 def create_widget(self):
     self.widget = wx.ToggleButton(self.parent_window.widget, self.id, self.label)
     self.widget.SetValue(self.value)
     self.widget.Bind(wx.EVT_TOGGLEBUTTON, self.on_set_focus, id=self.id)
     BitmapMixin._set_preview_bitmaps(self)
Example #13
0
 def _properties_changed(self, modified, actions):
     "update label (and size if label/stockitem have changed)"
     BitmapMixin._properties_changed(self, modified, actions)
     EditStylesMixin._properties_changed(self, modified, actions)
     ManagedBase._properties_changed(self, modified, actions)