wxPython弹出窗口,在范围内时列表超出范围

2024-09-20 03:41:38 发布

您现在位置:Python中文网/ 问答频道 /正文

我在这里开了一个快速的课堂wx.PopupWindow窗口从wx.框架WX按钮

班级:

class popupInfo(wx.PopupWindow):
    def __init__(self, *args, **kwargs):

        wx.PopupWindow.__init__(self, *args, **kwargs)

        panel = wx.Panel(self)
        self.panel = panel
        panel.SetBackgroundColour("GREY")

        st1 = wx.StaticText(panel, -1, finalSemester[0],pos =(10,20))
        st2 = wx.StaticText(panel, -1, finalSemester[1],pos =(10,40))
        st3 = wx.StaticText(panel, -1, finalSemester[2],pos =(10,60))
        st4 = wx.StaticText(panel, -1, finalSemester[3],pos =(10,80))
        st5 = wx.StaticText(panel, -1, finalSemester[4],pos =(10,100))
        st6 = wx.StaticText(panel, -1, finalSemester[5],pos =(10,120))
        st7 = wx.StaticText(panel, -1, finalSemester[6],pos =(10,140))
        st8 = wx.StaticText(panel, -1, finalSemester[7],pos =(10,160))

        self.SetSize((400, 400))
        panel.SetSize((400, 400))

        self.Centre()

当我的所有索引列表在任何类之外声明时,代码返回它们超出范围。为什么会这样?你知道吗


Tags: posself框架initargs按钮kwargswx
1条回答
网友
1楼 · 发布于 2024-09-20 03:41:38

如果finalsemeter数组超出了函数的作用域,python希望您正在创建一个本地数组,而不能以这种方式添加元素。你知道吗

您可以使用全局,但最好只是传递数组 作为初始值设定项的参数。你知道吗

相关问题 更多 >