chiark / gitweb /
Increment version number
[cura.git] / Cura / gui / expertConfig.py
1 __copyright__ = "Copyright (C) 2013 David Braam - Released under terms of the AGPLv3 License"
2
3 import wx
4
5 from Cura.gui import configBase
6 from Cura.util import profile
7
8 class expertConfigWindow(wx.Dialog):
9         "Expert configuration window"
10         def _addSettingsToPanels(self, category, sub_category, left, right):
11                 count = len(profile.getSubCategoriesFor(category)) + len(profile.getSettingsForCategory(category))
12
13                 p = left
14                 n = 0
15                 for title in profile.getSubCategoriesFor(category):
16                         if sub_category is not None and sub_category != title:
17                                 continue
18                         n += 1 + len(profile.getSettingsForCategory(category, title))
19                         if n > count / 2:
20                                 p = right
21                         configBase.TitleRow(p, _(title))
22                         for s in profile.getSettingsForCategory(category, title):
23                                 if s.checkConditions():
24                                         configBase.SettingRow(p, s.getName())
25
26         def __init__(self, callback, sub_category=None):
27                 super(expertConfigWindow, self).__init__(None, title=_('Expert config'), style=wx.DEFAULT_DIALOG_STYLE)
28
29                 wx.EVT_CLOSE(self, self.OnClose)
30                 self.panel = configBase.configPanelBase(self, callback)
31
32                 left, right, main = self.panel.CreateConfigPanel(self)
33                 self._addSettingsToPanels('expert', sub_category, left, right)
34
35                 button_panel = right
36                 if sub_category is not None:
37                         button_panel = left
38                 self.okButton = wx.Button(button_panel, -1, 'Ok')
39                 button_panel.GetSizer().Add(self.okButton, (button_panel.GetSizer().GetRows(), 0), flag=wx.LEFT|wx.TOP|wx.BOTTOM, border=10)
40                 self.Bind(wx.EVT_BUTTON, lambda e: self.Close(), self.okButton)
41                 
42                 main.Fit()
43                 self.Fit()
44
45         def OnClose(self, e):
46                 self.Destroy()