1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
| import wx
class mainframe(wx.Frame):
def __init__(self, *args, **kwds):
kwds["style"] = wx.DEFAULT_FRAME_STYLE
wx.Frame.__init__(self, *args, **kwds)
self.toolbook_1 = wx.Toolbook(self, -1, style=wx.BK_TOP)
self.Maximize()
self.Centre()
self.liste_1 = ['1', '2', '3']
self.makepanel1()
self.panel2 = wx.Panel(self.toolbook_1, -1, style=wx.RAISED_BORDER)
self.titre2 = wx.StaticBox(self.panel2, label=u"panel2")
self.sizer_2 = wx.StaticBoxSizer(self.titre2, wx.HORIZONTAL)
self.panel2.SetSizer(self.sizer_2)
self.sizer_2.Fit(self.panel1)
il = wx.ImageList(64, 64)
index2 = il.Add(wx.Image("1.png", wx.BITMAP_TYPE_PNG).ConvertToBitmap())
index1 = il.Add(wx.Image("1.png", wx.BITMAP_TYPE_PNG).ConvertToBitmap())
self.toolbook_1.AssignImageList(il)
self.toolbook_1.AddPage(self.panel1, "1", imageId=index2)
self.toolbook_1.AddPage(self.panel2, "2", imageId=index1)
self.ProcessEvent(wx.SizeEvent((-1,-1)))
self.Layout()
def makepanel1(self):
liste_str = "".join(self.liste_1)
self.panel1 = wx.Panel(self.toolbook_1, -1, style=wx.RAISED_BORDER)
self.titre1 = wx.StaticBox(self.panel1, label=u"panel1")
self.sizer_1 = wx.StaticBoxSizer(self.titre1, wx.HORIZONTAL)
self.tc1 = wx.TextCtrl(self.panel1, -1, liste_str, pos=wx.DefaultPosition, size=wx.DefaultSize)
bouton_add = wx.Button(self.panel1, -1, "APPEND LISTE", pos=(50,50))
bouton_refresh = wx.Button(self.panel1, -1, "REFRESH TEXTCTRL", pos=(100,100))
bouton_add.Bind(wx.EVT_BUTTON, self.AppendListe, bouton_add)
bouton_refresh.Bind(wx.EVT_BUTTON, self.RefreshListe, bouton_refresh)
self.sizer_1.Add(self.tc1)
self.panel1.SetSizer(self.sizer_1)
self.sizer_1.Fit(self.panel1)
def AppendListe(self, event):
self.liste_1.append("pwet")
print self.liste_1
def RefreshListe(self, event):
# u = self.panel1.GetSize()
self.panel1.Destroy()
self.makepanel1()
self.SendSizeEvent()
if __name__ == "__main__":
app = wx.PySimpleApp(0)
wx.InitAllImageHandlers()
frame_2 = mainframe(None, -1, "")
app.SetTopWindow(frame_2)
frame_2.Show()
app.MainLoop() |
Partager