| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2310 人关注过本帖
标题:照书敲的BoxSizer代码不知道怎么报错了
取消只看楼主 加入收藏
asd117118
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2020-2-25
收藏
 问题点数:0 回复次数:1 
照书敲的BoxSizer代码不知道怎么报错了
import wx
class MyFrame(wx.Frame):
    def __init__(self,parent,id):
        wx.Frame.__init__(self,parent,id,"用户登录",size=(400,300))
        #创建面板
        panel = wx.Panel(self)
        #创建确定和取消按钮,并绑定事件
        self.bt_confirm = wx.Button(panel,label="确定")
        self.bt_cancel = wx.Button(panel,label="取消")
        #创建文本,左对齐
        self.title = wx.StaticText(panel,label="请输入用户名和密码")
        self.label_user = wx.StaticText(panel,label="用户名")
        self.text_user = wx.TextCtrl(panel,style=wx.TE_LEFT)
        self.label_pwd = wx.StaticText(panel,label="密    码")
        self.text_password = wx.TextCtrl(panel,style=wx.TE_PASSWORD)
        #添加容器,容器中控件横向排列
        hsizer_user = wx.BoxSizer(wx.HORIZONTAL)
        hsizer_user.Add(self.label_user,proportion=0,flag=wx.ALL,boder=5)
        hsizer_user.Add(self.text_user,proportion=0,flag=wx.ALL,border=5)
        hsizer_pwd = wx.BoxSizer(wx.HORIZONTAL)
        hsizer_pwd.Add(self.label_pwd,proportion=0,flag=wx.ALL,border=5)
        hsizer_pwd.Add(self.text_password,proportion=wx.ALL,border=5)
        hsizer_button = wx.BoxSizer(wx.HORIZONTAL)
        hsizer_button.Add(self.bt_confirm,proportion=0,flag=wx.ALIGN_CENTER,border=5)
        hsizer_button.Add(self.bt_cancel,proportion=0,flag=wx.ALIGN_CENTER,border=5)
        #添加容器,容器中控件纵向排列
        vsizer_all = wx.BoxSizer(wx.VERTICAL)
        vsizer_all.Add(self.title,proportion=0,flag=wx.EXPAND|wx.LEFT|wx.RIGHT,border=15)
        vsizer_all.Add(hsizer_user,proportion=0,flag=wx.EXPAND|wx.LEFT|wx.RIGHT,border=45)
        vsizer_all.Add(hsizer_pwd,proportion=0,flag=wx.EXPAND|wx.LEFT|wx.RIGHT,border=45)
        vsizer_all.Add(hsizer_button,proportion=0,flag=wx.ALIGN_CENTER|wx.TOP,border=15)
        panel.SetSizer(vsizer_all)

if __name__=='__main__':
    app = wx.App()
    frame = MyFrame(parent=None,id=-1)
    frame.Show()
    app.MainLoop()




报错内容:
Traceback (most recent call last):
  File "D:/零基础学python/WXTEST/BoxSizer登陆界面.py", line 36, in <module>
    frame = MyFrame(parent=None,id=-1)
  File "D:/零基础学python/WXTEST/BoxSizer登陆界面.py", line 18, in __init__
    hsizer_user.Add(self.label_user,proportion=0,flag=wx.ALL,boder=5)
TypeError: Sizer.Add(): arguments did not match any overloaded call:
  overload 1: 'proportion' is not a valid keyword argument
  overload 2: 'boder' is not a valid keyword argument
  overload 3: argument 1 has unexpected type 'StaticText'
  overload 4: argument 1 has unexpected type 'StaticText'
  overload 5: argument 1 has unexpected type 'StaticText'
  overload 6: argument 1 has unexpected type 'StaticText'
  overload 7: argument 1 has unexpected type 'StaticText'
  overload 8: argument 1 has unexpected type 'StaticText'
  overload 9: argument 1 has unexpected type 'StaticText'




这是书中关于BoxSizer的第二个实例,我第一个运行的正常,第二个不知道怎么报错
搜索更多相关主题的帖子: panel flag argument border Add 
2020-02-25 09:39
asd117118
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2020-2-25
收藏
得分:0 
刚对照书又查了一遍 hsizer_user.Add(self.label_user,proportion=0,flag=wx.ALL,boder=5),最右边的boder打错了,正确的是border,唉找出错误好难,竟然是输入错误
2020-02-25 10:14
快速回复:照书敲的BoxSizer代码不知道怎么报错了
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.036509 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved