Ejemplo n.º 1
0
def save_template(data=None):
    """\
    Returns an out file name and template description for saving a template
    """
    dlg = templates_ui.TemplateInfoDialog(None, -1, "")
    if data is not None:
        dlg.template_name.SetValue(
            misc.wxstr(os.path.basename(os.path.splitext(data.filename)[0])))
        dlg.author.SetValue(misc.wxstr(data.author))
        dlg.description.SetValue(misc.wxstr(data.description))
        dlg.instructions.SetValue(misc.wxstr(data.instructions))
    ret = None
    retdata = Template()
    if dlg.ShowModal() == wx.ID_OK:
        ret = dlg.template_name.GetValue().strip()
        retdata.author = dlg.author.GetValue()
        retdata.description = dlg.description.GetValue()
        retdata.instructions = dlg.instructions.GetValue()
        if not ret:
            wx.MessageBox(_("Can't save a template with an empty name"),
                          _("Error"), wx.OK|wx.ICON_ERROR)
    dlg.Destroy()
    name = ret
    if ret:
        d = os.path.join(config._get_appdatapath(), '.wxglade', 'templates')
        if not os.path.exists(d):
            try:
                os.makedirs(d)
            except (OSError, IOError), e:
                print _("ERROR creating %s: %s") % (d, e)
                return None, retdata
        ret = os.path.join(d, ret + '.wgt')
Ejemplo n.º 2
0
 def createBrowseButton( self):
     """Create the browse-button control"""
     ID = wx.NewId()
     button =wx.Button(self, ID, misc.wxstr(self.buttonText))
     button.SetToolTipString(misc.wxstr(self.toolTip))
     w = button.GetTextExtent(self.buttonText)[0] + 10
     button.SetMinSize((w, -1))
     wx.EVT_BUTTON(button, ID, self.OnBrowse)
     return button
Ejemplo n.º 3
0
 def write( self, outfile, tabs ):
     if self.write_always or ( self.is_active() and self.get_value() ):
         if self.getter: value = misc.wxstr( self.getter() )
         else: value = misc.wxstr( self.owner[self.name][0]() )
         if value != 'None':
             fwrite = outfile.write
             fwrite( '    ' * tabs + '<%s>' % self.name )
             fwrite( escape( _encode( value ) ) )
             fwrite( '</%s>\n' % self.name )
Ejemplo n.º 4
0
 def write(self, outfile, tabs):
     if self.write_always or self.get_value():
         if self.getter:
             value = misc.wxstr(self.getter())
         else:
             value = misc.wxstr(self.owner[self.name][0]())
         if value != "None":
             fwrite = outfile.write
             fwrite("    " * tabs + "<%s>" % self.name)
             fwrite(escape(_encode(value)))
             fwrite("</%s>\n" % self.name)
Ejemplo n.º 5
0
def load_history():
    """\
    Loads the file history and returns a list of paths
    """
    if 'WXGLADE_CONFIG_PATH' in os.environ:
        path = os.path.expandvars('$WXGLADE_CONFIG_PATH')
    else:
        path = _get_appdatapath()
        if path != common.wxglade_path:
            path = os.path.join(path, '.wxglade')
    try:
        history = open(os.path.join(path, 'file_history.txt'))
        l = history.readlines()
        if l and l[0].startswith('# -*- coding:'):
            try:
                encoding = 'utf-8' 
                #l = [common._encode_from_xml(e, encoding) for e in l[1:]]
                l = [e.decode(encoding) for e in l[1:]]
            except Exception, e:
                print _("ERR:"), e
                l = l[1:]
        history.close()
        if common.use_gui:
            l = [misc.wxstr(e, 'utf-8') for e in l]
        return l
Ejemplo n.º 6
0
def kde_file_selector(message, default_path="", default_filename="",
                      default_extension="", wildcard="*.*", flags=0,
                      *args, **kwds):
    """\
    Pops up the standard KDE file selector box, calling kdialog. The API is
    identical to that of wx.FileSelector. If kdialog can't be invoked,
    reverts to the standard wx.FileSelector. Note that at the moment not all
    the arguments are meaningful (for example, parent and initial position are
    ignored), and multiple selections are not supported.
    """
    if not _kdialog_ok:
        return wx.FileSelector(message, default_path, default_filename,
                               default_extension, wildcard, flags,
                               *args, **kwds)
    
    r, w = os.pipe()
    handler = _SigChldHandler()
    oldhandler = signal.signal(signal.SIGCHLD, handler)

    pid = os.fork()

    if pid == 0:
        os.close(r)
        os.dup2(w, sys.stdout.fileno())
        os.close(w)
        startdir = default_path
        if default_filename:
            if not os.path.isdir(startdir):
                startdir = os.path.dirname(startdir)
            startdir = os.path.join(startdir, default_filename)
        if flags & wx.SAVE:
            kind = '--getsavefilename'
        else:
            kind = '--getopenfilename'
        os.execlp('kdialog', 'kdialog', kind, startdir,
                  _wx_to_kde_wildcard(wildcard), '--title', message)
    elif pid > 0:
        disabler = wx.WindowDisabler()
        app = wx.GetApp()
        os.close(w)
        while not handler.done:
            app.Dispatch()
        if handler.status != 0:
            os.close(r)
            return ""

        filename = os.fdopen(r).readline().strip()
        signal.signal(signal.SIGCHLD, oldhandler or signal.SIG_DFL)
        if (flags & wx.SAVE) and (flags & wx.OVERWRITE_PROMPT) and \
               os.path.exists(filename):
            if wx.MessageBox(_("File '%s' already exists: do you really want "
                               "to overwrite it?") % misc.wxstr(filename),
                             _("Confirm"),
                             style=wx.YES_NO|wx.ICON_QUESTION) == wx.NO:
                return kde_file_selector(message, default_path,
                                         default_filename, default_extension,
                                         wildcard, flags)
        return filename
    else:
        raise OSError, _("Fork Error")
Ejemplo n.º 7
0
 def _move_item_right(self, index):
     if index > 0 and (self.item_level(index) <= self.item_level(index-1)): 
         label = self.menu_items.GetItem(index, 0).m_text
         self.menu_items.SetStringItem(index, 0, misc.wxstr(" " * 4)
                                       + label)
         self.menu_items.SetItemState(index, wx.LIST_STATE_SELECTED, \
                                      wx.LIST_STATE_SELECTED)
Ejemplo n.º 8
0
    def display( self, parent ):
        """\
        Actually builds the panel (with the text ctrl and the button to display
        the dialog) to set the value of the property interactively
        """
        self.id = wx.NewId()
        val = misc.wxstr( self.owner[self.name][0]() )
        label = wxGenStaticText( parent, -1, _mangle( self.dispName ),
                                size = ( _label_initial_width, -1 ) )
        label.SetToolTip( wx.ToolTip( _mangle( self.dispName ) ) )
        self.text = wx.TextCtrl( parent, self.id, val, size = ( 1, -1 ) )
        self.btn = wx.Button( parent, self.id + 1, " ... ",
                            size = ( _label_initial_width, -1 ) )
        enabler = None
        if self.can_disable:
            enabler = wx.CheckBox( parent, self.id + 1, '', size = ( 1, -1 ) )
            wx.EVT_CHECKBOX( enabler, self.id + 1,
                         lambda event: self.toggle_active( event.IsChecked() ) )
        self.prepare_activator( enabler, self.text )
        if self.can_disable:
            self.btn.Enable( self.is_active() )
        wx.EVT_BUTTON( self.btn, self.id + 1, self.display_dialog )
        sizer = wx.BoxSizer( wx.HORIZONTAL )
        sizer.Add( label, 2, wx.ALL | wx.ALIGN_CENTER, 3 )
        if getattr( self, '_enabler', None ) is not None:
            sizer.Add( self._enabler, 1, wx.ALL | wx.ALIGN_CENTER, 3 )
            option = 3
        else:
            option = 4
        sizer.Add( self.text, option, wx.ALL | wx.ALIGN_CENTER, 3 )
        sizer.Add( self.btn, 1, wx.ALL | wx.ALIGN_CENTER, 3 )
        self.panel = sizer

        self.bind_event( self.on_change_val )
        wx.EVT_CHAR( self.text, self.on_char )
Ejemplo n.º 9
0
 def set_value(self, value):
     value = misc.wxstr(value)
     if not misc.streq(value, self.value):
         self.value = value
         if self.style & wx.TE_MULTILINE:
             value = value.replace('\\n', '\n')
         if self.widget: self.widget.SetValue(value)
Ejemplo n.º 10
0
 def set_label(self, value):
     value = misc.wxstr(value)
     if not misc.streq(value, self.label):
         self.label = value
         if self.widget:
             self.widget.SetLabel(value.replace("\\n", "\n"))
             if not self.properties["size"].is_active():
                 self.sizer.set_item(self.pos, size=self.widget.GetBestSize())
Ejemplo n.º 11
0
 def set_value( self, value ):
     value = misc.wxstr( value )
     if self.multiline:
         self.val = value.replace( '\n', '\\n' )
         value = value.replace( '\\n', '\n' )
     else: self.val = value
     try: self.text.SetValue( value )
     except AttributeError: pass
Ejemplo n.º 12
0
 def add(node, index):
     label = get(index, 0).lstrip()
     id = get(index, 1)
     name = get(index, 2)
     help_str = get(index, 3)
     event_handler = get(index, 5)
     try:
         item_type = int(get(index, 4))
     except ValueError:
         item_type = 0
     checkable = item_type == 1 and misc.wxstr("1") or misc.wxstr("")
     radio = item_type == 2 and misc.wxstr("1") or misc.wxstr("")
     n = MenuTree.Node(label, id, name, help_str, checkable, radio,
                       handler=event_handler)
     node.children.append(n)
     n.parent = node
     return n
Ejemplo n.º 13
0
 def set_choices(self, values):
     self.choices = [ misc.wxstr(v[0]) for v in values ]
     self.properties['selection'].set_range(0, len(self.choices)-1)
     if self.widget:
         self.widget.Clear()
         for c in self.choices: self.widget.Append(c)
         if not self.properties['size'].is_active():
             self.sizer.set_item(self.pos, size=self.widget.GetBestSize())
Ejemplo n.º 14
0
 def set_label(self, value):
     value = misc.wxstr(value)
     if not misc.streq(value, self.label):
         self.label = value
         if self.static_box:
             self.static_box.SetLabel(value)
             if not self.properties['size'].is_active():
                 self.sizer.set_item(self.pos,
                                     size=self.widget.GetBestSize())
Ejemplo n.º 15
0
 def add(tool):
     i = index[0]
     add_item(i, misc.wxstr(tool.label))
     set_item(i, 1, misc.wxstr(tool.id))
     set_item(i, 2, misc.wxstr(tool.bitmap1))
     set_item(i, 3, misc.wxstr(tool.bitmap2))
     set_item(i, 4, misc.wxstr(tool.short_help))
     set_item(i, 5, misc.wxstr(tool.long_help))
     set_item(i, 7, misc.wxstr(tool.handler))
     item_type = 0
     set_item(i, 6, misc.wxstr(tool.type))
     index[0] += 1
Ejemplo n.º 16
0
	def __call__( self, kind, fmt, *args ):
		if self.disabled:
				return
		kind = kind.upper()
		if use_gui:
				import wx, misc
				if args:
					msg = misc.wxstr( fmt ) % tuple( [misc.wxstr( a ) for a in args] )
				else:
					msg = misc.wxstr( fmt )
				self.lines.extend( msg.splitlines() )
##             if kind == 'WARNING':
##                 wx.LogWarning(msg)
##             else:
##                 wx.LogMessage(msg)
		else:
				if args: msg = fmt % tuple( args )
				else: msg = fmt
				print "%s: %s" % ( kind, msg )
Ejemplo n.º 17
0
    def __call__(self, kind, fmt, *args):
        if self.disabled:
            return
        kind = kind.upper()
        if use_gui:
            import misc
            if args:
                msg = misc.wxstr(fmt) % tuple([misc.wxstr(a) for a in args])
            else:
                msg = misc.wxstr(fmt)
            self.lines.extend(msg.splitlines())

        # show errors and exceptions always at console
        if not use_gui or kind in [_("EXCEPTION"),  _("ERROR")]:
            if args:
                msg = fmt % tuple(args)
            else:
                msg = fmt
            print "%s: %s" % (kind, msg)
Ejemplo n.º 18
0
    def _open_app(self, infilename, use_progress_dialog=True,
                  is_filelike=False, add_to_history=True):
        import time
        from xml_parse import XmlWidgetBuilder, ProgressXmlWidgetBuilder, \
             XmlParsingError
        from xml.sax import SAXParseException

        start = time.clock()

        common.app_tree.clear()
        if not is_filelike:
            common.app_tree.app.filename = infilename
        else:
            common.app_tree.filename = getattr(infilename, 'name', None)
        common.property_panel.Reparent(self.hidden_frame)
        # prevent the auto-expansion of nodes
        common.app_tree.auto_expand = False

        old_dir = os.getcwd()
        try:
            if not is_filelike:
                os.chdir(os.path.dirname(infilename))
                infile = open(infilename)
            else:
                infile = infilename
                infilename = getattr(infile, 'name', None)
            if use_progress_dialog and config.preferences.show_progress:
                p = ProgressXmlWidgetBuilder(input_file=infile)
            else:
                p = XmlWidgetBuilder()
            p.parse(infile)
        except (IOError, OSError, SAXParseException, XmlParsingError), msg:
            if locals().has_key('infile') and not is_filelike: infile.close()
            common.app_tree.clear()
            common.property_panel.Reparent(self.frame2)
            common.app_tree.app.saved = True
            wx.MessageBox(_("Error loading file %s: %s") % \
                          (misc.wxstr(infilename), misc.wxstr(msg)),
                          _("Error"), wx.OK|wx.CENTRE|wx.ICON_ERROR)
            # reset the auto-expansion of nodes
            common.app_tree.auto_expand = True
            os.chdir(old_dir)
            return False            
Ejemplo n.º 19
0
 def end_elem(self, name):
     if name == 'tabs':
         self.parent.tabs = [[misc.wxstr(name), None] for name in \
                             self.tab_names]
         self.parent.properties['tabs'].set_value([[name] for name in \
                                                   self.tab_names])
         return True
     elif name == 'tab':
         self.tab_names.append("".join(self.curr_tab))
         self.curr_tab = []
     return False
Ejemplo n.º 20
0
 def set_tools(self, tools):
     self.tools = tools
     if not self._tb: return # nothing left to do
     while self._tb.DeleteToolByPos(0):
         pass # clear the toolbar
     # now add all the tools
     for tool in self.tools:
         if misc.streq(tool.id, '---'): # the tool is a separator
             self._tb.AddSeparator()
         else:
             if tool.bitmap1:
                 bmp1 = None
                 if not (tool.bitmap1.startswith('var:') or
                         tool.bitmap1.startswith('code:')):
                     bmp1 = wx.Bitmap(
                         misc.get_relative_path(misc.wxstr(tool.bitmap1)),
                         wx.BITMAP_TYPE_ANY)
                 if not bmp1 or not bmp1.Ok(): bmp1 = wx.EmptyBitmap(1, 1)
             else:
                 bmp1 = wx.NullBitmap
             if tool.bitmap2:
                 bmp2 = None
                 if not (tool.bitmap2.startswith('var:') or
                         tool.bitmap2.startswith('code:')):
                     bmp2 = wx.Bitmap(
                         misc.get_relative_path(misc.wxstr(tool.bitmap2)),
                         wx.BITMAP_TYPE_ANY)
                 if not bmp2 or not bmp2.Ok(): bmp2 = wx.EmptyBitmap(1, 1)
             else:
                 bmp2 = wx.NullBitmap
             kinds = [wx.ITEM_NORMAL, wx.ITEM_CHECK, wx.ITEM_RADIO]
             try:
                 kind = kinds[int(tool.type)]
             except (ValueError, IndexError):
                 kind = wx.ITEM_NORMAL
             self._tb.AddLabelTool(wx.NewId(), misc.wxstr(tool.label),
                                   bmp1, bmp2, kind,
                                   misc.wxstr(tool.short_help),
                                   misc.wxstr(tool.long_help))
     # this is required to refresh the toolbar properly
     self._refresh_widget()
Ejemplo n.º 21
0
 def set_fields(self, values):
     # values is a list of lists
     self.fields = []
     if self.widget: self.widget.SetFieldsCount(len(values))
     for i in range(len(values)):
         try: v = int(values[i][1])
         except: v = 0
         s = misc.wxstr(values[i][0])
         self.fields.append([s, str(v)])
         if self.widget: self.widget.SetStatusText(s, i)
     if self.widget:
         self.widget.SetStatusWidths([int(i[1]) for i in self.fields])
Ejemplo n.º 22
0
 def on_select_template(self, event):
     self.selected_template = self.get_selected()
     if self.selected_template is not None:
         t = Template(self.selected_template)
         self.set_template_name(self.template_names.GetStringSelection())
         self.author.SetValue(misc.wxstr(t.author))
         self.description.SetValue(misc.wxstr(t.description))
         self.instructions.SetValue(misc.wxstr(t.instructions))
         if os.path.dirname(self.selected_template) == common.templates_path:
             self.btn_delete.Disable()
             self.btn_edit.Disable()
         else:
             self.btn_delete.Enable()
             self.btn_edit.Enable()
     else:
         self.set_template_name("")
         self.author.SetValue("")
         self.description.SetValue("")
         self.instructions.SetValue("")
     if event:
         event.Skip()
Ejemplo n.º 23
0
 def set_tools(self, tools):
     self.tools = tools
     if not self._tb: return # nothing left to do
     while self._tb.DeleteToolByPos(0):
         pass # clear the toolbar
     # now add all the tools
     for tool in self.tools:
         if misc.streq(tool.id, '---'): # the tool is a separator
             self._tb.AddSeparator()
         else:
             if tool.bitmap1:
                 bmp1 = None
                 if not (tool.bitmap1.startswith('var:') or
                         tool.bitmap1.startswith('code:')):
                     bmp1 = wx.Bitmap(
                         misc.get_relative_path(misc.wxstr(tool.bitmap1)),
                         wx.BITMAP_TYPE_ANY)
                 if not bmp1 or not bmp1.Ok(): bmp1 = wx.EmptyBitmap(1, 1)
             else:
                 bmp1 = wx.NullBitmap
             if tool.bitmap2:
                 bmp2 = None
                 if not (tool.bitmap2.startswith('var:') or
                         tool.bitmap2.startswith('code:')):
                     bmp2 = wx.Bitmap(
                         misc.get_relative_path(misc.wxstr(tool.bitmap2)),
                         wx.BITMAP_TYPE_ANY)
                 if not bmp2 or not bmp2.Ok(): bmp2 = wx.EmptyBitmap(1, 1)
             else:
                 bmp2 = wx.NullBitmap
             # signature of AddTool for 2.3.2.1:
             # wxToolBarToolBase *AddTool(
             #    int id, const wxBitmap& bitmap,
             #    const wxBitmap& pushedBitmap, bool toggle = FALSE,
             #    wxObject *clientData = NULL,
             #    const wxString& shortHelpString = wxEmptyString,
             #    const wxString& longHelpString = wxEmptyString)
             if not misc.check_wx_version(2, 3, 3):
                 # use the old signature, some of the entries are ignored
                 self._tb.AddTool(wx.NewId(), bmp1, bmp2, tool.type == 1,
                                  shortHelpString=\
                                  misc.wxstr(tool.short_help),
                                  longHelpString=misc.wxstr(tool.long_help))
             else:
                 kinds = [wx.ITEM_NORMAL, wx.ITEM_CHECK, wx.ITEM_RADIO]
                 try:
                     kind = kinds[int(tool.type)]
                 except (ValueError, IndexError):
                     kind = wx.ITEM_NORMAL
                 self._tb.AddLabelTool(wx.NewId(), misc.wxstr(tool.label),
                                       bmp1, bmp2, kind,
                                       misc.wxstr(tool.short_help),
                                       misc.wxstr(tool.long_help))
     # this is required to refresh the toolbar properly
     self._refresh_widget()
Ejemplo n.º 24
0
 def on_delete(self, event):
     self.selected_template = self.get_selected()
     if self.selected_template is not None:
         name = self.template_names.GetStringSelection()
         if wx.MessageBox(_("Delete template '%s'?") % misc.wxstr(name),
                          _("Are you sure?"),
                          style=wx.YES|wx.NO|wx.CENTRE) == wx.YES:
             try:
                 os.unlink(self.selected_template)
             except Exception, e:
                 print e
             self.fill_template_list()
             self.selected_template = None
Ejemplo n.º 25
0
 def set_value( self, values ):
     #self.val = values
     self.val = [[misc.wxstr( v ) for v in val] for val in values]
     if not hasattr( self, 'grid' ): return
     # values is a list of lists with the values of the cells
     size = len( values )
     if self.rows < size:
         self.grid.AppendRows( size - self.rows )
         self.rows = size
     elif self.rows != size: self.grid.DeleteRows( size, self.rows - size )
     for i in range( len( self.val ) ):
         for j in range( len( self.val[i] ) ):
             self.grid.SetCellValue( i, j, self.val[i][j] )
Ejemplo n.º 26
0
 def set_menus(self, menus):
     self.menus = menus
     if not self._mb: return # nothing left to do
     for i in range(self._mb.GetMenuCount()):
         self._mb.Remove(0)
     def append(menu, items):
         for item in items:
             if misc.streq(item.name, '---'): # item is a separator
                 menu.AppendSeparator()
             elif item.children:
                 m = wx.Menu()
                 append(m, item.children)
                 menu.AppendMenu(wx.NewId(), misc.wxstr(item.label), m,
                                 misc.wxstr(item.help_str))
             else:
                 check_radio = 0
                 try:
                     if int(item.checkable):
                         check_radio = 1
                 except:
                     check_radio = 0
                 if not check_radio:
                     try:
                         if int(item.radio):
                             check_radio = 2
                     except:
                         check_radio = 0
                 menu.Append(wx.NewId(), misc.wxstr(item.label),
                             misc.wxstr(item.help_str), check_radio)
     first = self._mb.GetMenuCount()
     for menu in self.menus:
         m = wx.Menu()
         append(m, menu.root.children)
         if first:
             self._mb.Replace(0, m, misc.wxstr(menu.root.label))
             first = 0
         else: self._mb.Append(m, misc.wxstr(menu.root.label))
     self._mb.Refresh()
Ejemplo n.º 27
0
 def set_stockitem(self, value):
     self.stockitem = misc.wxstr(value)
     if self.stockitem != "None":
         l = ButtonStockItems.stock_ids[self.stockitem]
         self.set_label(l)
         self.properties['label'].set_value(l)
         if self.properties['label'].panel is not None:
             self.properties['label'].text.Enable(False)
         self.window_id = "wxID_" + self.stockitem
         self.properties['id'].set_value(self.window_id)
         self.properties['id'].toggle_active(False)
     else:
         if self.properties['label'].panel is not None:
             self.properties['label'].text.Enable(True)
Ejemplo n.º 28
0
 def __init__(
     self, owner, name, parent=None, can_disable=False, enabled=False, readonly=False, multiline=False, label=None
 ):
     Property.__init__(self, owner, name, parent, label=label)
     self.val = misc.wxstr(owner[name][0]())
     self.can_disable = can_disable
     self.readonly = readonly
     self.multiline = multiline
     _activator.__init__(self)
     if can_disable:
         self.toggle_active(enabled)
     self.panel = None
     if parent is not None:
         self.display(parent)
Ejemplo n.º 29
0
 def append(menu, items):
     for item in items:
         if misc.streq(item.name, '---'): # item is a separator
             menu.AppendSeparator()
         elif item.children:
             m = wx.Menu()
             append(m, item.children)
             menu.AppendMenu(wx.NewId(), misc.wxstr(item.label), m,
                             misc.wxstr(item.help_str))
         else:
             check_radio = 0
             try:
                 if int(item.checkable):
                     check_radio = 1
             except:
                 check_radio = 0
             if not check_radio:
                 try:
                     if int(item.radio):
                         check_radio = 2
                 except:
                     check_radio = 0
             menu.Append(wx.NewId(), misc.wxstr(item.label),
                         misc.wxstr(item.help_str), check_radio)
Ejemplo n.º 30
0
 def __init__( self, owner, name, choices, parent = None, label = None,
              can_disable = False, enabled = False, write_always = False,
              blocked = False, omitter = None ):
     Property.__init__( self, owner, name, parent, label = label )
     self.val = misc.wxstr( owner[name][0]() )
     if label is None: label = _mangle( name )
     self.label = label
     self.panel = None
     self.write_always = write_always
     self.choices = choices
     self.can_disable = can_disable
     _activator.__init__( self, omitter = omitter )
     if can_disable:
         self.toggle_active( enabled )
         self.toggle_blocked( blocked )
     if parent is not None: self.display( parent )
Ejemplo n.º 31
0
 def _move_item_right(self, index):
     if index > 0 and (self.item_level(index) <= self.item_level(index-1)):
         label = self.menu_items.GetItem(index, 0).GetText()
         self.menu_items.SetStringItem(index, 0, misc.wxstr(" "*4) + label)
         self.menu_items.SetItemState(index, wx.LIST_STATE_SELECTED, wx.LIST_STATE_SELECTED)
Ejemplo n.º 32
0
 def _insert_item_string(self, index, s):
     if not isinstance(s, compat.unicode): s = misc.wxstr(s)
     return compat.ListCtrl_InsertStringItem(self.items, index, s)
Ejemplo n.º 33
0
 def _set_item_string(self, index, col, s):
     if not isinstance(s, compat.unicode): s = misc.wxstr(s)
     if isinstance(col, str): col = self.columns.index(col)
     compat.ListCtrl_SetStringItem(self.items, index, col, s)
Ejemplo n.º 34
0
 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)))