OSDN Git Service

revise view
[amulettoolsmh4/main.git] / view / mainframeview.py
1 # -*- coding: utf-8 -*-
2
3 # GUIのメインフレーム
4 # 2013/12/05 written by kei9
5 import wx
6 from wx import xrc
7 import wx.lib.intctrl
8
9 import constnumbers
10
11 class MainFrameView():
12     u""" メインのフレームクラス """
13     def __init__(self, filename):
14         self.res = wx.xrc.XmlResource(filename)
15         self._init_frame()
16
17     def _init_frame(self):
18         # load controls
19         self.frame = self.res.LoadFrame(None, "MainFrame")
20
21         self.note_book = xrc.XRCCTRL(self.frame, "NoteBookMain")
22
23         # buttons
24         self.button_seed_seaerch = xrc.XRCCTRL(self.frame, "ButtonSeedSearch")
25         self.button_seed_clear = xrc.XRCCTRL(self.frame, "ButtonSeedClear")
26         self.button_skill_from_seed_search = xrc.XRCCTRL(self.frame, "ButtonSkillFromSeedSearch")
27         self.button_skill_search = xrc.XRCCTRL(self.frame, "ButtonSeedSkillSearch")
28         self.button_skill_clear = xrc.XRCCTRL(self.frame, "ButtonSeedSkillClear")
29         self.button_amulet_search_seaerch = xrc.XRCCTRL(self.frame, "ButtonAmuletSearchSearch")
30         self.button_amulet_search_clear = xrc.XRCCTRL(self.frame, "ButtonAmuletSearchClear")
31         self.button_amulet_search_skill = xrc.XRCCTRL(self.frame, "ButtonAmuletSearchSkill")
32         self.button_setting_ok = xrc.XRCCTRL(self.frame, "ButtonSettingOK")
33         self.button_setting_clear = xrc.XRCCTRL(self.frame, "ButtonSettingClear")
34
35         self.ID_BUTTON_SEED_SEARCH = xrc.XRCID("ButtonSeedSearch")
36         self.ID_BUTTON_SEED_CLEAR = xrc.XRCID("ButtonSeedClear")
37         self.ID_BUTTON_SKILL_FROM_SEED_SEARCH = xrc.XRCID("ButtonSkillFromSeedSearch")
38         self.ID_BUTTON_SKILL_SEARCH = xrc.XRCID("ButtonSeedSkillSearch")
39         self.ID_BUTTON_SKILL_CLEAR = xrc.XRCID("ButtonSeedSkillClear")
40         self.ID_BUTTON_AMULET_SEARCH_SEARCH = xrc.XRCID("ButtonAmuletSearchSearch")
41         self.ID_BUTTON_AMULET_SEARCH_CLEAR = xrc.XRCID("ButtonAmuletSearchClear")
42         self.ID_BUTTON_AMULET_SEARCH_SKILL = xrc.XRCID("ButtonAmuletSearchSkill")
43         self.ID_BUTTON_SETTING_OK = xrc.XRCID("ButtonSettingOK")
44         self.ID_BUTTON_SETTING_CLEAR = xrc.XRCID("ButtonSettingClear")
45
46         # radio button
47         self.radio_button_amulet1 = xrc.XRCCTRL(self.frame, "RadioButtonAmulet1")
48         self.radio_button_amulet2 = xrc.XRCCTRL(self.frame, "RadioButtonAmulet2")
49         self.radio_button_amulet3 = xrc.XRCCTRL(self.frame, "RadioButtonAmulet3")
50         self.ID_RADIO_BUTTON_AMULET1 = xrc.XRCID("RadioButtonAmulet1")
51         self.ID_RADIO_BUTTON_AMULET2 = xrc.XRCID("RadioButtonAmulet2")
52         self.ID_RADIO_BUTTON_AMULET3 = xrc.XRCID("RadioButtonAmulet3")
53         self.amulet2radio_button_dict = {}
54         self.amulet2radio_button_dict[constnumbers.NAME_AMULET1] = self.radio_button_amulet1
55         self.amulet2radio_button_dict[constnumbers.NAME_AMULET2] = self.radio_button_amulet2
56         self.amulet2radio_button_dict[constnumbers.NAME_AMULET3] = self.radio_button_amulet3
57         self.amulet2radio_id_dict = {}
58         self.amulet2radio_id_dict[constnumbers.NAME_AMULET1] = self.ID_RADIO_BUTTON_AMULET1
59         self.amulet2radio_id_dict[constnumbers.NAME_AMULET2] = self.ID_RADIO_BUTTON_AMULET2
60         self.amulet2radio_id_dict[constnumbers.NAME_AMULET3] = self.ID_RADIO_BUTTON_AMULET3
61
62         # menu
63         self.ID_MENU_ITEM_EXIT = xrc.XRCID("wxID_EXIT") # same as wx.ID_EXIT
64         self.ID_MENU_ITEM_ABOUT = xrc.XRCID("wxID_ABOUT") # same as wx.ID_ABOUT
65
66         # load text ctrls
67         self._load_text_ctrls()
68
69         # load combo box
70         self._load_combo_boxes()
71
72         # load list box
73         self.list_box_seed = xrc.XRCCTRL(self.frame, "ListBoxSeed")
74         self.list_box_amulet_search_seeds = xrc.XRCCTRL(self.frame, "ListBoxAmuletSearchSeeds")
75         self.list_box_seed_skill_amulet_prospect = xrc.XRCCTRL(self.frame, "ListBoxSeedSkillAmuletProspect")
76         self.ID_LIST_BOX_SEED = xrc.XRCID("ListBoxSeed")
77         self.ID_LIST_BOX_AMULET_SEARCH_SEEDS = xrc.XRCID("ListBoxAmuletSearchSeeds")
78         self.ID_LIST_BOX_SEED_SKILL_AMULET_PROSPECT = xrc.XRCID("ListBoxSeedSkillAmuletProspect")
79
80         # load spin ctrl
81         self.spin_ctrl_amulet_search_skill1_val = xrc.XRCCTRL(self.frame, "SpinCtrlAmuletSearchSkill1Value")
82         self.spin_ctrl_amulet_search_skill2_val = xrc.XRCCTRL(self.frame, "SpinCtrlAmuletSearchSkill2Value")
83         self.spin_ctrl_amulet_search_slot_num = xrc.XRCCTRL(self.frame, "SpinCtrlAmuletSearchSlotNumber")
84         self.ID_SPIN_CTRL_AMULET_SKILL1_VAL = xrc.XRCID("SpinCtrlAmuletSearchSkill1Value")
85         self.ID_SPIN_CTRL_AMULET_SKILL2_VAL = xrc.XRCID("SpinCtrlAmuletSearchSkill2Value")
86         self.spin_ctrl_highlight = xrc.XRCCTRL(self.frame, "SpinCtrlHighlightThreshold")
87
88         # load custom ctrl
89         panel = xrc.XRCCTRL(self.frame, "CheckListBoxPos")
90         #panel = xrc.XRCCTRL(self.frame, "NoteBookPanelSettings")
91         self.ID_CHECK_LIST_BOX_HIGHLIGHT_SKILL = wx.NewId()
92         #self.check_list_box_highlight_skill = wx.CheckListBox(self.frame, self.ID_CHECK_LIST_BOX_HIGHLIGHT_SKILL)
93         self.check_list_box_highlight_skill = wx.CheckListBox(panel, id=self.ID_CHECK_LIST_BOX_HIGHLIGHT_SKILL,
94                 name="CheckListBoxHighlightSkills")
95         #self.res.AttachUnknownControl("CheckListBoxHighlightSkills", self.check_list_box_highlight_skill, panel) # list isn't shown. why?
96
97         vbox = wx.BoxSizer(wx.VERTICAL)
98         vbox.Add(self.check_list_box_highlight_skill, 1, wx.EXPAND)
99         panel.SetSizer(vbox)
100
101         #panel.Fit()
102
103         # set explanation text
104         self.text_ctrl_seed_explain.SetValue(constnumbers.SEED_DECISION_EXPLANATION)
105         self.text_ctrl_flow.SetValue(constnumbers.SECOND_SKILL_FLOW)
106
107     def _load_combo_boxes(self):
108         # load combo boxes
109         self.combo_box_skill_dict = {}
110         self.combo_box_skill_dict[constnumbers.KEY_AMULET1] = [
111                 xrc.XRCCTRL(self.frame, "ComboBoxAmulet1_1"),
112                 xrc.XRCCTRL(self.frame, "ComboBoxAmulet1_2"),
113                 xrc.XRCCTRL(self.frame, "ComboBoxAmulet1_3"),
114                 xrc.XRCCTRL(self.frame, "ComboBoxAmulet1_4"),
115                 xrc.XRCCTRL(self.frame, "ComboBoxAmulet1_5"),
116                 xrc.XRCCTRL(self.frame, "ComboBoxAmulet1_6"),
117                 xrc.XRCCTRL(self.frame, "ComboBoxAmulet1_7")]
118         self.combo_box_skill_dict[constnumbers.KEY_AMULET2] = [
119                 xrc.XRCCTRL(self.frame, "ComboBoxAmulet2_1"),
120                 xrc.XRCCTRL(self.frame, "ComboBoxAmulet2_2"),
121                 xrc.XRCCTRL(self.frame, "ComboBoxAmulet2_3"),
122                 xrc.XRCCTRL(self.frame, "ComboBoxAmulet2_4"),
123                 xrc.XRCCTRL(self.frame, "ComboBoxAmulet2_5"),
124                 xrc.XRCCTRL(self.frame, "ComboBoxAmulet2_6"),
125                 xrc.XRCCTRL(self.frame, "ComboBoxAmulet2_7")]
126         self.combo_box_skill_dict[constnumbers.KEY_AMULET3] = [
127                 xrc.XRCCTRL(self.frame, "ComboBoxAmulet3_1"),
128                 xrc.XRCCTRL(self.frame, "ComboBoxAmulet3_2"),
129                 xrc.XRCCTRL(self.frame, "ComboBoxAmulet3_3"),
130                 xrc.XRCCTRL(self.frame, "ComboBoxAmulet3_4"),
131                 xrc.XRCCTRL(self.frame, "ComboBoxAmulet3_5"),
132                 xrc.XRCCTRL(self.frame, "ComboBoxAmulet3_6"),
133                 xrc.XRCCTRL(self.frame, "ComboBoxAmulet3_7")]
134         self.combo_box_amulet_search_skill1 = xrc.XRCCTRL(self.frame, "ComboBoxAmuletSearchSkill1")
135         self.combo_box_amulet_search_skill2 = xrc.XRCCTRL(self.frame, "ComboBoxAmuletSearchSkill2")
136         self.ID_COMBO_BOX_AMULET_SEARCH_SKILL1 = xrc.XRCID("ComboBoxAmuletSearchSkill1")
137         self.ID_COMBO_BOX_AMULET_SEARCH_SKILL2 = xrc.XRCID("ComboBoxAmuletSearchSkill2")
138
139     def _load_text_ctrls(self):
140         # load text ctrls
141         self.text_ctrl_seed_explain = xrc.XRCCTRL(self.frame, "TextCtrlSeedExplain")
142         self.text_ctrl_seed_result = xrc.XRCCTRL(self.frame, "TextCtrlSeedResults")
143         self.text_ctrl_seed_select = xrc.XRCCTRL(self.frame, "TextCtrlSeedSelect")
144         self.text_ctrl_amulet_search_result = xrc.XRCCTRL(self.frame, "TextCtrlAmuletSearchResult")
145         self.text_ctrl_flow = xrc.XRCCTRL(self.frame, "TextCtrlFlow")
146         self.text_ctrl_seed_skill_dict = {}
147         self.text_ctrl_seed_skill_dict[constnumbers.KEY_AMULET1] = [
148                 xrc.XRCCTRL(self.frame, "TextCtrlSeedSkillAmulet1_1"),
149                 xrc.XRCCTRL(self.frame, "TextCtrlSeedSkillAmulet1_2"),
150                 xrc.XRCCTRL(self.frame, "TextCtrlSeedSkillAmulet1_3"),
151                 xrc.XRCCTRL(self.frame, "TextCtrlSeedSkillAmulet1_4"),
152                 xrc.XRCCTRL(self.frame, "TextCtrlSeedSkillAmulet1_5"),
153                 xrc.XRCCTRL(self.frame, "TextCtrlSeedSkillAmulet1_6"),
154                 xrc.XRCCTRL(self.frame, "TextCtrlSeedSkillAmulet1_7")]
155         self.text_ctrl_seed_skill_dict[constnumbers.KEY_AMULET2] = [
156                 xrc.XRCCTRL(self.frame, "TextCtrlSeedSkillAmulet2_1"),
157                 xrc.XRCCTRL(self.frame, "TextCtrlSeedSkillAmulet2_2"),
158                 xrc.XRCCTRL(self.frame, "TextCtrlSeedSkillAmulet2_3"),
159                 xrc.XRCCTRL(self.frame, "TextCtrlSeedSkillAmulet2_4"),
160                 xrc.XRCCTRL(self.frame, "TextCtrlSeedSkillAmulet2_5"),
161                 xrc.XRCCTRL(self.frame, "TextCtrlSeedSkillAmulet2_6"),
162                 xrc.XRCCTRL(self.frame, "TextCtrlSeedSkillAmulet2_7")]
163         self.text_ctrl_seed_skill_dict[constnumbers.KEY_AMULET3] = [
164                 xrc.XRCCTRL(self.frame, "TextCtrlSeedSkillAmulet3_1"),
165                 xrc.XRCCTRL(self.frame, "TextCtrlSeedSkillAmulet3_2"),
166                 xrc.XRCCTRL(self.frame, "TextCtrlSeedSkillAmulet3_3"),
167                 xrc.XRCCTRL(self.frame, "TextCtrlSeedSkillAmulet3_4"),
168                 xrc.XRCCTRL(self.frame, "TextCtrlSeedSkillAmulet3_5"),
169                 xrc.XRCCTRL(self.frame, "TextCtrlSeedSkillAmulet3_6"),
170                 xrc.XRCCTRL(self.frame, "TextCtrlSeedSkillAmulet3_7")]
171         self.text_ctrl_seed_skill_dict[constnumbers.KEY_THRESHOLD2] = [
172                 xrc.XRCCTRL(self.frame, "TextCtrlSeedSkillThreshold2_1"),
173                 xrc.XRCCTRL(self.frame, "TextCtrlSeedSkillThreshold2_2"),
174                 xrc.XRCCTRL(self.frame, "TextCtrlSeedSkillThreshold2_3"),
175                 xrc.XRCCTRL(self.frame, "TextCtrlSeedSkillThreshold2_4"),
176                 xrc.XRCCTRL(self.frame, "TextCtrlSeedSkillThreshold2_5"),
177                 xrc.XRCCTRL(self.frame, "TextCtrlSeedSkillThreshold2_6"),
178                 xrc.XRCCTRL(self.frame, "TextCtrlSeedSkillThreshold2_7")]
179
180     def Show(self):
181         self.frame.Show()
182
183     def Close(self):
184         self.frame.Close(True)
185
186     def DisableNoteBook(self):
187         self.note_book.Disable()
188
189     def EnableNoteBook(self):
190         self.note_book.Enable()
191         
192     def OnAboutBox(self, evt):
193         u""" Show About Box """
194         info = wx.AboutDialogInfo()
195         info.Name = constnumbers.NAME
196         info.Version = constnumbers.VERSION
197         info.Copyright = constnumbers.COPYRIGHT
198         info.Description = constnumbers.DESCRIPTION
199         info.WebSite = (constnumbers.WEBSITE_LINK, constnumbers.WEBSITE_TEXT)
200         info.Developers = constnumbers.DEVELOPERS
201         info.License = constnumbers.LICENSE_TEXT
202         wx.AboutBox(info)
203
204     def GetAboutInfo(self):
205         u""" create About info """
206         info = wx.AboutDialogInfo()
207         info.Name = constnumbers.NAME
208         info.Version = constnumbers.VERSION
209         info.Copyright = constnumbers.COPYRIGHT
210         info.Description = constnumbers.DESCRIPTION
211         info.WebSite = (constnumbers.WEBSITE_LINK, constnumbers.WEBSITE_TEXT)
212         info.Developers = constnumbers.DEVELOPERS
213         info.License = constnumbers.LICENSE_TEXT
214         return info
215
216 if __name__ == "__main__":
217     app = wx.App(False)
218     mainframe = MainFrameView()
219     mainframe.Show()
220     app.MainLoop()