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
| ##!/usr/bin/env python
# -*- coding:utf-8 -*-
import gtk
import time
import pango
def main():
mainWindow = gtk.Window(gtk.WINDOW_TOPLEVEL)
mainWindow.set_title("Chrono Entraînement")
mainWindow.set_position(gtk.WIN_POS_CENTER)
mainWindow.connect("destroy", on_mainWindow_destroy)
mainBox = gtk.VBox(False, 0)
setBox = gtk.VBox(False, 0)
setBoxLabelEntry = gtk.HBox(False, 0)
setBoxProgressbar = gtk.HBox(False, 0)
separatorBox = gtk.HBox(False, 0)
timeBox = gtk.VBox(False, 0)
timeBoxLabelEntry = gtk.HBox(False, 0)
timeBoxButtonLabel = gtk.HBox(False, 0)
timeBoxProgressbar = gtk.HBox(False, 0)
mainWindow.add(mainBox)
mainBox.pack_start(setBox, False, False, 0)
mainBox.pack_start(separatorBox, False, False, 20)
mainBox.pack_start(timeBox, False, False, 0)
setBox.pack_start(setBoxLabelEntry, False, False, 0)
setBox.pack_start(setBoxProgressbar, False, False, 0)
timeBox.pack_start(timeBoxLabelEntry, False, False, 0)
timeBox.pack_start(timeBoxButtonLabel, False, False, 0)
timeBox.pack_start(timeBoxProgressbar, False, False, 0)
labelNbSet = gtk.Label("Nombre de séries :")
setBoxLabelEntry.pack_start(labelNbSet, False, False, 0)
entryNbSet = gtk.Entry()
setBoxLabelEntry.pack_start(entryNbSet, False, False, 0)
progressbarNbSet = gtk.ProgressBar()
progressbarNbSet.set_size_request(400,30)
setBoxProgressbar.pack_start(progressbarNbSet, False, False, 0)
separatorSetTime = gtk.HSeparator()
separatorBox.pack_start(separatorSetTime, True, True, 0)
labelTime = gtk.Label("Temps en seconde :")
timeBoxLabelEntry.pack_start(labelTime, False, False, 0)
entryTime = gtk.Entry()
timeBoxLabelEntry.pack_start(entryTime, False, False, 0)
buttonStart = gtk.Button("Start")
buttonStart.set_size_request(75,50)
buttonStart.set_alignment(0.5,0.5)
timeBoxButtonLabel.pack_start(buttonStart, False, False, 0)
labelChrono = gtk.Label("5") #label que je veux mettre à jours toute les secondes
attr = pango.AttrList()
size = pango.AttrSize(72000, 0, -1)
weight = pango.AttrWeight(700, 0, -1)
attr.insert(size)
attr.insert(weight)
labelChrono.set_attributes(attr)
labelChrono.set_size_request(300,100)
timeBoxButtonLabel.pack_start(labelChrono, False, False, 0)
progressbarChrono = gtk.ProgressBar()
progressbarChrono.set_size_request(400,30)
timeBoxProgressbar.pack_start(progressbarChrono, False, False, 0)
buttonStart.connect("clicked", on_buttonStart_clicked,labelChrono) #connexion du bouton start
mainWindow.show_all()
gtk.main()
return 0
def on_mainWindow_destroy(widget):
gtk.main_quit()
def on_buttonStart_clicked(buttonStart,labelChrono): #fonction qui effectue le compte à rebours
t=5
while (t > 0):
time.sleep(1)
t = t-1
labelChrono.set_text("%s" % str(t))
while gtk.events_pending():
gtk.main_iteration_do(False)
if __name__ == "__main__":
main() |
Partager