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
| # -*- coding: cp1252 -*-
import wx
class MainFrame(wx.Frame):
def __init__(self):
wx.Frame.__init__(self, None, title="TestGBS",size=(800,600))
self.Maximize()
self.Center()#Centre la frame
# On crée un panel avec un Notebook dessus
p = wx.Panel(self)
nb = wx.Notebook(p)
# On met le tout dans un sizer
sizer = wx.BoxSizer()
sizer.Add(nb, 1, wx.EXPAND)
p.SetSizer(sizer)
page1=PageUn(nb)
nb.AddPage(page1, "PROBLEME DE GRID BAG SIZER >.<")
class PageUn(wx.Panel):
def __init__(self, parent):
global TapeMot,box1
wx.Panel.__init__(self, parent)
self.TapeMot = wx.TextCtrl(self, -1, "Entrez un mot",(5,5),size=(125, -1),style=wx.TE_PROCESS_ENTER)
self.Bind(wx.EVT_TEXT_ENTER,self.VerifMot,self.TapeMot)
txtMot = wx.StaticText(self, -1, "On affiche le mot tapé :")
box1 = wx.GridBagSizer(3,3) # Créer une box de 3lignes 3colonnes
box1.SetEmptyCellSize((20,20))
box1.Add(self.TapeMot,(0,0))
box1.Add(txtMot,(0,2))
box = wx.StaticBox(self, -1, "Gestion Menu des mots XD :")
sizer1 = wx.StaticBoxSizer(box, wx.HORIZONTAL)
sizer1.Add(box1, 1, wx.CENTRE|wx.ALL, 10)
#--------Ajustement des sizers----------
mainSizer = wx.BoxSizer(wx.VERTICAL)
mainSizer.Add(sizer1, 0,wx.ALL, 10)
self.SetSizer(mainSizer)
def VerifMot(self,event):
global TapeMot,box1
MotEntre = self.TapeMot.GetValue()
print MotEntre
box1.Add(wx.StaticText(self,-1,MotEntre),(2,2))#On place le mot entré sous "Entrez un mot"
if __name__ == "__main__":
app = wx.App()
frame = MainFrame() #Instanciation de la frame principale.
frame.Show(True)
app.MainLoop() #Fais tourner l'application. |
Partager