wxPython StaticText,TypeError:需要字符串或Unicode类型

2024-09-20 03:48:02 发布

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

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()

我有这门课,我知道现在一切都正常了。finalMester1可以被所有类和/或函数访问。在

问题是StaticText面板不接受它们作为字符串的参数。它返回TypeError:String或Unicode类型是必需的。。。有办法吗?在


Tags: posselfinitdefargskwargsclasswx
1条回答
网友
1楼 · 发布于 2024-09-20 03:48:02

也许在打印错误的参数之前添加str()?在

st1 = wx.StaticText(panel, -1, str(finalSemester[0]),pos =(10,20))

如果这不是你要找的,那我需要更多的信息。在

相关问题 更多 >