OSDN Git Service

f119d7706ea4555d169e028f5c1f50fbb732bd68
[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
10 import constnumbers
11
12 class MainFrameView():
13     u""" メインのフレームクラス """
14     def __init__(self, dirname=None):
15         if dirname is None:
16             self.res = wx.xrc.XmlResource(constnumbers.XRC_MAIN_FRAME)
17         else:
18             self.res = wx.xrc.XmlResource(os.path.join(dirname,constnumbers.XRC_MAIN_FRAME))
19         self._init_frame()
20
21     def _init_frame(self):
22         # load controls
23         self.frame = self.res.LoadFrame(None, "MainFrame")
24
25         # buttons
26         self.button_seed_seaerch = xrc.XRCCTRL(self.frame, "ButtonSeedSearch")
27         self.button_seed_clear = xrc.XRCCTRL(self.frame, "ButtonSeedClear")
28         self.button_skill_from_seed_search = xrc.XRCCTRL(self.frame, "ButtonSkillFromSeedSearch")
29         self.button_skill_search = xrc.XRCCTRL(self.frame, "ButtonSkillSearch")
30         self.button_skill_clear = xrc.XRCCTRL(self.frame, "ButtonSkillClear")
31         self.button_amulet_search_seaerch = xrc.XRCCTRL(self.frame, "ButtonAmuletSearchSearch")
32         self.button_amulet_search_clear = xrc.XRCCTRL(self.frame, "ButtonAmuletSearchClear")
33
34         # menu
35         self.ID_MENU_ITEM_EXIT = xrc.XRCID("wxID_EXIT") # same as wx.ID_EXIT
36         self.ID_MENU_ITEM_ABOUT = xrc.XRCID("wxID_ABOUT") # same as wx.ID_ABOUT
37
38         # load text ctrls
39         self._load_text_ctrls()
40
41         # load combo box
42         self._load_combo_boxes()
43
44         # load list box
45         self.list_box_amulet_search_seeds = xrc.XRCCTRL(self.frame, "ListBoxAmuletSearchSeeds")
46         self.list_box_seed_skill_amulet_prospect = xrc.XRCCTRL(self.frame, "ListBoxSeedSkillAmuletProspect")
47
48         # load spin ctrl
49         self.spin_ctrl_amulet_search_skill1_val = xrc.XRCCTRL(self.frame, "SpinCtrlAmuletSearchSkill1Value")
50         self.spin_ctrl_amulet_search_skill2_val = xrc.XRCCTRL(self.frame, "SpinCtrlAmuletSearchSkill2Value")
51         self.spin_ctrl_amulet_search_slot_num = xrc.XRCCTRL(self.frame, "SpinCtrlAmuletSearchSlotNumber")
52
53         # set explanation text
54         self.text_ctrl_seed_explain.SetValue(constnumbers.SEED_DECISION_EXPLANATION)
55         self.text_ctrl_flow.SetValue(constnumbers.SECOND_SKILL_FLOW)
56
57     def _load_combo_boxes(self):
58         # load combo boxes
59         self.combo_box_skill_dict = {}
60         self.combo_box_skill_dict[constnumbers.KEY_AMULET1] = [
61                 xrc.XRCCTRL(self.frame, "ComboBoxAmulet1_1"),
62                 xrc.XRCCTRL(self.frame, "ComboBoxAmulet1_3"),
63                 xrc.XRCCTRL(self.frame, "ComboBoxAmulet1_4"),
64                 xrc.XRCCTRL(self.frame, "ComboBoxAmulet1_4"),
65                 xrc.XRCCTRL(self.frame, "ComboBoxAmulet1_5"),
66                 xrc.XRCCTRL(self.frame, "ComboBoxAmulet1_6"),
67                 xrc.XRCCTRL(self.frame, "ComboBoxAmulet1_7")]
68         self.combo_box_skill_dict[constnumbers.KEY_AMULET2] = [
69                 xrc.XRCCTRL(self.frame, "ComboBoxAmulet2_1"),
70                 xrc.XRCCTRL(self.frame, "ComboBoxAmulet2_3"),
71                 xrc.XRCCTRL(self.frame, "ComboBoxAmulet2_4"),
72                 xrc.XRCCTRL(self.frame, "ComboBoxAmulet2_4"),
73                 xrc.XRCCTRL(self.frame, "ComboBoxAmulet2_5"),
74                 xrc.XRCCTRL(self.frame, "ComboBoxAmulet2_6"),
75                 xrc.XRCCTRL(self.frame, "ComboBoxAmulet2_7")]
76         self.combo_box_skill_dict[constnumbers.KEY_AMULET3] = [
77                 xrc.XRCCTRL(self.frame, "ComboBoxAmulet3_1"),
78                 xrc.XRCCTRL(self.frame, "ComboBoxAmulet3_3"),
79                 xrc.XRCCTRL(self.frame, "ComboBoxAmulet3_4"),
80                 xrc.XRCCTRL(self.frame, "ComboBoxAmulet3_4"),
81                 xrc.XRCCTRL(self.frame, "ComboBoxAmulet3_5"),
82                 xrc.XRCCTRL(self.frame, "ComboBoxAmulet3_6"),
83                 xrc.XRCCTRL(self.frame, "ComboBoxAmulet3_7")]
84         self.combo_box_amulet_search_skill1 = xrc.XRCCTRL(self.frame, "ComboBoxAmuletSearchSkill1")
85         self.combo_box_amulet_search_skill2 = xrc.XRCCTRL(self.frame, "ComboBoxAmuletSearchSkill2")
86
87     def _load_text_ctrls(self):
88         # load text ctrls
89         self.text_ctrl_seed_explain = xrc.XRCCTRL(self.frame, "TextCtrlSeedExplain")
90         self.text_ctrl_seed_result = xrc.XRCCTRL(self.frame, "TextCtrlSeedResults")
91         self.text_ctrl_seed_select = xrc.XRCCTRL(self.frame, "TextCtrlSeedSelect")
92         self.text_ctrl_amulet_search_result = xrc.XRCCTRL(self.frame, "TextCtrlAmuletSearchResult")
93         self.text_ctrl_flow = xrc.XRCCTRL(self.frame, "TextCtrlFlow")
94         self.text_ctrl_seed_skill_dict = {}
95         self.text_ctrl_seed_skill_dict[constnumbers.KEY_AMULET1] = [
96                 xrc.XRCCTRL(self.frame, "TextCtrlSeedSkillAmulet1_1"),
97                 xrc.XRCCTRL(self.frame, "TextCtrlSeedSkillAmulet1_2"),
98                 xrc.XRCCTRL(self.frame, "TextCtrlSeedSkillAmulet1_3"),
99                 xrc.XRCCTRL(self.frame, "TextCtrlSeedSkillAmulet1_4"),
100                 xrc.XRCCTRL(self.frame, "TextCtrlSeedSkillAmulet1_5"),
101                 xrc.XRCCTRL(self.frame, "TextCtrlSeedSkillAmulet1_6"),
102                 xrc.XRCCTRL(self.frame, "TextCtrlSeedSkillAmulet1_7")]
103         self.text_ctrl_seed_skill_dict[constnumbers.KEY_AMULET2] = [
104                 xrc.XRCCTRL(self.frame, "TextCtrlSeedSkillAmulet2_1"),
105                 xrc.XRCCTRL(self.frame, "TextCtrlSeedSkillAmulet2_2"),
106                 xrc.XRCCTRL(self.frame, "TextCtrlSeedSkillAmulet2_3"),
107                 xrc.XRCCTRL(self.frame, "TextCtrlSeedSkillAmulet2_4"),
108                 xrc.XRCCTRL(self.frame, "TextCtrlSeedSkillAmulet2_5"),
109                 xrc.XRCCTRL(self.frame, "TextCtrlSeedSkillAmulet2_6"),
110                 xrc.XRCCTRL(self.frame, "TextCtrlSeedSkillAmulet2_7")]
111         self.text_ctrl_seed_skill_dict[constnumbers.KEY_AMULET3] = [
112                 xrc.XRCCTRL(self.frame, "TextCtrlSeedSkillAmulet3_1"),
113                 xrc.XRCCTRL(self.frame, "TextCtrlSeedSkillAmulet3_2"),
114                 xrc.XRCCTRL(self.frame, "TextCtrlSeedSkillAmulet3_3"),
115                 xrc.XRCCTRL(self.frame, "TextCtrlSeedSkillAmulet3_4"),
116                 xrc.XRCCTRL(self.frame, "TextCtrlSeedSkillAmulet3_5"),
117                 xrc.XRCCTRL(self.frame, "TextCtrlSeedSkillAmulet3_6"),
118                 xrc.XRCCTRL(self.frame, "TextCtrlSeedSkillAmulet3_7")]
119         self.text_ctrl_seed_skill_dict[constnumbers.KEY_THRESHOLD2] = [
120                 xrc.XRCCTRL(self.frame, "TextCtrlSeedSkillThreshold2_1"),
121                 xrc.XRCCTRL(self.frame, "TextCtrlSeedSkillThreshold2_2"),
122                 xrc.XRCCTRL(self.frame, "TextCtrlSeedSkillThreshold2_3"),
123                 xrc.XRCCTRL(self.frame, "TextCtrlSeedSkillThreshold2_4"),
124                 xrc.XRCCTRL(self.frame, "TextCtrlSeedSkillThreshold2_5"),
125                 xrc.XRCCTRL(self.frame, "TextCtrlSeedSkillThreshold2_6"),
126                 xrc.XRCCTRL(self.frame, "TextCtrlSeedSkillThreshold2_7")]
127
128     def Show(self):
129         self.frame.Show()
130
131     def Close(self):
132         self.frame.Close(True)
133
134     def OnAboutBox(self, evt):
135         u""" Show About Box """
136         info = wx.AboutDialogInfo()
137         info.Name = constnumbers.NAME
138         info.Version = constnumbers.VERSION
139         info.Copyright = constnumbers.COPYRIGHT
140         info.Description = constnumbers.DESCRIPTION
141         info.WebSite = (constnumbers.WEBSITE_LINK, constnumbers.WEBSITE_TEXT)
142         info.Developers = constnumbers.DEVELOPERS
143         info.License = constnumbers.LICENSE_TEXT
144         wx.AboutBox(info)
145
146     def GetAboutInfo(self):
147         u""" create About info """
148         info = wx.AboutDialogInfo()
149         info.Name = constnumbers.NAME
150         info.Version = constnumbers.VERSION
151         info.Copyright = constnumbers.COPYRIGHT
152         info.Description = constnumbers.DESCRIPTION
153         info.WebSite = (constnumbers.WEBSITE_LINK, constnumbers.WEBSITE_TEXT)
154         info.Developers = constnumbers.DEVELOPERS
155         info.License = constnumbers.LICENSE_TEXT
156         return info
157
158 if __name__ == "__main__":
159     app = wx.App(False)
160     mainframe = MainFrameView()
161     mainframe.Show()
162     app.MainLoop()