Commit 1a5952ca7a91139e028ff00f0ede05a1dcaf82de
1 parent
74084ca6
Exists in
master
and in
5 other branches
ENH: Created preferences window
Showing
4 changed files
with
121 additions
and
4 deletions
Show diff stats
.gitattributes
@@ -135,6 +135,7 @@ icons/zh_TW.bmp -text | @@ -135,6 +135,7 @@ icons/zh_TW.bmp -text | ||
135 | invesalius/.svnignore -text | 135 | invesalius/.svnignore -text |
136 | invesalius/data/bases.py -text | 136 | invesalius/data/bases.py -text |
137 | invesalius/data/co_registration.py -text | 137 | invesalius/data/co_registration.py -text |
138 | +invesalius/gui/preferences.py -text | ||
138 | locale/de/LC_MESSAGES/invesalius.mo -text | 139 | locale/de/LC_MESSAGES/invesalius.mo -text |
139 | locale/el/LC_MESSAGES/invesalius.mo -text | 140 | locale/el/LC_MESSAGES/invesalius.mo -text |
140 | locale/en/LC_MESSAGES/invesalius.mo -text | 141 | locale/en/LC_MESSAGES/invesalius.mo -text |
invesalius/constants.py
@@ -441,7 +441,7 @@ VTK_WARNING = 0 | @@ -441,7 +441,7 @@ VTK_WARNING = 0 | ||
441 | 441 | ||
442 | [ID_DICOM_IMPORT, ID_PROJECT_OPEN, ID_PROJECT_SAVE_AS, ID_PROJECT_SAVE, | 442 | [ID_DICOM_IMPORT, ID_PROJECT_OPEN, ID_PROJECT_SAVE_AS, ID_PROJECT_SAVE, |
443 | ID_PROJECT_CLOSE, ID_PROJECT_INFO, ID_SAVE_SCREENSHOT, ID_DICOM_LOAD_NET, | 443 | ID_PROJECT_CLOSE, ID_PROJECT_INFO, ID_SAVE_SCREENSHOT, ID_DICOM_LOAD_NET, |
444 | -ID_PRINT_SCREENSHOT, ID_EXIT, ID_IMPORT_OTHERS_FILES, ID_ANALYZE_IMPORT] = [wx.NewId() for number in range(12)] | 444 | +ID_PRINT_SCREENSHOT, ID_EXIT, ID_IMPORT_OTHERS_FILES, ID_ANALYZE_IMPORT, ID_PREFERENCES] = [wx.NewId() for number in range(13)] |
445 | 445 | ||
446 | 446 | ||
447 | [ID_EDIT_UNDO, ID_EDIT_REDO, ID_EDIT_LIST] =\ | 447 | [ID_EDIT_UNDO, ID_EDIT_REDO, ID_EDIT_LIST] =\ |
invesalius/gui/frame.py
@@ -34,6 +34,7 @@ import import_panel as imp | @@ -34,6 +34,7 @@ import import_panel as imp | ||
34 | import project as prj | 34 | import project as prj |
35 | import session as ses | 35 | import session as ses |
36 | import utils | 36 | import utils |
37 | +import preferences | ||
37 | 38 | ||
38 | # Layout tools' IDs - this is used only locally, therefore doesn't | 39 | # Layout tools' IDs - this is used only locally, therefore doesn't |
39 | # need to be defined in constants.py | 40 | # need to be defined in constants.py |
@@ -312,6 +313,8 @@ class Frame(wx.Frame): | @@ -312,6 +313,8 @@ class Frame(wx.Frame): | ||
312 | self.ShowAbout() | 313 | self.ShowAbout() |
313 | elif id == const.ID_START: | 314 | elif id == const.ID_START: |
314 | self.ShowGettingStarted() | 315 | self.ShowGettingStarted() |
316 | + elif id == const.ID_PREFERENCES: | ||
317 | + self.ShowPreferences() | ||
315 | 318 | ||
316 | def OnSize(self, evt): | 319 | def OnSize(self, evt): |
317 | """ | 320 | """ |
@@ -320,6 +323,11 @@ class Frame(wx.Frame): | @@ -320,6 +323,11 @@ class Frame(wx.Frame): | ||
320 | ps.Publisher().sendMessage(('ProgressBar Reposition')) | 323 | ps.Publisher().sendMessage(('ProgressBar Reposition')) |
321 | evt.Skip() | 324 | evt.Skip() |
322 | 325 | ||
326 | + def ShowPreferences(self): | ||
327 | + prf = preferences.Preferences(self) | ||
328 | + prf.ShowModal() | ||
329 | + #print "Show Preferences" | ||
330 | + | ||
323 | def ShowAbout(self): | 331 | def ShowAbout(self): |
324 | """ | 332 | """ |
325 | Shows about dialog. | 333 | Shows about dialog. |
@@ -464,8 +472,8 @@ class MenuBar(wx.MenuBar): | @@ -464,8 +472,8 @@ class MenuBar(wx.MenuBar): | ||
464 | #tools_menu = wx.Menu() | 472 | #tools_menu = wx.Menu() |
465 | 473 | ||
466 | # OPTIONS | 474 | # OPTIONS |
467 | - #options_menu = wx.Menu() | ||
468 | - #options_menu.Append(104, "Preferences...") | 475 | + options_menu = wx.Menu() |
476 | + options_menu.Append(const.ID_PREFERENCES, _("Preferences...")) | ||
469 | 477 | ||
470 | # HELP | 478 | # HELP |
471 | help_menu = wx.Menu() | 479 | help_menu = wx.Menu() |
@@ -492,7 +500,7 @@ class MenuBar(wx.MenuBar): | @@ -492,7 +500,7 @@ class MenuBar(wx.MenuBar): | ||
492 | #self.Append(file_edit, "Edit") | 500 | #self.Append(file_edit, "Edit") |
493 | #self.Append(view_menu, "View") | 501 | #self.Append(view_menu, "View") |
494 | #self.Append(tools_menu, "Tools") | 502 | #self.Append(tools_menu, "Tools") |
495 | - #self.Append(options_menu, "Options") | 503 | + self.Append(options_menu, _("Options")) |
496 | self.Append(help_menu, _("Help")) | 504 | self.Append(help_menu, _("Help")) |
497 | 505 | ||
498 | def OnEnableState(self, pubsub_evt): | 506 | def OnEnableState(self, pubsub_evt): |
@@ -0,0 +1,108 @@ | @@ -0,0 +1,108 @@ | ||
1 | +import wx | ||
2 | + | ||
3 | +ID = wx.NewId() | ||
4 | + | ||
5 | +try: | ||
6 | + from agw import flatnotebook as fnb | ||
7 | +except ImportError: # if it's not there locally, try the wxPython lib. | ||
8 | + import wx.lib.agw.flatnotebook as fnb | ||
9 | + | ||
10 | + | ||
11 | +class Preferences(wx.Dialog): | ||
12 | + | ||
13 | + def __init__( self, parent, id = ID, title = "Preferences", size=wx.DefaultSize,\ | ||
14 | + pos=wx.DefaultPosition, style=wx.DEFAULT_DIALOG_STYLE): | ||
15 | + | ||
16 | + pre = wx.PreDialog() | ||
17 | + pre.SetExtraStyle(wx.DIALOG_EX_CONTEXTHELP) | ||
18 | + pre.Create(parent, ID, title, pos, size, style) | ||
19 | + | ||
20 | + self.PostCreate(pre) | ||
21 | + | ||
22 | + sizer = wx.BoxSizer(wx.VERTICAL) | ||
23 | + | ||
24 | + bookStyle = fnb.FNB_NODRAG | fnb.FNB_NO_NAV_BUTTONS | fnb.FNB_NO_X_BUTTON | ||
25 | + self.book = fnb.FlatNotebook(self, wx.ID_ANY, agwStyle=bookStyle) | ||
26 | + sizer.Add(self.book, 80, wx.EXPAND|wx.ALL) | ||
27 | + | ||
28 | + self.pnl_volume_rendering = Viewer3D(self) | ||
29 | + self.pnl_language = Language(self) | ||
30 | + | ||
31 | + self.book.AddPage(self.pnl_volume_rendering, "Visualization") | ||
32 | + self.book.AddPage(self.pnl_language, "Language") | ||
33 | + | ||
34 | + line = wx.StaticLine(self, -1, size=(20,-1), style=wx.LI_HORIZONTAL) | ||
35 | + sizer.Add(line, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.RIGHT|wx.TOP, 5) | ||
36 | + | ||
37 | + btnsizer = wx.StdDialogButtonSizer() | ||
38 | + | ||
39 | + btn = wx.Button(self, wx.ID_OK, "Apply") | ||
40 | + btnsizer.AddButton(btn) | ||
41 | + | ||
42 | + btn = wx.Button(self, wx.ID_CANCEL, "Cancel") | ||
43 | + btnsizer.AddButton(btn) | ||
44 | + | ||
45 | + btnsizer.Realize() | ||
46 | + | ||
47 | + sizer.AddSizer(btnsizer, 10, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.RIGHT|wx.TOP, 5) | ||
48 | + | ||
49 | + self.SetSizer(sizer) | ||
50 | + sizer.Fit(self) | ||
51 | + | ||
52 | + | ||
53 | + | ||
54 | +class Viewer3D(wx.Panel): | ||
55 | + | ||
56 | + def __init__(self, parent): | ||
57 | + | ||
58 | + wx.Panel.__init__(self, parent, size = wx.Size(800,600)) | ||
59 | + | ||
60 | + | ||
61 | + box_visualization = wx.StaticBox(self, -1, "Surface") | ||
62 | + bsizer = wx.StaticBoxSizer(box_visualization, wx.VERTICAL) | ||
63 | + | ||
64 | + lbl_inter = wx.StaticText(self, -1, "Interpolation ") | ||
65 | + bsizer.Add(lbl_inter, 0, wx.TOP|wx.LEFT, 10) | ||
66 | + | ||
67 | + rb_inter = wx.RadioBox(self, -1, "", wx.DefaultPosition, wx.DefaultSize, | ||
68 | + ['Flat','Gouraud','Phong'], 3, wx.RA_SPECIFY_COLS | wx.NO_BORDER) | ||
69 | + | ||
70 | + bsizer.Add(rb_inter, 0, wx.TOP|wx.LEFT, 0) | ||
71 | + | ||
72 | + box_rendering = wx.StaticBox(self, -1, "Volume Rendering") | ||
73 | + bsizer_ren = wx.StaticBoxSizer(box_rendering, wx.VERTICAL) | ||
74 | + | ||
75 | + lbl_rendering = wx.StaticText(self, -1, "Rendering") | ||
76 | + bsizer_ren.Add(lbl_rendering, 0, wx.TOP | wx.LEFT, 10) | ||
77 | + | ||
78 | + rb_rendering = wx.RadioBox(self, -1, "", wx.DefaultPosition, wx.DefaultSize, | ||
79 | + ['CPU', 'GPU (Only NVidia video card)'], 3, wx.RA_SPECIFY_COLS | wx.NO_BORDER) | ||
80 | + | ||
81 | + bsizer_ren.Add(rb_rendering, 0, wx.TOP | wx.LEFT, 0) | ||
82 | + | ||
83 | + border = wx.BoxSizer(wx.VERTICAL) | ||
84 | + border.Add(bsizer, 50, wx.EXPAND|wx.ALL, 10) | ||
85 | + border.Add(bsizer_ren, 50, wx.EXPAND|wx.ALL, 10) | ||
86 | + self.SetSizer(border) | ||
87 | + | ||
88 | + border.Fit(self) | ||
89 | + | ||
90 | +class Language(wx.Panel): | ||
91 | + | ||
92 | + def __init__(self, parent): | ||
93 | + | ||
94 | + wx.Panel.__init__(self, parent, size = wx.Size(800,600)) | ||
95 | + | ||
96 | + | ||
97 | + box = wx.StaticBox(self, -1, "Language") | ||
98 | + bsizer = wx.StaticBoxSizer(box, wx.VERTICAL) | ||
99 | + | ||
100 | + t = wx.StaticText(self, -1, "Control Test....") | ||
101 | + bsizer.Add(t, 0, wx.TOP|wx.LEFT, 10) | ||
102 | + | ||
103 | + | ||
104 | + border = wx.BoxSizer() | ||
105 | + border.Add(bsizer, 1, wx.EXPAND|wx.ALL, 20) | ||
106 | + self.SetSizer(border) | ||
107 | + | ||
108 | + border.Fit(self) |