#!/usr/bin/python3
# -*- coding: UTF-8 -*-

from tkinter import *

root = Tk()
root.title("Tkinter GUI")  # 设置标题
root.geometry("300x300-100+100")  # 设置窗口大小和起始位置


# # 001. 建立输入姓名与地址的标签和文本框
# name_label = Label(root, text="请输入姓名:")
# name_entry = Entry(root)
# # 如果column未设置,默认取值0
# name_label.grid(row=0, column=0)
# name_entry.grid(row=0, column=1)

# addr_label = Label(root, text="请输入地址:")
# addr_entry = Entry(root)
# addr_label.grid(row=1, column=0)
# addr_entry.grid(row=1, column=1)


# # 002. 建立输入姓名与密码的标签和文本框,要求密码文本框显示*
# name_label = Label(root, text="请输入姓名:")
# name_entry = Entry(root)
# name_label.grid(row=0, column=0)
# name_entry.grid(row=0, column=1)

# password_label = Label(root, text="请输入密码:")
# password_entry = Entry(root, show="*")
# password_label.grid(row=1, column=0)
# password_entry.grid(row=1, column=1)

# # 003. 设置选取字符的颜色
# label_1 = Label(root, text="请关注选取字符的变化:")
# entry_1 = Entry(root,selectbackground="yellow",selectborderwidth=10,selectforeground="blue")
# label_1.grid(row=0, column=0)
# entry_1.grid(row=0, column=1)

# 004. 设置文字变量,关联知识点-变量类别
# username = StringVar()
# username.set("我是默认名字")
# name_label = Label(root, text="请输入姓名:")
# name_entry = Entry(root, textvariable=username)
# name_label.grid(row=0, column=0)
# name_entry.grid(row=0, column=1)

# # 005. 开始x轴滚动条,关联知识点:滚动条
# label_1 = Label(root, text="开启滚动条的文本框:")
# scrollbar_1 = Scrollbar(orient="horizontal")
# entry_1 = Entry(root, xscrollcommand=scrollbar_1.set)
# label_1.pack()
# scrollbar_1.pack(fill=X,padx=10)
# scrollbar_1.config(command=entry_1.xview)
# entry_1.pack()


# # 006. 做一个登录的案例,熟悉文本框的常用方法
# def reset():
#     account_entry.delete(0, END)
#     password_entry.delete(0, END)
#     account_entry.focus_set()

# def login():
#     account = account_entry.get()
#     password = password_entry.get()
#     print(f"用户输入的密码是:{account},输入的密码是:{password}")


# account_label = Label(root, text="请输入账号:")
# account_entry = Entry(root)
# account_label.grid(row=0, column=0)
# account_entry.grid(row=0, column=1)
# account_entry.focus_set()

# password_label = Label(root, text="请输入密码:")
# password_entry = Entry(root, show="*")
# password_label.grid(row=1, column=0)
# password_entry.grid(row=1, column=1)

# reset_btn = Button(root, text="重置", command=reset)
# reset_btn.grid(row=2, column=0)
# login_btn = Button(root, text="登录", command=login)
# login_btn.grid(row=2, column=2)


root.mainloop()

标签: 暂无标签