from tkinter.messagebox import *
from tkinter import *
root = tk()
imglabel = label(root,image=photo,text="初春的雪!") #把整合到標籤類中
imglabel.pack(side=right) #自動對齊
tl = "this is my window"
root.geometry("1024x900") #視窗大小
root.title(tl) #視窗題目
original_background = root.cget("background") #得到視窗背景色
print(original_background)
#root.configure(background=original_background)
root.configure(background="yellow") #設定視窗背景色
data = strin**ar()
def action():
print("i am a button!")
root.title("click me!")
root.geometry("+220+150")
root.update()
bg = root.cget("background")
showinfo(bg) #彈出資訊視窗
label = label(root,text="it's me!")
label.pack()
btn = button(root,text="enter",command=action)
btn.pack()
ent = entry(root,textvariable=data)
ent.pack()
chk1 = checkbutton(root,text="電視")
chk2 = checkbutton(root,text="電腦")
chk3 = checkbutton(root,text="電吹風")
chk1.pack()
chk2.pack()
chk3.pack()
frm = frame(root,bord=6)
frm.pack(side="top")
text = text(frm,width=30,height=6,background="light blue")
text.pack()
im = image("雪.jpg",imgtype="jpg")
im.pack
root.mainloop()
Tkinter 元件詳解 Toplevel
toplevel 頂級視窗 元件類似於 frame 元件,但 toplevel 元件是乙個獨立的頂級視窗,這種視窗通常擁有標題欄 邊框等部件。何時使用 toplevel 元件?toplevel 元件通常用在顯示額外的視窗 對話方塊和其他彈出視窗上。用法下邊例子中,我們在 root 視窗新增乙個按鈕用...
Tkinter 元件詳解(四) Entry
使用 為 entry 元件新增文字,可以使用 insert 方法。import tkinter as tk master tk.tk e tk.entry master e.pack padx 20,pady 20 e.delete 0,end e.insert 0,預設文字.獲取當前輸入框的文字,...
tkinter繪製元件(4) Label
label元件在tkinter中算是十分基礎的了。label主要用來顯示不可更改的文字資訊,在程式ui中作為資訊指示控制項使用。使用畫布畫出label也是十分簡單,思路與繪製按鈕一樣。由於過於簡單,直接在tinui類下加上這樣乙個函式 def add label self,pos tuple tex...