-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpoker-blind-timer.py
196 lines (143 loc) · 6.46 KB
/
poker-blind-timer.py
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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
#!/usr/bin/env python
import pygtk
pygtk.require('2.0')
import gtk, time, sys
from threading import Timer
class Base:
def on_quit_click(self, widget):
print "Beendet"
gtk.mainquit()
sys.exit(0)
def on_button_click(self, widget):
# Blinderhoehung
radio = [r for r in self.button.get_group() if r.get_active()][0]
radiolabel = radio.get_label()
if radiolabel == "Double":
be = 2
elif radiolabel == "Triple":
be = 3
# Blindpruefung
small_blind = int(self.entry1.get_text())
big_blind = int(self.entry2.get_text())
if small_blind == "":
self.label7.set_markup("<span foreground='red'>Fehler: Kein Start moeglich, es fehlt der SMALL Blind!!!</span>")
return False
if big_blind == "":
self.label7.set_markup("<span foreground='red'>Fehler: Kein Start moeglich, es fehlt der BIG Blind!!!</span>")
return False
if small_blind >= big_blind:
print "Small groesser / gleich Blind " + str(small_blind) + " | " + str(big_blind)
self.label7.set_markup("<span foreground='red'>Fehler: Kein Start moeglich, der SMALL Blind ist groesser/gleich als der Big Blind!!!</span>")
return False
# Intervalpruefung
interval = self.entry3.get_text()
if interval == "":
print "Interval leer"
self.label7.set_markup("<span foreground='red'>Fehler: Kein Start moeglich, der Interval ist leer!!!</span>")
return False
# Wenn alles okay ist dann wird die naechsten Blinderhoehung eingeblendet
var = "Naechste Runde Blinderhoehung Small Blind: " + str(int(small_blind) * int(be)) + " | Big Blind: " + str(int(big_blind) * int(be))
self.label7.set_markup("<span foreground='blue'>{0}</span>".format(var))
a = int(self.entry3.get_text()) * 60
i = int(self.entry3.get_text()) * 60
while i > 0:
i-=1
time.sleep(1)
self.progressbar1.set_fraction(float(i) / float(a))
self.entry4.set_text(str(i))
if i == 300:
self.label7.set_markup("<span foreground='black'>{0}</span>".format(var))
if i < 120:
self.label7.set_markup("<span foreground='red'>{0}</span>".format(var))
if i < 11:
# an dieser Stelle soll mal ein beep umgesetzt werden
# TODO
self.progressbar1.set_text("")
if i == 1:
small_blind = int(small_blind) * int(be)
big_blind = int(big_blind) * int(be)
self.entry1.set_text(str(int(small_blind)))
self.entry2.set_text(str(int(big_blind)))
var = "Naechste Runde Blinderhoehung Small Blind: " + str(int(small_blind) * int(be)) + " | Big Blind: " + str(int(big_blind) * int(be))
self.label7.set_markup("<span foreground='blue'>{0}</span>".format(var))
i = int(self.entry3.get_text()) * 60
while gtk.events_pending():
gtk.main_iteration_do(False)
def callback(self, widget, data=None):
print "%s was toggled %s" % (data, ("OFF", "ON")[widget.get_active()])
def __init__(self):
self.window = gtk.Window()
self.window.connect('destroy', lambda w: gtk.main_quit())
# self.window.set_size_request(900, 600)
self.window.set_title("Poker Blind Timer")
self.boxV = gtk.VBox()
self.window.add(self.boxV)
self.box = gtk.HBox()
self.boxV.pack_start(self.box)
self.label1 = gtk.Label("Small Blind:")
self.box.pack_start(self.label1)
self.entry1 = gtk.Entry()
self.box.pack_start(self.entry1)
self.entry1.set_text("50")
self.hs2 = gtk.VSeparator()
self.box.pack_start(self.hs2)
self.label2 = gtk.Label("Big Blind:")
self.box.pack_start(self.label2)
self.entry2 = gtk.Entry()
self.box.pack_start(self.entry2)
self.entry2.set_text("100")
self.box2 = gtk.VBox()
self.button = gtk.RadioButton(None, "Double")
self.button.connect("toggled", self.callback, "2")
self.box2.pack_start(self.button, True, True, 0)
self.button.show()
self.button = gtk.RadioButton(self.button, "Triple")
self.button.connect("toggled", self.callback, "3")
self.box2.pack_start(self.button, True, True, 0)
self.button.show()
self.hs3 = gtk.VSeparator()
self.box.pack_start(self.hs3)
self.label3 = gtk.Label("Blinderhoehung:")
self.box.pack_start(self.label3)
self.box.pack_start(self.box2)
self.hs1 = gtk.HSeparator()
self.boxV.pack_start(self.hs1)
self.boxH2 = gtk.HBox()
self.boxV.pack_start(self.boxH2)
self.label4 = gtk.Label("Interval:")
self.boxH2.pack_start(self.label4)
self.entry3 = gtk.Entry()
self.entry3.set_tooltip_text("Das Interval entspricht der Rundenlaenge!")
self.boxH2.pack_start(self.entry3)
self.entry3.set_text("15")
self.label5 = gtk.Label("Minuten")
self.boxH2.pack_start(self.label5)
self.vs1 = gtk.VSeparator()
self.boxH2.pack_start(self.vs1)
self.label6 = gtk.Label("Verbleibende Zeit:")
self.boxH2.pack_start(self.label6)
self.entry4 = gtk.Entry()
self.boxH2.pack_start(self.entry4)
self.label7 = gtk.Label("Sekunden")
self.boxH2.pack_start(self.label7)
self.hs3 = gtk.HSeparator()
self.boxV.pack_start(self.hs3)
self.label7 = gtk.Label(" ")
self.boxV.pack_start(self.label7)
# self.hs2 = gtk.HSeparator()
# self.boxV.pack_start(self.hs2)
self.progressbar1 = gtk.ProgressBar(adjustment=None)
self.boxV.pack_start(self.progressbar1)
self.button_start = gtk.Button("Start")
self.button_start.connect( 'clicked', self.on_button_click )
self.button_start.set_tooltip_text("Los geht die Wahnsinnsrunde")
self.boxV.pack_start(self.button_start)
self.button_quit = gtk.Button("Quit")
self.button_quit.connect( 'clicked', self.on_quit_click )
self.boxV.pack_start(self.button_quit)
self.window.show_all()
def main(self):
gtk.main()
if __name__ == "__main__":
base = Base()
base.main()