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
| #!/usr/bin/python
# *- coding: iso-8859-1 -*
import wx
import winsound
from random import randrange
ID_PARENT = 1000
class LesMenus(wx.Frame):
def __init__(self, titre):
wx.Frame.__init__(self, None, ID_PARENT, title = titre, size = (800, 600))
self.panel = wx.Panel(self, -1, pos=(10,50),size=(300,400))
self.panel.SetBackgroundColour('black')
menuFichier = wx.Menu(style = wx.MENU_TEAROFF)
menuFichier.Append(wx.ID_EXIT, "&Quitter\tCTRL+q")
menuAide = wx.Menu(style = wx.MENU_TEAROFF)
menuAide.Append(wx.ID_ABOUT, "&A propos ...\tCTRL+N")
menuBarre = wx.MenuBar()
menuBarre.Append(menuFichier, "&Fichier")
menuBarre.Append(menuAide, "&Aide")
self.SetMenuBar(menuBarre)
bouton1 = wx.Button(self.panel, -1, "Jeu1", pos=(400, 200))
boutonExit = wx.Button(self.panel, -1, "Quitter", pos=(400, 400))
wx.EVT_MENU(self, wx.ID_EXIT, self.OnExit)
wx.EVT_MENU(self, wx.ID_ABOUT, self.OnAbout)
self.Bind(wx.EVT_BUTTON, self.OnExit, boutonExit)
self.Bind(wx.EVT_BUTTON, self.Jeu1, bouton1)
def OnExit(self, evt):
#play('fermeture')
self.Destroy()
def OnAbout(self, evt):
d = wx.MessageDialog(self, "Exemple d'un jeu en langage Python", "A propos : Jeu 01, Septembre 2007, ", wx.OK)
d.ShowModal()
d.Destroy()
def Jeu1(self,evt):
x = randrange(99)
d = wx.MessageDialog(self, "le chiffre tiré est: " +str (x), "Affichage du chiffre ", wx.OK)
d.ShowModal()
d.Destroy()
class MonApp(wx.App):
def OnInit(self):
fen = LesMenus("V E 9 L O S")
fen.Show(True)
self.SetTopWindow(fen)
return True
app = MonApp()
app.MainLoop() |
Partager