def __init__(self, parent, property_window): EditBase.__init__(self, parent.name + '_statusbar', 'wxStatusBar', parent, id, property_window, custom_class=False, show=False) # style property self.style_pos = (wx.ST_SIZEGRIP,) style_labels = ('#section#' + _('Style'), 'wxST_SIZEGRIP') self.access_functions['style'] = (self.get_style, self.set_style) self.properties['style'] = CheckListProperty(self, 'style', None, style_labels) self.node = Tree.Node(self) common.app_tree.add(self.node, parent.node) self.fields = [ [self.name, "-1"] ] # list of 2-lists label, size # for the statusbar fields self.access_functions['fields'] = (self.get_fields, self.set_fields) prop = self.properties['fields'] = GridProperty( self, 'fields', None, [("Text", GridProperty.STRING), ("Size", GridProperty.INT)]) # replace the default 'write' method of 'prop' with a custom one def write_prop(outfile, tabs): from xml.sax.saxutils import escape, quoteattr fwrite = outfile.write fwrite(' ' * tabs + '<fields>\n') tabs += 1 import widget_properties for label, width in self.fields: fwrite(' ' * tabs + '<field width=%s>%s</field>\n' % (quoteattr(width), escape(widget_properties._encode(label)))) tabs -= 1 fwrite(' ' * tabs + '</fields>\n') prop.write = write_prop
def __init__(self, name, klass, parent): custom_class = parent is None EditBase.__init__(self, name, 'wxToolBar', parent, wx.NewId(), custom_class=custom_class) EditStylesMixin.__init__(self) # initialise instance properties self.bitmapsize = np.IntPairPropertyD('16, 15', default_value='16, 15') self.margins = np.IntPairPropertyD('0, 0', default_value='0, 0') self.packing = np.SpinPropertyD(1, val_range=(0, 100), default_value=1, immediate=True) self.separation = np.SpinPropertyD(5, val_range=(0, 100), default_value=5, immediate=True) self.tools = ToolsProperty() # incl. the Edit button self.window_id = None # just a dummy for code generation self.widget = self._tb = None # a panel and the actual ToolBar if not self.parent: PreviewMixin.__init__(self) # add a preview button self._is_toplevel = True else: self.preview = None self._is_toplevel = False
def create_properties(self): EditBase.create_properties(self) page = self._common_panel sizer = page.GetSizer() self.properties['bitmapsize'].display(page) self.properties['margins'].display(page) self.properties['packing'].display(page) self.properties['separation'].display(page) self.properties['style'].display(page) self.properties['tools'].display(page) if not sizer: sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(self.name_prop.panel, 0, wx.EXPAND) sizer.Add(self.klass_prop.panel, 0, wx.EXPAND) page.SetAutoLayout(1) page.SetSizer(sizer) sizer.Add(self.properties['bitmapsize'].panel, 0, wx.EXPAND) sizer.Add(self.properties['margins'].panel, 0, wx.EXPAND) sizer.Add(self.properties['packing'].panel, 0, wx.EXPAND) sizer.Add(self.properties['separation'].panel, 0, wx.EXPAND) sizer.Add(self.properties['style'].panel, 0, wx.EXPAND) sizer.Add(self.properties['tools'].panel, 0, wx.ALL|wx.EXPAND, 3) sizer.Layout() sizer.Fit(page) w, h = page.GetClientSize() self.notebook.AddPage(page, _("Common")) if self.parent is not None: self.property_window.Layout() page.SetScrollbars(1, 5, 1, int(math.ceil(h/5.0))) else: PreviewMixin.create_properties(self)
def create_properties(self): EditBase.create_properties(self) page = self._common_panel sizer = page.GetSizer() self.properties['bitmapsize'].display(page) self.properties['margins'].display(page) self.properties['packing'].display(page) self.properties['separation'].display(page) self.properties['style'].display(page) self.properties['tools'].display(page) if not sizer: sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(self.name_prop.panel, 0, wx.EXPAND) sizer.Add(self.klass_prop.panel, 0, wx.EXPAND) page.SetAutoLayout(1) page.SetSizer(sizer) sizer.Add(self.properties['bitmapsize'].panel, 0, wx.EXPAND) sizer.Add(self.properties['margins'].panel, 0, wx.EXPAND) sizer.Add(self.properties['packing'].panel, 0, wx.EXPAND) sizer.Add(self.properties['separation'].panel, 0, wx.EXPAND) sizer.Add(self.properties['style'].panel, 0, wx.EXPAND) sizer.Add(self.properties['tools'].panel, 0, wx.ALL | wx.EXPAND, 3) sizer.Layout() sizer.Fit(page) w, h = page.GetClientSize() self.notebook.AddPage(page, _("Common")) if self.parent is not None: self.property_window.Layout() page.SetScrollbars(1, 5, 1, int(math.ceil(h / 5.0))) else: PreviewMixin.create_properties(self)
def _properties_changed(self, modified, actions): if modified and "style" in modified: actions.add("recreate_parent") return if not modified or "name" in modified and self.widget is not self._tb: self.widget.SetTitle(misc.design_title(misc.wxstr(self.name))) if not modified or "margins" in modified and self._tb: self._set_margins() actions.add("refresh") if not modified or "bitmapsize" in modified and self._tb: self._set_bitmapsize() actions.add("refresh") if not modified or "packing" in modified and self._tb: self._set_packing() actions.add("refresh") if not modified or "separation" in modified and self._tb: self._set_separation() actions.add("refresh") if not modified or "tools" in modified and self._tb: self._set_tools() actions.add("refresh") EditStylesMixin._properties_changed(self, modified, actions) EditBase._properties_changed(self, modified, actions)
def __init__(self, name, klass, parent): if parent.IS_ROOT: self.__dict__["IS_TOPLEVEL"] = True if self.IS_TOPLEVEL: custom_class = True pos = None else: custom_class = False pos = "_toolbar" EditBase.__init__(self, name, 'wxToolBar', parent, custom_class, pos) EditStylesMixin.__init__(self) # initialise instance properties self.bitmapsize = np.IntPairPropertyD('16, 15', default_value='16, 15') self.margins = np.IntPairPropertyD('0, 0', default_value='0, 0') self.packing = np.SpinPropertyD(1, val_range=(0, 100), default_value=1, immediate=True) self.separation = np.SpinPropertyD(5, val_range=(0, 100), default_value=5, immediate=True) self.tools = ToolsProperty() # incl. the Edit button self.window_id = None # just a dummy for code generation self.widget = self._tb = None # a panel and the actual ToolBar if self.IS_TOPLEVEL: PreviewMixin.__init__(self) # add a preview button else: self.preview = None
def __init__(self, name, parent): EditBase.__init__(self, name, parent, "_menubar") self.menus = MenuProperty() self.window_id = None # just a dummy for code generation self._mb = None # the real menubar self.parent.properties["menubar"].set(True, notify=False)
def _properties_changed(self, modified, actions): if not modified or "fields" in modified: self._set_fields() EditStylesMixin._properties_changed(self, modified, actions) EditBase._properties_changed(self, modified, actions) if "recreate2" in actions: # usually, this would be done in WindowBase, but StatusBar is derived from EditBase self.destroy_widget(level=0) self.create_widget()
def __init__(self, name, parent): EditBase.__init__( self, name, parent, index="_statusbar") EditStylesMixin.__init__(self) # for the statusbar fields fields = [[self.name, "-1"]] # list of 2-lists label, size self.fields = FieldsProperty(fields) self.window_id = None # just a dummy for code generation
def __init__(self, name, parent, class_): EditBase.__init__(self, name, parent, None, class_) self.menus = MenuProperty() self.window_id = None # just a dummy for code generation self._mb = None # the real menubar PreviewMixin.__init__(self) # add a preview button
def __init__(self, name, klass, parent): EditBase.__init__( self, name, klass, parent, wx.NewId(), custom_class=False ) EditStylesMixin.__init__(self) # for the statusbar fields fields = [[self.name, "-1"]] # list of 2-lists label, size self.fields = FieldsProperty(fields) self.node = Node(self) common.app_tree.add(self.node, parent.node)
def __init__(self, name, klass, parent): custom_class = parent is None EditBase.__init__(self, name, klass, parent, wx.NewId(), custom_class=custom_class) self.properties["base"].set('wxMenuBar') self.menus = MenuProperty() self._mb = None # the real menubar if not self.parent: PreviewMixin.__init__(self) # add a preview button else: self.preview = None
def remove(self, *args, **kwds): if not kwds.get('do_nothing', False): if self.parent.widget: self.parent.widget.SetStatusBar(None) try: self.parent.properties['statusbar'].set_value(0) except KeyError: pass if self.widget: self.widget.Hide() EditBase.remove(self) else: if EditStatusBar._hidden_frame is None: EditStatusBar._hidden_frame = wx.Frame(None, -1, "") if self.widget is not None: self.widget.Reparent(EditStatusBar._hidden_frame) self.widget = None
def __init__(self, name, klass, parent, property_window): custom_class = parent is None EditBase.__init__(self, name, klass, parent, wx.NewId(), property_window, custom_class=custom_class, show=False) self.base = 'wx.ToolBar' def nil(*args): return () self.tools = [] # list of Tool objects self._tb = None # the real toolbar self.style = 0 self.access_functions['style'] = (self.get_style, self.set_style) self.style_pos = [wx.TB_FLAT, wx.TB_DOCKABLE, wx.TB_3DBUTTONS] if misc.check_wx_version(2, 3, 3): self.style_pos += [wx.TB_TEXT, wx.TB_NOICONS, wx.TB_NODIVIDER, wx.TB_NOALIGN] if misc.check_wx_version(2, 5, 0): self.style_pos += [wx.TB_HORZ_LAYOUT, wx.TB_HORZ_TEXT] style_labels = ['#section#' + _('Style'), 'wxTB_FLAT', 'wxTB_DOCKABLE', 'wxTB_3DBUTTONS'] if misc.check_wx_version(2, 3, 3): style_labels += ['wxTB_TEXT', 'wxTB_NOICONS', 'wxTB_NODIVIDER', 'wxTB_NOALIGN'] if misc.check_wx_version(2, 5, 0): style_labels += ['wxTB_HORZ_LAYOUT', 'wxTB_HORZ_TEXT'] self.properties['style'] = CheckListProperty(self, 'style', None, style_labels) self.bitmapsize = '16, 15' self.access_functions['bitmapsize'] = (self.get_bitmapsize, self.set_bitmapsize) self.properties['bitmapsize'] = TextProperty(self, 'bitmapsize', None, can_disable=True, label=_("bitmapsize")) self.margins = '0, 0' self.access_functions['margins'] = (self.get_margins, self.set_margins) self.properties['margins'] = TextProperty(self, 'margins', None, can_disable=True, label=_("margins")) self.access_functions['tools'] = (self.get_tools, self.set_tools) prop = self.properties['tools'] = ToolsProperty(self, 'tools', None) self.packing = 1 self.access_functions['packing'] = (self.get_packing, self.set_packing) self.properties['packing'] = SpinProperty(self, 'packing', None, r=(0, 100), can_disable=True, label=_("packing")) self.separation = 5 self.access_functions['separation'] = (self.get_separation, self.set_separation) self.properties['separation'] = SpinProperty( self, 'separation', None, r=(0, 100), can_disable=True, label=_("separation")) # 2003-05-07 preview support PreviewMixin.__init__(self)
def remove(self, *args, **kwds): if self.parent is not None: self.parent.properties['toolbar'].set_value(0) if kwds.get('do_nothing', False): # and wxPlatform == '__WXGTK__': # this probably leaks memory, but avoids segfaults self.widget = None else: if self.parent.widget: self.parent.widget.SetToolBar(None) else: if self.widget: self.widget.Destroy() self.widget = None EditBase.remove(self)
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 __init__(self, name, klass, parent): custom_class = parent is None EditBase.__init__(self, name, klass, parent, wx.NewId(), custom_class=custom_class) self.base = 'wxMenuBar' self.menus = MenuProperty() self.window_id = None # just a dummy for code generation self._mb = None # the real menubar if not self.parent: PreviewMixin.__init__(self) # add a preview button self._is_toplevel = True else: self.preview = None self._is_toplevel = False
def __init__(self, name, klass, parent, property_window): custom_class = parent is None EditBase.__init__(self, name, klass, parent, wx.NewId(), property_window, custom_class=custom_class, show=False) self.base = 'wxMenuBar' def nil(*args): return () self.menus = [] # list of MenuTree objects self._mb = None # the real menubar self.access_functions['menus'] = (self.get_menus, self.set_menus) prop = self.properties['menus'] = MenuProperty(self, 'menus', None) ## self.node = Tree.Node(self) ## common.app_tree.add(self.node, parent.node) PreviewMixin.__init__(self)
def remove(self, *args, **kwds): if self.parent is not None: self.parent.properties['menubar'].set_value(0) 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: self.widget.Destroy() self.widget = None EditBase.remove(self)
def remove(self, *args, **kwds): if not kwds.get('do_nothing', False): if self.parent.widget: self.parent.widget.SetStatusBar(None) try: self.parent.properties['statusbar'].set_value(0) except KeyError: pass if self.widget: self.widget.Hide() EditBase.remove(self) else: if misc.check_wx_version(2, 6): if EditStatusBar._hidden_frame is None: EditStatusBar._hidden_frame = wx.Frame(None, -1, "") if self.widget is not None: self.widget.Reparent(EditStatusBar._hidden_frame) self.widget = None
def properties_changed(self, modified): actions = EditBase.properties_changed(self, modified) # widget properties modified; trigger updates if self.widget: if config.debugging: print("Actions", actions) if "recreate_parent" in actions: self.parent.recreate_widget2() return actions
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)
def remove(self, *args, **kwds): if not kwds.get('do_nothing', False): if self.parent.widget: self.parent.widget.SetStatusBar(None) try: self.parent._statusbar = None except KeyError: pass if self.widget: self.widget.Hide() EditBase.remove(self) else: if EditStatusBar._hidden_frame is None: EditStatusBar._hidden_frame = wx.Frame(None, -1, "") if self.widget is not None: self.widget.Reparent(EditStatusBar._hidden_frame) self.widget = None
def __init__(self, name, klass, parent): if parent.IS_ROOT: self.__dict__["IS_TOPLEVEL"] = True if self.IS_TOPLEVEL: custom_class = True pos = None else: custom_class = False pos = "_menubar" EditBase.__init__(self, name, klass, parent, custom_class, pos) self.menus = MenuProperty() self.window_id = None # just a dummy for code generation self._mb = None # the real menubar if self.IS_TOPLEVEL: PreviewMixin.__init__(self) # add a preview button else: self.preview = None
def create_properties(self): EditBase.create_properties(self) page = self._common_panel sizer = page.GetSizer() self.properties['menus'].display(page) if not sizer: sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(self.name_prop.panel, 0, wx.EXPAND) sizer.Add(self.klass_prop.panel, 0, wx.EXPAND) page.SetAutoLayout(1) page.SetSizer(sizer) sizer.Add(self.properties['menus'].panel, 0, wx.ALL|wx.EXPAND, 3) sizer.Fit(page) page.SetSize(self.notebook.GetClientSize()) sizer.Layout() self.notebook.AddPage(page, _("Common")) if self.parent is not None: self.property_window.Layout() else: PreviewMixin.create_properties(self)
def remove(self, *args, **kwds): if self.parent is not None: self.parent.properties['menubar'].set_value(0) 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: if wx.Platform == '__WXGTK__' and \ not misc.check_wx_version(2, 5): self.widget.Reparent(EditMenuBar.__hidden_frame) self.widget.Hide() self.parent.widget.SetMenuBar(None) else: if self.widget: self.widget.Destroy() self.widget = None EditBase.remove(self)
def __init__(self, parent, property_window): EditBase.__init__(self, parent.name + '_statusbar', 'wxStatusBar', parent, id, property_window, custom_class=False, show=False) # style property self.style_pos = (wx.ST_SIZEGRIP, ) style_labels = ('#section#' + _('Style'), 'wxST_SIZEGRIP') self.access_functions['style'] = (self.get_style, self.set_style) self.properties['style'] = CheckListProperty(self, 'style', None, style_labels) self.node = Tree.Node(self) common.app_tree.add(self.node, parent.node) self.fields = [[self.name, "-1"]] # list of 2-lists label, size # for the statusbar fields self.access_functions['fields'] = (self.get_fields, self.set_fields) prop = self.properties['fields'] = GridProperty( self, 'fields', None, [("Text", GridProperty.STRING), ("Size", GridProperty.INT)]) # replace the default 'write' method of 'prop' with a custom one def write_prop(outfile, tabs): from xml.sax.saxutils import escape, quoteattr fwrite = outfile.write fwrite(' ' * tabs + '<fields>\n') tabs += 1 import widget_properties for label, width in self.fields: fwrite(' ' * tabs + '<field width=%s>%s</field>\n' % (quoteattr(width), escape(widget_properties._encode(label)))) tabs -= 1 fwrite(' ' * tabs + '</fields>\n') prop.write = write_prop
def create_properties(self): EditBase.create_properties(self) page = self._common_panel self.properties['style'].display(page) prop = self.properties['fields'] prop.display(page) sizer = page.GetSizer() if not sizer: sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(self.name_prop.panel, 0, wx.EXPAND) sizer.Add(self.klass_prop.panel, 0, wx.EXPAND) page.SetAutoLayout(1) page.SetSizer(sizer) sizer.Add(self.properties['style'].panel, 0, wx.EXPAND) sizer.Add(prop.panel, 1, wx.ALL|wx.EXPAND, 3) sizer.Fit(page) page.SetSize(self.notebook.GetClientSize()) sizer.Layout() self.notebook.AddPage(page, _("Common")) self.property_window.Layout() prop.set_col_sizes([190, 0])
def create_properties(self): EditBase.create_properties(self) page = self._common_panel self.properties['style'].display(page) prop = self.properties['fields'] prop.display(page) sizer = page.GetSizer() if not sizer: sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(self.name_prop.panel, 0, wx.EXPAND) sizer.Add(self.klass_prop.panel, 0, wx.EXPAND) page.SetAutoLayout(1) page.SetSizer(sizer) sizer.Add(self.properties['style'].panel, 0, wx.EXPAND) sizer.Add(prop.panel, 1, wx.ALL | wx.EXPAND, 3) sizer.Fit(page) page.SetSize(self.notebook.GetClientSize()) sizer.Layout() self.notebook.AddPage(page, _("Common")) self.property_window.Layout() prop.set_col_sizes([190, 0])
def properties_changed(self, modified): if not modified or "name" in modified and self.pwidget is not self.widget: self.pwidget.SetTitle(misc.design_title(misc.wxstr(self.name))) refresh = False if not modified or "margins" in modified and self.widget: self._set_margins() refresh = True if not modified or "bitmapsize" in modified and self.widget: self._set_bitmapsize() refresh = True if not modified or "packing" in modified and self.widget: self._set_packing() refresh = True if not modified or "separation" in modified and self.widget: self._set_separation() refresh = True if not modified or "tools" in modified and self.widget: self._set_tools() refresh = True if refresh: self._refresh_widget() EditBase.properties_changed(self, modified)
def destroy_widget(self, level): # if parent is being deleted, we rely on this being destroyed if level==0 and not self.IS_TOPLEVEL and self.parent.widget: self.parent.widget.SetStatusBar(None) if level==0: EditBase.destroy_widget(self, level)
def remove(self, user=True): EditBase.remove(self, user=user) self.parent.properties['statusbar'].set(False) return None # explicitely return not a Slot; see history
def set_name(self, name): EditBase.set_name(self, name) if self.widget is not self._mb: self.widget.SetTitle(misc.design_title(misc.wxstr(self.name)))
def remove(self, user=True): EditBase.remove(self, user=user) self.parent.properties['statusbar'].set(False)
def __init__(self, name, parent, klass): EditBase.__init__( self, name, parent, None, klass ) EditStylesMixin.__init__(self) self._init_properties() PreviewMixin.__init__(self) # add a preview button
def remove(self): EditBase.remove(self) if 'toolbar' in self.parent.properties: self.parent.properties['toolbar'].set(False)
def __init__(self, name, parent): EditBase.__init__( self, name, parent, "_toolbar" ) EditStylesMixin.__init__(self) self._init_properties() self.parent.properties["toolbar"].set(True, notify=False)