From 1a5952ca7a91139e028ff00f0ede05a1dcaf82de Mon Sep 17 00:00:00 2001 From: paulojamorim Date: Tue, 3 May 2011 18:57:00 +0000 Subject: [PATCH] ENH: Created preferences window --- .gitattributes | 1 + invesalius/constants.py | 2 +- invesalius/gui/frame.py | 14 +++++++++++--- invesalius/gui/preferences.py | 108 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 121 insertions(+), 4 deletions(-) create mode 100644 invesalius/gui/preferences.py diff --git a/.gitattributes b/.gitattributes index 88273c7..2aca73b 100644 --- a/.gitattributes +++ b/.gitattributes @@ -135,6 +135,7 @@ icons/zh_TW.bmp -text invesalius/.svnignore -text invesalius/data/bases.py -text invesalius/data/co_registration.py -text +invesalius/gui/preferences.py -text locale/de/LC_MESSAGES/invesalius.mo -text locale/el/LC_MESSAGES/invesalius.mo -text locale/en/LC_MESSAGES/invesalius.mo -text diff --git a/invesalius/constants.py b/invesalius/constants.py index 558eb6c..46ff2a8 100644 --- a/invesalius/constants.py +++ b/invesalius/constants.py @@ -441,7 +441,7 @@ VTK_WARNING = 0 [ID_DICOM_IMPORT, ID_PROJECT_OPEN, ID_PROJECT_SAVE_AS, ID_PROJECT_SAVE, ID_PROJECT_CLOSE, ID_PROJECT_INFO, ID_SAVE_SCREENSHOT, ID_DICOM_LOAD_NET, -ID_PRINT_SCREENSHOT, ID_EXIT, ID_IMPORT_OTHERS_FILES, ID_ANALYZE_IMPORT] = [wx.NewId() for number in range(12)] +ID_PRINT_SCREENSHOT, ID_EXIT, ID_IMPORT_OTHERS_FILES, ID_ANALYZE_IMPORT, ID_PREFERENCES] = [wx.NewId() for number in range(13)] [ID_EDIT_UNDO, ID_EDIT_REDO, ID_EDIT_LIST] =\ diff --git a/invesalius/gui/frame.py b/invesalius/gui/frame.py index 8e1e2e8..521a7bd 100755 --- a/invesalius/gui/frame.py +++ b/invesalius/gui/frame.py @@ -34,6 +34,7 @@ import import_panel as imp import project as prj import session as ses import utils +import preferences # Layout tools' IDs - this is used only locally, therefore doesn't # need to be defined in constants.py @@ -312,6 +313,8 @@ class Frame(wx.Frame): self.ShowAbout() elif id == const.ID_START: self.ShowGettingStarted() + elif id == const.ID_PREFERENCES: + self.ShowPreferences() def OnSize(self, evt): """ @@ -320,6 +323,11 @@ class Frame(wx.Frame): ps.Publisher().sendMessage(('ProgressBar Reposition')) evt.Skip() + def ShowPreferences(self): + prf = preferences.Preferences(self) + prf.ShowModal() + #print "Show Preferences" + def ShowAbout(self): """ Shows about dialog. @@ -464,8 +472,8 @@ class MenuBar(wx.MenuBar): #tools_menu = wx.Menu() # OPTIONS - #options_menu = wx.Menu() - #options_menu.Append(104, "Preferences...") + options_menu = wx.Menu() + options_menu.Append(const.ID_PREFERENCES, _("Preferences...")) # HELP help_menu = wx.Menu() @@ -492,7 +500,7 @@ class MenuBar(wx.MenuBar): #self.Append(file_edit, "Edit") #self.Append(view_menu, "View") #self.Append(tools_menu, "Tools") - #self.Append(options_menu, "Options") + self.Append(options_menu, _("Options")) self.Append(help_menu, _("Help")) def OnEnableState(self, pubsub_evt): diff --git a/invesalius/gui/preferences.py b/invesalius/gui/preferences.py new file mode 100644 index 0000000..800c1af --- /dev/null +++ b/invesalius/gui/preferences.py @@ -0,0 +1,108 @@ +import wx + +ID = wx.NewId() + +try: + from agw import flatnotebook as fnb +except ImportError: # if it's not there locally, try the wxPython lib. + import wx.lib.agw.flatnotebook as fnb + + +class Preferences(wx.Dialog): + + def __init__( self, parent, id = ID, title = "Preferences", size=wx.DefaultSize,\ + pos=wx.DefaultPosition, style=wx.DEFAULT_DIALOG_STYLE): + + pre = wx.PreDialog() + pre.SetExtraStyle(wx.DIALOG_EX_CONTEXTHELP) + pre.Create(parent, ID, title, pos, size, style) + + self.PostCreate(pre) + + sizer = wx.BoxSizer(wx.VERTICAL) + + bookStyle = fnb.FNB_NODRAG | fnb.FNB_NO_NAV_BUTTONS | fnb.FNB_NO_X_BUTTON + self.book = fnb.FlatNotebook(self, wx.ID_ANY, agwStyle=bookStyle) + sizer.Add(self.book, 80, wx.EXPAND|wx.ALL) + + self.pnl_volume_rendering = Viewer3D(self) + self.pnl_language = Language(self) + + self.book.AddPage(self.pnl_volume_rendering, "Visualization") + self.book.AddPage(self.pnl_language, "Language") + + line = wx.StaticLine(self, -1, size=(20,-1), style=wx.LI_HORIZONTAL) + sizer.Add(line, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.RIGHT|wx.TOP, 5) + + btnsizer = wx.StdDialogButtonSizer() + + btn = wx.Button(self, wx.ID_OK, "Apply") + btnsizer.AddButton(btn) + + btn = wx.Button(self, wx.ID_CANCEL, "Cancel") + btnsizer.AddButton(btn) + + btnsizer.Realize() + + sizer.AddSizer(btnsizer, 10, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.RIGHT|wx.TOP, 5) + + self.SetSizer(sizer) + sizer.Fit(self) + + + +class Viewer3D(wx.Panel): + + def __init__(self, parent): + + wx.Panel.__init__(self, parent, size = wx.Size(800,600)) + + + box_visualization = wx.StaticBox(self, -1, "Surface") + bsizer = wx.StaticBoxSizer(box_visualization, wx.VERTICAL) + + lbl_inter = wx.StaticText(self, -1, "Interpolation ") + bsizer.Add(lbl_inter, 0, wx.TOP|wx.LEFT, 10) + + rb_inter = wx.RadioBox(self, -1, "", wx.DefaultPosition, wx.DefaultSize, + ['Flat','Gouraud','Phong'], 3, wx.RA_SPECIFY_COLS | wx.NO_BORDER) + + bsizer.Add(rb_inter, 0, wx.TOP|wx.LEFT, 0) + + box_rendering = wx.StaticBox(self, -1, "Volume Rendering") + bsizer_ren = wx.StaticBoxSizer(box_rendering, wx.VERTICAL) + + lbl_rendering = wx.StaticText(self, -1, "Rendering") + bsizer_ren.Add(lbl_rendering, 0, wx.TOP | wx.LEFT, 10) + + rb_rendering = wx.RadioBox(self, -1, "", wx.DefaultPosition, wx.DefaultSize, + ['CPU', 'GPU (Only NVidia video card)'], 3, wx.RA_SPECIFY_COLS | wx.NO_BORDER) + + bsizer_ren.Add(rb_rendering, 0, wx.TOP | wx.LEFT, 0) + + border = wx.BoxSizer(wx.VERTICAL) + border.Add(bsizer, 50, wx.EXPAND|wx.ALL, 10) + border.Add(bsizer_ren, 50, wx.EXPAND|wx.ALL, 10) + self.SetSizer(border) + + border.Fit(self) + +class Language(wx.Panel): + + def __init__(self, parent): + + wx.Panel.__init__(self, parent, size = wx.Size(800,600)) + + + box = wx.StaticBox(self, -1, "Language") + bsizer = wx.StaticBoxSizer(box, wx.VERTICAL) + + t = wx.StaticText(self, -1, "Control Test....") + bsizer.Add(t, 0, wx.TOP|wx.LEFT, 10) + + + border = wx.BoxSizer() + border.Add(bsizer, 1, wx.EXPAND|wx.ALL, 20) + self.SetSizer(border) + + border.Fit(self) -- libgit2 0.21.2