from __future__ import division
-from Cura.gui.configWizard import ConfigWizard
__copyright__ = "Copyright (C) 2013 David Braam - Released under terms of the AGPLv3 License"
import wx, wx.lib.stattext, types
from Cura.util import validators
from Cura.util import profile
+from Cura.gui import configWizard
class configPanelBase(wx.Panel):
"A base class for configuration dialogs. Handles creation of settings, and popups"
self.ctrl.SetValue(value)
class ToolheadRow(object):
- def __init__(self, panel, configName, valueOverride = None, index = None):
+ def __init__(self, panel, configName, index = None):
sizer = panel.GetSizer()
x = sizer.GetRows()
y = 0
self.settingIndex = index
self.validationMsg = ''
self.panel = panel
- # We need a subpanel here because SettingRow always takes 2 grid spaces
- # and we shouldn't take more than that.
+ # We need a subpanel here because SettingRow always takes 2 grid spaces
+ # and we shouldn't take more than that.
self.subpanel = wx.Panel(self.panel)
subsizer = wx.BoxSizer(wx.HORIZONTAL)
self.subpanel.SetSizer(subsizer)
self.ctrl = wx.TextCtrl(self.subpanel, -1, self.setting.getValue(self.settingIndex))
self.ctrl.Enable(False)
- self.changeToolheadButton = wx.Button(self.subpanel, -1, _("Change Toolhead"))
- self.changeToolheadButton.Bind(wx.EVT_BUTTON, self.OnChangeToolheadButton)
+ self.button = wx.Button(self.subpanel, -1, _("Change Toolhead"))
flag = wx.EXPAND
self.ctrl.Bind(wx.EVT_ENTER_WINDOW, self.OnMouseEnter)
subsizer.Add(self.ctrl, 1, flag=wx.ALIGN_CENTER_VERTICAL|wx.EXPAND)
- subsizer.Add(self.changeToolheadButton, 0, flag=wx.ALIGN_CENTER_VERTICAL|wx.LEFT,border=2)
+ subsizer.Add(self.button, 0, flag=wx.ALIGN_CENTER_VERTICAL|wx.LEFT,border=2)
sizer.Add(self.label, (x,y), flag=wx.ALIGN_CENTER_VERTICAL|wx.LEFT,border=10)
sizer.Add(self.subpanel, (x,y+1), flag=wx.ALIGN_CENTER_VERTICAL|flag)
sizer.SetRows(x+1)
- self.ctrl.Bind(wx.EVT_ENTER_WINDOW, self.OnMouseEnter)
- if isinstance(self.ctrl, floatspin.FloatSpin):
- self.ctrl.GetTextCtrl().Bind(wx.EVT_ENTER_WINDOW, self.OnMouseEnter)
- self.defaultBGColour = self.ctrl.GetTextCtrl().GetBackgroundColour()
- else:
- self.defaultBGColour = self.ctrl.GetBackgroundColour()
-
panel.main.settingControlList.append(self)
- def OnChangeToolheadButton(self, e):
- import configWizard
- import wx.wizard
- self.ToolheadSelectPage = configWizard.ToolheadSelectPage(self)
- wx.wizard.WizardPageSimple.Chain(self, self.GetParent().ToolheadSelectPage)
- self.ToolheadSelectPage.test()
-
def OnMouseEnter(self, e):
self.label.SetToolTipString(self.setting.getTooltip())
self.ctrl.SetToolTipString(self.setting.getTooltip())
+ e.Skip()
def OnMouseExit(self, e):
self.label.SetToolTipString('')
e.Skip()
def GetValue(self):
- if isinstance(self.ctrl, wx.ColourPickerCtrl):
- return str(self.ctrl.GetColour().GetAsString(wx.C2S_HTML_SYNTAX))
- elif isinstance(self.ctrl, wx.ComboBox):
- value = unicode(self.ctrl.GetValue())
- for ret in self._englishChoices:
- if _(ret) == value:
- return ret
- return value
- else:
- return str(self.ctrl.GetValue())
+ return str(self.ctrl.GetValue())
def SetValue(self, value):
- if isinstance(self.ctrl, wx.CheckBox):
- self.ctrl.SetValue(str(value) == "True")
- elif isinstance(self.ctrl, wx.ColourPickerCtrl):
- self.ctrl.SetColour(value)
- elif isinstance(self.ctrl, floatspin.FloatSpin):
- try:
- self.ctrl.SetValue(float(value))
- except ValueError:
- pass
- elif isinstance(self.ctrl, wx.ComboBox):
- self.ctrl.SetValue(_(value))
- else:
- self.ctrl.SetValue(value)
-
+ self.ctrl.SetValue(value)
+
+ def _validate(self):
+ pass
+
+
class PopUp(wx.Frame):
def __init__(self, parent, id, text):
wx.Frame.__init__(self, parent, id, 'Frame title', size=(400,300))