如何使tkinter框架落后于其他框架

时间:2016-07-12 08:21:30

标签: python tkinter

我正在努力使(self.center = Separator)落后于只有线将位于中心,因为我需要分开2帧,但是当我尝试小屏幕时,这些2帧被分隔符覆盖或者在如果您需要完整代码https://github.com/aurimasjank/Pinger-Alpha/tree/pinger

,请至少使中心框架背景透明
    self.right= Frame(self.tk, bg="black")
    self.right.grid(column=2, row = 0, pady=5,padx=10, sticky=N)

    self.probar= Frame(self.tk, bg= "black")
    self.probar.grid(column=0 ,columnspan= 2, row = 2, sticky= E)

    self.center = Separator(self.tk, orient="vertical")
    self.center.grid(column=1, row=0, sticky="ns")

    sty = Style(self.center)
    sty.configure("TSeparator", background="#00CC00")

    self.botFrame = Frame(self.tk, bg="black")
    self.botFrame.grid(column=2, row = 2, pady=1, sticky= SE)

    self.colnr = 0
    self.rownrleft = 0
    self.rownrright = 0

    self.titlelbl= Label(self.right, text="Service Status:",bg="black",
                            fg="#00CC00",font=("Helvetica", 24))
    self.titlelbl2= Label(self.left, text="GW Status:",bg="black",
                            fg="#00CC00",font=("Helvetica", 24))
    self.titlelbl.grid(column=0, row = 0,sticky=N)        
    self.titlelbl2.grid(column=0, row = 0,sticky=N)

    self.progress = ttk.Progressbar(self.probar,orient ="horizontal",
                                        length = 410, mode ="determinate")
    self.progress.grid(column=0, row = 0,pady= (20,0))

    self.string = StringVar()
    self.timecount = StringVar()

    self.titlelbl3= Label(self.probar, textvariable= self.string ,
                            bg="black", fg="#00CC00",font=("Helvetica", 24))
    self.titlelbl3.grid(column=0, row = 1)

编辑:

所以基本上错误的是进度条正在扩大专栏。但是有一个新问题,如何将进度条放在底部中间,它不会扩展col 1

1 个答案:

答案 0 :(得分:0)

我认为你的问题是由于第1列的宽度由最大的小部件决定的(我不认为它是这里的分隔符,但是进度条)。我建议你将所有第0行小部件放在一个框架中,这样它们就不会受到其他wigets宽度的影响:

from tkinter import Tk, Frame
from tkinter import ttk

root = Tk()
root.columnconfigure(0, weight=1)
root.rowconfigure(0, weight=1)

# create a top frame that will contain left, center and right
# and will spread other the 3 columns so that the width of column 1
# does not decrease the width of the left and right frames
top = Frame(root)
top.grid(row=0, columnspan=3, sticky="nswe")
top.columnconfigure(0, weight=1)
top.rowconfigure(0, weight=1)

left= Frame(top, bg="blue", width=200, height=100)
left.grid(column=0, row = 0, pady=5 ,padx=10, sticky="n")

center = ttk.Separator(top, orient="vertical")
center.grid(column=1, row=0, sticky="ns")

sty = ttk.Style(center)
sty.configure("TSeparator", background="#00CC00")

right= Frame(top, bg="blue", width=200, height=100)
right.grid(column=2, row = 0, pady=5,padx=10, sticky="n")

probar= Frame(root, bg= "black")
probar.grid(column=1, row = 1, sticky= "s")

botFrame = Frame(root, bg="black", width=100, height=50)
botFrame.grid(column=2, row = 1, pady=5, sticky="se")

progress = ttk.Progressbar(probar,orient ="horizontal",
                           length = 410, mode ="determinate")
progress.grid(column=0, row = 0,pady= (20,0))

root.mainloop()