开发者社区> 问答> 正文

wxpython绑定事件弹错,python 报错

import wx
import gui

app = wx.App()
win = gui.login(None)
win.Show(True)
app.MainLoop()

# -*- coding: utf-8 -*- 

###########################################################################
## Python code generated with wxFormBuilder (version Feb 26 2014)
## http://www.wxformbuilder.org/
##
## PLEASE DO "NOT" EDIT THIS FILE!
###########################################################################

import wx
import wx.xrc

###########################################################################
## Class doctor1
###########################################################################

class doctor1 ( wx.Frame ):
	
	def __init__( self, parent ):
		wx.Frame.__init__ ( self, parent, id = wx.ID_ANY, title = u"医院电子病历信息系统", pos = wx.DefaultPosition, size = wx.Size( 1280,720 ), style = wx.DEFAULT_FRAME_STYLE|wx.TAB_TRAVERSAL )
		
		self.SetSizeHintsSz( wx.Size( 800,600 ), wx.Size( 1920,1080 ) )
		
		bSizer1 = wx.BoxSizer( wx.VERTICAL )
		
		bSizer1.SetMinSize( wx.Size( 800,600 ) ) 
		self.m_button5 = wx.Button( self, wx.ID_ANY, u"MyButton", wx.DefaultPosition, wx.DefaultSize, 0 )
		bSizer1.Add( self.m_button5, 0, 0, 5 )
		
		self.m_button6 = wx.Button( self, wx.ID_ANY, u"MyButton", wx.DefaultPosition, wx.DefaultSize, 0 )
		bSizer1.Add( self.m_button6, 0, 0, 5 )
		
		
		self.SetSizer( bSizer1 )
		self.Layout()
		
		self.Centre( wx.BOTH )
	
	def __del__( self ):
		pass

展开
收起
python小菜菜 2020-05-27 14:48:29 672 0
1 条回答
写回答
取消 提交回答
  • "

    test的代码有问题,因为test是在login类中,所以调用类属性时,直接使用self调用,详细修改如下:

    # Virtual event handlers, overide them in your derived class
    def test( self, event ):
        uid=self.userid.GetValue()
        upwd=self.userpwd.GetValue()
        if uid=='123' and upwd=='321':
            print 'True'
    如果想点这个按钮之后弹出另外1个窗口,并且原来的窗口自动关闭怎么弄?

    一样采用事件驱动,点击该按钮时运行另外一个GUI界面的代码,同时关闭当前界面

    ######非常感谢大神指点" ![image.png](https://ucc.alicdn.com/pic/developer-ecology/f0b4620ef153462cb4b54eee845049fe.png)
    2020-05-27 15:37:34
    赞同 展开评论 打赏
问答分类:
问答标签:
问答地址:
问答排行榜
最热
最新

相关电子书

更多
From Python Scikit-Learn to Sc 立即下载
Data Pre-Processing in Python: 立即下载
双剑合璧-Python和大数据计算平台的结合 立即下载