chiark / gitweb /
Merge branch 'master' into SteamEngine
[cura.git] / Cura / gui / preferencesDialog.py
1 from __future__ import absolute_import
2
3 import wx
4
5 from Cura.gui import configBase
6 from Cura.util import removableStorage
7 from Cura.util import machineCom
8 from Cura.util import profile
9
10 class preferencesDialog(wx.Frame):
11         def __init__(self, parent):
12                 super(preferencesDialog, self).__init__(None, title="Preferences", style=wx.DEFAULT_DIALOG_STYLE)
13                 
14                 wx.EVT_CLOSE(self, self.OnClose)
15                 
16                 self.parent = parent
17                 self.oldExtruderAmount = int(profile.getPreference('extruder_amount'))
18
19                 self.panel = configBase.configPanelBase(self)
20                 
21                 left, right, main = self.panel.CreateConfigPanel(self)
22                 configBase.TitleRow(left, 'Machine settings')
23                 configBase.SettingRow(left, 'steps_per_e')
24                 configBase.SettingRow(left, 'machine_width')
25                 configBase.SettingRow(left, 'machine_depth')
26                 configBase.SettingRow(left, 'machine_height')
27                 configBase.SettingRow(left, 'extruder_amount')
28                 configBase.SettingRow(left, 'has_heated_bed')
29                 
30                 for i in xrange(1, self.oldExtruderAmount):
31                         configBase.TitleRow(left, 'Extruder %d' % (i+1))
32                         configBase.SettingRow(left, 'extruder_offset_x%d' % (i))
33                         configBase.SettingRow(left, 'extruder_offset_y%d' % (i))
34
35                 configBase.TitleRow(left, 'Colours')
36                 configBase.SettingRow(left, 'model_colour')
37                 for i in xrange(1, self.oldExtruderAmount):
38                         configBase.SettingRow(left, 'model_colour%d' % (i+1))
39
40                 configBase.TitleRow(right, 'Filament settings')
41                 configBase.SettingRow(right, 'filament_physical_density')
42                 configBase.SettingRow(right, 'filament_cost_kg')
43                 configBase.SettingRow(right, 'filament_cost_meter')
44
45                 configBase.TitleRow(right, 'Communication settings')
46                 configBase.SettingRow(right, 'serial_port', ['AUTO'] + machineCom.serialList())
47                 configBase.SettingRow(right, 'serial_baud', ['AUTO'] + map(str, machineCom.baudrateList()))
48
49                 configBase.TitleRow(right, 'Slicer settings')
50                 configBase.SettingRow(right, 'save_profile')
51
52                 configBase.TitleRow(right, 'SD Card settings')
53                 configBase.SettingRow(right, 'sdpath', removableStorage.getPossibleSDcardDrives())
54
55                 configBase.TitleRow(right, 'Cura settings')
56                 configBase.SettingRow(right, 'check_for_updates')
57                 configBase.SettingRow(right, 'submit_slice_information')
58
59                 self.okButton = wx.Button(right, -1, 'Ok')
60                 right.GetSizer().Add(self.okButton, (right.GetSizer().GetRows(), 0), flag=wx.BOTTOM, border=5)
61                 self.okButton.Bind(wx.EVT_BUTTON, self.OnClose)
62                 
63                 self.MakeModal(True)
64                 main.Fit()
65                 self.Fit()
66
67         def OnClose(self, e):
68                 if self.oldExtruderAmount != int(profile.getPreference('extruder_amount')):
69                         wx.MessageBox('After changing the amount of extruders you need to restart Cura for full effect.', 'Extruder amount warning.', wx.OK | wx.ICON_INFORMATION)
70                 self.MakeModal(False)
71                 self.parent.updateProfileToControls()
72                 self.Destroy()