<GUI>Tkinter

1.初识Tkinter(python的图形化界面)

import tkinter as tk


class App:
	def __init__(self, master):
		# 自动调整
		frame = tk.Frame(master)
		# 用于自动调节主键的尺寸
		frame.pack(side=tk.LEFT, padx=100, pady=100)
		# 按钮
		self.hi_there = tk.Button(frame, text="打招呼", bg='red', fg='blue', command=self.say_hi)
		# left right top button
		self.hi_there.pack()

	def say_hi(self):
		print("hello world!!!")


root = tk.Tk()
app = App(root)
# 窗口的主事件循环
root.mainloop()

  结果

原文地址:https://www.cnblogs.com/shuimohei/p/11494650.html