24 win.title = 'AnchorLayout demo' |
24 win.title = 'AnchorLayout demo' |
25 win.resize(80, 25) |
25 win.resize(80, 25) |
26 self.top.add(win, halign='left', valign='top') |
26 self.top.add(win, halign='left', valign='top') |
27 self.win = win |
27 self.win = win |
28 |
28 |
29 button_valign = Button('valign: ' + self.win.hints['valign'].selected) |
29 button_valign = Button('valign: ' + self.win.hint_value('valign')) |
30 button_valign.name = 'button_valign' |
30 button_valign.name = 'button_valign' |
31 button_valign.add_handler('click', self.on_button_align_click) |
31 button_valign.add_handler('click', self.on_button_align_click) |
32 win.add(button_valign, halign='center', margin=Borders(t=2)) |
32 win.add(button_valign, halign='center', margin=Borders(t=2)) |
33 |
33 |
34 button_halign = Button('halign: ' + self.win.hints['halign'].selected) |
34 button_halign = Button('halign: ' + self.win.hint_value('halign')) |
35 button_halign.name = 'button_halign' |
35 button_halign.name = 'button_halign' |
36 button_halign.add_handler('click', self.on_button_align_click) |
36 button_halign.add_handler('click', self.on_button_align_click) |
37 win.add(button_halign, halign='center', margin=Borders(t=4)) |
37 win.add(button_halign, halign='center', margin=Borders(t=4)) |
38 |
38 |
39 label_margin = Label(str(self.win.hints['margin'])) |
39 label_margin = Label(str(self.win.hint_value('margin'))) |
40 label_margin.name = 'label_margin' |
40 label_margin.name = 'label_margin' |
41 label_margin.add_handler('draw', self.on_label_margin_draw) |
41 label_margin.add_handler('draw', self.on_label_margin_draw) |
42 win.add(label_margin, halign='center', margin=Borders(t=6)) |
42 win.add(label_margin, halign='center', margin=Borders(t=6)) |
43 |
43 |
44 label_size = Label(str(self.win.sizereq)) |
44 label_size = Label(str(self.win.sizereq)) |
46 label_size.add_handler('draw', self.on_label_size_draw) |
46 label_size.add_handler('draw', self.on_label_size_draw) |
47 win.add(label_size, halign='center', margin=Borders(t=8)) |
47 win.add(label_size, halign='center', margin=Borders(t=8)) |
48 |
48 |
49 def on_button_align_click(self, ev): |
49 def on_button_align_click(self, ev): |
50 align_type = ev.originator.label.split(':', 1)[0] |
50 align_type = ev.originator.label.split(':', 1)[0] |
51 align = self.win.hints[align_type] |
51 align = self.win.get_hint(align_type) |
52 align.select_next() |
52 align.select_next() |
53 ev.originator.label = '%s: %s' % (align_type, align.selected) |
53 ev.originator.label = '%s: %s' % (align_type, align.selected) |
54 self.top.emit('resize') |
54 self.top.emit('resize') |
55 return True |
55 return True |
56 |
56 |
57 def on_label_margin_draw(self, ev): |
57 def on_label_margin_draw(self, ev): |
58 ev.originator.label = str(self.win.hints['margin']) |
58 ev.originator.label = str(self.win.hint_value('margin')) |
59 |
59 |
60 def on_label_size_draw(self, ev): |
60 def on_label_size_draw(self, ev): |
61 ev.originator.label = str(self.win.sizereq) |
61 ev.originator.label = str(self.win.sizereq) |
62 |
62 |
63 def on_top_keypress(self, ev): |
63 def on_top_keypress(self, ev): |