Esempio n. 1
0
 def destroy_widget(self):
     if not self.widget or self._dont_destroy: return
     if self.parent.IS_SIZER and self.parent.widget:
         self.parent.widget.Detach(
             self.widget)  # remove from sizer without destroying
     compat.DestroyLater(self.widget)
     self.widget = None
Esempio n. 2
0
    def destroy_widget(self, detach=True):
        if self.widget is None: return
        if misc.currently_under_mouse is self.widget:
            misc.currently_under_mouse = None

        if self._dont_destroy: return  # on a notebook page
        self.widget.Hide()

        if wx.VERSION_STRING != "2.8.12.0":
            # unbind events to prevent new created (and queued) events
            self.widget.Bind(wx.EVT_PAINT, None)
            self.widget.Bind(wx.EVT_RIGHT_DOWN, None)
            self.widget.Bind(wx.EVT_LEFT_DOWN, None)
            self.widget.Bind(wx.EVT_MIDDLE_DOWN, None)
            self.widget.Bind(wx.EVT_ENTER_WINDOW, None)
            self.widget.Bind(wx.EVT_LEAVE_WINDOW, None)
            self.widget.Bind(wx.EVT_KEY_DOWN, None)
        if detach and self.parent.IS_SIZER and self.parent.widget:
            self.parent.widget.Detach(
                self.widget)  # this will happen during recursive removal only
        compat.DestroyLater(self.widget)
        self.widget = None

        if misc.focused_widget is self:
            misc.set_focused_widget(None)
Esempio n. 3
0
 def destroy_widget(self):
     if not self.widget or self._dont_destroy: return
     if getattr(self, "sizer", None) and not self.sizer.is_virtual():
         self.sizer.widget.Detach(
             self.widget)  # remove from sizer without destroying
     compat.DestroyLater(self.widget)
     self.widget = None
Esempio n. 4
0
 def _set_choices(self):
     if not self.widget: return
     for b in self.buttons or []:
         if b: compat.DestroyLater(b)
     self.static_box = self._create_static_box()
     self.buttons = [self._create_button(c) for (c, ) in self.choices]
     self._do_layout()
Esempio n. 5
0
    def recreate_widget(self):
        "currently used by EditTopLevelPanel to re-create after switch between ScrolledWindow and Panel"
        old_widget = self.widget
        size = self.widget.GetSize()
        with self.frozen():
            self.create_widget()
            self.widget.SetSize(size)
            old_widget.Hide()
            if self.sel_marker:
                self.sel_marker.Destroy()
                self.sel_marker = None

            if self.sizer and not self.sizer.is_virtual():
                self.sizer.widget.Detach(old_widget)
                # finish_widget_creation below will add the new widget to the sizer; alternatively add it here

            sizer = old_widget.GetSizer()
            if sizer:
                self.widget.SetSizer(sizer)
                old_widget.SetSizer(None, False)
                sizer.SetContainingWindow(self.widget)
                self._reparent_widget(sizer)
                #sizer.Layout()
            else:
                for child in self.widget.GetChildren():
                    # actually, for now a panel may only have a sizer as child, so this code is not executed
                    self._reparent_widget(child)
            if old_widget in misc.design_windows:
                misc.design_windows.remove(old_widget)
                misc.design_windows.append(self.widget)
            compat.DestroyLater(old_widget)
            self.finish_widget_creation(
            )  # this will add the new widget to the sizer (default argument re_add=True)
Esempio n. 6
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)
Esempio n. 7
0
 def delete(self, *args):
     if self.preview_widget is not None:
         self.preview_widget.Unbind(wx.EVT_CHAR_HOOK)
         compat.DestroyLater(self.preview_widget)
         self.preview_widget = None
     widget = self.widget
     WindowBase.delete(self)
     if widget is not None: misc.design_windows.remove(widget)
Esempio n. 8
0
 def destroy_widget(self, level, later=True):
     # just destroy the widget; all bookkeeping / data structure update is done in recursive_remove
     # level is 0 for toplevel or when the user just deletes this one
     if not self.widget: return
     if later:
         compat.DestroyLater(self.widget)
     else:
         self.widget.Destroy()
     self.widget = None
Esempio n. 9
0
 def delete(self, *args):
     if self.preview_widget is not None:
         if misc.preview_event_filter:
             self.preview_widget.RemoveFilter(misc.preview_event_filter)
         compat.DestroyLater(self.preview_widget)
         self.preview_widget = None
     widget = self.widget
     WindowBase.delete(self)
     if widget is not None: misc.design_windows.remove(widget)
Esempio n. 10
0
    def delete(self):
        """Destructor. deallocates the popup menu, the notebook and all the properties.
        Why we need explicit deallocation? Well, basically because otherwise we get a lot of memory leaks... :)"""
        # XXX tell property editor

        # ...finally, destroy our widget (if needed)
        if self.widget and not self._dont_destroy:
            if getattr(self, "sizer", None) and not self.sizer.is_virtual():
                self.sizer.widget.Detach(self.widget)  # remove from sizer without destroying
            compat.DestroyLater(self.widget)
            self.widget = None
        if misc.focused_widget is self:
            misc.focused_widget = None
Esempio n. 11
0
 def remove(self, *args, **kwds):
     if self.parent is not None:
         self.parent.properties['toolbar'].set(False)
         self.parent._toolbar = None
         if kwds.get('do_nothing', False):
             # this probably leaks memory, but avoids segfaults
             self.widget = None
         else:
             if self.parent.widget:
                 self.parent.widget.SetToolBar(None)
     else:
         if self.widget:
             compat.DestroyLater(self.widget)
             self.widget = None
     EditBase.remove(self)
 def remove(self, *args, **kwds):
     if self.parent is not None:
         self.parent.properties['menubar'].set(False)
         self.parent._menubar = None
         if kwds.get('gtk_do_nothing', False) and wx.Platform == '__WXGTK__':
             # workaround to prevent some segfaults on GTK: unfortunately,
             # I'm not sure that this works in all cases, and moreover it
             # could probably leak some memory (but I'm not sure)
             self.widget = None
         else:
             if self.parent.widget:
                 self.parent.widget.SetMenuBar(None)
     else:
         if self.widget:
             compat.DestroyLater(self.widget)
             self.widget = None
     EditBase.remove(self)
Esempio n. 13
0
    def destroy_widget(self, level):
        if self.widget is None: return
        if misc.currently_under_mouse is self.widget:
            misc.currently_under_mouse = None

        self.widget.Hide()

        if wx.VERSION_STRING != "2.8.12.0":
            # unbind events to prevent new created (and queued) events
            self.widget.Bind(wx.EVT_PAINT, None)
            self.widget.Bind(wx.EVT_RIGHT_DOWN, None)
            self.widget.Bind(wx.EVT_LEFT_DOWN, None)
            self.widget.Bind(wx.EVT_MIDDLE_DOWN, None)
            self.widget.Bind(wx.EVT_ENTER_WINDOW, None)
            self.widget.Bind(wx.EVT_LEAVE_WINDOW, None)
            self.widget.Bind(wx.EVT_KEY_DOWN, None)
        compat.DestroyLater(self.widget)
        self.widget = None

        if misc.focused_widget is self:
            misc.set_focused_widget(None)
Esempio n. 14
0
 def on_close(event):
     frame.Unbind(wx.EVT_CHAR_HOOK)
     compat.DestroyLater(frame)
     widget.preview_widget = None
     widget.properties["preview"].set_label(_('Show Preview'))
Esempio n. 15
0
 def on_close(event):
     if misc.preview_event_filter:
         misc.preview_event_filter.add_window(frame)
     compat.DestroyLater(frame)
     widget.preview_widget = None
     widget.properties["preview"].set_label(_('Show Preview'))