如何垂直打包tkinter按钮?

时间:2015-07-02 23:59:36

标签: python tkinter

如何将以下按钮设置为垂直而不是水平?因为我想将这些按钮垂直放置并将图片放在右边? “用python语言”

    self.myParent = parent   
    self.myContainer1 = Frame(parent)
    self.myContainer1.pack()

    self.button1 = Button(self.myContainer1, command=self.button1Click)
    self.button1.configure(text="Generate The Fraud Detection File", background= "grey")
    self.button1.pack(side=LEFT)
    self.button1.focus_force()         


    self.button3 = Button(self.myContainer1, command=self.button2Click) 
    self.button3.configure(text="       Cancel       ", background="grey")     
    self.button3.pack(side=RIGHT)


    self.button3 = Button(self.myContainer1, command=self.button2Click) 
    self.button3.configure(text="       Edit        ", background="grey")     



    self.button2 = Button(self.myContainer1, command=self.button3Click) 
    self.button2.configure(text="Disply The File of Fraud Detection", background="grey")     
    self.button2.pack(side=RIGHT)

    self.button4 = Button(self.myContainer1, command=self.button4Click) 
    self.button4.configure(text="Display The Monthly Chart", background="grey")     
    self.button4.pack(side=RIGHT)

1 个答案:

答案 0 :(得分:3)

创建两个框架。在左边打包一个按钮,一个在右边用于其他一切。然后,将按钮添加到左侧框架并使用side="top"side="bottom"打包。

不要害怕使用额外的帧来阻止你的GUI进入部分。设置GUI的过程要容易得多,而不是试图使用单个几何管理器在一个窗口内排列所有内容。