37,720
社区成员
发帖
与我相关
我的任务
分享
# -*- coding: utf-8 -*-
import sqlite3 as lite
import wx,os,sys,string
import wx.lib.buttons
import wx.lib.buttons as buttons
from wxPython.wx import *
#界面############################主页############################################
class InFrame(wx.Frame):
def __init__(self, parent, id):
wx.Frame.__init__(self, parent, id,'人机交互检索界面',size=(800,740),pos=(200,1))
panel = wx.Panel(self)
menubar = wx.MenuBar(wx.MB_DOCKABLE)
file = wx.Menu()
manage=wx.MenuItem(file, 1, "&管理(M)\tCtrl+M")
quit = wx.MenuItem(file, 2, "&退出(Q)\tCtrl+Q")
file.AppendItem(manage)
file.AppendItem(quit)
self.Bind(wx.EVT_MENU, self.OnLoad, id=1)
self.Bind(wx.EVT_MENU, self.OnQuit, id=2)
menubar.Append(file, "&文件(F)")
help = wx.Menu()
helps=wx.MenuItem(help, 3, "&帮助(H)\tCtrl+H")
help.AppendItem(helps)
menubar.Append(help, "&帮助(H)")
self.SetMenuBar(menubar)
self.Centre()
self.Show(True)
#################下面Onload这个函数里添加密码输入对话框时候有问题###############################
def OnLoad(self, event):
#################为啥下一句有问题?#######################
wx.Dialog(parent, id, '管理员登陆')
self.ctrl_username = wx.TextCtrl(self, -1)
self.ctrl_passwd = wx.TextCtrl(self, -1,
style=wx.TE_PASSWORD)
self.ctrl_login = wx.Button(self, -1, '登陆')
self.ctrl_login.Bind(wx.EVT_BUTTON, self.OnDecide)
self.ctrl_login.SetDefault()
self.ctrl_cancel = wx.Button(self, wx.ID_CANCEL, '取消')
self._layout()
def OnDecide(self,event):
print "now"
print self.ctrl_username
print self.ctrl_passwd
if self.ctrl_username.GetValue()=='Ace' and self.ctrl_passwd.GetValue()=='1234':
print "ok"
else:
print "no"
def _layout(self):
sizer = wx.BoxSizer(wx.VERTICAL)
b = wx.StaticBoxSizer(wx.StaticBox(self, -1, '登陆'), wx.VERTICAL)
grid = wx.FlexGridSizer(2, 0, 3, 3)
grid.AddGrowableCol(1)
grid.Add(wx.StaticText(self, -1, '用户名:'))
grid.Add(self.ctrl_username, 0, wx.GROW)
grid.Add(wx.StaticText(self, -1, '密码:'))
grid.Add(self.ctrl_passwd, 0, wx.GROW)
b.Add(grid, 0, wx.GROW|wx.ALL, 3)
sizer.Add(b, 0, wx.GROW|wx.ALL, 3)
h = wx.BoxSizer(wx.HORIZONTAL)
h.Add(self.ctrl_login, 0, wx.ALL, 3)
h.Add(self.ctrl_cancel, 0, wx.ALL, 3)
h.Add((0, 0), 1)
sizer.Add(h, 0, wx.GROW)
self.SetAutoLayout(True)
self.SetSizerAndFit(sizer)
def OnQuit(self, event):
self.Close()
if __name__ == '__main__':
app = wx.PySimpleApp()
frame = InFrame(parent=None, id=-1)
frame.Show()
app.MainLoop()