def Configure(self, x=0, y=0, displayNumber=None): text = self.text panel = eg.ConfigPanel() # enableDisplay = displayNumber is not None enableX = x is not None enableY = y is not None displayLabel = wx.StaticText(panel, -1, text.display) # displayCheckBox = wx.CheckBox(panel, -1, text.display) # displayCheckBox.SetValue(enableDisplay) if displayNumber is None: displayNumber = 0 displayChoice = eg.DisplayChoice(panel, displayNumber) # displayChoice.Enable(enableDisplay) xCheckBox = wx.CheckBox(panel, -1, text.text1) xCheckBox.SetValue(enableX) xCtrl = eg.SpinIntCtrl(panel, -1, 0 if not enableX else x, min=-32768, max=32767) xCtrl.Enable(enableX) yCheckBox = wx.CheckBox(panel, -1, text.text3) yCheckBox.SetValue(enableY) yCtrl = eg.SpinIntCtrl(panel, -1, 0 if not enableY else y, min=-32768, max=32767) yCtrl.Enable(enableY) monsCtrl = eg.MonitorsCtrl(panel, background=(224, 238, 238)) sizer = wx.GridBagSizer(vgap=6, hgap=5) sizer.Add(xCheckBox, (0, 0), (1, 1)) sizer.Add(xCtrl, (0, 1), (1, 1)) sizer.Add(wx.StaticText(panel, -1, text.text2), (0, 2), (1, 1)) sizer.Add(yCheckBox, (1, 0), (1, 1)) sizer.Add(yCtrl, (1, 1), (1, 1)) sizer.Add(wx.StaticText(panel, -1, text.text2), (1, 2), (1, 1)) sizer.Add(displayLabel, (2, 0), (1, 1), flag=wx.TOP, border=18) sizer.Add(displayChoice, (2, 1), (1, 2), flag=wx.TOP, border=17) panel.sizer.Add(sizer, 1, wx.EXPAND) panel.sizer.Add(monsCtrl) def HandleXCheckBox(event): xCtrl.Enable(event.IsChecked()) event.Skip() xCheckBox.Bind(wx.EVT_CHECKBOX, HandleXCheckBox) def HandleYCheckBox(event): yCtrl.Enable(event.IsChecked()) event.Skip() yCheckBox.Bind(wx.EVT_CHECKBOX, HandleYCheckBox) while panel.Affirmed(): panel.SetResult(xCtrl.GetValue() if xCtrl.IsEnabled() else None, yCtrl.GetValue() if yCtrl.IsEnabled() else None, displayChoice.GetValue())
def Configure( self, osdText="", fontInfo=None, foregroundColour=(255, 255, 255), backgroundColour=(0, 0, 0), alignment=0, offset=(0, 0), displayNumber=0, timeout=3.0, skin=None, ): if fontInfo is None: fontInfo = DEFAULT_FONT_INFO panel = eg.ConfigPanel() text = self.text editTextCtrl = panel.TextCtrl("\n\n", style=wx.TE_MULTILINE) height = editTextCtrl.GetBestSize()[1] editTextCtrl.ChangeValue(osdText) editTextCtrl.SetMinSize((-1, height)) alignmentChoice = panel.Choice(alignment, choices=text.alignmentChoices) displayChoice = eg.DisplayChoice(panel, displayNumber) xOffsetCtrl = panel.SpinIntCtrl(offset[0], -32000, 32000) yOffsetCtrl = panel.SpinIntCtrl(offset[1], -32000, 32000) timeCtrl = panel.SpinNumCtrl(timeout) fontButton = panel.FontSelectButton(fontInfo) foregroundColourButton = panel.ColourSelectButton(foregroundColour) if backgroundColour is None: tmpColour = (0, 0, 0) else: tmpColour = backgroundColour outlineCheckBox = panel.CheckBox(backgroundColour is not None, text.outlineFont) backgroundColourButton = panel.ColourSelectButton(tmpColour) if backgroundColour is None: backgroundColourButton.Enable(False) skinCtrl = panel.CheckBox(bool(skin), text.skin) sizer = wx.GridBagSizer(5, 5) expand = wx.EXPAND align = wx.ALIGN_CENTER_VERTICAL sizer.AddMany([ (panel.StaticText(text.editText), (0, 0), (1, 1), align), (editTextCtrl, (0, 1), (1, 4), expand), (panel.StaticText(text.osdFont), (1, 3), (1, 1), align), (fontButton, (1, 4)), (panel.StaticText(text.osdColour), (2, 3), (1, 1), align), (foregroundColourButton, (2, 4)), (outlineCheckBox, (3, 3), (1, 1), expand), (backgroundColourButton, (3, 4)), (skinCtrl, (4, 3)), (panel.StaticText(text.alignment), (1, 0), (1, 1), align), (alignmentChoice, (1, 1), (1, 1), expand), (panel.StaticText(text.display), (2, 0), (1, 1), align), (displayChoice, (2, 1), (1, 1), expand), (panel.StaticText(text.xOffset), (3, 0), (1, 1), align), (xOffsetCtrl, (3, 1), (1, 1), expand), (panel.StaticText(text.yOffset), (4, 0), (1, 1), align), (yOffsetCtrl, (4, 1), (1, 1), expand), (panel.StaticText(text.wait1), (5, 0), (1, 1), align), (timeCtrl, (5, 1), (1, 1), expand), (panel.StaticText(text.wait2), (5, 2), (1, 3), align), ]) sizer.AddGrowableCol(2) panel.sizer.Add(sizer, 1, wx.EXPAND) def OnCheckBox(event): backgroundColourButton.Enable(outlineCheckBox.IsChecked()) event.Skip() outlineCheckBox.Bind(wx.EVT_CHECKBOX, OnCheckBox) while panel.Affirmed(): if outlineCheckBox.IsChecked(): outlineColour = backgroundColourButton.GetValue() else: outlineColour = None panel.SetResult(editTextCtrl.GetValue(), fontButton.GetValue(), foregroundColourButton.GetValue(), outlineColour, alignmentChoice.GetValue(), (xOffsetCtrl.GetValue(), yOffsetCtrl.GetValue()), displayChoice.GetValue(), timeCtrl.GetValue(), skinCtrl.GetValue())
def Configure(self, x=None, y=None, displayNumber=None, center=False, useAlternateMethod=False): panel = eg.ConfigPanel() text = self.text uAMCB = panel.CheckBox(useAlternateMethod, text.label_AM) cCB = panel.CheckBox(center, text.label_C) xCB = panel.CheckBox(x is not None, text.text1) yCB = panel.CheckBox(y is not None, text.text3) displayCB = panel.CheckBox(displayNumber is not None, text.display) #xCtrl = panel.SpinIntCtrl(x or 0, min = -maxint - 1, max = maxint) xCtrl = panel.SpinIntCtrl(x or 0, min=0, max=maxint) # since 1.0.1 xCtrl.Enable(x is not None) #yCtrl = panel.SpinIntCtrl(y or 0, min = -maxint - 1, max = maxint) yCtrl = panel.SpinIntCtrl(y or 0, min=0, max=maxint) # since 1.0.1 yCtrl.Enable(y is not None) display = -1 if displayNumber is None else displayNumber displayChoice = eg.DisplayChoice(panel, display) displayChoice.Enable(displayNumber is not None) xPixels = wx.StaticText(panel, -1, text.text2) yPixels = wx.StaticText(panel, -1, text.text2) monsCtrl = eg.MonitorsCtrl(panel, background=(224, 238, 238)) note = wx.StaticText(panel, -1, text.note) note.SetForegroundColour(wx.RED) sizer = wx.GridBagSizer(vgap=6, hgap=5) sizer.Add(cCB, (0, 0), (1, 3), flag=wx.BOTTOM, border=8) sizer.Add(xCB, (1, 0), (1, 1)) sizer.Add(xCtrl, (1, 1), (1, 1)) sizer.Add(xPixels, (1, 2), (1, 1)) sizer.Add(yCB, (2, 0), (1, 1)) sizer.Add(yCtrl, (2, 1), (1, 1)) sizer.Add(yPixels, (2, 2), (1, 1)) sizer.Add(note, (3, 0), (1, 3)) sizer.Add(displayCB, (4, 0), (1, 1), flag=wx.TOP, border=14) sizer.Add(displayChoice, (4, 1), (1, 2), flag=wx.TOP, border=13) sizer.Add(uAMCB, (5, 0), (1, 3)) panel.sizer.Add(sizer, 1, wx.EXPAND) panel.sizer.Add(monsCtrl, 0, wx.TOP, 8) def HandleCenterCheckBox(event=None): val = not cCB.GetValue() xCB.Enable(val) xCtrl.Enable(val) xPixels.Enable(val) yCB.Enable(val) yCtrl.Enable(val) yPixels.Enable(val) if not val: xCB.SetValue(False) yCB.SetValue(False) xCtrl.SetValue(0) yCtrl.SetValue(0) if event: event.Skip() cCB.Bind(wx.EVT_CHECKBOX, HandleCenterCheckBox) HandleCenterCheckBox() def HandleXCheckBox(event): xCtrl.Enable(event.IsChecked()) event.Skip() xCB.Bind(wx.EVT_CHECKBOX, HandleXCheckBox) def HandleYCheckBox(event): yCtrl.Enable(event.IsChecked()) event.Skip() yCB.Bind(wx.EVT_CHECKBOX, HandleYCheckBox) def HandleDisplayCB(event): flag = event.IsChecked() displayChoice.Enable(flag) if flag: display = 0 if displayNumber is None else displayNumber else: display = -1 displayChoice.SetValue(display) event.Skip() displayCB.Bind(wx.EVT_CHECKBOX, HandleDisplayCB) while panel.Affirmed(): if xCtrl.IsEnabled(): x = xCtrl.GetValue() else: x = None if yCtrl.IsEnabled(): y = yCtrl.GetValue() else: y = None if displayChoice.IsEnabled(): displayNumber = displayChoice.GetValue() else: displayNumber = None panel.SetResult(x, y, displayNumber, cCB.GetValue(), uAMCB.GetValue())
def DisplayChoice(self, value=0, *args, **kwargs): return eg.DisplayChoice(self, value, *args, **kwargs)
def Configure(self, osdText="", fontInfo=None, foregroundColour=(255, 255, 255), backgroundColour=(0, 0, 0), alignment=0, offset=(0, 0), displayNumber=0, timeout=3.0, skin=None, justification=0, scrollText=0): if isinstance(skin, bool): skin = SKINS[0] if skin else None if fontInfo is None: fontInfo = DEFAULT_FONT_INFO panel = eg.ConfigPanel() text = self.text editTextCtrl = panel.TextCtrl(osdText, style=wx.TE_MULTILINE) alignmentChoice = panel.Choice(alignment, choices=text.alignmentChoices) justificationChoice = panel.Choice(justification, choices=text.justificationChoices) displayChoice = eg.DisplayChoice(panel, displayNumber) xOffsetCtrl = panel.SpinIntCtrl(offset[0], -32000, 32000) yOffsetCtrl = panel.SpinIntCtrl(offset[1], -32000, 32000) timeCtrl = panel.SpinNumCtrl(timeout) fontButton = panel.FontSelectButton(fontInfo) foregroundColourButton = panel.ColourSelectButton(foregroundColour) if backgroundColour is None: tmpColour = (0, 0, 0) else: tmpColour = backgroundColour outlineCheck = panel.CheckBox(backgroundColour is not None, '') backgroundColourButton = panel.ColourSelectButton(tmpColour) backgroundColourButton.Enable(backgroundColour is not None) useSkin = skin is not None skinCheck = panel.CheckBox(useSkin, '') skinChoice = panel.Choice(SKINS.index(skin) if skin else 0, SKINS) skinChoice.Enable(useSkin) scrollCtrl = panel.SpinIntCtrl(scrollText) scrollCheck = panel.CheckBox(scrollText > 0, '') scrollCtrl.Enable(scrollText > 0) sts = [] ctrls = [] def h_sizer(text, ctrl, ctrl2=None, prop=0): st = panel.StaticText(text) sts.append(st) line_sizer = wx.BoxSizer(wx.HORIZONTAL) line_sizer.Add(st, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5) if ctrl2 is None: line_sizer.Add(ctrl, prop, wx.ALL | wx.EXPAND, 5) ctrls.append(ctrl) else: if isinstance(ctrl2, wx.StaticText): line_sizer.Add(ctrl, prop, wx.ALL | wx.EXPAND, 5) ctrls.append(ctrl) line_sizer.Add(ctrl2, prop, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5) else: line_sizer.Add(ctrl, prop, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5) ctrls.append(ctrl2) line_sizer.Add(ctrl2, prop, wx.ALL | wx.EXPAND, 5) return line_sizer left_sizer = wx.BoxSizer(wx.VERTICAL) center_sizer = wx.BoxSizer(wx.VERTICAL) right_sizer = wx.BoxSizer(wx.VERTICAL) top_sizer = wx.BoxSizer(wx.VERTICAL) bottom_sizer = wx.BoxSizer(wx.HORIZONTAL) top_sizer.Add(h_sizer(text.editText, editTextCtrl, prop=1), 1, wx.EXPAND) bottom_sizer.Add(left_sizer) bottom_sizer.Add(center_sizer) bottom_sizer.Add(right_sizer) del ctrls[:] left_sizer.Add(h_sizer(text.alignment, alignmentChoice)) left_sizer.Add(h_sizer(text.justification, justificationChoice)) left_sizer.Add(h_sizer(text.display, displayChoice)) left_sizer.Add(h_sizer(text.osdFont, fontButton)) eg.EqualizeWidths(tuple(sts)) del sts[:] center_sizer.Add( h_sizer(text.outlineFont, outlineCheck, backgroundColourButton)) center_sizer.Add(h_sizer(text.skin, skinCheck, skinChoice)) center_sizer.Add(h_sizer(text.scroll, scrollCheck, scrollCtrl)) eg.EqualizeWidths(tuple(sts)) del sts[:] wait_suffix = panel.StaticText('sec') timeCtrl.numCtrl.SetToolTipString(text.wait2) timeCtrl.spinbutton.SetToolTipString(text.wait2) right_sizer.Add(h_sizer(text.xOffset, xOffsetCtrl)) right_sizer.Add(h_sizer(text.yOffset, yOffsetCtrl)) right_sizer.Add(h_sizer(text.wait1, timeCtrl, wait_suffix)) right_sizer.Add(h_sizer(text.osdColour, foregroundColourButton)) eg.EqualizeWidths(tuple(sts)) eg.EqualizeWidths(tuple(ctrls)) panel.sizer.Add(top_sizer, 1, wx.EXPAND) panel.sizer.Add(bottom_sizer) def OnCheckBoxBGColour(event): backgroundColourButton.Enable(outlineCheck.IsChecked()) event.Skip() outlineCheck.Bind(wx.EVT_CHECKBOX, OnCheckBoxBGColour) def OnCheckBoxSkin(event): skinChoice.Enable(skinCheck.IsChecked()) event.Skip() skinCheck.Bind(wx.EVT_CHECKBOX, OnCheckBoxSkin) def OnCheckBoxScroll(event): scrollCtrl.Enable(scrollCheck.IsChecked()) event.Skip() scrollCheck.Bind(wx.EVT_CHECKBOX, OnCheckBoxScroll) while panel.Affirmed(): if outlineCheck.IsChecked(): outlineColour = backgroundColourButton.GetValue() else: outlineColour = None if skinCheck.IsChecked(): skin = skinChoice.GetStringSelection() else: skin = None if scrollCheck.IsChecked(): scroll = scrollCtrl.GetValue() else: scroll = 0 panel.SetResult(editTextCtrl.GetValue(), fontButton.GetValue(), foregroundColourButton.GetValue(), outlineColour, alignmentChoice.GetValue(), (xOffsetCtrl.GetValue(), yOffsetCtrl.GetValue()), displayChoice.GetValue(), timeCtrl.GetValue(), skin, justificationChoice.GetSelection(), scroll)