Python wx 模块,TR_HAS_BUTTONS 实例源码

我们从Python开源项目中,提取了以下7个代码示例,用于说明如何使用wx.TR_HAS_BUTTONS

项目:beremiz    作者:nucleron    | 项目源码 | 文件源码
def __init__(self, parent, name, library, default=None):
        wx.Dialog.__init__(self,
                           name='BrowseValueDialog', parent=parent,
                           style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER,
                           title=_('Browse %s values library') % name)

        self.staticText1 = wx.StaticText(
              label=_('Choose a value for %s:') % name, name='staticText1', parent=self,
              pos=wx.Point(0, 0), size=wx.DefaultSize, style=0)

        self.ValuesLibrary = wx.TreeCtrl(
              name='ValuesLibrary', parent=self, pos=wx.Point(0, 0),
              size=wx.Size(400, 200), style=wx.TR_HAS_BUTTONS | wx.TR_SINGLE | wx.SUNKEN_BORDER | wx.TR_HIDE_ROOT | wx.TR_LINES_AT_ROOT)

        self.ButtonSizer = self.CreateButtonSizer(wx.OK | wx.CANCEL | wx.CENTRE)

        self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.ButtonSizer.GetAffirmativeButton().GetId())

        self.flexGridSizer1 = wx.FlexGridSizer(cols=1, hgap=0, rows=3, vgap=10)

        self.flexGridSizer1.AddWindow(self.staticText1,   0, border=20, flag=wx.GROW | wx.TOP | wx.LEFT | wx.RIGHT)
        self.flexGridSizer1.AddWindow(self.ValuesLibrary, 0, border=20, flag=wx.GROW | wx.LEFT | wx.RIGHT)
        self.flexGridSizer1.AddSizer(self.ButtonSizer,    0, border=20, flag=wx.ALIGN_RIGHT | wx.BOTTOM | wx.LEFT | wx.RIGHT)

        self.flexGridSizer1.AddGrowableCol(0)
        self.flexGridSizer1.AddGrowableRow(1)

        self.SetSizer(self.flexGridSizer1)
        self.Fit()

        root = self.ValuesLibrary.AddRoot("")
        self.GenerateValuesLibraryBranch(root, library, default)
项目:SameKeyProxy    作者:xzhou    | 项目源码 | 文件源码
def _build(self):
      """
      Building widgets and setting static widget data.      
      """
      parent = wx.Panel(self, -1)
      sizer0 = wx.BoxSizer(wx.VERTICAL)
      sizer0.Add(self._buildTopBar(parent), 0, wx.ALIGN_LEFT|wx.GROW, 5)

      splitter = wx.SplitterWindow(parent, -1)
      #- TOP PART --------------------------------------------------------#
      topParent = wx.Panel(splitter, -1)
      topSizer = wx.BoxSizer(wx.VERTICAL)
      self.treeCtrlItems = wx.TreeCtrl(topParent, -1,
                         style = wx.TR_TWIST_BUTTONS|wx.TR_LINES_AT_ROOT|wx.TR_HAS_BUTTONS|wx.TR_HIDE_ROOT|wx.TR_MULTIPLE)
      topSizer.Add(self.treeCtrlItems, 1, wx.EXPAND, 5)
      topParent.SetAutoLayout( True )
      topParent.SetSizer(topSizer )
      topSizer.Fit(topParent)
      topSizer.SetSizeHints(topParent)
      #-------------------------------------------------------------------#
      #- BOTTOM PART -----------------------------------------------------#
      bottomParent = wx.Panel(splitter,-1)
      bottomSizer = wx.BoxSizer(wx.VERTICAL)
      self.txtCtrlLog=wx_StdoutLog(bottomParent, -1, "",
                                  size= wx.Size(-1, 10),
                                  style=wx.TE_MULTILINE|wx.TE_READONLY|wx.TE_RICH)
      bottomSizer.Add(self.txtCtrlLog, 1, wx.EXPAND, 5)
      bottomParent.SetAutoLayout( True )
      bottomParent.SetSizer(bottomSizer )
      bottomSizer.Fit(bottomParent)
      bottomSizer.SetSizeHints(bottomParent)
      #-------------------------------------------------------------------#
      splitter.SplitHorizontally(topParent,bottomParent, -100)
      sizer0.Add(splitter, 1, wx.EXPAND|wx.ALIGN_CENTRE, 5)

      self.buttonClose = wx.Button(parent, -1, 'Close')         # buttonClose
      sizer0.Add(self.buttonClose, 0, wx.ALIGN_CENTRE|wx.ALL, 5)

      parent.SetAutoLayout( True )
      parent.SetSizer( sizer0 )
      sizer0.Fit( parent)
      sizer0.SetSizeHints( parent)
项目:dxf2gcode    作者:cnc-club    | 项目源码 | 文件源码
def __init__(self, parent, id, title):
        wx.Frame.__init__(self,parent,wx.ID_ANY, title, size=(600, 600), pos=(200, 200))

        self.splitter_window = wx.SplitterWindow(self, -1, style=wx.SP_3D|wx.SP_BORDER)
        self.splitter_window.SetMinimumPaneSize(20)
        self.left_panel = wx.Panel(self.splitter_window, -1)
        self.right_panel = wx.Panel(self.splitter_window, -1)

        self.tree = CT.CustomTreeCtrl(self.left_panel, 1002, pos=(0, 0), 
            style=wx.TR_DEFAULT_STYLE | 
            wx.TR_HAS_VARIABLE_ROW_HEIGHT | 
            wx.TR_HAS_BUTTONS | 
            wx.TR_FULL_ROW_HIGHLIGHT | 
            wx.TR_MULTIPLE | 
            wx.TR_EDIT_LABELS)
        self.root = self.tree.AddRoot("Root Item")

        offset_lists = ["Clearance Reports", "Other Offsets"]
        offset_list_combo_box = wx.ComboBox(self.right_panel, -1, choices=offset_lists)

        #Sizers
        offset_sizer = wx.BoxSizer(wx.VERTICAL)
        offset_sizer.Add(offset_list_combo_box, 0, wx.EXPAND)
        vbox = wx.BoxSizer(wx.VERTICAL)
        vbox.Add(self.tree, 1, wx.EXPAND)
        self.left_panel.SetSizer(vbox)
        vbox2 = wx.BoxSizer(wx.VERTICAL)
        vbox2.Add(offset_sizer, 1, wx.EXPAND)
        self.right_panel.SetSizer(vbox2)
        main_sizer = wx.BoxSizer(wx.HORIZONTAL)
        self.splitter_window.SplitVertically(self.left_panel, self.right_panel)
        main_sizer.Add(self.splitter_window, 1, wx.EXPAND)
        self.SetSizer(main_sizer)

        self.Bind(wx.EVT_TREE_END_LABEL_EDIT, self.OnEndLabelEdit)
        self.Bind(wx.EVT_TREE_BEGIN_LABEL_EDIT, self.OnBeginLabelEdit)
        self.Bind(wx.EVT_KEY_DOWN, self.enterpressed)
        self.tree.Bind(wx.EVT_KEY_DOWN, self.enterpressed)
        self.Bind(wx.EVT_KEY_DOWN, self.enterpressed, self.tree)
        self.Bind(wx.EVT_COMMAND_ENTER, self.enterpressed)
        self.Bind(wx.EVT_TEXT_ENTER, self.enterpressed)

        self.Show(True)
项目:augment3D    作者:yulkang    | 项目源码 | 文件源码
def __init__(self, parent, title):
        """Create the pydicom image example's main frame window."""

        wx.Frame.__init__(self, parent, id=-1, title="", pos=wx.DefaultPosition,
                          size=wx.Size(w=1024, h=768),
                          style=wx.DEFAULT_FRAME_STYLE | wx.SUNKEN_BORDER | wx.CLIP_CHILDREN)

        # --------------------------------------------------------
        # Set up the menubar.
        # --------------------------------------------------------
        self.mainmenu = wx.MenuBar()

        # Make the 'File' menu.
        menu = wx.Menu()
        item = menu.Append(wx.ID_ANY, '&Open', 'Open file for editing')
        self.Bind(wx.EVT_MENU, self.OnFileOpen, item)
        item = menu.Append(wx.ID_ANY, 'E&xit', 'Exit Program')
        self.Bind(wx.EVT_MENU, self.OnFileExit, item)
        self.mainmenu.Append(menu, '&File')

        # Attach the menu bar to the window.
        self.SetMenuBar(self.mainmenu)

        # --------------------------------------------------------
        # Set up the main splitter window.
        # --------------------------------------------------------
        self.mainSplitter = wx.SplitterWindow(self, style=wx.NO_3D | wx.SP_3D)
        self.mainSplitter.SetMinimumPaneSize(1)

        # -------------------------------------------------------------
        # Create the folderTreeView on the left.
        # -------------------------------------------------------------
        self.dsTreeView = wx.TreeCtrl(self.mainSplitter, style=wx.TR_LINES_AT_ROOT | wx.TR_HAS_BUTTONS)

        # --------------------------------------------------------
        # Create the ImageView on the right pane.
        # --------------------------------------------------------
        self.imView = wx.Panel(self.mainSplitter, style=wx.VSCROLL | wx.HSCROLL | wx.CLIP_CHILDREN)
        self.imView.Bind(wx.EVT_PAINT, self.OnPaint)
        self.imView.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBackground)
        self.imView.Bind(wx.EVT_SIZE, self.OnSize)

        # --------------------------------------------------------
        # Install the splitter panes.
        # --------------------------------------------------------
        self.mainSplitter.SplitVertically(self.dsTreeView, self.imView)
        self.mainSplitter.SetSashPosition(300, True)

        # --------------------------------------------------------
        # Initialize some values
        # --------------------------------------------------------
        self.dcmdsRoot = False
        self.foldersRoot = False
        self.loadCentered = True
        self.bitmap = None
        self.Show(True)
项目:beremiz    作者:nucleron    | 项目源码 | 文件源码
def __init__(self, parent, folder, filter=None, editable=True):
        wx.Panel.__init__(self, parent, style=wx.TAB_TRAVERSAL)

        main_sizer = wx.BoxSizer(wx.VERTICAL)

        self.Tree = wx.TreeCtrl(self,
                                style=(wx.TR_HAS_BUTTONS |
                                       wx.TR_SINGLE |
                                       wx.SUNKEN_BORDER |
                                       wx.TR_HIDE_ROOT |
                                       wx.TR_LINES_AT_ROOT |
                                       wx.TR_EDIT_LABELS))
        if wx.Platform == '__WXMSW__':
            self.Bind(wx.EVT_TREE_ITEM_ACTIVATED, self.OnTreeItemExpanded, self.Tree)
            self.Tree.Bind(wx.EVT_LEFT_DOWN, self.OnTreeLeftDown)
        else:
            self.Bind(wx.EVT_TREE_ITEM_EXPANDED, self.OnTreeItemExpanded, self.Tree)
        self.Bind(wx.EVT_TREE_ITEM_COLLAPSED, self.OnTreeItemCollapsed, self.Tree)
        self.Bind(wx.EVT_TREE_BEGIN_LABEL_EDIT, self.OnTreeBeginLabelEdit, self.Tree)
        self.Bind(wx.EVT_TREE_END_LABEL_EDIT, self.OnTreeEndLabelEdit, self.Tree)
        main_sizer.AddWindow(self.Tree, 1, flag=wx.GROW)

        if filter is not None:
            self.Filter = wx.ComboBox(self, style=wx.CB_READONLY)
            self.Bind(wx.EVT_COMBOBOX, self.OnFilterChanged, self.Filter)
            main_sizer.AddWindow(self.Filter, flag=wx.GROW)
        else:
            self.Filter = None

        self.SetSizer(main_sizer)

        self.Folder = folder
        self.Editable = editable

        self.TreeImageList = wx.ImageList(16, 16)
        self.TreeImageDict = {}
        for item_type, bitmap in [(DRIVE, "tree_drive"),
                                  (FOLDER, "tree_folder"),
                                  (FILE, "tree_file")]:
            self.TreeImageDict[item_type] = self.TreeImageList.Add(GetBitmap(bitmap))
        self.Tree.SetImageList(self.TreeImageList)

        self.Filters = {}
        if self.Filter is not None:
            filter_parts = filter.split("|")
            for idx in xrange(0, len(filter_parts), 2):
                if filter_parts[idx + 1] == "*.*":
                    self.Filters[filter_parts[idx]] = ""
                else:
                    self.Filters[filter_parts[idx]] = filter_parts[idx + 1].replace("*", "")
                self.Filter.Append(filter_parts[idx])
                if idx == 0:
                    self.Filter.SetStringSelection(filter_parts[idx])

            self.CurrentFilter = self.Filters[self.Filter.GetStringSelection()]
        else:
            self.CurrentFilter = ""
项目:bids    作者:robertoostenveld    | 项目源码 | 文件源码
def __init__(self, parent, title):
        """Create the pydicom image example's main frame window."""

        wx.Frame.__init__(self, parent, id=-1, title="", pos=wx.DefaultPosition,
                          size=wx.Size(w=1024, h=768),
                          style=wx.DEFAULT_FRAME_STYLE | wx.SUNKEN_BORDER | wx.CLIP_CHILDREN)

        # --------------------------------------------------------
        # Set up the menubar.
        # --------------------------------------------------------
        self.mainmenu = wx.MenuBar()

        # Make the 'File' menu.
        menu = wx.Menu()
        item = menu.Append(wx.ID_ANY, '&Open', 'Open file for editing')
        self.Bind(wx.EVT_MENU, self.OnFileOpen, item)
        item = menu.Append(wx.ID_ANY, 'E&xit', 'Exit Program')
        self.Bind(wx.EVT_MENU, self.OnFileExit, item)
        self.mainmenu.Append(menu, '&File')

        # Attach the menu bar to the window.
        self.SetMenuBar(self.mainmenu)

        # --------------------------------------------------------
        # Set up the main splitter window.
        # --------------------------------------------------------
        self.mainSplitter = wx.SplitterWindow(self, style=wx.NO_3D | wx.SP_3D)
        self.mainSplitter.SetMinimumPaneSize(1)

        # -------------------------------------------------------------
        # Create the folderTreeView on the left.
        # -------------------------------------------------------------
        self.dsTreeView = wx.TreeCtrl(self.mainSplitter, style=wx.TR_LINES_AT_ROOT | wx.TR_HAS_BUTTONS)

        # --------------------------------------------------------
        # Create the ImageView on the right pane.
        # --------------------------------------------------------
        self.imView = wx.Panel(self.mainSplitter, style=wx.VSCROLL | wx.HSCROLL | wx.CLIP_CHILDREN)
        self.imView.Bind(wx.EVT_PAINT, self.OnPaint)
        self.imView.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBackground)
        self.imView.Bind(wx.EVT_SIZE, self.OnSize)

        # --------------------------------------------------------
        # Install the splitter panes.
        # --------------------------------------------------------
        self.mainSplitter.SplitVertically(self.dsTreeView, self.imView)
        self.mainSplitter.SetSashPosition(300, True)

        # --------------------------------------------------------
        # Initialize some values
        # --------------------------------------------------------
        self.dcmdsRoot = False
        self.foldersRoot = False
        self.loadCentered = True
        self.bitmap = None
        self.Show(True)
项目:LalkaChat    作者:DeForce    | 项目源码 | 文件源码
def create_layout(self):
        self.main_grid = wx.BoxSizer(wx.HORIZONTAL)
        style = wx.TR_DEFAULT_STYLE | wx.TR_HIDE_ROOT | wx.TR_TWIST_BUTTONS | wx.TR_NO_LINES
        # style = wx.TR_HAS_BUTTONS | wx.TR_SINGLE | wx.TR_HIDE_ROOT

        image_list = wx.ImageList(16, 16)

        tree_ctrl_id = id_renew('settings.tree', update=True)
        tree_ctrl = wx.TreeCtrl(self, id=tree_ctrl_id, style=style)
        root_key = MODULE_KEY.join(['settings', 'tree', 'root'])
        root_node = tree_ctrl.AddRoot(translate_key(root_key))
        for cat_name, category in self.categories.iteritems():
            item_key = MODULE_KEY.join(['settings', cat_name])
            item_data = wx.TreeItemData()
            item_data.SetData(item_key)

            item_node = tree_ctrl.AppendItem(root_node, translate_key(item_key), data=item_data)
            for module_name, module_settings in category.iteritems():
                if not module_name == cat_name:
                    if module_settings.get('gui', {}).get('icon'):
                        icon = wx.Bitmap(module_settings['gui']['icon'])
                        self.tree_ctrl_image_dict[module_name] = image_list.GetImageCount()
                        image_list.Add(icon)
                    else:
                        self.tree_ctrl_image_dict[module_name] = -1

                    f_item_key = MODULE_KEY.join([item_key, module_name])
                    f_item_data = wx.TreeItemData()
                    f_item_data.SetData(f_item_key)
                    tree_ctrl.AppendItem(item_node, translate_key(module_name),
                                         image=self.tree_ctrl_image_dict[module_name],
                                         data=f_item_data)
        if self.show_icons:
            tree_ctrl.AssignImageList(image_list)
        tree_ctrl.ExpandAll()

        self.tree_ctrl = tree_ctrl
        self.Bind(wx.EVT_TREE_SEL_CHANGED, self.on_tree_ctrl_changed, id=tree_ctrl_id)

        self.main_grid.Add(tree_ctrl, 7, wx.EXPAND | wx.ALL, 7)

        content_page_id = id_renew(MODULE_KEY.join(['settings', 'content']))
        self.content_page = wx.Panel(self, id=content_page_id)
        self.main_grid.Add(self.content_page, 15, wx.EXPAND)

        self.main_grid.Layout()
        self.SetSizer(self.main_grid)
        tree_ctrl.SelectItem(tree_ctrl.GetFirstChild(root_node)[0])