[Python][tkinter] Build tkinter GUI 使用tkinter建立圖形視窗
This example shows how to build a GUI by using tkinter.
Import tkinter
build a window named “win”.
window format 1: title()
window format 2: geometry() determine size and initial position(x,y)
window format 3: maxsize() set max size of a window
Build Button component and give a string to text
Use pack to arrange Button on left side
Build Label component and give a string to text
Use pack to arrange Build Label on right side
use mainloop() to keep window running for monitoring and handling events
這個範例介紹如何使用tkinter建立圖形視窗。
#1. 引入tkinter
#2. 建立一個名為win的新視窗
#3. 視窗格式: 標題 Title()
#4. 視窗格式: 設定視窗啟動時的大小與位置 geometry(“寬x長+x位移+y位移”)
#5. 視窗格式: 設定視窗最大尺寸 maxsize(int長,int寬)
#6. 建立Button元件,按鍵文字 Text = “”
#7. Button元件布局 pack(side=’left’) 靠左
#8. 建立Label元件,按鍵文字 Text = “”
#9. Label元件布局 pack(side=’right’) 靠右
#10. mainloop()在使用者關閉視窗之前持續偵測視窗並處理事件
import tkinter as tk
win = tk.Tk()
win.title(“tkinter test”)
win.geometry(“400x400+200+200”)
win.maxsize(600,600)
btn = tk.Button(win, text = “Click”)
btn.pack(side=’left’)
lbl = tk.Label(win, text = “Hello World !”)
lbl.pack(side=’right’)
win.mainloop()
We will share more tutorial videos with people who want to learn LabVIEW and Python welcome to subscribe this channel.
未來會陸續更新影片,讓想學習LabVIEW和Python的朋友可以看影片學習,歡迎訂閱此頻道。
其他網址/related websites:
https://labview-tech.blogspot.com/
https://fishark.pixnet.net/blog
email: jacklee3633 @gmail.com
Line: lvnet