ya2 · news · projects · code · about

e2ad88073459b36b4d5c56c6b4186cf5b6638c2e
[pmachines.git] / pmachines / gui / main_page.py
1 from sys import exit
2 from xmlrpc.client import ServerProxy
3 from ya2.utils.gui.base_page import BasePage, ButtonInfo
4
5
6 class MainPage(BasePage):
7
8 def _build_widgets(self):
9 play_args = ButtonInfo(
10 id='play',
11 text=_('Play'),
12 pos=(0, .6),
13 command=self._set_page,
14 command_args=['play'])
15 self._add_button(play_args)
16 option_args = ButtonInfo(
17 id='options',
18 text=_('Options'),
19 pos=(0, .2),
20 command=self._set_page,
21 command_args=['options'])
22 self._add_button(option_args)
23 credits_args = ButtonInfo(
24 id='credits',
25 text=_('Credits'),
26 pos=(0, -.2),
27 command=self._set_page,
28 command_args=['credits'])
29 self._add_button(credits_args)
30 exit_args = ButtonInfo(
31 id='exit',
32 text=_('Exit'),
33 pos=(0, -.6),
34 command=self.__on_exit)
35 self._add_button(exit_args)
36 self._rearrange_buttons_width()
37
38 def __on_exit(self):
39 if self._page_info.running_functional_tests:
40 ServerProxy('http://localhost:7000').destroy()
41 exit()