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 73 74 75 76 77 78 79 80 81 82 83 84 85 86
| # -*- coding: cp1252 -*-
import wx
from os import getcwd
#Vars#
ImgDir = (getcwd()+"\\ImgPays\\")#Chemin du dossier des images de pays
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,MotModif,gbox2
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é :")
MotModif = wx.StaticText(self,-1,"")
#-----Menu Geoloc------------
SiteGeo = wx.StaticText(self, -1, "Situation géographique :")
SiteGeo.SetFont(wx.Font(12, wx.DEFAULT , wx.NORMAL, wx.BOLD,False, "Tahoma" ));
#GridBagSizer 1#
gbox1 = wx.GridBagSizer(10,10) # Créer une box de 3lignes 3colonnes
gbox1.SetEmptyCellSize((20,20))
gbox1.Add(self.TapeMot,(0,0))
gbox1.Add(txtMot,(0,2))
gbox1.Add(MotModif,(2,2))
#GridBagSizer2#
gbox2 = wx.GridBagSizer(10,10) # Créer une box de 3lignes 3colonnes
gbox2.SetEmptyCellSize((20,20))
gbox2.Add(SiteGeo,(0,0))
box = wx.StaticBox(self, -1, "Gestion Menu des mots XD :")
bsizer1 = wx.StaticBoxSizer(box, wx.HORIZONTAL)
sizerH1 = wx.BoxSizer(wx.VERTICAL)
sizerH1.Add(gbox1, 0, wx.CENTRE|wx.ALL, 10)
bsizer1.Add(sizerH1, 1, wx.EXPAND, 0)
box2 = wx.StaticBox(self, -1, "Afffichage image :")
bsizer2 = wx.StaticBoxSizer(box2,wx.HORIZONTAL)
sizerH2 = wx.BoxSizer(wx.VERTICAL)
sizerH2.Add(gbox2, 0, wx.CENTRE|wx.ALL, 10)
bsizer2.Add(sizerH2, 1, wx.EXPAND, 0)
#--------Ajustement des sizers----------
mainSizer = wx.BoxSizer(wx.HORIZONTAL)
mainSizer.Add(bsizer1, 0,wx.ALL, 10)
mainSizer.Add(bsizer2, 1,wx.ALL, 10)
self.SetSizer(mainSizer)
def VerifMot(self,event):
global TapeMot,MotModif
MotModif.SetFont(wx.Font(12, wx.DEFAULT , wx.NORMAL, wx.BOLD,False, "Tahoma" ))
MotModif.SetLabel(str(self.TapeMot.GetValue()))
#image#
imgPays = ImgDir+str(self.TapeMot.GetValue())+".png"
bmpPays = wx.Image(imgPays, wx.BITMAP_TYPE_ANY).ConvertToBitmap()
bitmap1 = wx.StaticBitmap(self, -1, bmpPays)
#Fin#
gbox2.Add(bitmap1,(1,0))
#print type(MotModif)
self.Layout()
if __name__ == "__main__":
app = wx.App()
frame = MainFrame() #Instanciation de la frame principale.
frame.Show(True)
app.MainLoop() #Fais tourner l'application. |
Partager