-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsignup.py
116 lines (98 loc) · 4.78 KB
/
signup.py
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
from tkinter import *
from tkinter.messagebox import *
import datetime
# from MainPage import *
from tkinter import messagebox
import psycopg2
import etc
from Sql_Search import SqlSearch
import page1
from date import Date
class SignupPage(object):
def __init__(self, master=None):
self.root = master
winWidth = 650
winHeight = 400
screenWidth = self.root.winfo_screenwidth()
screenHeight = self.root.winfo_screenheight()
x = int((screenWidth - winWidth) / 2)
y = int((screenHeight - winHeight) / 2)
# 设置窗口初始位置在屏幕居中
self.root.geometry("%sx%s+%s+%s" % (winWidth, winHeight, x, y))
# 设置窗口图标
self.root.iconbitmap("./image/3.ico")
# 设置窗口宽高固定
self.root.resizable(0, 0)
self.user_id = StringVar()
self.passwd = StringVar()
self.username = StringVar()
self.nickname = StringVar()
self.tel_num = StringVar()
self.gender = StringVar()
self.v = IntVar()
self.birth_date = StringVar()
self.createPage()
def createPage(self):
self.page = Frame(self.root) # 创建Frame
self.page.pack()
Label(self.page).grid(row=0, stick=W)
Label(self.page, text='用户id: ').grid(row=1, stick=W, pady=10)
Entry(self.page, textvariable=self.user_id).grid(row=1,
column=1,
stick=E)
Label(self.page, text='密码: ').grid(row=2, stick=W, pady=10)
Entry(self.page, textvariable=self.passwd, show='*').grid(row=2,
column=1,
stick=E)
Label(self.page, text='用户名: ').grid(row=3, stick=W, pady=10)
Entry(self.page, textvariable=self.username).grid(row=3,
column=1,
stick=E)
Label(self.page, text='昵称: ').grid(row=4, stick=W, pady=10)
Entry(self.page, textvariable=self.nickname).grid(row=4,
column=1,
stick=E)
Label(self.page, text='电话: ').grid(row=5, stick=W, pady=10)
Entry(self.page, textvariable=self.tel_num).grid(row=5,
column=1,
stick=E)
Label(self.page, text='性别: ').grid(row=6, stick=W, pady=10)
rbt = Radiobutton(self.page, text='男', variable=self.v, value='M')
rbt.grid(row=6, column=0, padx=5, columnspan=2)
rbt = Radiobutton(self.page, text='女', variable=self.v, value='F')
rbt.grid(row=6, column=1, padx=80, columnspan=90)
# Label(self.page, text='出生日期: ').grid(row=7, stick=W, pady=10)
Button(self.page, text='出生日期:',
command=lambda: self.getdate('start')).grid(row=7,
stick=W,
pady=10)
Entry(self.page, textvariable=self.birth_date).grid(row=7, column=1)
Button(self.page, text='注册', command=self.signupCheck).grid(row=8,
stick=W,
pady=10)
Button(self.page, text='退出', command=self.page.quit).grid(row=8,
column=1,
stick=E)
def getdate(self, type): #获取选择的日期
for date in [Date().selection()]:
if date:
if (type == 'start'): #如果是开始按钮,就赋值给开始日期
self.birth_date.set(date)
def signupCheck(self):
user_id = self.user_id.get()
passwd = self.passwd.get()
username = self.username.get()
nickname = self.nickname.get()
tel_num = self.tel_num.get()
if self.v == 'M':
self.gender = 'M'
else:
self.gender = 'F'
gender = self.gender
birth_date = self.birth_date.get()
obj_r = SqlSearch()
tag = obj_r.insert_userinfo(user_id, passwd, username, nickname,
tel_num, gender, birth_date)
if (tag == True):
self.page.destroy()
page1.Page1(self.root)