1

我通常可以通过搜索解决我自己的所有问题,但这让我很难过。我只是想制作一个用于登录网站的 GUI,但在使用 wxFormBuilder 时遇到了麻烦。

GUI 在构建器中看起来非常好,但是当我执行时,我在 Python 中出现错误代码 139 错误退出。所以我启动了调试器,这行有问题:

self.m_staticText3 = wx.StaticText( sbSizer1.GetStaticBox(), wx.ID_ANY, u"Username:", wx.DefaultPosition, wx.DefaultSize, 0 )

跟着它进入wx框架的深处,在_controls.py,StaticText类

_controls_.StaticText_swiginit(self,_controls_.new_StaticText(*args, **kwargs))

这是类的全部代码

import wx 
class Login ( wx.Dialog ):

def __init__( self, parent ):
    wx.Dialog.__init__ ( self, parent, id = wx.ID_ANY, title = u"Login", pos = wx.DefaultPosition, size = wx.Size( 261,163 ), style = wx.DEFAULT_DIALOG_STYLE )

    self.SetSizeHintsSz( wx.DefaultSize, wx.DefaultSize )

    sbSizer1 = wx.StaticBoxSizer( wx.StaticBox( self, wx.ID_ANY, u"Login" ), wx.VERTICAL )

    bSizer5 = wx.BoxSizer( wx.HORIZONTAL )

    self.m_staticText3 = wx.StaticText( sbSizer1.GetStaticBox(), wx.ID_ANY, u"Username:", wx.DefaultPosition, wx.DefaultSize, 0 )
    self.m_staticText3.Wrap( -1 )
    bSizer5.Add( self.m_staticText3, 0, wx.LEFT|wx.TOP, 5 )

    self.m_txtUser = wx.TextCtrl( sbSizer1.GetStaticBox(), wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.Size( 150,-1 ), wx.TE_CENTRE )
    bSizer5.Add( self.m_txtUser, 0, wx.LEFT, 20 )


    sbSizer1.Add( bSizer5, 0, wx.EXPAND, 5 )

    bSizer6 = wx.BoxSizer( wx.HORIZONTAL )

    self.m_staticText4 = wx.StaticText( sbSizer1.GetStaticBox(), wx.ID_ANY, u"Password:", wx.DefaultPosition, wx.DefaultSize, 0 )
    self.m_staticText4.Wrap( -1 )
    bSizer6.Add( self.m_staticText4, 0, wx.ALL, 5 )

    self.m_txtPass = wx.TextCtrl( sbSizer1.GetStaticBox(), wx.ID_ANY, wx.EmptyString, wx.Point( -1,-1 ), wx.Size( 150,-1 ), wx.TE_CENTRE )
    bSizer6.Add( self.m_txtPass, 0, wx.LEFT, 20 )


    sbSizer1.Add( bSizer6, 0, wx.EXPAND, 5 )

    bSizer7 = wx.BoxSizer( wx.VERTICAL )

    self.m_butLogin = wx.Button( sbSizer1.GetStaticBox(), wx.ID_ANY, u"Proceed to ", wx.DefaultPosition, wx.DefaultSize, 0 )
    bSizer7.Add( self.m_butLogin, 0, wx.ALL|wx.EXPAND, 5 )


    sbSizer1.Add( bSizer7, 0, wx.EXPAND, 5 )

    bSizer8 = wx.BoxSizer( wx.VERTICAL )

    self.m_lblStatus = wx.StaticText( sbSizer1.GetStaticBox(), wx.ID_ANY, u"Idle...", wx.DefaultPosition, wx.Size( -1,-1 ), wx.ALIGN_CENTRE|wx.RAISED_BORDER )
    self.m_lblStatus.Wrap( 0 )
    self.m_lblStatus.SetFont( wx.Font( 10, 74, 93, 92, False, "Sans" ) )

    bSizer8.Add( self.m_lblStatus, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.LEFT|wx.TOP, 5 )


    sbSizer1.Add( bSizer8, 1, wx.EXPAND, 5 )


    self.SetSizer( sbSizer1 )
    self.Layout()

    self.Centre( wx.BOTH )

    # Connect Events
    self.m_butLogin.Bind( wx.EVT_BUTTON, self.m_butLoginOnButtonClick )

def __del__( self ):
    pass


# Virtual event handlers, overide them in your derived class
def m_butLoginOnButtonClick( self, event ):
    event.Skip()

格拉西亚斯!!

4

1 回答 1

0

只是更新。我使用 3.6.2。在 wxStaticBox 的属性中添加字段“parent” - 只是未选中。

于 2018-02-28T05:35:09.527 回答