From d8c404fbf7bf3d3352cdbe93f15207823e9205a4 Mon Sep 17 00:00:00 2001 From: daid303 Date: Wed, 20 Mar 2013 17:05:48 +0100 Subject: [PATCH] Update the preference window to use the new setting code. --- Cura/gui/configBase.py | 19 ++++-------- Cura/gui/preferencesDialog.py | 54 ++++++++++++++--------------------- Cura/util/profile.py | 52 ++++++++++++++++----------------- 3 files changed, 54 insertions(+), 71 deletions(-) diff --git a/Cura/gui/configBase.py b/Cura/gui/configBase.py index 83448e98..6b20cbe6 100644 --- a/Cura/gui/configBase.py +++ b/Cura/gui/configBase.py @@ -136,7 +136,7 @@ class TitleRow(): sizer.SetRows(x + 2) class SettingRow(): - def __init__(self, panel, configName): + def __init__(self, panel, configName, valueOverride = None): "Add a setting to the configuration panel" sizer = panel.GetSizer() x = sizer.GetRows() @@ -166,8 +166,11 @@ class SettingRow(): self.ctrl = wx.ColourPickerCtrl(panel, -1) self.SetValue(self.setting.getValue()) self.ctrl.Bind(wx.EVT_COLOURPICKER_CHANGED, self.OnSettingChange) - elif type(self.setting.getType()) is list: - self.ctrl = wx.ComboBox(panel, -1, self.setting.getValue(), choices=self.setting.getType(), style=wx.CB_DROPDOWN|wx.CB_READONLY) + elif type(self.setting.getType()) is list or valueOverride is not None: + if valueOverride is not None: + self.ctrl = wx.ComboBox(panel, -1, self.setting.getValue(), choices=valueOverride, style=wx.CB_DROPDOWN|wx.CB_READONLY) + else: + self.ctrl = wx.ComboBox(panel, -1, self.setting.getValue(), choices=self.setting.getType(), style=wx.CB_DROPDOWN|wx.CB_READONLY) self.ctrl.Bind(wx.EVT_COMBOBOX, self.OnSettingChange) self.ctrl.Bind(wx.EVT_LEFT_DOWN, self.OnMouseExit) flag = wx.EXPAND @@ -176,16 +179,6 @@ class SettingRow(): self.ctrl.Bind(wx.EVT_TEXT, self.OnSettingChange) flag = wx.EXPAND - # Set the minimum size of control to something other than the humungous default - minSize = self.ctrl.GetMinSize() - - ##if platform.system() == "Darwin": - ## # Under MacOS, it appears that the minSize is used for the actual size, so give the field a bit more room... - ## minSize[0] = 150 - ##else: - ## minSize[0] = 50 - ##self.ctrl.SetMinSize(minSize) - sizer.Add(self.label, (x,y), flag=wx.ALIGN_CENTER_VERTICAL|wx.LEFT,border=10) sizer.Add(self.ctrl, (x,y+1), flag=wx.ALIGN_BOTTOM|flag) sizer.SetRows(x+1) diff --git a/Cura/gui/preferencesDialog.py b/Cura/gui/preferencesDialog.py index 3ef3fc1a..baf103eb 100644 --- a/Cura/gui/preferencesDialog.py +++ b/Cura/gui/preferencesDialog.py @@ -20,55 +20,45 @@ class preferencesDialog(wx.Frame): left, right, main = self.panel.CreateConfigPanel(self) configBase.TitleRow(left, 'Machine settings') - c = configBase.SettingRow(left, 'Steps per E', 'steps_per_e', '0', 'Amount of steps per mm filament extrusion', type = 'preference') - validators.validFloat(c, 0.1) - c = configBase.SettingRow(left, 'Maximum width (mm)', 'machine_width', '205', 'Size of the machine in mm', type = 'preference') - validators.validFloat(c, 10.0) - c = configBase.SettingRow(left, 'Maximum depth (mm)', 'machine_depth', '205', 'Size of the machine in mm', type = 'preference') - validators.validFloat(c, 10.0) - c = configBase.SettingRow(left, 'Maximum height (mm)', 'machine_height', '200', 'Size of the machine in mm', type = 'preference') - validators.validFloat(c, 10.0) - c = configBase.SettingRow(left, 'Extruder count', 'extruder_amount', ['1', '2', '3', '4'], 'Amount of extruders in your machine.', type = 'preference') - c = configBase.SettingRow(left, 'Heated bed', 'has_heated_bed', False, 'If you have an heated bed, this enabled heated bed settings', type = 'preference') + configBase.SettingRow(left, 'steps_per_e') + configBase.SettingRow(left, 'machine_width') + configBase.SettingRow(left, 'machine_depth') + configBase.SettingRow(left, 'machine_height') + configBase.SettingRow(left, 'extruder_amount') + configBase.SettingRow(left, 'has_heated_bed') for i in xrange(1, self.oldExtruderAmount): configBase.TitleRow(left, 'Extruder %d' % (i+1)) - c = configBase.SettingRow(left, 'Offset X', 'extruder_offset_x%d' % (i), '0.0', 'The offset of your secondary extruder compared to the primary.', type = 'preference') - validators.validFloat(c) - c = configBase.SettingRow(left, 'Offset Y', 'extruder_offset_y%d' % (i), '0.0', 'The offset of your secondary extruder compared to the primary.', type = 'preference') - validators.validFloat(c) + configBase.SettingRow(left, 'extruder_offset_x%d' % (i)) + configBase.SettingRow(left, 'extruder_offset_y%d' % (i)) configBase.TitleRow(left, 'Colours') - c = configBase.SettingRow(left, 'Model colour', 'model_colour', wx.Colour(0,0,0), '', type = 'preference') + configBase.SettingRow(left, 'model_colour') for i in xrange(1, self.oldExtruderAmount): - c = configBase.SettingRow(left, 'Model colour (%d)' % (i+1), 'model_colour%d' % (i+1), wx.Colour(0,0,0), '', type = 'preference') + configBase.SettingRow(left, 'model_colour%d' % (i+1)) configBase.TitleRow(right, 'Filament settings') - c = configBase.SettingRow(right, 'Density (kg/m3)', 'filament_physical_density', '1300', 'Weight of the filament per m3. Around 1300 for PLA. And around 1040 for ABS. This value is used to estimate the weight if the filament used for the print.', type = 'preference') - validators.validFloat(c, 500.0, 3000.0) - c = configBase.SettingRow(right, 'Cost (price/kg)', 'filament_cost_kg', '0', 'Cost of your filament per kg, to estimate the cost of the final print.', type = 'preference') - validators.validFloat(c, 0.0) - c = configBase.SettingRow(right, 'Cost (price/m)', 'filament_cost_meter', '0', 'Cost of your filament per meter, to estimate the cost of the final print.', type = 'preference') - validators.validFloat(c, 0.0) - + configBase.SettingRow(right, 'filament_physical_density') + configBase.SettingRow(right, 'filament_cost_kg') + configBase.SettingRow(right, 'filament_cost_meter') + configBase.TitleRow(right, 'Communication settings') - c = configBase.SettingRow(right, 'Serial port', 'serial_port', ['AUTO'] + machineCom.serialList(), 'Serial port to use for communication with the printer', type = 'preference') - c = configBase.SettingRow(right, 'Baudrate', 'serial_baud', ['AUTO'] + map(str, machineCom.baudrateList()), 'Speed of the serial port communication\nNeeds to match your firmware settings\nCommon values are 250000, 115200, 57600', type = 'preference') + configBase.SettingRow(right, 'serial_port', ['AUTO'] + machineCom.serialList()) + configBase.SettingRow(right, 'serial_baud', ['AUTO'] + map(str, machineCom.baudrateList())) configBase.TitleRow(right, 'Slicer settings') - #c = configBase.SettingRow(right, 'Slicer selection', 'slicer', ['Cura (Skeinforge based)', 'Slic3r'], 'Which slicer to use to slice objects. Usually the Cura engine produces the best results. But Slic3r is developing fast and is faster with slicing.', type = 'preference') - c = configBase.SettingRow(right, 'Save profile on slice', 'save_profile', False, 'When slicing save the profile as [stl_file]_profile.ini next to the model.', type = 'preference') + configBase.SettingRow(right, 'save_profile') configBase.TitleRow(right, 'SD Card settings') if len(profile.getSDcardDrives()) > 1: - c = configBase.SettingRow(right, 'SD card drive', 'sdpath', profile.getSDcardDrives(), 'Location of your SD card, when using the copy to SD feature.', type = 'preference') + configBase.SettingRow(right, 'sdpath', profile.getSDcardDrives()) else: - c = configBase.SettingRow(right, 'SD card path', 'sdpath', '', 'Location of your SD card, when using the copy to SD feature.', type = 'preference') - c = configBase.SettingRow(right, 'Copy to SD with 8.3 names', 'sdshortnames', False, 'Save the gcode files in short filenames, so they are properly shown on the UltiController', type = 'preference') + configBase.SettingRow(right, 'sdpath') + configBase.SettingRow(right, 'sdshortnames') configBase.TitleRow(right, 'Cura settings') - c = configBase.SettingRow(right, 'Check for updates', 'check_for_updates', True, 'Check for newer versions of Cura on startup', type = 'preference') - c = configBase.SettingRow(right, 'Send usage statistics', 'submit_slice_information', True, 'Submit anonymous usage information to improve next versions of Cura', type = 'preference') + configBase.SettingRow(right, 'check_for_updates') + configBase.SettingRow(right, 'submit_slice_information') self.okButton = wx.Button(right, -1, 'Ok') right.GetSizer().Add(self.okButton, (right.GetSizer().GetRows(), 0), flag=wx.BOTTOM, border=5) diff --git a/Cura/util/profile.py b/Cura/util/profile.py index 0c716462..36357eee 100644 --- a/Cura/util/profile.py +++ b/Cura/util/profile.py @@ -236,34 +236,34 @@ G92 E0 setting('startMode', 'Simple', ['Simple', 'Normal'], 'preference', 'hidden') setting('lastFile', os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', 'resources', 'example', 'UltimakerRobot_support.stl')), str, 'preference', 'hidden') -setting('machine_width', '205', float, 'preference', 'hidden') -setting('machine_depth', '205', float, 'preference', 'hidden') -setting('machine_height', '200', float, 'preference', 'hidden') +setting('machine_width', '205', float, 'preference', 'hidden').setLabel('Maximum width (mm)', 'Size of the machine in mm') +setting('machine_depth', '205', float, 'preference', 'hidden').setLabel('Maximum depth (mm)', 'Size of the machine in mm') +setting('machine_height', '200', float, 'preference', 'hidden').setLabel('Maximum height (mm)', 'Size of the machine in mm') setting('machine_type', 'unknown', str, 'preference', 'hidden') setting('machine_center_is_zero', 'False', bool, 'preference', 'hidden') setting('ultimaker_extruder_upgrade', 'False', bool, 'preference', 'hidden') -setting('has_heated_bed', 'False', bool, 'preference', 'hidden') +setting('has_heated_bed', 'False', bool, 'preference', 'hidden').setLabel('Heated bed', 'If you have an heated bed, this enabled heated bed settings (requires restart)') setting('reprap_name', 'RepRap', str, 'preference', 'hidden') -setting('extruder_amount', '1', int, 'preference', 'hidden') -setting('extruder_offset_x1', '-21.6', float, 'preference', 'hidden') -setting('extruder_offset_y1', '0.0', float, 'preference', 'hidden') -setting('extruder_offset_x2', '0.0', float, 'preference', 'hidden') -setting('extruder_offset_y2', '0.0', float, 'preference', 'hidden') -setting('extruder_offset_x3', '0.0', float, 'preference', 'hidden') -setting('extruder_offset_y3', '0.0', float, 'preference', 'hidden') -setting('filament_physical_density', '1300', float, 'preference', 'hidden') -setting('steps_per_e', '0', float, 'preference', 'hidden') -setting('serial_port', 'AUTO', str, 'preference', 'hidden') +setting('extruder_amount', '1', ['1','2','3','4'], 'preference', 'hidden').setLabel('Extruder count', 'Amount of extruders in your machine.') +setting('extruder_offset_x1', '-21.6', float, 'preference', 'hidden').setLabel('Offset X', 'The offset of your secondary extruder compared to the primary.') +setting('extruder_offset_y1', '0.0', float, 'preference', 'hidden').setLabel('Offset Y', 'The offset of your secondary extruder compared to the primary.') +setting('extruder_offset_x2', '0.0', float, 'preference', 'hidden').setLabel('Offset X', 'The offset of your secondary extruder compared to the primary.') +setting('extruder_offset_y2', '0.0', float, 'preference', 'hidden').setLabel('Offset Y', 'The offset of your secondary extruder compared to the primary.') +setting('extruder_offset_x3', '0.0', float, 'preference', 'hidden').setLabel('Offset X', 'The offset of your secondary extruder compared to the primary.') +setting('extruder_offset_y3', '0.0', float, 'preference', 'hidden').setLabel('Offset Y', 'The offset of your secondary extruder compared to the primary.') +setting('filament_physical_density', '1300', float, 'preference', 'hidden').setRange(500.0, 3000.0).setLabel('Density (kg/m3)', 'Weight of the filament per m3. Around 1300 for PLA. And around 1040 for ABS. This value is used to estimate the weight if the filament used for the print.') +setting('steps_per_e', '0', float, 'preference', 'hidden').setRange(0).setLabel('E-Steps per 1mm filament', 'Amount of steps per mm filament extrusion') +setting('serial_port', 'AUTO', str, 'preference', 'hidden').setLabel('Serial port', 'Serial port to use for communication with the printer') setting('serial_port_auto', '', str, 'preference', 'hidden') -setting('serial_baud', 'AUTO', str, 'preference', 'hidden') +setting('serial_baud', 'AUTO', str, 'preference', 'hidden').setLabel('Baudrate', 'Speed of the serial port communication\nNeeds to match your firmware settings\nCommon values are 250000, 115200, 57600') setting('serial_baud_auto', '', int, 'preference', 'hidden') -setting('save_profile', 'False', bool, 'preference', 'hidden') -setting('filament_cost_kg', '0', float, 'preference', 'hidden') -setting('filament_cost_meter', '0', float, 'preference', 'hidden') -setting('sdpath', '', str, 'preference', 'hidden') -setting('sdshortnames', 'False', bool, 'preference', 'hidden') -setting('check_for_updates', 'True', bool, 'preference', 'hidden') -setting('submit_slice_information', 'False', bool, 'preference', 'hidden') +setting('save_profile', 'False', bool, 'preference', 'hidden').setLabel('Save profile on slice', 'When slicing save the profile as [stl_file]_profile.ini next to the model.') +setting('filament_cost_kg', '0', float, 'preference', 'hidden').setLabel('Cost (price/kg)', 'Cost of your filament per kg, to estimate the cost of the final print.') +setting('filament_cost_meter', '0', float, 'preference', 'hidden').setLabel('Cost (price/m)', 'Cost of your filament per meter, to estimate the cost of the final print.') +setting('sdpath', '', str, 'preference', 'hidden').setLabel('SD card drive', 'Location of your SD card, when using the copy to SD feature.') +setting('sdshortnames', 'False', bool, 'preference', 'hidden').setLabel('Copy to SD with 8.3 names', 'Save the gcode files in short filenames, so they are properly shown on the UltiController') +setting('check_for_updates', 'True', bool, 'preference', 'hidden').setLabel('Check for updates', 'Check for newer versions of Cura on startup') +setting('submit_slice_information', 'False', bool, 'preference', 'hidden').setLabel('Send usage statistics', 'Submit anonymous usage information to improve next versions of Cura') setting('planner_always_autoplace', 'True', bool, 'preference', 'hidden') setting('extruder_head_size_min_x', '75.0', float, 'preference', 'hidden') @@ -272,10 +272,10 @@ setting('extruder_head_size_max_x', '18.0', float, 'preference', 'hidden') setting('extruder_head_size_max_y', '35.0', float, 'preference', 'hidden') setting('extruder_head_size_height', '60.0', float, 'preference', 'hidden') -setting('model_colour', '#7AB645', str, 'preference', 'hidden') -setting('model_colour2', '#CB3030', str, 'preference', 'hidden') -setting('model_colour3', '#DDD93C', str, 'preference', 'hidden') -setting('model_colour4', '#4550D3', str, 'preference', 'hidden') +setting('model_colour', '#7AB645', str, 'preference', 'hidden').setLabel('Model colour') +setting('model_colour2', '#CB3030', str, 'preference', 'hidden').setLabel('Model colour (2)') +setting('model_colour3', '#DDD93C', str, 'preference', 'hidden').setLabel('Model colour (3)') +setting('model_colour4', '#4550D3', str, 'preference', 'hidden').setLabel('Model colour (4)') setting('window_maximized', 'False', bool, 'preference', 'hidden') setting('window_pos_x', '-1', float, 'preference', 'hidden') -- 2.30.2