当前位置: 首页>>代码示例>>Python>>正文


Python TreeNode.expand方法代码示例

本文整理汇总了Python中idlelib.TreeWidget.TreeNode.expand方法的典型用法代码示例。如果您正苦于以下问题:Python TreeNode.expand方法的具体用法?Python TreeNode.expand怎么用?Python TreeNode.expand使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在idlelib.TreeWidget.TreeNode的用法示例。


在下文中一共展示了TreeNode.expand方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: TreeCanvas

# 需要导入模块: from idlelib.TreeWidget import TreeNode [as 别名]
# 或者: from idlelib.TreeWidget.TreeNode import expand [as 别名]
class TreeCanvas(tk.Canvas):

    def __init__(self, master, tagger=None):
        tk.Canvas.__init__(self, master)
        self.tagger = tagger or Tagger()
        self.config(bg='white')
        # add scrollbar
        self.scrollbar = tk.Scrollbar(master)
        self.config(yscrollcommand=self.scrollbar.set)
        self.scrollbar.config(command=self.yview)
        # pack widgets
        self.pack(side=tk.LEFT, expand=tk.YES, fill=tk.BOTH)
        self.scrollbar.pack(side=tk.RIGHT, fill=tk.Y)

    def wheel(self, event):
        if event.num == 5 or event.delta <= -120:
            self.yview_scroll(2, 'units')
        if event.num == 4 or event.delta >= 120:
            self.yview_scroll(-2, 'units')

    def show(self, name, data, expanded=False):
        self.node = TreeNode(self, None, self.tagger.item(data, name))
        self.node.expand()
        if expanded:
            for item in self.node.children:
                self._expand(item)
        self.node.update()

    def _expand(self, node):
        node.expand()
        for item in node.children:
            self._expand(item)
开发者ID:rjrivero,项目名称:Plantillator,代码行数:34,代码来源:tree.py

示例2: StackBrowser

# 需要导入模块: from idlelib.TreeWidget import TreeNode [as 别名]
# 或者: from idlelib.TreeWidget.TreeNode import expand [as 别名]
def StackBrowser(root, flist=None, tb=None, top=None):
    if top is None:
        top = tk.Toplevel(root)
    sc = ScrolledCanvas(top, bg="white", highlightthickness=0)
    sc.frame.pack(expand=1, fill="both")
    item = StackTreeItem(flist, tb)
    node = TreeNode(sc.canvas, None, item)
    node.expand()
开发者ID:Connor124,项目名称:Gran-Theft-Crop-Toe,代码行数:10,代码来源:StackViewer.py

示例3: StackBrowser

# 需要导入模块: from idlelib.TreeWidget import TreeNode [as 别名]
# 或者: from idlelib.TreeWidget.TreeNode import expand [as 别名]
def StackBrowser(root, flist = None, tb = None, top = None):
    if top is None:
        from Tkinter import Toplevel
        top = Toplevel(root)
    sc = ScrolledCanvas(top, bg='white', highlightthickness=0)
    sc.frame.pack(expand=1, fill='both')
    item = StackTreeItem(flist, tb)
    node = TreeNode(sc.canvas, None, item)
    node.expand()
    return
开发者ID:webiumsk,项目名称:WOT-0.9.12,代码行数:12,代码来源:stackviewer.py

示例4: remote_stack_viewer

# 需要导入模块: from idlelib.TreeWidget import TreeNode [as 别名]
# 或者: from idlelib.TreeWidget.TreeNode import expand [as 别名]
 def remote_stack_viewer(self):
     from idlelib import RemoteObjectBrowser
     oid = self.rpcclt.remotequeue("exec", "stackviewer", ("flist",), {})
     if oid is None:
         self.tkconsole.root.bell()
         return
     item = RemoteObjectBrowser.StubObjectTreeItem(self.rpcclt, oid)
     from idlelib.TreeWidget import ScrolledCanvas, TreeNode
     top = Toplevel(self.tkconsole.root)
     theme = idleConf.GetOption('main','Theme','name')
     background = idleConf.GetHighlight(theme, 'normal')['background']
     sc = ScrolledCanvas(top, bg=background, highlightthickness=0)
     sc.frame.pack(expand=1, fill="both")
     node = TreeNode(sc.canvas, None, item)
     node.expand()
开发者ID:LinkedModernismProject,项目名称:web_code,代码行数:17,代码来源:PyShell.py

示例5: Tk

# 需要导入模块: from idlelib.TreeWidget import TreeNode [as 别名]
# 或者: from idlelib.TreeWidget.TreeNode import expand [as 别名]
                        </Persistence>
                    </ServiceProfile>
                    <ServiceProfile>
                        <IsEnabled>false</IsEnabled>
                        <Protocol>TCP</Protocol>
                        <Port/>
                        <Persistence>
                            <Method/>
                        </Persistence>
                    </ServiceProfile>
                    <Logging>true</Logging>
                    <Pool>DCTM-UKHTTPD</Pool>
                </VirtualServer>
            </LoadBalancerService>
        </EdgeGatewayServiceConfiguration>
        <HaEnabled>true</HaEnabled>
        <UseDefaultRouteForDnsRelay>false</UseDefaultRouteForDnsRelay>
    </Configuration>
</EdgeGateway>
    '''
    root = Tk()
    canvas = Canvas(root)
    canvas.config(bg='white')
    canvas.pack()
    dom = parseString(example_data)
    item = DomTreeItem(dom.documentElement)
    node = TreeNode(canvas, None, item)
    node.update()
    node.expand()
    root.mainloop()
开发者ID:avirgo,项目名称:20140820,代码行数:32,代码来源:browse_lo3.py

示例6: App

# 需要导入模块: from idlelib.TreeWidget import TreeNode [as 别名]
# 或者: from idlelib.TreeWidget.TreeNode import expand [as 别名]
class App(object):
    def __init__(self):
        self.root = Tkinter.Tk()
        self.root.title("Source Monitor Treemap")
        self.initMenu()
        self.initDropDown()
        self.pane = Tkinter.PanedWindow(self.root, orient=Tkinter.HORIZONTAL)
        self.pane.pack(fill=Tkinter.BOTH, expand=1)
        self.initTreeCanvas()
        self.initTreemapCanvas()
        self.filetree = None

    def initTreemapCanvas(self):
        self.tmcanvas = TreemapSquarified(self.pane, width="13i", height="8i")
        self.tmcanvas.config(bg="white")
        self.pane.config(bg="blue")
        self.pane.add(self.tmcanvas.frame)
        self.pane.paneconfigure(self.tmcanvas.frame, sticky=Tkinter.N + Tkinter.S + Tkinter.E + Tkinter.W)
        self.tooltip = TkCanvasToolTip(self.tmcanvas, follow=True)

    def initTreeCanvas(self):
        frame = Tkinter.Frame(self.pane)
        self.treecanvas = createScrollableCanvas(frame, width="2i")
        self.pane.add(frame)
        self.pane.paneconfigure(frame, sticky=Tkinter.N + Tkinter.S + Tkinter.E + Tkinter.W)

    def initMenu(self):
        menubar = Tkinter.Menu(self.root)
        filemenu = Tkinter.Menu(menubar, tearoff=0)
        filemenu.add_command(label="Open", command=self.openSMFile)
        filemenu.add_command(label="Exit", command=self.root.quit)
        menubar.add_cascade(label="File", menu=filemenu)
        self.root.config(menu=menubar)

    def initDropDown(self):
        self.dropdownframe = Tkinter.Frame(self.root)
        self.sizeOption = Tkinter.StringVar()
        self.sizeOption.set(SIZE_PROP)
        self.colorOption = Tkinter.StringVar()
        self.colorOption.set(CLR_PROP)
        # get the list of options
        options = set(SMPROP_MAPPING.itervalues())
        # now convert the set to sorted list
        options = sorted(options)

        self.optionsSize = Tkinter.OptionMenu(self.dropdownframe, self.sizeOption, command=self.optionchange, *options)
        self.optionsSize.grid(row=0, column=0)
        self.optionsClr = Tkinter.OptionMenu(self.dropdownframe, self.colorOption, command=self.optionchange, *options)
        self.optionsClr.grid(row=0, column=1)
        self.dropdownframe.pack()

    def optionchange(self, param):
        sizepropname = self.sizeOption.get()
        clrpropname = self.colorOption.get()
        self.createtreemap(sizepropname=sizepropname, clrpropname=clrpropname)

    def createtreemap(self, tmrootnode=None, sizepropname=SIZE_PROP, clrpropname=CLR_PROP):
        del self.filetree
        if tmrootnode != None:
            self.tmrootnode = tmrootnode
        ftreeroot = FileTreeItem(self.tmrootnode, self.tmcanvas)
        self.filetree = TreeNode(self.treecanvas, None, ftreeroot)
        self.filetree.update()
        self.filetree.expand()
        clrmap = self.getPropClrMap(self.tmrootnode, clrpropname)
        self.tmcanvas.set(
            tmcolormap=clrmap, sizeprop=sizepropname, clrprop=clrpropname, upper=[1200, 700], tooltip=self.tooltip
        )
        self.tmcanvas.drawTreemap(self.tmrootnode)

    def getNeutralVal(self, clrpropname, minval, maxval):
        neutralval = COLOR_PROP_CONFIG.get(clrpropname)

        if neutralval == None:
            neutralval = 0.5 * (minval + maxval)
        return neutralval

    def getPropClrMap(self, tmrootnode, clrpropname):
        clrmap = TMColorMap(minclr=(0, 255, 0), maxclr=(255, 0, 0))
        minval = tmrootnode.minclr(clrpropname)
        maxval = tmrootnode.maxclr(clrpropname)
        neutralval = self.getNeutralVal(clrpropname, minval, maxval)
        clrmap.setlimits(minval, maxval, neutralval=neutralval)
        return clrmap

    def openSMFile(self):
        filename = tkFileDialog.askopenfilename(
            title="Choose Source Monitor output file", filetypes=SMFILEFORMATS, defaultextension=".xml"
        )
        smtree = SMTree(filename)
        self.createtreemap(smtree)

    def run(self):
        self.root.mainloop()
开发者ID:Pranav1210,项目名称:tctoolkit,代码行数:96,代码来源:smtreemap.py

示例7: __init__

# 需要导入模块: from idlelib.TreeWidget import TreeNode [as 别名]
# 或者: from idlelib.TreeWidget.TreeNode import expand [as 别名]
class App:
    def __init__(self):
        self.root = Tkinter.Tk()
        self.root.title("Source Monitor Treemap")
        self.initMenu()
        self.initDropDown()
        self.pane = Tkinter.PanedWindow(self.root, orient=Tkinter.HORIZONTAL)
        self.pane.pack(fill=Tkinter.BOTH, expand=1)
        self.initTreeCanvas()
        self.initTreemapCanvas()
        self.childtree = None

    def initTreemapCanvas(self):
        self.tmcanvas = TreemapSquarified(self.pane,width='13i', height='8i')
        self.tmcanvas.config(bg='white')
        #self.tmcanvas.grid(column=1,row=1, sticky="nsew")
        self.tmcanvas.pack()
        self.pane.add(self.tmcanvas.frame)
        self.tooltip = TkCanvasToolTip(self.tmcanvas, follow=True)
        
    def initTreeCanvas(self):
        frame = Tkinter.Frame(self.pane)
        self.treecanvas = createScrollableCanvas(frame, width='2i')
        self.treecanvas.pack()
        self.pane.add(frame)

    def initMenu(self):
        menubar = Tkinter.Menu(self.root)
        filemenu = Tkinter.Menu(menubar, tearoff=0)
        filemenu.add_command(label="Open", command=self.openTreemapFile)
        filemenu.add_command(label="Exit", command=self.root.quit)
        menubar.add_cascade(label="File", menu=filemenu)
        self.root.config(menu=menubar)

    def initDropDown(self):
        self.dropdownframe = Tkinter.Frame(self.root)
        self.sizeOption = Tkinter.StringVar()
        self.sizeOption.set(SIZE_PROP)
        self.colorOption = Tkinter.StringVar()
        self.colorOption.set(CLR_PROP)
        #get the list of options        
        options = ['Field 0', 'Field 1']
        
        self.optionsSize = Tkinter.OptionMenu(self.dropdownframe, self.sizeOption,command=self.optionchange, *options)
        self.optionsSize.grid(row=0, column=0)
        self.optionsClr = Tkinter.OptionMenu(self.dropdownframe,self.colorOption,command=self.optionchange, *options)
        self.optionsClr.grid(row=0, column=1)
        self.dropdownframe.pack()

    def optionchange(self, param):
        sizepropname = self.sizeOption.get()
        clrpropname = self.colorOption.get()
        self.createtreemap(sizepropname=sizepropname, clrpropname=clrpropname)
        
    def createtreemap(self, tmrootnode=None,sizepropname=SIZE_PROP, clrpropname=CLR_PROP):
        del self.childtree
        if( tmrootnode != None):
            self.tmrootnode = tmrootnode
        ftreeroot = ChildTreeItem(self.tmrootnode, self.tmcanvas)
        self.childtree = TreeNode(self.treecanvas, None, ftreeroot)
        self.childtree.update()
        self.childtree.expand()
        clrmap = self.getPropClrMap(self.tmrootnode, clrpropname)
        self.tmcanvas.set(tmcolormap=clrmap,sizeprop=sizepropname,clrprop=clrpropname,upper=[1200,700],tooltip=self.tooltip)
        self.tmcanvas.drawTreemap(self.tmrootnode)

    def getNeutralVal(self, clrpropname, minval, maxval):
        #neutralval = 0.5*(minval+maxval)
        neutralval = 15
        return(neutralval)
            
    def getPropClrMap(self,tmrootnode, clrpropname):
        clrmap = TMColorMap(minclr=(0,255,0),maxclr=(255,0,0))        
        minval = tmrootnode.minclr(clrpropname)
        maxval = tmrootnode.maxclr(clrpropname)
        neutralval = self.getNeutralVal(clrpropname, minval, maxval)
        clrmap.setlimits(minval,maxval, neutralval=neutralval)
        return(clrmap)

    def openTreemapFile(self):
        filename = tkFileDialog.askopenfilename(title="Choose Treemap CSV file", defaultextension=".csv")
        tmtree = TMTree(filename)
        self.createtreemap(tmtree)
            
    def run(self):
        self.root.mainloop()
开发者ID:renemilk,项目名称:tctoolkit,代码行数:88,代码来源:tmview.py

示例8: __init__

# 需要导入模块: from idlelib.TreeWidget import TreeNode [as 别名]
# 或者: from idlelib.TreeWidget.TreeNode import expand [as 别名]
class CDDApp:
    def __init__(self, dirname, options):
        self.dirname=dirname
        self.options = options
        self.filelist = None
        self.matches = None
        self.dupsInFile = None

    def getFileList(self):
        if( self.filelist == None):
            if( self.options.pattern ==''):
                self.filelist = PreparePygmentsFileList(self.dirname)
            else:
                rawfilelist = GetDirFileList(self.dirname)
                self.filelist = fnmatch.filter(rawfilelist,self.options.pattern)
                
        return(self.filelist)

    def run(self):
        filelist = self.getFileList()        
        self.cdd = CodeDupDetect(filelist,self.options.minimum)
        self.PrintDuplicates()
        if self.options.report:
            self.cdd.html_output(self.options.report)
        if self.options.comments:
            self.cdd.insert_comments(self.dirname)
        
        if( self.options.treemap == True and self.foundMatches()):
            self.ShowDuplicatesTreemap()
            self.root.mainloop()        
    
    def PrintDuplicates(self):
        tm1 = datetime.datetime.now()
        with FileOrStdout(self.options.filename) as output:
            exactmatch = self.cdd.printmatches(output)
            tm2 = datetime.datetime.now()
            output.write("time to find matches - %s\n" %(tm2-tm1))

    def foundMatches(self):
        '''
        return true if there is atleast one match found.
        '''
        matches = self.getMatches()
        return( len(matches) > 0)
            
    def ShowDuplicatesTreemap(self):
        assert(self.foundMatches()==True)
        self.initTk()
        self.createTreemap()
        self.showDupListTree()
        
    def initTk(self):
        self.root = Tkinter.Tk()
        self.root.title("Code Duplication Treemap")
        self.pane = Tkinter.PanedWindow(self.root, orient=Tkinter.HORIZONTAL)
        self.pane.pack(fill=Tkinter.BOTH, expand=1)
        self.initDupListTree()
        self.initTreemap()
        
    def initDupListTree(self):
        frame = Tkinter.Frame(self.pane)
        self.duplisttree = createScrollableCanvas(frame, width='2i')
        self.pane.add(frame)
        self.pane.paneconfigure(frame, sticky=Tkinter.N+Tkinter.S+Tkinter.E+Tkinter.W)

    def initTreemap(self):
        self.tmcanvas = TreemapSquarified(self.pane,width='13i', height='8i',leafnodecb = self.tmLeafnodeCallback)
        self.tmcanvas.config(bg='white')
        self.pane.add(self.tmcanvas.frame)
        self.pane.paneconfigure(self.tmcanvas.frame, sticky=Tkinter.N+Tkinter.S+Tkinter.E+Tkinter.W)
        self.tooltip = TkCanvasToolTip(self.tmcanvas, follow=True)

    def getColormap(self,tmrootnode):
        clrmap = TMColorMap(minclr=(0,255,0),maxclr=(255,0,0))        
        minval = tmrootnode.minclr(CLR_PROP)
        maxval = tmrootnode.maxclr(CLR_PROP)
        clrmap.setlimits(minval,maxval, neutralval=3)
        return(clrmap)
        
    def createTreemap(self):
        tmrootnode = self.makeTree()
        clrmap = self.getColormap(tmrootnode)
        self.tmcanvas.set(tmcolormap=clrmap,sizeprop=SIZE_PROP,clrprop=CLR_PROP,upper=[1200,700])
        self.tmcanvas.drawTreemap(tmrootnode)
        self.tooltip.updatebindings()

    def getMatches(self):
        if( self.matches == None):
            exactmatches = self.cdd.findcopies()
            self.matches = sorted(exactmatches,reverse=True,key=lambda x:x.matchedlines)
        return(self.matches)
    
    def getMatchLcInfo(self):
        #get the line count information of the duplicates
        matches = self.getMatches()
        #convert the matches to dictionary of filename against the number of copied lines
        matchinfodict = dict()
        for matchset in matches:
            for match in matchset:
                fname = match.srcfile()
#.........这里部分代码省略.........
开发者ID:renemilk,项目名称:tctoolkit,代码行数:103,代码来源:cdd.py

示例9: __SetDom

# 需要导入模块: from idlelib.TreeWidget import TreeNode [as 别名]
# 或者: from idlelib.TreeWidget.TreeNode import expand [as 别名]
 def __SetDom(self, dom):
   item = DomTreeItem(dom)
   node = TreeNode(self.__canvas, None, item)
   node.update()
   node.expand()
开发者ID:Avenza,项目名称:libkml,代码行数:7,代码来源:domviewer.py


注:本文中的idlelib.TreeWidget.TreeNode.expand方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。