def Configure(self, program="", winName=None, winClass=None, childName=None, childClass=None, matchNum=1, includeInvisible=False, timeout=0, stop=STOP_IF_NOT_FOUND): panel = eg.ConfigPanel(resizable=True) text = self.text searchOnlyFrontmost = False if stop is None: program = "" matchNum = 1 includeInvisible = False timeout = 0 stop = 0 searchOnlyFrontmost = True self.dialog = panel.dialog self.lastHwnd = None self.lastPid = None self.hideOnDrag = True # the "only search for the frontmost" checkbox cbOnlyFrontmost = wx.CheckBox(panel, -1, text.onlyFrontmost) def OnSearchOnlyFrontmostCheckbox(event): flag = not cbOnlyFrontmost.IsChecked() cbIncludeInvisible.Enable(flag) if not flag: stopMacroCtrl_1.SetValue(False) stopMacroCtrl_2.SetValue(False) stopMacroCtrl_1.Enable(flag) stopMacroCtrl_2.Enable(flag) waitCtrl.Enable(flag) for checkBox, textCtrl in self.options[:-1]: checkBox.Enable(flag) textCtrl.Enable(flag and checkBox.GetValue()) self.options[-1][0].Enable(flag) self.options[-1][1].Enable(flag) event.Skip() cbOnlyFrontmost.Bind(wx.EVT_CHECKBOX, OnSearchOnlyFrontmostCheckbox) # the IncludeInvisible checkbox cbIncludeInvisible = wx.CheckBox(panel, -1, text.invisible_box) def OnIncludeInvisibleCheckbox(event): hwnd = self.lastHwnd self.tree.includeInvisible = cbIncludeInvisible.IsChecked() self.tree.Refresh() self.tree.SelectHwnd(hwnd) event.Skip() cbIncludeInvisible.Bind(wx.EVT_CHECKBOX, OnIncludeInvisibleCheckbox) # the stop-macro choice id_1 = wx.NewId() stopMacroCtrl_1 = wx.CheckBox(panel, id_1, text.stopMacro[0]) id_2 = wx.NewId() stopMacroCtrl_2 = wx.CheckBox(panel, id_2, text.stopMacro[1]) if stop == STOP_IF_NOT_FOUND: stopMacroCtrl_1.SetValue(True) stopMacroCtrl_2.Enable(False) elif stop == STOP_IF_FOUND: stopMacroCtrl_2.SetValue(True) stopMacroCtrl_1.Enable(False) def OnStopMacroCtrl(event): # if cbOnlyFrontmost.IsChecked(): id = event.GetId() flag = event.IsChecked() if id == id_1: stopMacroCtrl_2.Enable(not flag) if flag: stopMacroCtrl_2.SetValue(False) else: stopMacroCtrl_1.Enable(not flag) if flag: stopMacroCtrl_1.SetValue(False) event.Skip() stopMacroCtrl_1.Bind(wx.EVT_CHECKBOX, OnStopMacroCtrl) stopMacroCtrl_2.Bind(wx.EVT_CHECKBOX, OnStopMacroCtrl) finderTool = eg.WindowDragFinder(panel, self.OnFinderToolLeftClick, self.OnFinderTool) self.finderTool = finderTool # the HideOnDrag checkbox cbHideOnDrag = wx.CheckBox(panel, -1, text.hide_box) cbHideOnDrag.SetValue(Config.hideOnDrag) def OnHideOnDragCheckbox(dummyEvent): Config.hideOnDrag = cbHideOnDrag.IsChecked() cbHideOnDrag.Bind(wx.EVT_CHECKBOX, OnHideOnDragCheckbox) # the tree to display processes and windows self.tree = eg.WindowTree(panel, includeInvisible=includeInvisible) cbIncludeInvisible.SetValue(includeInvisible) # the refresh button refreshButton = wx.Button(panel, -1, text.refresh_btn) def OnButton(dummyEvent): hwnd = self.lastHwnd self.tree.Refresh() self.tree.SelectHwnd(hwnd) refreshButton.Bind(wx.EVT_BUTTON, OnButton) # construction of the layout with sizers dragSizer = wx.StaticBoxSizer(wx.StaticBox(panel, -1, "Drag Finder"), wx.VERTICAL) dragSizer.Add(finderTool, 0, wx.ALIGN_CENTER_HORIZONTAL | wx.BOTTOM, 4) dragSizer.Add(cbHideOnDrag) leftTopSizer = wx.BoxSizer(wx.VERTICAL) leftTopSizer.Add(cbOnlyFrontmost, 0, wx.BOTTOM, 5) leftTopSizer.Add(cbIncludeInvisible, 0, wx.BOTTOM, 5) leftTopSizer.Add(stopMacroCtrl_1, 0, wx.BOTTOM, 5) leftTopSizer.Add(stopMacroCtrl_2, 0, wx.BOTTOM, 5) topSizer = wx.BoxSizer(wx.HORIZONTAL) topSizer.Add(leftTopSizer, 1, wx.EXPAND) topSizer.Add(dragSizer) sizer1 = wx.GridBagSizer(vgap=4, hgap=4) sizer1.SetEmptyCellSize((0, 0)) sizer1.Add(self.tree, (0, 0), (1, 5), wx.EXPAND) sizer1.Add(refreshButton, (1, 4), (2, 1), wx.ALIGN_TOP | wx.ALIGN_RIGHT) self.options = options = [] def Wrapper(textCtrl, checkBox): def OnCheckBox(event): textCtrl.Enable(checkBox.GetValue()) event.Skip() return OnCheckBox def MakeLine(line, checkBoxText, value): checkBox = wx.CheckBox(panel, -1, checkBoxText) sizer1.Add(checkBox, (line, 0), (1, 1), wx.ALIGN_CENTER_VERTICAL) textCtrl = wx.TextCtrl(panel, -1, size=(20, -1)) if value is not None: checkBox.SetValue(True) textCtrl.SetValue(value) else: textCtrl.Enable(False) sizer1.Add(textCtrl, (line, 1), (1, 3), wx.EXPAND) checkBox.Bind(wx.EVT_CHECKBOX, Wrapper(textCtrl, checkBox)) options.append((checkBox, textCtrl)) line += 1 MakeLine(1, text.options[0], program) MakeLine(2, text.options[1], winName) MakeLine(3, text.options[2], winClass) MakeLine(4, text.options[3], childName) MakeLine(5, text.options[4], childClass) line = 6 numMatchCB = wx.CheckBox(panel, -1, text.matchNum1) numMatchCB.SetValue(bool(matchNum)) sizer1.Add(numMatchCB, (line, 0), (1, 1), wx.ALIGN_CENTER_VERTICAL) numMatchCtrl = eg.SpinIntCtrl(panel, -1, matchNum or 1, 1) sizer1.Add(numMatchCtrl, (line, 1), (1, 1), wx.EXPAND) sizer1.Add(wx.StaticText(panel, -1, text.matchNum2), (line, 2), (1, 3), wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_LEFT) numMatchCB.Bind(wx.EVT_CHECKBOX, Wrapper(numMatchCtrl, numMatchCB)) options.append((numMatchCB, numMatchCtrl)) line += 1 # the wait parameter waitCtrl = eg.SpinNumCtrl(panel) waitCtrl.SetValue(timeout) sizer1.Add(panel.StaticText(text.wait1), (line, 0), (1, 1), wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT) sizer1.Add(waitCtrl, (line, 1), (1, 1), wx.ALIGN_CENTER_VERTICAL | wx.EXPAND) sizer1.Add(panel.StaticText(text.wait2), (line, 2), (1, 3), wx.ALIGN_CENTER_VERTICAL) line += 1 sizer1.Add((1, 1), (line, 0)) sizer1.AddGrowableCol(2, 100) sizer1.AddGrowableRow(0, 100) #sizer1.SetItemMinSize(options[0][1], 300, -1) # group the main lines together panel.sizer.AddMany([ (topSizer, 0, wx.EXPAND), ((5, 5), ), (sizer1, 1, wx.EXPAND), ]) # re-assign the test button def OnTestButton(dummyEvent): args = GetResult()[:-2] # we don't need timeout and stopMacro hwnds = eg.WindowMatcher(*args)() dialog = TestDialog(panel.dialog, hwnds) dialog.ShowModal() dialog.Destroy() panel.dialog.buttonRow.testButton.Bind(wx.EVT_BUTTON, OnTestButton) @eg.LogIt def GetResult(): resultList = [] for checkBox, textCtrl in options: if not checkBox.IsChecked(): resultList.append(None) else: resultList.append(textCtrl.GetValue()) resultList.append(self.tree.includeInvisible) resultList.append(waitCtrl.GetValue()) if stopMacroCtrl_1.IsChecked(): resultList.append(STOP_IF_NOT_FOUND) elif stopMacroCtrl_2.IsChecked(): resultList.append(STOP_IF_FOUND) else: resultList.append(STOP_NEVER) return resultList hwnds = eg.WindowMatcher( program, winName, winClass, childName, childClass, matchNum, includeInvisible, )() if matchNum is not None and len(hwnds): self.lastHwnd = hwnds[0] self.tree.SelectHwnd(self.lastHwnd) if searchOnlyFrontmost: cbOnlyFrontmost.SetValue(True) OnSearchOnlyFrontmostCheckbox(wx.CommandEvent()) while True: self.tree.Bind(wx.EVT_TREE_SEL_CHANGED, self.OnSelectionChanged) affirmed = panel.Affirmed() self.tree.Unbind(wx.EVT_TREE_SEL_CHANGED) if not affirmed: break if cbOnlyFrontmost.IsChecked(): panel.SetResult(None, None, None, None, None, None, None, None, None) else: panel.SetResult(*GetResult())
def Configure(self, voiceName=None, rate=0, voiceText="", suffix="", volume=100, device=None): text = self.text panel = eg.ConfigPanel() textCtrl = wx.TextCtrl(panel, wx.ID_ANY, voiceText) suffCtrl = wx.TextCtrl(panel, wx.ID_ANY, suffix) def MakeButton(txt, value): def OnButton(event): textCtrl.WriteText(value) textCtrl.SetFocus() btn = wx.Button(panel, wx.ID_ANY, txt) btn.Bind(wx.EVT_BUTTON, OnButton) return btn insertTimeButton = MakeButton(text.buttonInsertTime, '{TIME}') insertTimeButton1 = MakeButton(text.buttonInsertTime1, '{TIME1}') insertDateButton = MakeButton(text.buttonInsertDate, '{DATE}') insertDateButton1 = MakeButton(text.buttonInsertDate1, '{DATE1}') voices = self.plugin.GetVoices() devs = self.plugin.GetAudioOutputs() voiceChoice = wx.Choice(panel, wx.ID_ANY, choices=voices) voiceName = voiceName if voiceName else voices[0] voiceChoice.SetStringSelection(voiceName) devChoice = wx.Choice(panel, wx.ID_ANY, choices=devs) devName = device if device else devs[0] devChoice.SetStringSelection(devName) rateCtrl = CustomSlider(panel, value=int(rate), valueLabel=text.normal, minValue=-5, minLabel=text.slow, maxValue=5, maxLabel=text.fast, style=wx.SL_AUTOTICKS | wx.SL_TOP) volumeCtrl = CustomSlider(panel, value=volume, valueLabel="%(1)i %%", minValue=0, minLabel=text.silent, maxValue=100, maxLabel=text.loud, style=wx.SL_AUTOTICKS | wx.SL_TOP) volumeCtrl.slider.SetTickFreq(10, 3) sizer1 = eg.HBoxSizer((textCtrl, 1, wx.EXPAND)) sizer2 = eg.HBoxSizer(insertTimeButton, (insertTimeButton1, 0, wx.ALIGN_LEFT, 3), ((10, 5), 0), (insertDateButton, 0, wx.ALIGN_RIGHT, 3), (insertDateButton1, 0, wx.ALIGN_RIGHT)) staticBoxSizer1 = panel.VStaticBoxSizer( text.textBoxLabel, (sizer1, 0, wx.EXPAND | wx.ALL, 5), (sizer2, 0, wx.EXPAND | wx.ALL, 5), ) ACV = wx.ALIGN_CENTER_VERTICAL sizer3 = wx.FlexGridSizer(0, 2, 5, 5) sizer3.AddGrowableCol(1, 1) sizer3.AddMany( ((panel.StaticText(text.labelVoice), 0, ACV | wx.BOTTOM, 10), (voiceChoice, 0, wx.EXPAND | wx.BOTTOM, 10), (panel.StaticText(text.device), 0, ACV | wx.BOTTOM, 10), (devChoice, 0, wx.EXPAND | wx.BOTTOM, 10), (panel.StaticText(text.labelRate), 0, ACV), (rateCtrl, 0, wx.EXPAND), (panel.StaticText(text.labelVolume), 0, ACV), (volumeCtrl, 0, wx.EXPAND), (panel.StaticText(text.addSuffix), 0, ACV), (suffCtrl, 0, wx.EXPAND))) staticBoxSizer2 = panel.VStaticBoxSizer( text.voiceProperties, (sizer3, 0, wx.EXPAND | wx.ALL, 5), ) panel.sizer.Add(staticBoxSizer1, 0, wx.EXPAND) panel.sizer.Add(staticBoxSizer2, 0, wx.EXPAND | wx.TOP, 10) while panel.Affirmed(): panel.SetResult(voiceChoice.GetStringSelection(), rateCtrl.GetValue(), textCtrl.GetValue(), suffCtrl.GetValue(), volumeCtrl.GetValue(), devChoice.GetStringSelection())
def Configure(self, menuData=[]): menuData = self.Compile(menuData) panel = eg.ConfigPanel(resizable=True) text = self.text tree = MenuTreeListCtrl(panel, text, menuData) root = tree.GetRootItem() @eg.LogIt def OnSelectionChanged(dummyEvent): itemType = 0 item = tree.GetSelection() if item == root: enableMoveFlag = False enableEditFlag = False elif tree.GetPyData(item)[1] == "separator": enableMoveFlag = True enableEditFlag = False itemType = 2 else: enableMoveFlag = True enableEditFlag = True upButton.Enable(enableMoveFlag) downButton.Enable(enableMoveFlag) deleteButton.Enable(enableMoveFlag) labelBox.Enable(enableEditFlag) eventBox.Enable(enableEditFlag) labelBox.SetLabel(tree.GetItemText(item, 0)) eventBox.SetLabel(tree.GetItemText(item, 1)) #itemTypeCtrl.SetSelection(itemType) #event.Skip() tree.Bind(wx.EVT_TREE_SEL_CHANGED, OnSelectionChanged) # Delete button deleteButton = wx.Button(panel, -1, text.deleteButton) deleteButton.Enable(False) def OnDelete(dummyEvent): item = tree.GetSelection() next = tree.GetNextSibling(item) if not next.IsOk(): next = tree.GetPrevSibling(item) if not next.IsOk(): next = tree.GetItemParent(item) tree.SelectItem(next) tree.Delete(item) tree.EnsureVisible(next) deleteButton.Bind(wx.EVT_BUTTON, OnDelete) # Up button bmp = wx.ArtProvider.GetBitmap(wx.ART_GO_UP, wx.ART_OTHER, (16, 16)) upButton = wx.BitmapButton(panel, -1, bmp) upButton.Enable(False) def OnUp(dummyEvent): item = tree.GetSelection() previous = tree.GetPrevSibling(item) if previous.IsOk(): id = tree.GetPrevSibling(previous) if not id.IsOk(): id = None newId = tree.CopyItem(item, tree.GetItemParent(previous), id) tree.SelectItem(newId) tree.EnsureVisible(newId) tree.Delete(item) upButton.Bind(wx.EVT_BUTTON, OnUp) # Down button bmp = wx.ArtProvider.GetBitmap(wx.ART_GO_DOWN, wx.ART_OTHER, (16, 16)) downButton = wx.BitmapButton(panel, -1, bmp) downButton.Enable(False) def OnDown(dummyEvent): item = tree.GetSelection() nextId = tree.GetNext(item) if nextId is not None: newId = tree.CopyItem(item, tree.GetItemParent(nextId), nextId) tree.Delete(item) tree.SelectItem(newId) tree.EnsureVisible(newId) downButton.Bind(wx.EVT_BUTTON, OnDown) # Add menu item button addItemButton = wx.Button(panel, -1, text.addItemButton) @eg.LogIt def OnAddItem(dummyEvent): numStr = str(tree.GetCount() + 1) item = tree.AppendItem(root, text.unnamedLabel % numStr) data = ("", "item", "", tree.GetNewMenuId()) tree.SetPyData(item, data) tree.SetItemText(item, text.unnamedEvent % numStr, 1) tree.Expand(tree.GetItemParent(item)) tree.SelectItem(item) tree.EnsureVisible(item) tree.Update() addItemButton.Bind(wx.EVT_BUTTON, OnAddItem) # Add separator button addSeparatorButton = wx.Button(panel, -1, text.addSeparatorButton) def OnAddSeparator(dummyEvent): item = tree.AppendItem(root, "---------") tree.SetPyData(item, ("", "separator", "", tree.GetNewMenuId())) tree.Expand(tree.GetItemParent(item)) tree.SelectItem(item) tree.EnsureVisible(item) tree.Update() addSeparatorButton.Bind(wx.EVT_BUTTON, OnAddSeparator) # Label edit box labelBox = wx.TextCtrl(panel, -1) def OnLabelTextChange(event): item = tree.GetSelection() tree.SetItemText(item, labelBox.GetValue(), 0) event.Skip() labelBox.Bind(wx.EVT_TEXT, OnLabelTextChange) # Event edit box eventBox = wx.TextCtrl(panel, -1) def OnEventTextChange(event): item = tree.GetSelection() tree.SetItemText(item, eventBox.GetValue(), 1) event.Skip() eventBox.Bind(wx.EVT_TEXT, OnEventTextChange) # Item type control #choices = ["Menu item", "Check menu item", "Separator"] #itemTypeCtrl = wx.Choice(dialog, choices=choices) # construction of the dialog with sizers staticBox = wx.StaticBox(panel, -1, text.addBox) addSizer = wx.StaticBoxSizer(staticBox, wx.VERTICAL) addSizer.Add(addItemButton, 0, wx.EXPAND) addSizer.Add((5, 5)) addSizer.Add(addSeparatorButton, 0, wx.EXPAND) editSizer = wx.FlexGridSizer(2, 2, 5, 5) editSizer.AddGrowableCol(1) editSizer.AddMany(( (panel.StaticText(text.editLabel), 0, wx.ALIGN_CENTER_VERTICAL), (labelBox, 0, wx.EXPAND), (panel.StaticText(text.editEvent), 0, wx.ALIGN_CENTER_VERTICAL), (eventBox, 0, wx.EXPAND), )) mainSizer = eg.HBoxSizer( (eg.VBoxSizer( (tree, 1, wx.EXPAND), (editSizer, 0, wx.EXPAND | wx.TOP, 5), ), 1, wx.EXPAND), ((5, 5)), (eg.VBoxSizer( (deleteButton, 0, wx.EXPAND), ((5, 5), 1, wx.EXPAND), (upButton), (downButton, 0, wx.TOP, 5), ((5, 5), 1, wx.EXPAND), (addSizer, 0, wx.EXPAND), ), 0, wx.EXPAND), ) panel.sizer.Add(mainSizer, 1, wx.EXPAND) nextId = tree.GetFirstChild(root)[0] if nextId.IsOk(): tree.SelectItem(nextId) else: tree.SelectItem(root) while panel.Affirmed(): resultList = [] def Traverse(item): child, cookie = tree.GetFirstChild(item) while child.IsOk(): name, kind, eventString, menuId = tree.GetPyData(child) name = tree.GetItemText(child, 0) eventString = tree.GetItemText(child, 1) resultList.append((name, kind, eventString, menuId)) if tree.HasChildren(child): Traverse(child) child, cookie = tree.GetNextChild(item, cookie) Traverse(root) self.Compile(resultList) panel.SetResult(resultList)
def Configure( self, pathname='', arguments='', winState=0, waitForCompletion=False, priority=2, workingDir="", triggerEvent=False, disableWOW64=False, additionalSuffix="", disableParsingPathname=False, disableParsingArguments=False, disableParsingAdditionalSuffix=False, runAsAdmin = False, ): panel = eg.ConfigPanel() text = self.text filepathCtrl = panel.FileBrowseButton( pathname, fileMask="*.*", dialogTitle=text.browseExecutableDialogTitle ) disableParsingPathnameBox = panel.CheckBox( bool(disableParsingPathname), text.disableParsing ) argumentsCtrl = panel.TextCtrl(arguments) disableParsingArgumentsBox = panel.CheckBox( bool(disableParsingArguments), text.disableParsing ) workingDirCtrl = panel.DirBrowseButton( workingDir or "", dialogTitle=text.browseWorkingDirDialogTitle ) #workingDirCtrl.SetValue(workingDir) winStateChoice = panel.Choice(winState, text.WindowOptions) priorityChoice = panel.Choice(5 - priority, text.ProcessOptions) waitCheckBox = panel.CheckBox( bool(waitForCompletion), text.waitCheckbox ) eventCheckBox = panel.CheckBox( bool(triggerEvent), text.eventCheckbox ) additionalSuffixCtrl = panel.TextCtrl(additionalSuffix) disableParsingAdditionalSuffixBox = panel.CheckBox( bool(disableParsingAdditionalSuffix), text.disableParsing ) wow64CheckBox = panel.CheckBox( bool(disableWOW64), text.wow64Checkbox ) runAsAdminCheckBox = panel.CheckBox( bool(runAsAdmin), text.runAsAdminCheckbox ) SText = panel.StaticText procPriorLabel = SText(text.ProcessOptionsDesc) lowerSizer = wx.GridBagSizer(0, 0) lowerSizer.AddMany([ (SText(text.WindowOptionsDesc), (0, 0), (1, 1), wx.ALIGN_BOTTOM), (winStateChoice, (1, 0)), ((1, 1), (0, 1), (1, 1), wx.EXPAND), (procPriorLabel, (0, 2), (1, 1), wx.ALIGN_BOTTOM), (priorityChoice, (1, 2)), ((1, 1), (0, 3), (1, 1), wx.EXPAND), ]) lowerSizer.AddGrowableCol(1) lowerSizer.AddGrowableCol(3) lowerSizer2 = wx.GridBagSizer(2, 0) stTxt = SText(text.additionalSuffix) lowerSizer2.AddMany([ ((eventCheckBox), (0, 0), (1, 1), wx.ALIGN_BOTTOM), ((1, 1), (0, 1), (1, 1), wx.EXPAND), (stTxt, (0, 2), (1, 1), wx.ALIGN_BOTTOM), (additionalSuffixCtrl, (1, 2)), (disableParsingAdditionalSuffixBox, (2, 2)), ((1, 1), (0, 3), (1, 1), wx.EXPAND), ]) lowerSizer2.AddGrowableCol(1) lowerSizer2.AddGrowableCol(3) def OnPathnameChanged(evt = None): path = filepathCtrl.GetValue().upper() if not isdir(path): enable = True else: enable = False wow64CheckBox.SetValue(False) runAsAdminCheckBox.SetValue(False) argumentsCtrl.Enable(enable) disableParsingArgumentsBox.Enable(enable) workingDirCtrl.Enable(enable) wow64CheckBox.Enable(enable) runAsAdminCheckBox.Enable(enable) filepathCtrl.changeCallback = OnPathnameChanged OnPathnameChanged() def OnEventCheckBox(evt = None): enable = eventCheckBox.GetValue() stTxt.Enable(enable) additionalSuffixCtrl.Enable(enable) disableParsingAdditionalSuffixBox.Enable(enable) if not enable: additionalSuffixCtrl.ChangeValue("") if evt: evt.Skip() eventCheckBox.Bind(wx.EVT_CHECKBOX, OnEventCheckBox) OnEventCheckBox() panel.sizer.AddMany([ (SText(text.FilePath)), (filepathCtrl, 0, wx.EXPAND), (disableParsingPathnameBox), ((10, 10)), (SText(text.Parameters)), (argumentsCtrl, 0, wx.EXPAND), ((10, 2)), (disableParsingArgumentsBox), ((10, 10)), (SText(text.WorkingDir)), (workingDirCtrl, 0, wx.EXPAND), (lowerSizer, 0, wx.EXPAND), ((10, 15)), (waitCheckBox), ((10, 8)), (lowerSizer2, 0, wx.EXPAND), ((10, 8)), (wow64CheckBox), ((10, 8)), (runAsAdminCheckBox), ]) while panel.Affirmed(): panel.SetResult( filepathCtrl.GetValue(), argumentsCtrl.GetValue(), winStateChoice.GetValue(), waitCheckBox.GetValue(), 5 - priorityChoice.GetValue(), workingDirCtrl.GetValue(), eventCheckBox.GetValue(), wow64CheckBox.GetValue(), additionalSuffixCtrl.GetValue(), disableParsingPathnameBox.GetValue(), disableParsingArgumentsBox.GetValue(), disableParsingAdditionalSuffixBox.GetValue(), runAsAdminCheckBox.GetValue() )
def Configure( self, command = '', waitForCompletion = True, triggerEvent = False, additionalSuffix = "", disableParsingCommand = True, disableParsingAdditionalSuffix = False, payload = False, disableWOW64=False, runAsAdmin = False, ): panel = eg.ConfigPanel() text = self.text commandCtrl = panel.TextCtrl(command) disableParsingCommandBox = panel.CheckBox( bool(disableParsingCommand), text.disableParsing ) waitCheckBox = panel.CheckBox( bool(waitForCompletion), text.waitCheckbox ) eventCheckBox = panel.CheckBox( bool(triggerEvent), text.eventCheckbox ) pldCheckBox = panel.CheckBox( bool(payload), text.payload ) additionalSuffixCtrl = panel.TextCtrl(additionalSuffix) disableParsingAdditionalSuffixBox = panel.CheckBox( bool(disableParsingAdditionalSuffix), text.disableParsing ) wow64CheckBox = panel.CheckBox( bool(disableWOW64), text.wow64Checkbox ) runAsAdminCheckBox = panel.CheckBox( bool(runAsAdmin), text.runAsAdminCheckbox ) SText = panel.StaticText lowerSizer2 = wx.GridBagSizer(2, 0) stTxt = SText(text.additionalSuffix) lowerSizer2.AddMany([ ((eventCheckBox), (0, 0), (1, 1), wx.ALIGN_BOTTOM), ((1, 1), (0, 1), (1, 1), wx.EXPAND), (pldCheckBox, (0, 2), (1, 1)), (stTxt, (1, 2), (1, 1), wx.ALIGN_BOTTOM), (additionalSuffixCtrl, (2, 2)), (disableParsingAdditionalSuffixBox, (3, 2)), ((1, 1), (0, 3), (1, 1), wx.EXPAND), ]) lowerSizer2.AddGrowableCol(1) lowerSizer2.AddGrowableCol(3) def onEventCheckBox(evt = None): enable = eventCheckBox.GetValue() stTxt.Enable(enable) additionalSuffixCtrl.Enable(enable) disableParsingAdditionalSuffixBox.Enable(enable) disableParsingAdditionalSuffixBox.SetValue(enable) pldCheckBox.Enable(enable) if not enable: additionalSuffixCtrl.ChangeValue("") if evt: pldCheckBox.SetValue(False) evt.Skip() eventCheckBox.Bind(wx.EVT_CHECKBOX, onEventCheckBox) onEventCheckBox() panel.sizer.AddMany([ (SText(text.Command)), ((1, 2)), (commandCtrl, 0, wx.EXPAND), ((1, 2)), (disableParsingCommandBox), ((10, 15)), (waitCheckBox), ((10, 8)), (lowerSizer2, 0, wx.EXPAND), ((10, 8)), (wow64CheckBox), ((10, 8)), (runAsAdminCheckBox), ]) while panel.Affirmed(): panel.SetResult( commandCtrl.GetValue(), waitCheckBox.GetValue(), eventCheckBox.GetValue(), additionalSuffixCtrl.GetValue(), disableParsingCommandBox.GetValue(), disableParsingAdditionalSuffixBox.GetValue(), pldCheckBox.GetValue(), wow64CheckBox.GetValue(), runAsAdminCheckBox.GetValue() )
def Configure( self, link = None, kind = 0, gosub = False, link2 = None, gosub2 = False ): text = self.text panel = eg.ConfigPanel() kindCtrl = panel.Choice(kind, choices=text.choices) linkCtrl = panel.MacroSelectButton( eg.text.General.choose, text.mesg1, text.mesg2, link ) gosubCtrl = panel.CheckBox(gosub, text.text3) linkCtrl2 = panel.MacroSelectButton( eg.text.General.choose, text.mesg1, text.mesg3, link2 ) gosubCtrl2 = panel.CheckBox(gosub2, text.text3) labels = ( panel.StaticText(text.text1), panel.StaticText(text.text2), panel.StaticText(text.text4), ) eg.EqualizeWidths(labels) def onKind(evt = None): enable = kindCtrl.GetSelection() < 2 labels[2].Enable(enable) linkCtrl2.Enable(enable) gosubCtrl2.Enable(enable) if not enable: linkCtrl2.textBox.textCtrl.ChangeValue("") linkCtrl2.treeLink = eg.TreeLink( eg.Utils.GetTopLevelWindow(panel).treeItem ) linkCtrl2.macro = None gosubCtrl2.SetValue(False) if evt: evt.Skip() kindCtrl.Bind(wx.EVT_CHOICE, onKind) onKind() sizer = wx.FlexGridSizer(7, 2, 3, 5) sizer.AddGrowableCol(1, 1) sizer.Add(labels[0], 0, wx.ALIGN_CENTER_VERTICAL) sizer.Add(kindCtrl) sizer.Add((0, 15)) sizer.Add((0, 15)) sizer.Add(labels[1], 0, wx.ALIGN_CENTER_VERTICAL) sizer.Add(linkCtrl, 1, wx.EXPAND) sizer.Add((0, 0)) sizer.Add(gosubCtrl) sizer.Add((0, 15)) sizer.Add((0, 15)) sizer.Add(labels[2], 0, wx.ALIGN_CENTER_VERTICAL) sizer.Add(linkCtrl2, 1, wx.EXPAND) sizer.Add((0, 0)) sizer.Add(gosubCtrl2) panel.sizer.Add(sizer, 1, wx.EXPAND, wx.ALIGN_CENTER_VERTICAL) while panel.Affirmed(): lnk = linkCtrl.GetValue() lnk2 = linkCtrl2.GetValue() panel.SetResult( None if repr(lnk) == "XmlIdLink(-1)" else lnk, kindCtrl.GetValue(), gosubCtrl.GetValue(), None if repr(lnk2) == "XmlIdLink(-1)" else lnk2, gosubCtrl2.GetValue() )
def Configure(self, data="", useAlternateMethod=False, mode=2): panel = eg.ConfigPanel() text = self.text key = text.Keys keyChoices = [ (key.returnKey, "Return"), (key.enter, "Enter"), (key.tabulator, "Tabulator"), (key.backspace, "Backspace"), (key.escape, "Escape"), (key.space, "Space"), (key.up, "Up"), (key.down, "Down"), (key.left, "Left"), (key.right, "Right"), (key.insert, "Insert"), (key.delete, "Delete"), (key.home, "Home"), (key.end, "End"), (key.pageUp, "PageUp"), (key.pageDown, "PageDown"), (key.win, "Win"), (key.context, "Apps"), (key.numDivide, "Divide"), (key.numMultiply, "Multiply"), (key.numSubtract, "Subtract"), (key.numAdd, "Add"), (key.numDecimal, "Decimal"), (key.num0, "Numpad0"), (key.num1, "Numpad1"), (key.num2, "Numpad2"), (key.num3, "Numpad3"), (key.num4, "Numpad4"), (key.num5, "Numpad5"), (key.num6, "Numpad6"), (key.num7, "Numpad7"), (key.num8, "Numpad8"), (key.num9, "Numpad9"), ] fKeys = ("F1", "F2", "F3", "F4", "F5", "F6", "F7", "F8", "F9", "F10", "F11", "F12", "F13", "F14", "F15", "F16", "F17", "F18", "F19", "F20", "F21", "F22", "F23", "F24") keyLabels, keyWords = zip(*keyChoices) keyLabels += fKeys keyWords += fKeys textCtrl = panel.TextCtrl(data, style=wx.TE_NOHIDESEL) alternateMethodCB = panel.CheckBox(useAlternateMethod, text.useAlternativeMethod) radioBox = wx.RadioBox(panel, label=text.radioBoxLabel, choices=text.radioBoxOptions, style=wx.RA_SPECIFY_ROWS) radioBox.SetSelection(mode) shiftCB = wx.CheckBox(panel, -1, "Shift") ctrlCB = wx.CheckBox(panel, -1, "Ctrl") altCB = wx.CheckBox(panel, -1, "Alt") keyChoice = wx.Choice(panel, -1, choices=keyLabels) keyChoice.SetSelection(0) insertButton = wx.Button(panel, -1, text.insertButton) def DummyHandler(dummyEvent): pass # used to prevent propagating of the event to the panel shiftCB.Bind(wx.EVT_CHECKBOX, DummyHandler) ctrlCB.Bind(wx.EVT_CHECKBOX, DummyHandler) altCB.Bind(wx.EVT_CHECKBOX, DummyHandler) keyChoice.Bind(wx.EVT_CHOICE, DummyHandler) def OnInsert(dummyEvent): res = [] if shiftCB.GetValue(): res.append("Shift") if ctrlCB.GetValue(): res.append("Ctrl") if altCB.GetValue(): res.append("Alt") res.append(keyWords[keyChoice.GetSelection()]) textCtrl.WriteText("{%s}" % "+".join(res)) insertButton.Bind(wx.EVT_BUTTON, OnInsert) cbSizer = eg.VBoxSizer( (shiftCB, 0, wx.EXPAND | wx.BOTTOM, 5), (ctrlCB, 0, wx.EXPAND | wx.BOTTOM, 5), (altCB, 0, wx.EXPAND, 0), ) rightSizer = eg.VBoxSizer( (keyChoice), (insertButton, 0, wx.TOP | wx.ALIGN_CENTER_HORIZONTAL, 15), ) staticBox = wx.StaticBox(panel, -1, text.specialKeyTool) specialKeySizer = wx.StaticBoxSizer(staticBox, wx.HORIZONTAL) specialKeySizer.Add(cbSizer) specialKeySizer.Add((15, 15)) specialKeySizer.Add(rightSizer) panel.sizer.AddMany(( (panel.StaticText(text.textToType)), (textCtrl, 0, wx.EXPAND), ((10, 10)), (specialKeySizer, 0, wx.ALIGN_RIGHT), ((10, 10), 1), (alternateMethodCB), (radioBox), )) while panel.Affirmed(): panel.SetResult(textCtrl.GetValue(), alternateMethodCB.GetValue(), radioBox.GetSelection())