簡體   English   中英

樹視圖不適合框架

[英]treeview doesn't fit the frame

我嘗試將樹視圖放入子框架中,但它不適合框架。

class Application(Frame):
    def __init__(self,master=None):
        self.pipeLine =[]
        super().__init__(master)
        self.master = master
        self.PipeFrame = Frame(self.master,width=200,height=200).place(x=30,y=30)
        self.PipeLineFrame = Frame(self.PipeFrame,width=200,height=220,bg='white',).place(x=10,y=100)
        self.createPipeTree()
        self.createWidget()
        self.pack()
    def createPipeTree(self):
        self.PipeTree = ttk.Treeview(self.PipeLineFrame,column=("input","output"))
        self.PipeTree.column("#0",minwidth=25,width= 60)
        self.PipeTree.column("input",anchor=W,width=60)
        self.PipeTree.column("output",anchor=W,width=60)
        self.PipeTree.heading("#0",text="PipeLine")
        self.PipeTree.heading("input",text="input")
        self.PipeTree.heading("output",text="output")
        self.PipeTree.pack(side=LEFT,expand=True)
    def createWidget(self):
        self.addNode = Button(self.PipeFrame,text="click to add procedure into pipeline",command=self.addNode).place(x=10,y=20)
        self.inputBtn1 = Button(self.PipeFrame, text="F0").place(x=10,y=350)
        self.inputBtn2 = Button(self.PipeFrame, text="Mel" ).place(x=50, y=350)
        self.inputBtn3 = Button(self.PipeFrame, text="audio" ).place(x=100, y=350)
        self.inputBtn4 = Button(self.PipeFrame, text="text").place(x=150,y=350)
        self.inputBtn5 = Button(self.PipeFrame, text="f0").place(x=200, y=350)
    if __name__ == '__main__':
        root = Tk()
        root.geometry("800x400+200+300")
        root.title("HDI is the best")
        Application(master=root)
        root.mainloop()

PipeTree 應該適合 PipeLineFrame(白色區域),但目前,它像這樣脫離了框架。 當前結果

當你布局一個小部件時,你可以像這樣在 1 行中完成:

Widget(root).pack()

或者你可以給它一個名字並使用兩行這樣的:

name = Widget(root)
name.pack()

您不能將這 2 種方法結合起來並使用一行為其命名。 如果您嘗試這樣做,這就是您得到的錯誤。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM