class SettingSectionHeaderWithCheckbox(SettingSectionHeaderBase): def ApplyAttributes(self, attributes): SettingSectionHeaderBase.ApplyAttributes(self, attributes) self.sgController = attributes.sgController checked = bool(self.sgController.GetValue()) left = SECTION_LABEL_LEFT - 20 - 2 self.checkbox = Checkbox(parent=self, align=uiconst.CENTERLEFT, text='', checked=checked, callback=self.CheckBoxChange, pos=(4, 0, 0, 20)) def CheckBoxChange(self, cb): value = cb.GetValue() self.sgController.SetValue(value) def OnClick(self, *args): self.checkbox.ToggleState()
class ProbeTooltipCheckboxRow(ProbeTooltipButtonBase): deleteFunction = None editFunction = None def ApplyAttributes(self, attributes): ProbeTooltipButtonBase.ApplyAttributes(self, attributes) self.checkBox = Checkbox(groupname=attributes.groupName, align=uiconst.CENTER, checked=attributes.checked, retval=attributes.retval, wrapLabel=True, prefstype=None, width=16, height=16, state=uiconst.UI_DISABLED) self.AddCell(self.checkBox, cellPadding=(5, 1, 4, 1)) self.deleteFunction = attributes.deleteFunc self.editFunction = attributes.editFunc self.label = EveLabelSmall(text=attributes.text, bold=True, align=uiconst.CENTERLEFT, autoFitToText=True, width=128) self.AddCell(self.label, colSpan=1 if attributes.filterIndex is not None else 2, cellPadding=(0, 2, 6, 2)) if attributes.filterIndex is not None: shortcutObj = ShortcutHint(text=str(attributes.filterIndex)) self.AddCell(shortcutObj, cellPadding=(2, 2, 2, 0)) return shortcutObj def OnDelete(self, *args): if self.deleteFunction: self.state = uiconst.UI_DISABLED if callable(self.deleteFunction): self.deleteFunction() elif isinstance(self.deleteFunction, tuple): func, args = self.deleteFunction func(*args) uicore.animations.FadeOut(self, duration=0.5, callback=self.Close) def OnEdit(self, *args): if callable(self.editFunction): self.editFunction() elif isinstance(self.editFunction, tuple): func, args = self.editFunction func(*args) def OnClick(self, *args): self.checkBox.ToggleState() if self.func: self.func(self.checkBox.data['value'], self.checkBox.GetValue()) def GetMenu(self): m = [] if self.editFunction: m.append((localization.GetByLabel('UI/Inventory/Filters/Edit'), self.OnEdit)) if self.deleteFunction: m.append( (localization.GetByLabel('UI/Common/Delete'), self.OnDelete)) return m