-
Notifications
You must be signed in to change notification settings - Fork 1
/
myframe.py
34 lines (30 loc) · 1.33 KB
/
myframe.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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from tkinter import *
from tkinter.messagebox import *
from gfxtest import GFXTest
class myframe(object):
def __init__(self, master=None):
self.root = master # 定义内部变量root
self.root.geometry('%dx%d' % (300, 180)) # 设置窗口大小
self.username = StringVar()
self.password = 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='账户: ').grid(row=1, stick=W, pady=10)
Entry(self.page, textvariable=self.username).grid(row=1, column=1, stick=E)
Label(self.page, text='密码: ').grid(row=2, stick=W, pady=10)
Entry(self.page, textvariable=self.password, show='*').grid(row=2, column=1, stick=E)
Button(self.page, text='登陆', command=self.loginCheck).grid(row=3, stick=W, pady=10)
Button(self.page, text='退出', command=self.page.quit).grid(row=3, column=1, stick=E)
def loginCheck(self):
name = self.username.get()
secret = self.password.get()
if name == '1' and secret == '1':
self.page.destroy()
GFXTest()
else:
showinfo(title='错误', message='账号或密码错误!')