def getProfileSettings(self):
        settingsSizer = wx.GridBagSizer(hgap=2, vgap=1)
        settingsRow = 0

        for craftName in sorted(self.moduleSettingsMap.keys()):

            craftStaticBox = wx.StaticBox(self.scrollbarPanel, -1,
                                          craftName.capitalize())
            craftStaticBoxSizer = wx.StaticBoxSizer(craftStaticBox,
                                                    wx.VERTICAL)

            # For some reason the dialog size is not consistent between Windows and Linux - this is a hack to get it working
            if (os.name == 'nt'):
                craftStaticBoxSizer.SetMinSize((320, -1))
            else:
                craftStaticBoxSizer.SetMinSize((450, -1))
            pluginModule = archive.getModuleWithPath(
                os.path.join(skeinforge_craft.getPluginsDirectoryPath(),
                             craftName))
            repo = pluginModule.getNewRepository()

            for setting in settings.getReadRepository(repo).preferences:
                if setting.name in self.moduleSettingsMap[craftName]:

                    settingSizer = wx.GridBagSizer(hgap=2, vgap=2)
                    settingSizer.AddGrowableCol(0)
                    settingRow = 0
                    settingLabel = wx.StaticText(self.scrollbarPanel, -1,
                                                 setting.name)
                    settingLabel.Wrap(400)
                    settingSizer.Add(settingLabel, pos=(settingRow, 0))

                    if (isinstance(setting.value, bool)):
                        checkbox = wx.CheckBox(self.scrollbarPanel)
                        checkbox.SetName(craftName + '.' + setting.name)
                        checkbox.SetValue(setting.value)
                        settingSizer.Add(checkbox, pos=(settingRow, 1))
                        settingSizer.AddSpacer((25, -1), pos=(settingRow, 2))
                    else:
                        textCtrl = wx.TextCtrl(self.scrollbarPanel,
                                               value=str(setting.value),
                                               size=(50, -1))
                        textCtrl.SetName(craftName + '.' + setting.name)
                        settingSizer.Add(textCtrl, pos=(settingRow, 1))

                    craftStaticBoxSizer.Add(settingSizer, 1, wx.EXPAND, 0)
                    settingRow += 1
            col = settingsRow % 2
            settingsSizer.Add(craftStaticBoxSizer,
                              pos=(settingsRow - col, col))
            settingsRow += 1

        return settingsSizer
예제 #2
0
    def OnSave(self, e):
        for x in self.scrollbarPanel.GetChildren():
            if (isinstance(x, (wx.CheckBox, wx.TextCtrl))):
                name = x.GetName().partition('.')
                craftName = name[0]
                settingName = name[2]
                pluginModule = archive.getModuleWithPath(os.path.join(skeinforge_craft.getPluginsDirectoryPath(), craftName))
                repo = pluginModule.getNewRepository()

                for setting in settings.getReadRepository(repo).preferences:
                    if setting.name == settingName:
                        if setting.value == None or str(x.GetValue()) != str(setting.value):
                            self.saveSetting(repo, settingName, setting.value, x.GetValue())
        print("Skeinforge settings have been saved.")
        self.Destroy()
예제 #3
0
    def getProfileSettings(self):
        settingsSizer = wx.GridBagSizer(hgap=2, vgap=1)
        settingsRow = 0

        for craftName in sorted(self.moduleSettingsMap.keys()):

            craftStaticBox = wx.StaticBox(self.scrollbarPanel, -1, craftName.capitalize())
            craftStaticBoxSizer = wx.StaticBoxSizer(craftStaticBox, wx.VERTICAL)

            # For some reason the dialog size is not consistent between Windows and Linux - this is a hack to get it working
            if os.name == "nt":
                craftStaticBoxSizer.SetMinSize((320, -1))
            else:
                craftStaticBoxSizer.SetMinSize((450, -1))
            pluginModule = archive.getModuleWithPath(
                os.path.join(skeinforge_craft.getPluginsDirectoryPath(), craftName)
            )
            repo = pluginModule.getNewRepository()

            for setting in settings.getReadRepository(repo).preferences:
                if setting.name in self.moduleSettingsMap[craftName]:

                    settingSizer = wx.GridBagSizer(hgap=2, vgap=2)
                    settingSizer.AddGrowableCol(0)
                    settingRow = 0
                    settingLabel = wx.StaticText(self.scrollbarPanel, -1, setting.name)
                    settingLabel.Wrap(400)
                    settingSizer.Add(settingLabel, pos=(settingRow, 0))

                    if isinstance(setting.value, bool):
                        checkbox = wx.CheckBox(self.scrollbarPanel)
                        checkbox.SetName(craftName + "." + setting.name)
                        checkbox.SetValue(setting.value)
                        settingSizer.Add(checkbox, pos=(settingRow, 1))
                        settingSizer.AddSpacer((25, -1), pos=(settingRow, 2))
                    else:
                        textCtrl = wx.TextCtrl(self.scrollbarPanel, value=str(setting.value), size=(50, -1))
                        textCtrl.SetName(craftName + "." + setting.name)
                        settingSizer.Add(textCtrl, pos=(settingRow, 1))

                    craftStaticBoxSizer.Add(settingSizer, 1, wx.EXPAND, 0)
                    settingRow += 1
            col = settingsRow % 2
            settingsSizer.Add(craftStaticBoxSizer, pos=(settingsRow - col, col))
            settingsRow += 1

        return settingsSizer
예제 #4
0
 def OnSave(self, e):
     for x in self.scrollbarPanel.GetChildren():
         if (isinstance(x, (wx.CheckBox, wx.TextCtrl))):
             name = x.GetName().partition('.')
             craftName = name[0]
             settingName = name[2]
             pluginModule = archive.getModuleWithPath(os.path.join(skeinforge_craft.getPluginsDirectoryPath(), craftName))
             repo = pluginModule.getNewRepository()
             isDirty = False
             for setting in settings.getReadRepository(repo).preferences:
                 if setting.name == settingName:
                     if setting.value is None or str(x.GetValue()) != str(setting.value):
                         print('Saving ... ' + settingName + ' = ' + str(x.GetValue()))
                         setting.value = x.GetValue()
                         isDirty = True
             if isDirty:
                 settings.saveRepository(repo)
     print("Skeinforge settings have been saved.")
     self.Destroy()