示例#1
0
 def select_path(self, path):
     """\
     sets the selected widget from a path_list, which should be in the
     form returned by get_selected_path
     """
     index = 0
     item, cookie = self._get_first_child(self.GetRootItem())
     itemok = None
     parent = None
     pos = None
     while item.Ok() and index < len(path):
         widget = self.GetPyData(item).widget
         name = path[index]
         if index == 0 and type(name) == type(()):
             name, pos = name
         if misc.streq(widget.name, name):
             #print 'OK:', widget.name
             #self.EnsureVisible(item)
             itemok = item
             if parent is None:
                 parent = self.GetPyData(itemok)
             self.cur_widget = widget
             item, cookie = self._get_first_child(item)
             index += 1
         else:
             #print 'NO:', widget.name
             item = self.GetNextSibling(item)
     if itemok is not None:
         node = self.GetPyData(itemok)
         if parent is not None:
             self.show_widget(parent, True)
             if pos is not None:
                 misc.get_toplevel_parent(parent.widget).SetPosition(pos)
         self.select_item(node)
示例#2
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)
示例#3
0
文件: tree.py 项目: dsqiu/qzystudy
 def select_path(self, path):
     """\
     sets the selected widget from a path_list, which should be in the
     form returned by get_selected_path
     """
     index = 0
     item, cookie = self._get_first_child(self.GetRootItem())
     itemok = None
     parent = None
     pos = None
     while item.Ok() and index < len(path):
         widget = self.GetPyData(item).widget
         name = path[index]
         if index == 0 and type(name) == type(()):
             name, pos = name
         if misc.streq(widget.name, name):
             #print 'OK:', widget.name
             #self.EnsureVisible(item)
             itemok = item
             if parent is None:
                 parent = self.GetPyData(itemok)
             self.cur_widget = widget
             item, cookie = self._get_first_child(item)
             index += 1
         else:
             #print 'NO:', widget.name
             item = self.GetNextSibling(item)
     if itemok is not None:
         node = self.GetPyData(itemok)
         if parent is not None:
             self.show_widget(parent, True)
             if pos is not None:
                 misc.get_toplevel_parent(parent.widget).SetPosition(pos)
         self.select_item(node)
示例#4
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)
示例#5
0
 def _move_item_left(self, index):
     if index > 0:
         if ( index+1 < self.menu_items.GetItemCount() and (self.item_level(index) < self.item_level(index+1)) ):
             return
         label = self.menu_items.GetItem(index, 0).GetText()
         if misc.streq(label[:4], " " * 4):
             self.menu_items.SetStringItem(index, 0, label[4:])
             self.menu_items.SetItemState(index, wx.LIST_STATE_SELECTED, wx.LIST_STATE_SELECTED)
示例#6
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())
示例#7
0
 def ok():
     if len(self.val) != len(val):
         return True
     for i in range(len(val)):
         for j in range(len(val[i])):
             if not misc.streq(val[i][j], self.val[i][j]):
                 return True
     return False
示例#8
0
    def set_name(self, name):
        oldname = self.name

        # check and set name
        WindowBase.set_name(self, name)

        # update top window name
        if not misc.streq(oldname, self.name):
            common.app_tree.app.update_top_window_name(oldname, self.name)
示例#9
0
 def _set_filename(self, value):
     if not misc.streq(self.__filename, value):
         self.__filename = value
         if self.__saved: flag = ' '
         else: flag = '* '
         if self.__filename is not None:
             common.app_tree.set_title('%s(%s)' % (flag, self.__filename))
         else:
             common.app_tree.set_title(flag)
示例#10
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())
示例#11
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())
示例#12
0
 def _move_item_left(self, index):
     if index > 0:
         if (index+1 < self.menu_items.GetItemCount() and \
             (self.item_level(index) < self.item_level(index+1))):
             return
         label = self.menu_items.GetItem(index, 0).m_text
         if misc.streq(label[:4], " " * 4):
             self.menu_items.SetStringItem(index, 0, label[4:])
             self.menu_items.SetItemState(index, wx.LIST_STATE_SELECTED, 
                                          wx.LIST_STATE_SELECTED)
示例#13
0
文件: toolbar.py 项目: italomaia/spe
 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()
示例#14
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()
示例#15
0
 def write(self, outfile=None, tabs=0):
     """\
     Writes the xml code for this property onto the given file.
     """
     if self.getter: value = self.getter()
     else: value = self.owner[self.name][0]() 
     if not misc.streq(value, ''):
         fwrite = outfile.write
         fwrite('    ' * tabs + '<%s>' % self.name)
         fwrite(escape(_encode(value)))
         fwrite('</%s>\n' % self.name)
示例#16
0
 def write( self, outfile = None, tabs = 0 ):
     """\
     Writes the xml code for this property onto the given file.
     """
     if self.getter: value = self.getter()
     else: value = self.owner[self.name][0]()
     if not misc.streq( value, '' ):
         fwrite = outfile.write
         fwrite( '    ' * tabs + '<%s>' % self.name )
         fwrite( escape( _encode( value ) ) )
         fwrite( '</%s>\n' % self.name )
示例#17
0
 def show_menu_item(self, event):
     "Event handler called when a menu item in the list is selected"
     self.selected_index = index = event.GetIndex()
     if not misc.streq(self.menu_items.GetItem(index, 2).GetText(), '---'):
         # skip if the selected item is a separator
         for (s, i) in ((self.label, 0), (self.id, 1), (self.name, 2), (self.help_str, 3), (self.event_handler, 5)):
             s.SetValue(self.menu_items.GetItem(index, i).GetText())
         self.label.SetValue(self.label.GetValue().lstrip())
         try:
             self.check_radio.SetSelection( int(self.menu_items.GetItem(index, 4).GetText()))
         except:
             self.check_radio.SetSelection(0)
     event.Skip()
示例#18
0
 def on_change_val( self, event, first = [True] ):
     """\
     Event handler called to notify owner that the value of the Property
     has changed
     """
     val = self.get_value()
     if not misc.streq( self.val, val ):
         common.app_tree.app.saved = False # update the status of the app
         if self.setter: self.setter( val )
         else:
             self.owner[self.name][1]( val )
         self.val = self.get_value()
     first[0] = False
     event.Skip()
示例#19
0
 def on_change_val(self, event, first=[True]):
     """\
     Event handler called to notify owner that the value of the Property
     has changed
     """
     val = self.get_value()
     if not misc.streq(self.val, val):
         common.app_tree.app.saved = False # update the status of the app
         if self.setter: self.setter(val)
         else:
             self.owner[self.name][1](val)
         self.val = self.get_value()
     first[0] = False
     event.Skip()
示例#20
0
 def show_menu_item(self, event):
     """\
     Event handler called when a menu item in the list is selected
     """        
     self.selected_index = index = event.GetIndex()
     if not misc.streq(self.menu_items.GetItem(index, 2).m_text, '---'):
         # skip if the selected item is a separator
         for (s, i) in ((self.label, 0), (self.id, 1), (self.name, 2),
                        (self.help_str, 3), (self.event_handler, 5)):
             s.SetValue(self.menu_items.GetItem(index, i).m_text)
         self.label.SetValue(self.label.GetValue().lstrip())
         try:
             self.check_radio.SetSelection(
                 int(self.menu_items.GetItem(index, 4).m_text))
         except:
             self.check_radio.SetSelection(0)
     event.Skip()
示例#21
0
 def _set_tools(self):
     if not self.widget: return  # nothing left to do
     self.widget.ClearTools()
     # now add all the tools
     for tool in self.tools:
         if misc.streq(tool.id, '---'):  # the tool is a separator
             self.widget.AddSeparator()
         else:
             bmp1 = self.get_preview_obj_bitmap(tool.bitmap1)
             bmp2 = self.get_preview_obj_bitmap(tool.bitmap2)
             kinds = [wx.ITEM_NORMAL, wx.ITEM_CHECK, wx.ITEM_RADIO]
             try:
                 kind = kinds[int(tool.type)]
             except (ValueError, IndexError):
                 kind = wx.ITEM_NORMAL
             self.widget.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()
示例#22
0
文件: toolbar.py 项目: dsqiu/qzystudy
 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()
示例#23
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 )
示例#24
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)
示例#25
0
 def set_name(self, name):
     if not misc.streq(self.name, name):
         common.app_tree.app.update_top_window_name(self.name, name)
     WindowBase.set_name(self, name)
示例#26
0
 def set_name(self, name):
     if not misc.streq(self.name, name):
         common.app_tree.app.update_top_window_name(self.name, name)
     WindowBase.set_name(self, name)
示例#27
0
 def ok():
     if len(self.val) != len(val): return True
     for i in range(len(val)):
         for j in range(len(val[i])):
             if not misc.streq(val[i][j], self.val[i][j]): return True
     return False