請問各位大俠,我想把顯示時間的label放到最右邊,左邊的label充滿剩余的怎么做,我的總是顯示不對
import time
import tkinter as tk
class Application():
#定義主表單
def __init__(self, root):
#呼叫create_statusbar,生成狀態欄
self.create_statusbar()
#定義程式表單標題
root.title('我的Python程式')
#定義程式表單大小,起始位置
root.geometry('1000x300')
root.anchor('center')
#定義狀態欄
def create_statusbar(self):
#添加一Frame容器
self.theFrame = tk.Frame(root, height = 1, bd = 1, relief = 'sunken')
self.theFrame.pack(side = 'bottom', fill = 'x')
#顯示日期、時間
date_time_now = time.strftime('%Y年%m月%d日 %H:%M:%S', time.localtime())
self.date_time_label = tk.Label(self.theFrame, text = date_time_now, fg = 'red')
self.date_time_label.config(width = 30, anchor = 'c')
self.date_time_label.grid(row=0, column = 1, sticky = 'e', padx = 2)
#顯示檔案名
self.filename_label = tk.Label(self.theFrame, text= 'good')
self.filename_label.grid(row=0, column = 0, padx = 2, sticky = 'we')
if __name__ == '__main__':
root = tk.Tk()
app = Application(root)
root.mainloop()
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/60792.html
