|
24 | 24 |
|
25 | 25 | __author__ = "Ganda" |
26 | 26 |
|
| 27 | +from collections import defaultdict |
27 | 28 | import wx |
28 | 29 | import wx.wizard as wiz |
29 | 30 |
|
@@ -163,13 +164,8 @@ def run(self): |
163 | 164 | msg = "This installer cannot start due to the following unmet conditions:\n" |
164 | 165 | for line in str(exc).splitlines(): |
165 | 166 | msg += " {}\n".format(line) |
166 | | - dialog = wx.MessageDialog( |
167 | | - self, |
168 | | - msg, |
169 | | - caption="Cannot Run Installer", |
170 | | - style=wx.OK | wx.CENTER | wx.ICON_EXCLAMATION, |
171 | | - ) |
172 | | - dialog.ShowModal() |
| 167 | + balt.showWarning(self, msg, title="Cannot Run Installer", |
| 168 | + do_center=True) |
173 | 169 | self.ret.cancelled = True |
174 | 170 | else: |
175 | 171 | if first_page is not None: # if installer has any gui pages |
@@ -242,16 +238,24 @@ def GetPrev(self): |
242 | 238 | # that item is selected |
243 | 239 | # ------------------------------------------------------------ |
244 | 240 | class PageSelect(PageInstaller): |
| 241 | + _option_type_string = defaultdict(str) |
| 242 | + _option_type_string["Required"] = "=== This option is required ===\n\n" |
| 243 | + _option_type_string["Recommended"] = \ |
| 244 | + "=== This option is recommended ===\n\n" |
| 245 | + _option_type_string["CouldBeUsable"] = \ |
| 246 | + "=== This option could result in instability ===\n\n" |
| 247 | + _option_type_string["NotUsable"] = \ |
| 248 | + "=== This option cannot be selected ===\n\n" |
| 249 | + |
245 | 250 | def __init__(self, parent, page): |
246 | 251 | PageInstaller.__init__(self, parent) |
247 | 252 |
|
248 | 253 | # group_sizer -> [option_button, ...] |
249 | 254 | self.group_option_map = {} |
250 | 255 |
|
251 | 256 | sizer_main = wx.FlexGridSizer(2, 1, 10, 10) |
252 | | - label_step_name = wx.StaticText( |
253 | | - self, wx.ID_ANY, page.name, style=wx.ALIGN_CENTER |
254 | | - ) |
| 257 | + label_step_name = balt.StaticText(self, page.name, |
| 258 | + style=wx.ALIGN_CENTER) |
255 | 259 | label_step_name.SetFont(wx.Font(12, wx.DEFAULT, wx.NORMAL, wx.NORMAL, 0, "")) |
256 | 260 | sizer_main.Add(label_step_name, 0, wx.EXPAND) |
257 | 261 | sizer_content = wx.GridSizer(1, 2, 5, 5) |
@@ -293,17 +297,13 @@ def __init__(self, parent, page): |
293 | 297 | ) |
294 | 298 |
|
295 | 299 | for option in group: |
296 | | - if option is group[0]: |
297 | | - radio_style = wx.RB_GROUP |
298 | | - else: |
299 | | - radio_style = 0 |
300 | | - |
301 | 300 | if group.type in ("SelectExactlyOne", "SelectAtMostOne"): |
| 301 | + radio_style = wx.RB_GROUP if option is group[0] else 0 |
302 | 302 | button = wx.RadioButton( |
303 | 303 | panel_groups, label=option.name, style=radio_style |
304 | 304 | ) |
305 | 305 | else: |
306 | | - button = wx.CheckBox(panel_groups, label=option.name) |
| 306 | + button = balt.checkBox(panel_groups, label=option.name) |
307 | 307 | if group.type == "SelectAll": |
308 | 308 | button.SetValue(True) |
309 | 309 | any_selected = True |
@@ -376,28 +376,15 @@ def on_hover(self, event): |
376 | 376 | else: |
377 | 377 | self.bmp_item.SetBitmap(None) |
378 | 378 | self.bmp_item.Thaw() |
379 | | - |
380 | | - if option.type == "Required": |
381 | | - prefix = "=== This option is required ===\n\n" |
382 | | - elif option.type == "Recommended": |
383 | | - prefix = "=== This option is recommended ===\n\n" |
384 | | - elif option.type == "CouldBeUsable": |
385 | | - prefix = "=== This option could result in instability ===\n\n" |
386 | | - elif option.type == "NotUsable": |
387 | | - prefix = "=== This option cannot be selected ===\n\n" |
388 | | - else: |
389 | | - prefix = "" |
390 | | - self.text_item.SetValue(prefix + option.description) |
| 379 | + self.text_item.SetValue( |
| 380 | + self._option_type_string[option.type] + option.description) |
391 | 381 |
|
392 | 382 | def on_error(self, msg): |
393 | 383 | msg += ( |
394 | 384 | "\nPlease ensure the fomod files are correct and " |
395 | 385 | "contact the Wrye Bash Dev Team." |
396 | 386 | ) |
397 | | - dialog = wx.MessageDialog( |
398 | | - self, msg, caption="Warning", style=wx.OK | wx.CENTER | wx.ICON_EXCLAMATION |
399 | | - ) |
400 | | - dialog.ShowModal() |
| 387 | + balt.showWarning(self, msg, title="Warning", do_center=True) |
401 | 388 |
|
402 | 389 | def on_next(self): |
403 | 390 | selection = [] |
|
0 commit comments