0

I'm creating table with static text with a while loop, after that I want to set labels. I'm having problem with it, because it only works with the last one. Here is my code:

import wx

class Mainframe(wx.Frame):
    def __init__(self, parent):
        wx.Frame.__init__(self, parent)
        self.panel = wx.Panel(self)

        def test(self,n):
            while n <=5:
                a = wx.StaticText(self.panel, label='bad', id=n, pos=(20,30*n))
                n = n+1
            return a

        test(self,0)

        if test(self,0).GetId()==1:
            test(self,0).SetLabel('good')

        if test(self,0).GetId()==5:
            test(self,0).SetLabel('exelent')

if __name__=='__main__':
    app = wx.App(False)
    frame = Mainframe(None)
    frame.Show()
    app.MainLoop()
4

1 に答える 1