Thiker ——制作界面

 

参考的链接:

https://www.cnblogs.com/xy-ju24/p/9212855.html

https://www.bilibili.com/video/BV1jW411Y7dL?p=3

 

练习

1.初步

import tkinter as tk

window = tk.Tk()
window.title("学生信息管理系统")
window.geometry("500x500")

var = tk.StringVar()
l = tk.Label(window, textvariable=var, bg="blue", font=('Arial',12), width=15, height=2)
# 放置,
# 放置点:l.place() l.pack() on_hit = False def hit_me(): global on_hit if not on_hit: on_hit = True var.set('Sno') else: on_hit = False var.set("学号") b = tk.Button(window, text="Sno", width=15, height=2, command=hit_me)
# hit_me 是命令具体内容 b.pack() # while 点一下就会更新数据 window.mainloop()

 2.Entry

import tkinter as tk

window = tk.Tk()
window.title("学生信息管理系统")
window.geometry("500x500")


e = tk.Entry(window, show=None)  # show="*",不显示
e.pack()


def insert_point():
    var = e.get()
    t.insert('insert', var)


def insert_end():
    var = e.get()
    t.insert(1.1, var)


b1 = tk.Button(window, text="insert_point", width=15, height=2, command=insert_point)
b1.pack()
b2 = tk.Button(window, text="insert_end", width=15, height=2, command=insert_end)
b2.pack()

t = tk.Text(window, height=2)
t.pack()


# while 点一下就会更新数据
window.mainloop()

 

posted @ 2020-05-14 16:37  kekefu  阅读(453)  评论(0编辑  收藏  举报