-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathfixstarsorbdlg.py
More file actions
167 lines (122 loc) · 5.84 KB
/
fixstarsorbdlg.py
File metadata and controls
167 lines (122 loc) · 5.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
# -*- coding: utf-8 -*-
import wx
import astrology
import floatvalidator
import chart
import fixstars
import util
import mtexts
#---------------------------------------------------------------------------
# Create and set a help provider. Normally you would do this in
# the app's OnInit as it must be done before any SetHelpText calls.
provider = wx.SimpleHelpProvider()
wx.HelpProvider.Set(provider)
#---------------------------------------------------------------------------
class FixStarsOrbDlg(wx.Dialog):
def __init__(self, parent, fixstrs, options):
# ###########################################
# Elias - V 8.0.0
# ###########################################
self.options = options
# ###########################################
self.fixstars = fixstrs.copy()
self.prevselection = 0
# Instead of calling wx.Dialog.__init__ we precreate the dialog
# so we can set an extra style that must be set before
# creation, and then we create the GUI object using the Create
# method.
# pre = wx.PreDialog()
# pre.SetExtraStyle(wx.DIALOG_EX_CONTEXTHELP)
# pre.Create(parent, -1, mtexts.txts['Orbis'], pos=wx.DefaultPosition, size=wx.DefaultSize, style=wx.DEFAULT_DIALOG_STYLE)
# This next step is the most important, it turns this Python
# object into the real wrapper of the dialog (instead of pre)
# as far as the wxPython extension is concerned.
# self.PostCreate(pre)
wx.Dialog.__init__(self, None, -1, mtexts.txts['Orbis'], size=wx.DefaultSize)
#main vertical sizer
mvsizer = wx.BoxSizer(wx.VERTICAL)
#Orbs
sorbs =wx.StaticBox(self, label='')
orbssizer = wx.StaticBoxSizer(sorbs, wx.HORIZONTAL)
self.fsnames = list(self.fixstars)
#self.fscb = wx.ComboBox(self, -1, self.fsnames[0], size=(100, -1), choices=self.fsnames, style=wx.CB_DROPDOWN|wx.CB_READONLY)
self.fscb = wx.ComboBox(
self,
-1,
self.fsnames[0],
size=(100, -1),
choices=self.fsnames,
style=wx.CB_DROPDOWN|wx.CB_READONLY
)
orbssizer.Add(self.fscb, 1, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)
self.fsorbstxt = wx.TextCtrl(self, -1, '', validator=floatvalidator.FloatValidator(0.0, 6.0), size=(50, -1))
self.fsorbstxt.SetValue(str(self.fixstars[self.fsnames[0]]))
orbssizer.Add(self.fsorbstxt, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)
mvsizer.Add(orbssizer, 0, wx.GROW|wx.ALIGN_LEFT|wx.LEFT|wx.RIGHT, 5)
sallorbs =wx.StaticBox(self, label='')
allorbssizer = wx.StaticBoxSizer(sallorbs, wx.HORIZONTAL)
ID_All = wx.NewId()
self.btnAll = wx.Button(self, ID_All, mtexts.txts['All'])
allorbssizer.Add(self.btnAll, 1, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)
self.maxval = 6.0
self.fsorbtxt = wx.TextCtrl(self, -1, '', validator=floatvalidator.FloatValidator(0.0, self.maxval), size=(50, -1))
self.fsorbtxt.SetValue(str(chart.Chart.def_fixstarsorb))
allorbssizer.Add(self.fsorbtxt, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)
mvsizer.Add(allorbssizer, 0, wx.GROW|wx.ALIGN_LEFT|wx.LEFT|wx.RIGHT, 5)
btnsizer = wx.StdDialogButtonSizer()
if wx.Platform != '__WXMSW__':
btn = wx.ContextHelpButton(self)
btnsizer.AddButton(btn)
btnOk = wx.Button(self, wx.ID_OK, mtexts.txts['Ok'])
btnsizer.AddButton(btnOk)
btnOk.SetHelpText(mtexts.txts['HelpOk'])
btnOk.SetDefault()
btn = wx.Button(self, wx.ID_CANCEL, mtexts.txts['Cancel'])
btnsizer.AddButton(btn)
btn.SetHelpText(mtexts.txts['HelpCancel'])
btnsizer.Realize()
mvsizer.Add(btnsizer, 0, wx.GROW|wx.ALL, 10)
self.SetSizer(mvsizer)
mvsizer.Fit(self)
self.Bind(wx.EVT_COMBOBOX, self.onSelect, id=self.fscb.GetId())
self.Bind(wx.EVT_BUTTON, self.onAll, id=ID_All)
self.Bind(wx.EVT_BUTTON, self.onOK, id=wx.ID_OK)
btnOk.SetFocus()
def onOK(self, event):
if (self.Validate()):
self.fixstars[self.fsnames[self.prevselection]] = float(self.fsorbstxt.GetValue())
# 옵션 객체에는 항상 반영
self.options.fixstars = self.fixstars
# Auto-save가 켜져 있으면 즉시 파일 저장
if self.options.autosave:
self.options.saveFixstars()
self.Close()
self.SetReturnCode(wx.ID_OK)
def onSelect(self, evnt):
if float(self.fsorbstxt.GetValue()) >= self.maxval:
s = mtexts.txts['RangeError3'] + '%2.1f' % self.maxval
dlgm = wx.MessageDialog(None, s, mtexts.txts['Error'], wx.OK|wx.ICON_EXCLAMATION)
dlgm.ShowModal()
dlgm.Destroy()
else:
self.fixstars[self.fsnames[self.prevselection]] = float(self.fsorbstxt.GetValue())
idx = evnt.GetSelection()
self.fsorbstxt.SetValue(str(self.fixstars[self.fsnames[idx]]))
self.prevselection = idx
def onAll(self, evnt):
if float(self.fsorbtxt.GetValue()) >= self.maxval:
s = mtexts.txts['RangeError3'] + '%2.1f' % self.maxval
dlgm = wx.MessageDialog(None, s, mtexts.txts['Error'], wx.OK|wx.ICON_EXCLAMATION)
dlgm.ShowModal()
dlgm.Destroy()
return
dlg = wx.MessageDialog(self, mtexts.txts['AreYouSure'], mtexts.txts['Confirm'], wx.YES_NO|wx.ICON_QUESTION)
val = dlg.ShowModal()
if val == wx.ID_YES:
for name in self.fsnames:
self.fixstars[name] = float(self.fsorbtxt.GetValue())
self.fsorbstxt.SetValue(str(float(self.fsorbtxt.GetValue())))
self.fsorbtxt.SetValue(str(float(self.fsorbtxt.GetValue())))
dlg.Destroy()
def getFixstars(self):
return self.fixstars.copy()