diff --git a/.gitattributes b/.gitattributes index 8abc5e3..b401c91 100644 --- a/.gitattributes +++ b/.gitattributes @@ -113,6 +113,7 @@ invesalius/gui/__init__.py -text invesalius/gui/data_notebook.py -text invesalius/gui/default_tasks.py -text invesalius/gui/default_viewers.py -text +invesalius/gui/dialogs.py -text invesalius/gui/frame.py -text invesalius/gui/import_data_wizard.py -text invesalius/gui/import_panel.py -text diff --git a/invesalius/gui/dialogs.py b/invesalius/gui/dialogs.py new file mode 100644 index 0000000..8c28cf1 --- /dev/null +++ b/invesalius/gui/dialogs.py @@ -0,0 +1,59 @@ +import wx +from wx.lib import masked + +class NumberDialog(wx.Dialog): + def __init__(self, message, value=0): + pre = wx.PreDialog() + pre.Create(None, -1, "InVesalius 3", size=wx.DefaultSize, pos=wx.DefaultPosition, + style=wx.DEFAULT_DIALOG_STYLE) + self.PostCreate(pre) + + # Static text which contains message to user + print "message: ", message + label = wx.StaticText(self, -1, message) + + # Numeric value to be changed by user + num_ctrl = masked.NumCtrl(self, value=value, integerWidth=3, + fractionWidth=2, allowNegative=True) + self.num_ctrl = num_ctrl + + # Buttons + btn_ok = wx.Button(self, wx.ID_OK) + btn_ok.SetHelpText("Above value will be applied.") + btn_ok.SetDefault() + + btn_cancel = wx.Button(self, wx.ID_CANCEL) + btn_cancel.SetHelpText("Value will not be applied.)") + + btnsizer = wx.StdDialogButtonSizer() + btnsizer.AddButton(btn_ok) + btnsizer.AddButton(btn_cancel) + btnsizer.Realize() + + + sizer = wx.BoxSizer(wx.VERTICAL) + sizer.Add(label, 0, wx.ALIGN_CENTRE|wx.ALL, 5) + sizer.Add(num_ctrl, 0, wx.ALIGN_CENTRE|wx.ALL, 5) + sizer.Add(btnsizer, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5) + + self.SetSizer(sizer) + sizer.Fit(self) + + self.Centre() + + def SetValue(self, value): + self.num_ctrl.SetValue(value) + + def GetValue(self): + return self.num_ctrl.GetValue() + +def ShowNumberDialog(message, value=0): + dlg = NumberDialog(message, value) + dlg.SetValue(value) + + if dlg.ShowModal() == wx.ID_OK: + return dlg.GetValue() + dlg.Destroy() + + return 0 + -- libgit2 0.21.2