龙空技术网

Python 制作生日计时软件(4),编写查询界面

小戏游戏 426

前言:

此刻同学们对“python窗口界面设计学生消息查询”都比较珍视,咱们都想要知道一些“python窗口界面设计学生消息查询”的相关内容。那么小编同时在网上网罗了一些有关“python窗口界面设计学生消息查询””的相关内容,希望看官们能喜欢,看官们一起来学习一下吧!

查询界面和新建面大部分相同,只是修改了按钮绑定的函数。

主界面

查询界面

废话不多说,直接上干货:

#! /usr/bin/env python

#coding=utf-8

import mysql

from Tkinter import*

from FileDialog import*

from tkFont import*

import mysql

import MySQLdb

from tkMessageBox import showinfo

def getPerson(event):

name=(text11.get(1.3,'end')).strip()

conn=MySQLdb.connect(host='127.0.0.1',port=3306,user='root',passwd='root',\

db='mysql',charset='utf8')

cur=conn.cursor()

sql='select * from Birth where bname='+"'"+name+"'"

cur.execute(sql)

result=cur.fetchone()

cur.close()

conn.commit()

conn.close()

if result==None:

text11.delete('1.3','end')

showinfo(title='查询提示:',message='请输入正确姓名!')

else:

text22.insert(INSERT,str(result[1]))

text33.insert(INSERT,str(result[2]))

text44.insert(INSERT,str(result[3]))

#定义清除函数

def Qchu(event):

text11.delete('1.3','end')

text22.delete('1.3','end')

text33.delete('1.3','end')

text44.delete('1.3','end')

def Cha_xun(event):

win=Tk()

win.minsize(160,120)

win.maxsize(160,120)

global text11,text22,text33,text44

win.wm_title("玖郎")

frame=LabelFrame(win,width=100,height=20,text="请输入姓名查找")

frame.pack()

text11=Text(win,width=20,height=1)

text11.insert(INSERT,"姓名:")

text11.pack()

text22=Text(win,width=20,height=1)

text22.insert(INSERT,"生日:")

text22.pack()

text33=Text(win,width=20,height=1)

text33.insert(INSERT,"电话:")

text33.pack()

text44=Text(win,width=20,height=1)

text44.insert(INSERT,"备注:")

text44.pack()

#按钮‘保存’

button=Button(win,text='查询',width=5,height=1)

button.bind('<Button-1>',getPerson)

button.pack(fill=X,expand=1,side=LEFT)

#按钮‘清除’

button1=Button(win,width=5,height=1,text='清除')

button1.bind('<Button-1>',Qchu)

button1.pack(fill=X,expand=1,side=RIGHT)

win.mainloop()

代码截图:

代码1

代码2

代码3

中途上车的朋友,请查看一下前边的文章。

Python 制作生日计时软件(3),编写新建界面

Python 制作生日计时软件(5),编写删除界面

新手上路请多多关照,喜欢的朋友可以点下关注,每天都有更新!

标签: #python窗口界面设计学生消息查询