#!/usr/bin/env python # -*- coding: utf8 -*- # MonFichier.py # Import des modules import wx # Ce module utilise le nouvel espace de nom wx. #--------------------------------------------------------------------------- class MainWindow(wx.Frame): def __init__(self, parent, id, title): wx.Frame.__init__(self, parent, -1, title) # Crée le conteneur self.panel = wx.Panel(self, -1) # Affiche les textes self.txt1 = wx.StaticText(self.panel, -1, "texte numero 1") self.txt2 = wx.StaticText(self.panel, -1, "texte numero 2") # Crée une BoxSizer VERTICALE qui englobe les 2 StaticText sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(self.txt1, 0, wx.ALL | wx.CENTRE, 40) sizer.Add(self.txt2, 0, wx.ALL | wx.CENTRE, 40) self.panel.SetAutoLayout(True) self.panel.SetSizer(sizer) sizer.Fit(self.panel) # Centre et affiche la fenêtre self.Centre(wx.BOTH) self.Show(True) #--------------------------------------------------------------------------- # Toutes les applications wxWindows doivent avoir une classe dérivée de wxApp app = wx.App() # Crée une instance de la classe MainWindow frame = MainWindow(None, wx.ID_ANY, 'test 0004 deux StaticText') # Démarrage du gestionnaire d'événements (boucle principale) app.MainLoop()