|
@@ -1,6 +1,8 @@
|
1
|
1
|
# coding: utf-8
|
|
2
|
+import typing
|
2
|
3
|
from tkinter import Tk
|
3
|
|
-from tkinter import Label
|
|
4
|
+from tkinter import StringVar
|
|
5
|
+from tkinter import OptionMenu
|
4
|
6
|
from tkinter import W
|
5
|
7
|
|
6
|
8
|
from synergine2.config import Config
|
|
@@ -15,10 +17,25 @@ class SelectTroopsGui(Gui):
|
15
|
17
|
config: Config,
|
16
|
18
|
master: Tk,
|
17
|
19
|
troop_manager: TroopManager,
|
|
20
|
+ countries: typing.List[str],
|
18
|
21
|
) -> None:
|
19
|
22
|
super().__init__(config, master)
|
20
|
23
|
self._master.title('Troops selection')
|
21
|
|
- self.label = Label(master, text="Hello")
|
|
24
|
+
|
|
25
|
+ # Widgets
|
|
26
|
+ self.selected_country_var = StringVar(self._master)
|
|
27
|
+ self.selected_country_var.set(countries[0])
|
|
28
|
+ self.selected_country_var.trace('w', self.change_country)
|
|
29
|
+ self.select_country_menu = OptionMenu(
|
|
30
|
+ self._master,
|
|
31
|
+ self.selected_country_var,
|
|
32
|
+ *countries,
|
|
33
|
+ )
|
22
|
34
|
|
23
|
35
|
# Layout
|
24
|
|
- self.label.grid(row=0, column=0, sticky=W)
|
|
36
|
+ self.select_country_menu.grid(row=0, column=0, sticky=W)
|
|
37
|
+
|
|
38
|
+ def change_country(self, *args, **kwargs) -> None:
|
|
39
|
+ self._logger.info('Change country to "{}"'.format(
|
|
40
|
+ self.selected_country_var.get(),
|
|
41
|
+ ))
|