?
python : 3.7.0
OS : Ubuntu 18.04.1 LTS
IDE : PyCharm 2018.2.4
conda : 4.5.11
type setting : Markdown
?
code
"""
@Author : 行初心
@Date : 18-10-1
@Blog : www.cnblogs.com/xingchuxin
@GitHub : github.com/GratefulHeartCoder
"""
import tkinter as tk
class APP:
def __init__(self, master):
# 自动选定大小与位置
self.frame = tk.Frame(master)
self.frame.pack()
# 新建一个按钮
self.hi_there = tk.Button(self.frame, text=‘菠萝蜜‘,
bg="blue") # 背景色:蓝色
self.hi_there.pack() # 自动设置按钮的位置
def main():
root = tk.Tk()
app = APP(root)
root.mainloop()
if __name__ == ‘__main__‘:
main()
?
result