#!/usr/bin/python # -*- coding: cp1252 -*- # Module : Module3.py import wx import Module4 import Main from Module2 import * #------------------------------------------------------------------------- class InterfaceGraphique(wx.Panel): """Interface_Graphique de la fenêtre principale""" #------------------------------------------------------------------------- def __init__(self, parent): wx.Panel.__init__(self, parent, -1) # Initialise les différents Sizer vbox_top = wx.BoxSizer(wx.VERTICAL) vbox = wx.BoxSizer(wx.HORIZONTAL) #********************************************************* # Panel1 : The Map #********************************************************* # Create a panel to house everything self.panel1 = wx.Panel(self, -1) # Create vertical box sizer : bordure self.bordure1 = wx.BoxSizer(wx.VERTICAL) # Création du Widget wxStaticBox : 'Terrain de jeu' avec son Sizer self.staticBox1 = wx.StaticBox ( self.panel1, -1, 'Terrain de jeu' ) self.staticBoxSizer1 = wx.StaticBoxSizer ( box = self.staticBox1, orient=wx.VERTICAL ) #------------------------------------------------------------- # écran "Map_Terrain" #------------------------------------------------------------- self.sizer_Map = wx.BoxSizer(orient=wx.VERTICAL) # Création du panel "P_Map" self.P_Map = Interface_Map(self.panel1) self.sizer_Map.AddSizer(self.P_Map, 1, border=0, flag=wx.EXPAND) self.staticBoxSizer1.AddSizer(self.sizer_Map, 1, border=0, flag=wx.EXPAND) #----------------------------------------------------------- # Configure the box sizers du Panel1 self.bordure1.Add(self.staticBoxSizer1, 1, wx.EXPAND | wx.ALL, 5) # Attach everything self.panel1.SetSizerAndFit (self.bordure1) vbox.Add(self.panel1, 3, wx.EXPAND) #********************************************************* # Rendu final du sizer vbox_top.Add(vbox, 1, wx.EXPAND) self.SetSizer(vbox_top) #********************************************************* #------------------------------------------------------------------------- class Interface_Map(wx.ScrolledWindow): """Création de l'interface "Map Terrain""" #------------------------------------------------------------------------- def __init__(self, conteneur): wx.ScrolledWindow.__init__(self,parent = conteneur) # Initialisation self.InitMap() self.SetBackgroundColour(wx.Colour(255, 141, 14)) # Evenements self.image.Bind(wx.EVT_MOTION, self.OnMouseMove) #********************************************************* # Méthodes du panel: "Interface_Map" def Affiche(self, bmp, ratio): if self.bmp != None: posX, posY = self.GetViewStart() self.image.Destroy() self.SetScrollRate(0, 0) else: posX = 0 posY = 0 self.bmp = bmp self.SetVirtualSize(wx.Size(bmp.GetWidth(), bmp.GetHeight())) self.image = wx.StaticBitmap(self, -1, self.bmp) self.SetScrollRate((10*ratio)/100, (10*ratio)/100) self.Scroll(posX, posY) self.Refresh() def InitMap(self): # Map "Terrain de jeu" : self.bmp = None self.ratio = 100 self.bmpRESU = gloImg['imgORIG'].ConvertToBitmap() self.Affiche(self.bmpRESU, self.ratio) def OnMouseMove(self, event): event.Skip() pt = event.GetPositionTuple() wx.GetTopLevelParent(self).SetTitle('Sourie Coords = %s' % str(pt)) #-------------------------------------------------------------------------