Example #1
0
    def _set_widget_style(self):
        """Set a new widget style if the style has changed.
        For some widgets style changes are not possible, so they need to be re-created.
        The attribute recreate_on_style_change needs to be True in this case."""
        if not self.widget or not self.update_widget_style: return
        old_style = self.widget.GetWindowStyleFlag()
        new_style = self.style
        if old_style == new_style: return

        if not self.recreate_on_style_change:
            # update style without re-creating the widget
            self.widget.SetWindowStyleFlag(new_style)
            self.widget.Refresh()
            return

        # some widgets can't be updated, e.g. Gauge can't be switched between horizontal and vertical after creation
        # this is for ManagedBase derived classes only
        focused = misc.focused_widget is self
        if self.sel_marker:
            self.sel_marker.Destroy()
            self.sel_marker = None
        old_widget = self.widget
        old_widget.Hide()
        si = self.sizer.widget.GetItem(old_widget)
        self.create_widget()
        compat.SizerItem_SetWindow(si, self.widget)
        compat.DestroyLater(old_widget)
        self.sizer.item_properties_modified(self)

        self.finish_widget_creation(re_add=False)
        self.sizer.layout()
        if focused:
            misc.focused_widget = self
            if self.sel_marker: self.sel_marker.Show(True)
Example #2
0
    def show_properties(self, *args):
        sizer_tmp = self.property_window.GetSizer()
        child = sizer_tmp.GetChildren()[0]
        w = child.GetWindow()
        if w is self.notebook:
            return
        w.Hide()

        self.notebook.Reparent(self.property_window)
        compat.SizerItem_SetWindow(child, self.notebook)

        self.notebook.Show(True)
        self.property_window.Layout()
        self.property_window.SetTitle(_('Properties - <%s>') % self.name)
        try:
            common.app_tree.select_item(self.node)
        except AttributeError:
            pass