OSDN Git Service

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