程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

Python visual Tkinter first experience

編輯:Python

Python visualization tkinter First experience

1、 Basic usage

# coding:utf-8
import tkinter as tk
# Create window objects 
window = tk.Tk()
# Set serial port title 
window.title("Python GUI")
# Set window size 
window.geometry("600x100") # Fixed writing ,600x600, In pixels 
# Using window objects 
window.mainloop()

  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.

2、 Commonly used labels

# coding:utf-8
import tkinter as tk
# Create window objects 
window = tk.Tk()
# Set serial port title 
window.title("Python GUI")
# Set window size 
window.geometry("600x400") # Fixed writing ,600x400, In pixels 
# Text label 
# Create objects 
lb1 = tk.Label(window, text=" I am a text tag ")
# Configuration object 
lb1.pack()
# Button 
bt1 = tk.Button(window, text=" I'm a button ")
bt1.pack()
# Enter text box 
et1 = tk.Entry(window,text=" I am a text input box ")
et1.pack()
# Content input box , Can enter , With format 
tt1 = tk.Text(window)
tt1.pack()
# Define a tkinter The variable of 
var1 = tk.StringVar()
# Variable assignment 
var1.set(" I am a test text ")
# Display the value of the variable on the text label of the window 
tk.Label(window, textvariable=var1).pack()
# Using window objects 
window.mainloop()

  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.


  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved