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