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 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163
|
# -*- coding: iso8859-15 -*-
import wx, os, sys, time, winsound
i=0
tempsBlack=6300
tempsBlanc=6300
#des constantes qui ne sont pas encore toutes utilisées
ID_START = 101
ID_TOUTSTOPER = 102
touchef8 = wx.WXK_F8 # la bascule
def play(n):
# winsound.PlaySound(n+'.wav', winsound.SND_NODEFAULT)
winsound.PlaySound(n, winsound.SND_FILENAME|winsound.SND_NOWAIT,)
play("notification")
class MainApp(wx.App):
def OnInit(self):
frame = MainWindow('MonChrono')
self.SetTopWindow(frame)
return True
class MainWindow(wx.Frame):
def __init__(self, title):
wx.Frame.__init__(self, None, wx.ID_ANY, title, size = (400, 600))
self.control = wx.TextCtrl(self, style=wx.TE_MULTILINE)
self.dirname=''
#self.control = wx.TextCtrl(self, 1, style=wx.TE_MULTILINE)
self.CreateStatusBar()
self.Show(True)
self.panel = wx.Panel(self, -1)
sizer = wx.BoxSizer(wx.HORIZONTAL)
self.MSGwhite = wx.StaticText(self.panel, 1100, "Les Blancs")
sizer.Add(self.MSGwhite, flag=wx.ALIGN_CENTER|wx.ALL, border=10)
self.panel.SetSizerAndFit(sizer)
self.Fit()
self.white = wx.StaticText(self.panel, 1200, u'00:00:00')
sizer.Add(self.white, flag=wx.ALIGN_CENTER|wx.ALL, border=20)
self.panel.SetSizerAndFit(sizer)
self.Fit()
self.MSGblack = wx.StaticText(self.panel, 1101, "Les Noirs")
sizer.Add(self.MSGblack, flag=wx.ALIGN_CENTER|wx.ALL, border=15)
self.panel.SetSizerAndFit(sizer)
self.Fit()
self.black = wx.StaticText(self.panel, 1201, u'00:00:00')
sizer.Add(self.black, flag=wx.ALIGN_CENTER|wx.ALL, border=30)
self.panel.SetSizerAndFit(sizer)
self.Fit()
# évènements
self.Bind(wx.EVT_TIMER, self.label)
menuFichier = wx.Menu()
menuFichier.Append(wx.ID_EXIT, "&Quitter\tCTRL+q")
menuJouer = wx.Menu()
menuJouer.Append(ID_START, "&Demarrer\tf8")
menuJouer.Append(ID_TOUTSTOPER , "&stop\tf5")
menuBarre = wx.MenuBar()
menuBarre.Append(menuFichier, "&Fichier")
menuBarre.Append(menuJouer, "&Jouer")
self.SetMenuBar(menuBarre)
wx.EVT_MENU(self, ID_TOUTSTOPER, self.stop)
wx.EVT_MENU(self, ID_START, self.depart)
wx.EVT_MENU(self, wx.ID_EXIT, self.OnExit)
# Chrono
self.spend_time = 0
self.timer = wx.Timer(self)
def label (self, event):
global i
global tempsBlack
global tempsBlanc
if i %2 == 0:
tempsBlack-=1
temps = tempsBlack
# ---------------------------------- Calculs
heure = temps / 3600
temps = temps - (heure * 3600)
minute = temps / 60
temps = temps - (minute * 60)
seconde = temps
self.black.SetLabel(str(heure).zfill(2) + ':' + str(minute).zfill(2) + ':' + str(seconde).zfill(2))
elif i % 2 != 0:
tempsBlanc-=1
temps = tempsBlanc
# ---------------------------------- Calculs
heure = temps / 3600
temps = temps - (heure * 3600)
minute = temps / 60
temps = temps - (minute * 60)
seconde = temps
self.white.SetLabel(str(heure).zfill(2) + ':' + str(minute).zfill(2) + ':' + str(seconde).zfill(2))
self.SetClientSize(self.panel.GetBestSize())
def OnExit(self, evt):
# play ('Quitter')
self.Destroy()
def depart(self, event):
global i
if touchef8:
if i %2 == 0:
# self.white
self.timer.Stop()
self.timer.Start(1000)
play("notification")
elif i % 2 != 0:
self.timer.Stop()
play("sonnerie")
# self.black
self.timer.Start(1000)
i+=1
def stop(self, event):
self.timer.Stop ()
if __name__ == "__main__":
app = MainApp()
app.MainLoop()
app.MainLoop() |
Partager