切换风格

Wizard Sky California Sunset glow Black Cloud Beige Dragon Lavender NewYear City Snow Flowers London
收藏本站XSS平台字符串转换jsfuck
wxpython数据库值显示grid[复制链接]
发表于 2015-3-12 22:26:01 | 显示全部楼层 |!read_mode!
求教怎么样让数据库查询出来的值,做成一个表格显示出来???前面都看grid,完全看懵了,求大神给意见

#!/bin/env python
# -*- coding: utf-8 -*- 

#################################################################################
#程序测试
#################################################################################
import wx
import pymongo

class MyFrame(wx.Frame):
	def __init__(self):
		win = wx.Frame.__init__(self, parent=None,title="reger",pos = (100,100), size=(500,450))
		panel1 = wx.Panel(self,-1)
		#定义变量
		self.conn = pymongo.Connection('127.0.0.1',27017)
		self.sampleList1 = ['中国', '美国', '韩国', '英国', '澳大利亚', '备注']
		self.sampleList2 = ['昵称', '姓名', 'IP', '邮箱', '电话', '地址','生日','注册地址']
		
		#添加组件
		self.searchCtl = wx.TextCtrl(panel1)
		self.Button1 = wx.Button(panel1,label = 'Search')
		self.xianshi = wx.TextCtrl(panel1,style = wx.TE_MULTILINE|wx.HSCROLL)
		self.choice3 = wx.Choice(panel1, -1, (90, 198), choices=self.sampleList1)
		self.choice3.SetSelection(0) 
		self.choice4 = wx.Choice(panel1, -1, (90, 198), choices=self.sampleList2)
		self.choice4.SetSelection(3) 
		
		#设置搜索模块,控件按照先后顺序排列,flag设置拉伸的时候扩展
		hbox = wx.BoxSizer()
		hbox.Add(self.choice3,proportion = 0,flag = wx.LEFT,border = 5)
		hbox.Add(self.choice4,proportion = 0,flag = wx.LEFT,border = 5)
		hbox.Add(self.searchCtl,proportion = 1,flag = wx.EXPAND)
		hbox.Add(self.Button1,proportion = 0,flag = wx.LEFT,border = 5)
		

		bbox = wx.BoxSizer(wx.VERTICAL)
		bbox.Add(hbox,proportion = 0,flag = wx.EXPAND|wx.ALL,border = 5)
		bbox.Add(self.xianshi,proportion = 1,flag = wx.EXPAND|wx.LEFT|wx.RIGHT|wx.BOTTOM,border = 5)
		

		panel1.SetSizer(bbox)
		
		'''
		self.searchCtl = wx.TextCtrl(panel1,pos = (150,5),size = (240,25))
		self.Button1 = wx.Button(panel1,label = 'Search',pos = (395,5),size = (80,25))
		self.searchCtl = wx.TextCtrl(panel1,pos = (5,35),size = (480,380),style = wx.TE_MULTILINE|wx.HSCROLL)
		'''
		
		#控件事件绑定
		self.Button1.Bind(wx.EVT_BUTTON,self.Onsearch)
		

	#定义事件
	def Onsearch(self, event):
		content1 = self.choice3.GetStringSelection()
		content2 = self.choice4.GetStringSelection()
		content3 = self.searchCtl.GetValue()
		self.db = self.conn.foorbar
		self.select("name",content3)
		
	def select(self,con1,con2):
		self.db.authenticate("wufeng","123")
		query = {con1:{"$regex":con2,"$options":"i"}}
		oed = self.db.user.find(query)  #OED是数据库查询出来的值,类型是数组{"age":12,"name":"li11","sex":1}

		


		
		

 

#################################################################################
if __name__ == '__main__':
    app = wx.App()
    frame = MyFrame()
    frame.Show(True)
    app.MainLoop()
#################################################################################


代码区

GMT+8, 2019-10-17 08:29

Powered by Discuz! X2

© 2001-2018 Comsenz Inc.

回顶部