/GUI/Generic/GAlerts.py
Python | 67 lines | 46 code | 17 blank | 4 comment | 0 complexity | ae3149c2625a4dced0289073dc5b538d MD5 | raw file
1#
2# Python GUI - Alerts - Generic
3#
4
5from BaseAlerts import BaseAlert
6from Buttons import Button
7from StdButtons import DefaultButton, CancelButton
8
9
10class Alert(BaseAlert):
11
12 def __init__(self, kind, prompt,
13 ok_label = "OK", default = 1, **kwds):
14 BaseAlert.__init__(self, kind, prompt,
15 button_labels = [ok_label], default = default, **kwds)
16
17 def _create_buttons(self, ok_label):
18 self.yes_button = DefaultButton(title = ok_label, action = self.yes)
19 #self.default_button = self.ok_button
20
21 def _layout_buttons(self):
22 self.place(self.yes_button,
23 right = self.label.right,
24 top = self.label + self._label_button_spacing)
25
26
27class Alert2(BaseAlert):
28
29 def __init__(self, kind, prompt,
30 yes_label = "Yes", no_label = "No",
31 default = 1, cancel = 0, **kwds):
32 BaseAlert.__init__(self, kind, prompt,
33 button_labels = [yes_label, no_label],
34 default = default, cancel = cancel, **kwds)
35
36 def _create_buttons(self, yes_label, no_label):
37 self.yes_button = DefaultButton(title = yes_label, action = self.yes)
38 self.no_button = CancelButton(title = no_label, action = self.no)
39
40 def _layout_buttons(self):
41 self.place_row([self.no_button, self.yes_button],
42 right = self.label.right,
43 top = self.label + self._label_button_spacing)
44
45
46class Alert3(BaseAlert):
47
48 _minimum_width = 300
49
50 def __init__(self, kind, prompt,
51 yes_label = "Yes", no_label = "No", other_label = "Cancel",
52 default = 1, cancel = -1, **kwds):
53 BaseAlert.__init__(self, kind, prompt,
54 button_labels = [yes_label, no_label, other_label],
55 default = default, cancel = cancel, **kwds)
56
57 def _create_buttons(self, yes_label, no_label, cancel_label):
58 self.yes_button = DefaultButton(title = yes_label, action = self.yes)
59 self.no_button = CancelButton(title = no_label, action = self.no)
60 self.other_button = Button(title = cancel_label, action = self.other)
61
62 def _layout_buttons(self):
63 self.place_row([self.other_button, self.yes_button],
64 right = self.label.right,
65 top = self.label + self._label_button_spacing)
66 self.place(self.no_button,
67 left = self._left_margin, top = self.label + self._label_button_spacing)