基本的には画面の片側に時計を置き、もう一方にはテキストを置いて、フレームを使用します。これどうやってするの。ここに今見たものの写真があります:Tkinterで隣り合ったフレームを持つ
時計は同じ行にあるテキストと一直線になるようにしたいと思います。私のコードを見て、あなたがいつか私を助けることができるかどうかを見てください!
from tkinter import *
from tkinter import ttk
import time
root = Tk()
root.state("zoomed") #to make it full screen
root.title("Vehicle Window Fitting - Management System")
root.configure(bg="grey80")
Title = Frame(root, width=675, height=50, bd=4, relief="ridge")
Title.pack(side=TOP, anchor='w')
titleLabel = Label(Title, font=('arial', 12, 'bold'), text="Vehicle Window Fitting - Management System", bd=5, anchor='w')
titleLabel.grid(row=0, column=0)
clockFrame = Frame(root, width=675, height=50, bd=4, relief="ridge")
clockFrame.pack(side=TOP, anchor='e')
clockLabel = Label(clockFrame, font=('arial', 12, 'bold'), bd=5, anchor='e')
clockLabel.grid(row=0, column=1)
curtime = ""
def tick():
global curtime
newtime = time.strftime('%H:%M:%S')
if newtime != curtime:
curtime = newtime
clockLabel.config(text=curtime)
clockLabel.after(200, tick)
tick()
Bottom = Frame(root, width=1350, height=50, bd=4, relief="ridge")
Bottom.pack(side=TOP)
root.mainloop()
パーフェクト、私はそれを見ていないと信じてすることはできません。フレームの内側にフレームを置くのではなく、華麗なルートの内側に置きます。助けてくれてありがとう。 –
@Sam:聞いて嬉しいです。ちょうど 'root 'の底に' Bottom''フレームを貼り付けました( 'side = BOTTOM'オプション付き)。それがあなたが望む場所か、代わりに新しい 'topFrame'の直下にあるのかどうかは分かりませんでした。変更するのは簡単です... – martineau