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
#!/usr/bin/env python

import pygtk
pygtk.require('2.0')
import gtk
from Time_Calculation import *
from gobject import *

class EggTimer:

    # Method to prepare the timer
    def prepare_timer(self, widget, spin1, spin2, spin3):
        self.rSeconds = spin1.get_value_as_int()
        self.rMinutes = spin2.get_value_as_int()
        self.rHours = spin3.get_value_as_int()
        self.timer = eggTimer(self.rHours,self.rMinutes, self.rSeconds,"Title", "Text")
        self.timer.prepare()

    # Check how timer progressed
    def check_timer(self):
        self.timer.update_progress()
        if self.timer.finished == False:
            return True
        elif self.timer.finished == True:
            return False

    def do_nothing(self):
        return True

    # Do interval checks of the timer
    def timed_check(self, widget):
        self.check_timing = gobject.timeout_add(500, self.do_nothing())

    def __init__(self):
        # The main window
        window = gtk.Window(gtk.WINDOW_TOPLEVEL)
        window.connect("destroy", lambda w: gtk.main_quit())
        window.set_title("Timer settings")

        # Vbox to put all the stuff in
        main_vbox = gtk.VBox(False, 5)
        main_vbox.set_border_width(5)
        window.add(main_vbox)

        # Create a frame and pack it into the box
        frame = gtk.Frame("Remind in ...")
        main_vbox.pack_start(frame, True, True, 0)

        # Create a second box
        vbox = gtk.VBox(False, 0)
        vbox.set_border_width(5)
        frame.add(vbox)

        # Day, month, year spinners
        hbox = gtk.HBox(False, 0)
        vbox.pack_start(hbox, True, True, 5)

        vbox2 = gtk.VBox(False, 0)
        hbox.pack_start(vbox2, True, True, 5)

        # label = simple text-output
        label = gtk.Label("Hours:")
        label.set_alignment(0, 0.5)
        vbox2.pack_start(label, False, True, 0)

        #  (value=0, lower=0, upper=0, step_incr=0, page_incr=0, page_size=0)
        adj = gtk.Adjustment(0, 0, 24, 1.0, 5.0, 0.0)
        # (adjustment=None, climb_rate=0.0, digits=0)
        # Climb_rate is the acceleration
        spinnerH = gtk.SpinButton(adj, 0, 0)
        spinnerH.set_wrap(False)
        spinnerH.set_update_policy(gtk.UPDATE_IF_VALID)
        vbox2.pack_start(spinnerH, False, True, 0)

        # Just create a new vbox, can have the same name!
        vbox2 = gtk.VBox(False, 0)
        hbox.pack_start(vbox2, True, True, 5)

        label = gtk.Label("Minutes:")
        label.set_alignment(0, 0.5)
        vbox2.pack_start(label, False, True, 0)

        adj = gtk.Adjustment(0, 0, 60.0, 1.0, 5.0, 0.0)
        spinnerM = gtk.SpinButton(adj, 0, 0)
        spinnerM.set_wrap(False)
        spinnerM.set_update_policy(gtk.UPDATE_IF_VALID)
        vbox2.pack_start(spinnerM, False, True, 0)

        vbox2 = gtk.VBox(False, 0)
        hbox.pack_start(vbox2, True, True, 5)

        label = gtk.Label("Seconds:")
        label.set_alignment(0, 0.5)
        vbox2.pack_start(label, False, True, 0)

        adj = gtk.Adjustment(0, 0, 60.0, 1.0, 5.0, 0.0)
        spinnerS = gtk.SpinButton(adj, 0, 0)
        spinnerS.set_wrap(False)
        spinnerS.set_update_policy(gtk.UPDATE_IF_VALID)
        vbox2.pack_start(spinnerS, False, True, 0)

        hbox = gtk.HBox(False, 0)
        main_vbox.pack_start(hbox, False, True, 0)

        self.progressbar = gtk.ProgressBar(adjustment=None)
        self.progressbar.set_orientation(gtk.PROGRESS_LEFT_TO_RIGHT)
        main_vbox.pack_start(self.progressbar, True, True, 0)

        button = gtk.Button("Start")
        button.connect("clicked", self.prepare_timer, spinnerS, spinnerM, spinnerH)
        button.connect("clicked", self.timed_check)
        hbox.pack_start(button, True, True, 5)

        button = gtk.Button("Close")
        button.connect("clicked", lambda w: gtk.main_quit())
        hbox.pack_start(button, True, True, 5)
        window.show_all()

def main():
    gtk.main()
    return 0

if __name__ == "__main__":
    EggTimer()
    main()