def __init__(self, parent, title, cbil1, descr1, btns1, cbil2 = None, descr2 = None, btns2 = None): wx.Dialog.__init__(self, parent, -1, title, style = wx.DEFAULT_DIALOG_STYLE) vsizer = wx.BoxSizer(wx.VERTICAL) self.cbil1 = cbil1 self.list1 = self.addList(descr1, self, vsizer, cbil1, btns1, True) if cbil2 != None: self.cbil2 = cbil2 self.list2 = self.addList(descr2, self, vsizer, cbil2, btns2, False, 20) hsizer = wx.BoxSizer(wx.HORIZONTAL) hsizer.Add((1, 1), 1) cancelBtn = gutil.createStockButton(self, "Cancel") hsizer.Add(cancelBtn) okBtn = gutil.createStockButton(self, "OK") hsizer.Add(okBtn, 0, wx.LEFT, 10) vsizer.Add(hsizer, 0, wx.EXPAND | wx.TOP, 10) util.finishWindow(self, vsizer) wx.EVT_BUTTON(self, cancelBtn.GetId(), self.OnCancel) wx.EVT_BUTTON(self, okBtn.GetId(), self.OnOK) okBtn.SetFocus()
def __init__(self, parent, id, cfg): wx.Panel.__init__(self, parent, id) self.cfg = cfg # list of names. each name is both the name of a wx.TextCtrl in # this class and the name of a string configuration variable in # cfg. self.items = [] vsizer = wx.BoxSizer(wx.VERTICAL) gsizer = wx.FlexGridSizer(4, 2, 5, 0) self.addEntry("strContinuedPageEnd", "(CONTINUED)", self, gsizer) self.addEntry("strContinuedPageStart", "CONTINUED:", self, gsizer) self.addEntry("strMore", "(MORE)", self, gsizer) self.addEntry("strDialogueContinued", " (cont'd)", self, gsizer) gsizer.AddGrowableCol(1) vsizer.Add(gsizer, 0, wx.EXPAND) self.cfg2gui() util.finishWindow(self, vsizer, center=False) for it in self.items: wx.EVT_TEXT(self, getattr(self, it).GetId(), self.OnMisc)
def __init__(self, parent, id, cfg): wx.Panel.__init__(self, parent, id) self.cfg = cfg vsizer = wx.BoxSizer(wx.VERTICAL) # wxGTK adds way more space by default than wxMSW between the # items, have to adjust for that pad = 0 if misc.isWindows: pad = 10 self.includeTOCCb = self.addCb("Add table of contents", vsizer, pad) self.showTOCCb = self.addCb("Show table of contents on PDF open", vsizer, pad) self.openOnCurrentPageCb = self.addCb("Open PDF on current page", vsizer, pad) self.removeNotesCb = self.addCb("Omit Note elements", vsizer, pad) self.outlineNotesCb = self.addCb(" Draw rectangles around Note elements", vsizer, pad) self.marginsCb = self.addCb("Show margins (debug)", vsizer, pad) self.cfg2gui() util.finishWindow(self, vsizer, center=False)
def __init__(self, parent, id, cfg): wx.Panel.__init__(self, parent, id) self.cfg = cfg self.blockEvents = True # last directory we chose a font from self.lastDir = u"" vsizer = wx.BoxSizer(wx.VERTICAL) vsizer.Add(wx.StaticText(self, -1, "Leave all the fields empty to use the default PDF Courier\n" "fonts. This is highly recommended.\n" "\n" "Otherwise, fill in the font name (e.g. AndaleMono) to use\n" "the specified TrueType font. If you want to embed the font\n" "in the generated PDF files, fill in the font filename as well.\n" "\n" "See the manual for the full details.\n")) hsizer = wx.BoxSizer(wx.HORIZONTAL) hsizer.Add(wx.StaticText(self, -1, "Type:"), 0, wx.ALIGN_CENTER_VERTICAL | wx.RIGHT, 10) self.typeCombo = wx.ComboBox(self, -1, style = wx.CB_READONLY) for pfi in self.cfg.getPDFFontIds(): pf = self.cfg.getPDFFont(pfi) self.typeCombo.Append(pf.name, pf) hsizer.Add(self.typeCombo, 0) vsizer.Add(hsizer, 0, wx.EXPAND) vsizer.Add(wx.StaticLine(self, -1), 0, wx.EXPAND | wx.TOP | wx.BOTTOM, 10) gsizer = wx.FlexGridSizer(2, 3, 5, 5) gsizer.AddGrowableCol(1) self.addEntry("nameEntry", "Name:", self, gsizer) gsizer.Add((1,1), 0) self.addEntry("fileEntry", "File:", self, gsizer) btn = wx.Button(self, -1, "Browse") gsizer.Add(btn) wx.EVT_BUTTON(self, btn.GetId(), self.OnBrowse) vsizer.Add(gsizer, 0, wx.EXPAND) util.finishWindow(self, vsizer, center = False) wx.EVT_COMBOBOX(self, self.typeCombo.GetId(), self.OnTypeCombo) self.typeCombo.SetSelection(0) self.OnTypeCombo() self.blockEvents = False
def __init__(self, parent, text, title): wx.Dialog.__init__(self, parent, -1, title, style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER) vsizer = wx.BoxSizer(wx.VERTICAL) tc = wx.TextCtrl(self, -1, size=wx.Size(400, 200), style=wx.TE_MULTILINE | wx.TE_READONLY | wx.TE_LINEWRAP) tc.SetValue(text) vsizer.Add(tc, 1, wx.EXPAND) vsizer.Add(wx.StaticLine(self, -1), 0, wx.EXPAND | wx.TOP | wx.BOTTOM, 5) okBtn = gutil.createStockButton(self, "OK") vsizer.Add(okBtn, 0, wx.ALIGN_CENTER) util.finishWindow(self, vsizer) wx.EVT_BUTTON(self, okBtn.GetId(), self.OnOK) okBtn.SetFocus()
def __init__(self, parent, items): wx.Dialog.__init__(self, parent, -1, "Choose scripts", style = wx.DEFAULT_DIALOG_STYLE) vsizer = wx.BoxSizer(wx.VERTICAL) gsizer = wx.FlexGridSizer(2, 2, 5, 0) self.addCombo("first", "Compare script", self, gsizer, items, 0) self.addCombo("second", "to", self, gsizer, items, 1) vsizer.Add(gsizer) self.forceCb = wx.CheckBox(self, -1, "Use same configuration") self.forceCb.SetValue(True) vsizer.Add(self.forceCb, 0, wx.TOP, 10) hsizer = wx.BoxSizer(wx.HORIZONTAL) hsizer.Add((1, 1), 1) cancelBtn = gutil.createStockButton(self, "Cancel") hsizer.Add(cancelBtn) okBtn = gutil.createStockButton(self, "OK") hsizer.Add(okBtn, 0, wx.LEFT, 10) vsizer.Add(hsizer, 0, wx.EXPAND | wx.TOP, 10) util.finishWindow(self, vsizer) wx.EVT_BUTTON(self, cancelBtn.GetId(), self.OnCancel) wx.EVT_BUTTON(self, okBtn.GetId(), self.OnOK) okBtn.SetFocus()
def __init__(self, parent, id, cfg): wx.Panel.__init__(self, parent, id) self.cfg = cfg vsizer = wx.BoxSizer(wx.VERTICAL) hsizer = wx.BoxSizer(wx.HORIZONTAL) vsizer2 = wx.BoxSizer(wx.VERTICAL) vsizer2.Add(wx.StaticText(self, -1, "Commands:")) self.commandsLb = wx.ListBox(self, -1, size = (175, 50)) for cmd in self.cfg.commands: self.commandsLb.Append(cmd.name, cmd) vsizer2.Add(self.commandsLb, 1) hsizer.Add(vsizer2, 0, wx.EXPAND | wx.RIGHT, 15) vsizer2 = wx.BoxSizer(wx.VERTICAL) vsizer2.Add(wx.StaticText(self, -1, "Keys:")) self.keysLb = wx.ListBox(self, -1, size = (150, 60)) vsizer2.Add(self.keysLb, 1, wx.BOTTOM, 10) btn = wx.Button(self, -1, "Add") wx.EVT_BUTTON(self, btn.GetId(), self.OnAdd) vsizer2.Add(btn, 0, wx.ALIGN_CENTER | wx.BOTTOM, 10) self.addBtn = btn btn = wx.Button(self, -1, "Delete") wx.EVT_BUTTON(self, btn.GetId(), self.OnDelete) vsizer2.Add(btn, 0, wx.ALIGN_CENTER | wx.BOTTOM, 10) self.deleteBtn = btn vsizer2.Add(wx.StaticText(self, -1, "Description:")) self.descEntry = wx.TextCtrl(self, -1, style = wx.TE_MULTILINE | wx.TE_READONLY, size = (150, 75)) vsizer2.Add(self.descEntry, 1, wx.EXPAND) hsizer.Add(vsizer2, 0, wx.EXPAND | wx.BOTTOM, 10) vsizer.Add(hsizer) vsizer.Add(wx.StaticText(self, -1, "Conflicting keys:"), 0, wx.TOP, 10) self.conflictsEntry = wx.TextCtrl(self, -1, style = wx.TE_MULTILINE | wx.TE_READONLY, size = (50, 75)) vsizer.Add(self.conflictsEntry, 1, wx.EXPAND) util.finishWindow(self, vsizer, center = False) wx.EVT_LISTBOX(self, self.commandsLb.GetId(), self.OnCommandLb) self.commandsLb.SetSelection(0) self.OnCommandLb()
def __init__(self, parent, autoCompletion): wx.Dialog.__init__(self, parent, -1, "Auto-completion", style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER) self.autoCompletion = autoCompletion vsizer = wx.BoxSizer(wx.VERTICAL) hsizer = wx.BoxSizer(wx.HORIZONTAL) self.elementsCombo = wx.ComboBox(self, -1, style=wx.CB_READONLY | wx.EXPAND) for t in autoCompletion.types.itervalues(): self.elementsCombo.Append(t.ti.name, t.ti.lt) wx.EVT_COMBOBOX(self, self.elementsCombo.GetId(), self.OnElementCombo) hsizer.Add(self.elementsCombo, 0) vsizer.Add(hsizer, 0, wx.EXPAND) vsizer.Add(wx.StaticLine(self, -1), 0, wx.EXPAND | wx.TOP | wx.BOTTOM, 10) self.enabledCb = wx.CheckBox(self, -1, "Auto-completion Enabled") wx.EVT_CHECKBOX(self, self.enabledCb.GetId(), self.OnMisc) vsizer.Add(self.enabledCb, 0, wx.BOTTOM, 10) self.itemsEntry = wx.TextCtrl(self, -1, style=wx.TE_MULTILINE | wx.TE_DONTWRAP, size=(200, 250)) wx.EVT_TEXT(self, self.itemsEntry.GetId(), self.OnMisc) vsizer.Add(self.itemsEntry, 1, wx.EXPAND) hsizer = wx.BoxSizer(wx.HORIZONTAL) hsizer.Add((1, 1), 1) cancelBtn = gutil.createStockButton(self, "Cancel") hsizer.Add(cancelBtn, 0, wx.LEFT, 10) okBtn = gutil.createStockButton(self, "OK") hsizer.Add(okBtn, 0, wx.LEFT, 10) vsizer.Add(hsizer, 0, wx.EXPAND | wx.TOP, 10) util.finishWindow(self, vsizer) self.elementsCombo.SetSelection(0) self.OnElementCombo() wx.EVT_BUTTON(self, cancelBtn.GetId(), self.OnCancel) wx.EVT_BUTTON(self, okBtn.GetId(), self.OnOK)
def __init__(self, parent, id, cfg, text): wx.Panel.__init__(self, parent, id) vsizer = wx.BoxSizer(wx.VERTICAL) vsizer.Add(wx.StaticText(self, -1, text)) util.finishWindow(self, vsizer, center=False)
def __init__(self, parent, indents): wx.Dialog.__init__(self, parent, -1, "Adjust styles", style=wx.DEFAULT_DIALOG_STYLE) indents.sort(lambda i1, i2: -cmp(len(i1.lines), len(i2.lines))) vsizer = wx.BoxSizer(wx.VERTICAL) tmp = wx.StaticText(self, -1, "Input:") vsizer.Add(tmp) self.inputLb = wx.ListBox(self, -1, size=(400, 200)) for it in indents: self.inputLb.Append("%d lines (indented %d characters)" % (len(it.lines), it.indent), it) vsizer.Add(self.inputLb, 0, wx.EXPAND) hsizer = wx.BoxSizer(wx.HORIZONTAL) hsizer.Add(wx.StaticText(self, -1, "Style:"), 0, wx.ALIGN_CENTER_VERTICAL) self.styleCombo = wx.ComboBox(self, -1, style=wx.CB_READONLY) self.styleCombo.Append("Scene / Action", SCENE_ACTION) for t in config.getTIs(): self.styleCombo.Append(t.name, t.lt) util.setWH(self.styleCombo, w=150) hsizer.Add(self.styleCombo, 0, wx.LEFT, 10) vsizer.Add(hsizer, 0, wx.TOP | wx.BOTTOM, 10) vsizer.Add(wx.StaticText(self, -1, "Lines:")) self.linesEntry = wx.TextCtrl(self, -1, size=(400, 200), style=wx.TE_MULTILINE | wx.TE_DONTWRAP) vsizer.Add(self.linesEntry, 0, wx.EXPAND) hsizer = wx.BoxSizer(wx.HORIZONTAL) hsizer.Add((1, 1), 1) cancelBtn = gutil.createStockButton(self, "Cancel") hsizer.Add(cancelBtn) okBtn = gutil.createStockButton(self, "OK") hsizer.Add(okBtn, 0, wx.LEFT, 10) vsizer.Add(hsizer, 0, wx.EXPAND | wx.TOP, 10) util.finishWindow(self, vsizer) wx.EVT_COMBOBOX(self, self.styleCombo.GetId(), self.OnStyleCombo) wx.EVT_LISTBOX(self, self.inputLb.GetId(), self.OnInputLb) wx.EVT_BUTTON(self, cancelBtn.GetId(), self.OnCancel) wx.EVT_BUTTON(self, okBtn.GetId(), self.OnOK) self.inputLb.SetSelection(0) self.OnInputLb()
def __init__(self, parent, id, cfg): wx.Panel.__init__(self, parent, id) self.cfg = cfg vsizer = wx.BoxSizer(wx.VERTICAL) vsizer.Add( wx.StaticText( self, -1, "Leave at least this many lines at the end of a page when\n" "breaking in the middle of an element:", ), 0, wx.BOTTOM, 5, ) gsizer = wx.FlexGridSizer(2, 2, 5, 0) self.addSpin("action", "Action:", self, gsizer, "pbActionLines") self.addSpin("dialogue", "Dialogue", self, gsizer, "pbDialogueLines") vsizer.Add(gsizer, 0, wx.LEFT, 10) hsizer = wx.BoxSizer(wx.HORIZONTAL) self.addSpin("fontSize", "Font size:", self, hsizer, "fontSize") vsizer.Add(hsizer, 0, wx.TOP, 20) vsizer.Add(wx.StaticText(self, -1, "Scene CONTINUEDs:"), 0, wx.TOP, 20) hsizer = wx.BoxSizer(wx.HORIZONTAL) self.sceneContinuedsCb = wx.CheckBox(self, -1, "Include,") wx.EVT_CHECKBOX(self, self.sceneContinuedsCb.GetId(), self.OnMisc) hsizer.Add(self.sceneContinuedsCb, 0, wx.ALIGN_CENTER_VERTICAL | wx.LEFT, 10) self.addSpin("sceneContinuedIndent", "indent:", self, hsizer, "sceneContinuedIndent") hsizer.Add(wx.StaticText(self, -1, "characters"), 0, wx.ALIGN_CENTER_VERTICAL | wx.LEFT, 10) vsizer.Add(hsizer, 0, wx.LEFT, 5) self.scenesCb = wx.CheckBox(self, -1, "Include scene numbers") wx.EVT_CHECKBOX(self, self.scenesCb.GetId(), self.OnMisc) vsizer.Add(self.scenesCb, 0, wx.TOP, 10) # wxGTK adds way more space by default than wxMSW between the # items, have to adjust for that pad = 0 if misc.isWindows: pad = 10 self.lineNumbersCb = wx.CheckBox(self, -1, "Show line numbers (debug)") wx.EVT_CHECKBOX(self, self.lineNumbersCb.GetId(), self.OnMisc) vsizer.Add(self.lineNumbersCb, 0, wx.TOP, pad) self.cfg2gui() util.finishWindow(self, vsizer, center=False)
def __init__(self, parent, sp): wx.Dialog.__init__(self, parent, -1, "Locations", style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER) self.sp = sp vsizer = wx.BoxSizer(wx.VERTICAL) tmp = wx.StaticText(self, -1, "Locations:") vsizer.Add(tmp) self.locationsLb = wx.ListBox(self, -1, size=(450, 200)) vsizer.Add(self.locationsLb, 1, wx.EXPAND) hsizer = wx.BoxSizer(wx.HORIZONTAL) self.addBtn = gutil.createStockButton(self, "Add") hsizer.Add(self.addBtn) wx.EVT_BUTTON(self, self.addBtn.GetId(), self.OnAdd) self.delBtn = gutil.createStockButton(self, "Delete") hsizer.Add(self.delBtn, 0, wx.LEFT, 10) wx.EVT_BUTTON(self, self.delBtn.GetId(), self.OnDelete) vsizer.Add(hsizer, 0, wx.ALIGN_CENTER | wx.TOP, 10) tmp = wx.StaticText(self, -1, "Scenes:") vsizer.Add(tmp) self.scenesLb = wx.ListBox(self, -1, size=(450, 200), style=wx.LB_EXTENDED) vsizer.Add(self.scenesLb, 1, wx.EXPAND) hsizer = wx.BoxSizer(wx.HORIZONTAL) hsizer.Add((1, 1), 1) cancelBtn = gutil.createStockButton(self, "Cancel") hsizer.Add(cancelBtn, 0, wx.LEFT, 10) okBtn = gutil.createStockButton(self, "OK") hsizer.Add(okBtn, 0, wx.LEFT, 10) vsizer.Add(hsizer, 0, wx.EXPAND | wx.TOP, 10) util.finishWindow(self, vsizer) wx.EVT_BUTTON(self, cancelBtn.GetId(), self.OnCancel) wx.EVT_BUTTON(self, okBtn.GetId(), self.OnOK) self.fillGui()
def __init__(self, parent, sp, prefix): wx.Dialog.__init__(self, parent, -1, "Watermarked PDFs generator", style = wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER) self.frame = parent self.sp = sp vsizer = wx.BoxSizer(wx.VERTICAL) vsizer.Add(wx.StaticText(self, -1, "Directory to save in:"), 0) hsizer = wx.BoxSizer(wx.HORIZONTAL) self.dirEntry = wx.TextCtrl(self, -1) hsizer.Add(self.dirEntry, 1, wx.EXPAND) btn = wx.Button(self, -1, "Browse") wx.EVT_BUTTON(self, btn.GetId(), self.OnBrowse) hsizer.Add(btn, 0, wx.ALIGN_CENTER_VERTICAL | wx.LEFT, 10) vsizer.Add(hsizer, 0, wx.EXPAND | wx.TOP | wx.BOTTOM, 5) vsizer.Add(wx.StaticText(self, -1, "Filename prefix:"), 0) self.filenamePrefix = wx.TextCtrl(self, -1, prefix) vsizer.Add(self.filenamePrefix, 0, wx.EXPAND | wx.BOTTOM, 5) vsizer.Add(wx.StaticText(self, -1, "Watermark font size:"), 0) self.markSize = wx.SpinCtrl(self, -1, size=(60, -1)) self.markSize.SetRange(20, 80) self.markSize.SetValue(40) vsizer.Add(self.markSize, 0, wx.BOTTOM, 5) vsizer.Add(wx.StaticLine(self, -1), 0, wx.EXPAND | wx.TOP | wx.BOTTOM, 5) vsizer.Add(wx.StaticText(self, -1, "Common mark:"), 0) self.commonMark = wx.TextCtrl(self, -1, "Confidential") vsizer.Add(self.commonMark, 0, wx.EXPAND| wx.BOTTOM, 5) vsizer.Add(wx.StaticText(self, -1, "Watermarks (one per line):")) self.itemsEntry = wx.TextCtrl( self, -1, style = wx.TE_MULTILINE | wx.TE_DONTWRAP, size = (300, 200)) vsizer.Add(self.itemsEntry, 1, wx.EXPAND) hsizer = wx.BoxSizer(wx.HORIZONTAL) closeBtn = wx.Button(self, -1, "Close") hsizer.Add(closeBtn, 0) hsizer.Add((1, 1), 1) generateBtn = wx.Button(self, -1, "Generate PDFs") hsizer.Add(generateBtn, 0) vsizer.Add(hsizer, 0, wx.EXPAND | wx.TOP, 10) util.finishWindow(self, vsizer) wx.EVT_BUTTON(self, closeBtn.GetId(), self.OnClose) wx.EVT_BUTTON(self, generateBtn.GetId(), self.OnGenerate) self.dirEntry.SetFocus()
def __init__(self, parent, sp): wx.Dialog.__init__(self, parent, -1, "Locations", style = wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER) self.sp = sp vsizer = wx.BoxSizer(wx.VERTICAL) tmp = wx.StaticText(self, -1, "Locations:") vsizer.Add(tmp) self.locationsLb = wx.ListBox(self, -1, size = (450, 200)) vsizer.Add(self.locationsLb, 1, wx.EXPAND) hsizer = wx.BoxSizer(wx.HORIZONTAL) self.addBtn = gutil.createStockButton(self, "Add") hsizer.Add(self.addBtn) wx.EVT_BUTTON(self, self.addBtn.GetId(), self.OnAdd) self.delBtn = gutil.createStockButton(self, "Delete") hsizer.Add(self.delBtn, 0, wx.LEFT, 10) wx.EVT_BUTTON(self, self.delBtn.GetId(), self.OnDelete) vsizer.Add(hsizer, 0, wx.ALIGN_CENTER | wx.TOP, 10) tmp = wx.StaticText(self, -1, "Scenes:") vsizer.Add(tmp) self.scenesLb = wx.ListBox(self, -1, size = (450, 200), style = wx.LB_EXTENDED) vsizer.Add(self.scenesLb, 1, wx.EXPAND) hsizer = wx.BoxSizer(wx.HORIZONTAL) hsizer.Add((1, 1), 1) cancelBtn = gutil.createStockButton(self, "Cancel") hsizer.Add(cancelBtn, 0, wx.LEFT, 10) okBtn = gutil.createStockButton(self, "OK") hsizer.Add(okBtn, 0, wx.LEFT, 10) vsizer.Add(hsizer, 0, wx.EXPAND | wx.TOP, 10) util.finishWindow(self, vsizer) wx.EVT_BUTTON(self, cancelBtn.GetId(), self.OnCancel) wx.EVT_BUTTON(self, okBtn.GetId(), self.OnOK) self.fillGui()
def __init__(self, parent, id, cfg): wx.Panel.__init__(self, parent, id) self.cfg = cfg vsizer = wx.BoxSizer(wx.VERTICAL) vsizer.Add(wx.StaticText(self, -1, "Screen fonts:")) self.fontsLb = wx.ListBox(self, -1, size = (300, 100)) for it in ["fontNormal", "fontBold", "fontItalic", "fontBoldItalic"]: self.fontsLb.Append("", it) self.fontsLb.SetSelection(0) self.updateFontLb() vsizer.Add(self.fontsLb, 0, wx.BOTTOM, 10) btn = wx.Button(self, -1, "Change") wx.EVT_BUTTON(self, btn.GetId(), self.OnChangeFont) vsizer.Add(btn, 0, wx.BOTTOM, 20) vsizer.Add(wx.StaticText(self, -1, "The settings below apply only" " to 'Draft' view mode."), 0, wx.BOTTOM, 15) hsizer = wx.BoxSizer(wx.HORIZONTAL) hsizer.Add(wx.StaticText(self, -1, "Row spacing:"), 0, wx.ALIGN_CENTER_VERTICAL | wx.RIGHT, 10) self.spacingEntry = wx.SpinCtrl(self, -1) self.spacingEntry.SetRange(*self.cfg.cvars.getMinMax("fontYdelta")) wx.EVT_SPINCTRL(self, self.spacingEntry.GetId(), self.OnMisc) wx.EVT_KILL_FOCUS(self.spacingEntry, self.OnKillFocus) hsizer.Add(self.spacingEntry, 0) hsizer.Add(wx.StaticText(self, -1, "pixels"), 0, wx.ALIGN_CENTER_VERTICAL | wx.LEFT, 10) vsizer.Add(hsizer, 0, wx.EXPAND | wx.BOTTOM, 15) self.pbRb = wx.RadioBox(self, -1, "Page break lines to show", style = wx.RA_SPECIFY_COLS, majorDimension = 1, choices = [ "None", "Normal", "Normal + unadjusted " ]) vsizer.Add(self.pbRb) self.cfg2gui() util.finishWindow(self, vsizer, center = False) wx.EVT_RADIOBOX(self, self.pbRb.GetId(), self.OnMisc)
def __init__(self, parent, cmdName): wx.Dialog.__init__(self, parent, -1, "Key capture", style = wx.DEFAULT_DIALOG_STYLE) vsizer = wx.BoxSizer(wx.VERTICAL) vsizer.Add(wx.StaticText(self, -1, "Press the key combination you\n" "want to bind to the command\n'%s'." % cmdName)) tmp = KeyDlgWidget(self, -1, (1, 1)) vsizer.Add(tmp) util.finishWindow(self, vsizer) tmp.SetFocus()
def __init__(self, parent, id, cfg): wx.Panel.__init__(self, parent, id) self.cfg = cfg vsizer = wx.BoxSizer(wx.VERTICAL) hsizer = wx.BoxSizer(wx.HORIZONTAL) self.colorsLb = wx.ListBox(self, -1, size=(300, 250)) tmp = self.cfg.cvars.color.values() tmp.sort(lambda c1, c2: cmp(c1.descr, c2.descr)) for it in tmp: self.colorsLb.Append(it.descr, it.name) hsizer.Add(self.colorsLb, 1) vsizer.Add(hsizer, 0, wx.EXPAND | wx.BOTTOM, 10) hsizer = wx.BoxSizer(wx.HORIZONTAL) vsizer2 = wx.BoxSizer(wx.VERTICAL) btn = wx.Button(self, -1, "Change") wx.EVT_BUTTON(self, btn.GetId(), self.OnChangeColor) vsizer2.Add(btn, 0, wx.BOTTOM, 10) btn = wx.Button(self, -1, "Restore default") wx.EVT_BUTTON(self, btn.GetId(), self.OnDefaultColor) vsizer2.Add(btn) hsizer.Add(vsizer2, 0, wx.ALIGN_CENTER_VERTICAL | wx.RIGHT, 10) self.colorSample = misc.MyColorSample(self, -1, size=wx.Size(200, 50)) hsizer.Add(self.colorSample, 1, wx.EXPAND) vsizer.Add(hsizer, 0, wx.EXPAND | wx.BOTTOM, 10) self.useCustomElemColors = wx.CheckBox(self, -1, "Use per-element-type colors") wx.EVT_CHECKBOX(self, self.useCustomElemColors.GetId(), self.OnMisc) vsizer.Add(self.useCustomElemColors) util.finishWindow(self, vsizer, center=False) wx.EVT_LISTBOX(self, self.colorsLb.GetId(), self.OnColorLb) self.colorsLb.SetSelection(0) self.OnColorLb()
def __init__(self, parent, ctrl): wx.Dialog.__init__(self, parent, -1, "Character map") self.ctrl = ctrl hsizer = wx.BoxSizer(wx.HORIZONTAL) self.charMap = MyCharMap(self) hsizer.Add(self.charMap) self.insertButton = wx.Button(self, -1, " Insert character ") hsizer.Add(self.insertButton, 0, wx.ALL, 10) wx.EVT_BUTTON(self, self.insertButton.GetId(), self.OnInsert) gutil.btnDblClick(self.insertButton, self.OnInsert) util.finishWindow(self, hsizer, 0)
def __init__(self, parent, text, title, validateFunc=None): wx.Dialog.__init__(self, parent, -1, title, style=wx.DEFAULT_DIALOG_STYLE | wx.WANTS_CHARS) # function to call to validate the input string on OK. can be # None, in which case it is not called. if it returns "", the # input is valid, otherwise the string it returns is displayed in # a message box and the dialog is not closed. self.validateFunc = validateFunc vsizer = wx.BoxSizer(wx.VERTICAL) vsizer.Add(wx.StaticText(self, -1, text), 1, wx.EXPAND | wx.BOTTOM, 5) self.tc = wx.TextCtrl(self, -1, style=wx.TE_PROCESS_ENTER) vsizer.Add(self.tc, 1, wx.EXPAND) vsizer.Add(wx.StaticLine(self, -1), 0, wx.EXPAND | wx.TOP | wx.BOTTOM, 5) hsizer = wx.BoxSizer(wx.HORIZONTAL) cancelBtn = gutil.createStockButton(self, "Cancel") hsizer.Add(cancelBtn) okBtn = gutil.createStockButton(self, "OK") hsizer.Add(okBtn, 0, wx.LEFT, 10) vsizer.Add(hsizer, 0, wx.EXPAND | wx.TOP, 5) util.finishWindow(self, vsizer) wx.EVT_BUTTON(self, cancelBtn.GetId(), self.OnCancel) wx.EVT_BUTTON(self, okBtn.GetId(), self.OnOK) wx.EVT_TEXT_ENTER(self, self.tc.GetId(), self.OnOK) wx.EVT_CHAR(self.tc, self.OnCharEntry) wx.EVT_CHAR(cancelBtn, self.OnCharButton) wx.EVT_CHAR(okBtn, self.OnCharButton) self.tc.SetFocus()
def __init__(self, parent, scDict, isGlobal): wx.Dialog.__init__(self, parent, -1, "Spell checker dictionary", style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER) self.scDict = scDict vsizer = wx.BoxSizer(wx.VERTICAL) if isGlobal: s = "Global words:" else: s = "Script-specific words:" vsizer.Add(wx.StaticText(self, -1, s)) self.itemsEntry = wx.TextCtrl(self, -1, style=wx.TE_MULTILINE | wx.TE_DONTWRAP, size=(300, 300)) vsizer.Add(self.itemsEntry, 1, wx.EXPAND) hsizer = wx.BoxSizer(wx.HORIZONTAL) hsizer.Add((1, 1), 1) cancelBtn = gutil.createStockButton(self, "Cancel") hsizer.Add(cancelBtn, 0, wx.LEFT, 10) okBtn = gutil.createStockButton(self, "OK") hsizer.Add(okBtn, 0, wx.LEFT, 10) vsizer.Add(hsizer, 0, wx.EXPAND | wx.TOP, 10) self.cfg2gui() util.finishWindow(self, vsizer) self.Bind(wx.EVT_TEXT, self.OnMisc, id=self.itemsEntry.GetId()) self.Bind(wx.EVT_BUTTON, self.OnCancel, id=cancelBtn.GetId()) self.Bind(wx.EVT_BUTTON, self.OnOK, id=okBtn.GetId())
def __init__(self, parent, text, title, validateFunc = None): wx.Dialog.__init__(self, parent, -1, title, style = wx.DEFAULT_DIALOG_STYLE | wx.WANTS_CHARS) # function to call to validate the input string on OK. can be # None, in which case it is not called. if it returns "", the # input is valid, otherwise the string it returns is displayed in # a message box and the dialog is not closed. self.validateFunc = validateFunc vsizer = wx.BoxSizer(wx.VERTICAL) vsizer.Add(wx.StaticText(self, -1, text), 1, wx.EXPAND | wx.BOTTOM, 5) self.tc = wx.TextCtrl(self, -1, style = wx.TE_PROCESS_ENTER) vsizer.Add(self.tc, 1, wx.EXPAND); vsizer.Add(wx.StaticLine(self, -1), 0, wx.EXPAND | wx.TOP | wx.BOTTOM, 5) hsizer = wx.BoxSizer(wx.HORIZONTAL) cancelBtn = gutil.createStockButton(self, "Cancel") hsizer.Add(cancelBtn) okBtn = gutil.createStockButton(self, "OK") hsizer.Add(okBtn, 0, wx.LEFT, 10) vsizer.Add(hsizer, 0, wx.EXPAND | wx.TOP, 5) util.finishWindow(self, vsizer) wx.EVT_BUTTON(self, cancelBtn.GetId(), self.OnCancel) wx.EVT_BUTTON(self, okBtn.GetId(), self.OnOK) wx.EVT_TEXT_ENTER(self, self.tc.GetId(), self.OnOK) wx.EVT_CHAR(self.tc, self.OnCharEntry) wx.EVT_CHAR(cancelBtn, self.OnCharButton) wx.EVT_CHAR(okBtn, self.OnCharButton) self.tc.SetFocus()
def __init__(self, parent, scDict, isGlobal): wx.Dialog.__init__(self, parent, -1, "Spell checker dictionary", style = wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER) self.scDict = scDict vsizer = wx.BoxSizer(wx.VERTICAL) if isGlobal: s = "Global words:" else: s = "Script-specific words:" vsizer.Add(wx.StaticText(self, -1, s)) self.itemsEntry = wx.TextCtrl(self, -1, style = wx.TE_MULTILINE | wx.TE_DONTWRAP, size = (300, 300)) vsizer.Add(self.itemsEntry, 1, wx.EXPAND) hsizer = wx.BoxSizer(wx.HORIZONTAL) hsizer.Add((1, 1), 1) cancelBtn = gutil.createStockButton(self, "Cancel") hsizer.Add(cancelBtn, 0, wx.LEFT, 10) okBtn = gutil.createStockButton(self, "OK") hsizer.Add(okBtn, 0, wx.LEFT, 10) vsizer.Add(hsizer, 0, wx.EXPAND | wx.TOP, 10) self.cfg2gui() util.finishWindow(self, vsizer) wx.EVT_TEXT(self, self.itemsEntry.GetId(), self.OnMisc) wx.EVT_BUTTON(self, cancelBtn.GetId(), self.OnCancel) wx.EVT_BUTTON(self, okBtn.GetId(), self.OnOK)
def __init__(self, parent, text, title): wx.Dialog.__init__(self, parent, -1, title, style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER) vsizer = wx.BoxSizer(wx.VERTICAL) hsizer = wx.BoxSizer(wx.HORIZONTAL) bmp = wx.ArtProvider_GetBitmap(wx.ART_WARNING, wx.ART_MESSAGE_BOX, (32, 32)) img = wx.StaticBitmap(self, wx.ID_ANY, bmp) tc = wx.StaticText(self, -1) tc.SetLabel(text) hsizer.Add(img, 0, wx.ALIGN_CENTER_VERTICAL) hsizer.Add(tc, 0, wx.LEFT, 10) vsizer.Add(hsizer) hsizer = wx.BoxSizer(wx.HORIZONTAL) exitBtn = wx.Button(self, -1, "&Exit Without Saving") hsizer.Add(exitBtn) wx.EVT_BUTTON(self, exitBtn.GetId(), self.OnExitWithout) cancelBtn = gutil.createStockButton(self, "Cancel") hsizer.Add(cancelBtn, 0, wx.LEFT, 10) wx.EVT_BUTTON(self, cancelBtn.GetId(), self.OnCancel) vsizer.Add(hsizer, 0, wx.ALIGN_RIGHT | wx.TOP, 20) util.finishWindow(self, vsizer) cancelBtn.SetFocus()
def __init__(self, parent, id, cfg): wx.Panel.__init__(self, parent, id) self.cfg = cfg vsizer = wx.BoxSizer(wx.VERTICAL) hsizer = wx.BoxSizer(wx.HORIZONTAL) hsizer.Add(wx.StaticText(self, -1, "Element:"), 0, wx.ALIGN_CENTER_VERTICAL | wx.RIGHT, 10) self.elementsCombo = wx.ComboBox(self, -1, style = wx.CB_READONLY) for t in config.getTIs(): self.elementsCombo.Append(t.name, t.lt) hsizer.Add(self.elementsCombo, 0) vsizer.Add(hsizer, 0, wx.EXPAND) vsizer.Add(wx.StaticLine(self, -1), 0, wx.EXPAND | wx.TOP | wx.BOTTOM, 10) gsizer = wx.FlexGridSizer(2, 2, 5, 0) self.addTypeCombo("newEnter", "Enter creates", self, gsizer) self.addTypeCombo("newTab", "Tab creates", self, gsizer) self.addTypeCombo("nextTab", "Tab switches to", self, gsizer) self.addTypeCombo("prevTab", "Shift+Tab switches to", self, gsizer) vsizer.Add(gsizer) util.finishWindow(self, vsizer, center = False) wx.EVT_COMBOBOX(self, self.elementsCombo.GetId(), self.OnElementCombo) self.elementsCombo.SetSelection(0) self.OnElementCombo()
def __init__(self, parent, id, cfg): wx.Panel.__init__(self, parent, id) self.cfg = cfg vsizer = wx.BoxSizer(wx.VERTICAL) bsizer = wx.StaticBoxSizer(wx.StaticBox(self, -1, "Default script directory"), wx.VERTICAL) hsizer = wx.BoxSizer(wx.HORIZONTAL) self.scriptDirEntry = wx.TextCtrl(self, -1) hsizer.Add(self.scriptDirEntry, 1, wx.ALIGN_CENTER_VERTICAL | wx.LEFT, 10) btn = wx.Button(self, -1, "Browse") wx.EVT_BUTTON(self, btn.GetId(), self.OnBrowse) hsizer.Add(btn, 0, wx.ALIGN_CENTER_VERTICAL | wx.LEFT, 10) bsizer.Add(hsizer, 1, wx.EXPAND | wx.TOP | wx.BOTTOM, 5) vsizer.Add(bsizer, 0, wx.EXPAND | wx.BOTTOM, 10) bsizer = wx.StaticBoxSizer(wx.StaticBox(self, -1, "PDF viewer application"), wx.VERTICAL) hsizer = wx.BoxSizer(wx.HORIZONTAL) hsizer.Add(wx.StaticText(self, -1, "Path:"), 0, wx.ALIGN_CENTER_VERTICAL | wx.RIGHT, 10) self.progEntry = wx.TextCtrl(self, -1) hsizer.Add(self.progEntry, 1, wx.ALIGN_CENTER_VERTICAL) btn = wx.Button(self, -1, "Browse") wx.EVT_BUTTON(self, btn.GetId(), self.OnBrowsePDF) hsizer.Add(btn, 0, wx.ALIGN_CENTER_VERTICAL | wx.LEFT, 10) bsizer.Add(hsizer, 1, wx.EXPAND) hsizer = wx.BoxSizer(wx.HORIZONTAL) hsizer.Add(wx.StaticText(self, -1, "Arguments:"), 0, wx.ALIGN_CENTER_VERTICAL | wx.RIGHT, 10) self.argsEntry = wx.TextCtrl(self, -1) hsizer.Add(self.argsEntry, 1, wx.ALIGN_CENTER_VERTICAL) bsizer.Add(hsizer, 1, wx.EXPAND) vsizer.Add(bsizer, 1, wx.EXPAND) # wxGTK adds way more space by default than wxMSW between the # items, have to adjust for that pad = 0 if misc.isWindows: pad = 10 self.autoCapSentences = wx.CheckBox(self, -1, "Auto-capitalize sentences") wx.EVT_CHECKBOX(self, self.autoCapSentences.GetId(), self.OnMisc) vsizer.Add(self.autoCapSentences, 0, wx.TOP | wx.BOTTOM, pad) self.autoCapI = wx.CheckBox(self, -1, "Auto-capitalize i -> I") wx.EVT_CHECKBOX(self, self.autoCapI.GetId(), self.OnMisc) vsizer.Add(self.autoCapI, 0, wx.BOTTOM, pad) self.honorSavedPos = wx.CheckBox(self, -1, "When opening a script, start at last saved position") wx.EVT_CHECKBOX(self, self.honorSavedPos.GetId(), self.OnMisc) vsizer.Add(self.honorSavedPos, 0, wx.BOTTOM, pad) self.checkErrorsCb = wx.CheckBox(self, -1, "Check script for errors before print, export or compare") wx.EVT_CHECKBOX(self, self.checkErrorsCb.GetId(), self.OnMisc) vsizer.Add(self.checkErrorsCb, 0, wx.BOTTOM, 10) self.addSpin("splashTime", "Show splash screen for X seconds:\n" " (0 = disable)", self, vsizer, "splashTime") self.addSpin("paginate", "Auto-paginate interval in seconds:\n" " (0 = disable)", self, vsizer, "paginateInterval") self.addSpin("confDel", "Confirm deletes >= this many lines\n" " (0 = disable):", self, vsizer, "confirmDeletes") self.addSpin("wheelScroll", "Lines to scroll per mouse wheel event:", self, vsizer, "mouseWheelLines") self.cfg2gui() util.finishWindow(self, vsizer, center = False) wx.EVT_TEXT(self, self.scriptDirEntry.GetId(), self.OnMisc) wx.EVT_TEXT(self, self.progEntry.GetId(), self.OnMisc) wx.EVT_TEXT(self, self.argsEntry.GetId(), self.OnMisc)
def __init__(self, parent, ctrl, sc, gScDict): wx.Dialog.__init__(self, parent, -1, "Spell checker", style=wx.DEFAULT_DIALOG_STYLE | wx.WANTS_CHARS) self.ctrl = ctrl # spellcheck.SpellCheck self.sc = sc # user's global spell checker dictionary self.gScDict = gScDict # have we replaced any text in the script self.didReplaces = False # have we added any words to global dictionary self.changedGlobalDict = False vsizer = wx.BoxSizer(wx.VERTICAL) hsizer = wx.BoxSizer(wx.HORIZONTAL) hsizer.Add(wx.StaticText(self, -1, "Word:"), 0, wx.ALIGN_CENTER_VERTICAL | wx.RIGHT, 10) self.replaceEntry = wx.TextCtrl(self, -1, style=wx.TE_PROCESS_ENTER) hsizer.Add(self.replaceEntry, 1, wx.EXPAND) vsizer.Add(hsizer, 1, wx.EXPAND | wx.BOTTOM, 15) gsizer = wx.FlexGridSizer(2, 2, 10, 10) gsizer.AddGrowableCol(1) replaceBtn = wx.Button(self, -1, "&Replace") gsizer.Add(replaceBtn) addScriptBtn = wx.Button(self, -1, "Add to &script dictionary") gsizer.Add(addScriptBtn, 0, wx.EXPAND) skipBtn = wx.Button(self, -1, "S&kip") gsizer.Add(skipBtn) addGlobalBtn = wx.Button(self, -1, "Add to &global dictionary") gsizer.Add(addGlobalBtn, 0, wx.EXPAND) vsizer.Add(gsizer, 0, wx.EXPAND, 0) suggestBtn = wx.Button(self, -1, "S&uggest replacement") vsizer.Add(suggestBtn, 0, wx.EXPAND | wx.TOP, 10) wx.EVT_TEXT_ENTER(self, self.replaceEntry.GetId(), self.OnReplace) wx.EVT_BUTTON(self, replaceBtn.GetId(), self.OnReplace) wx.EVT_BUTTON(self, addScriptBtn.GetId(), self.OnAddScript) wx.EVT_BUTTON(self, addGlobalBtn.GetId(), self.OnAddGlobal) wx.EVT_BUTTON(self, skipBtn.GetId(), self.OnSkip) wx.EVT_BUTTON(self, suggestBtn.GetId(), self.OnSuggest) wx.EVT_CHAR(self, self.OnChar) wx.EVT_CHAR(self.replaceEntry, self.OnChar) wx.EVT_CHAR(replaceBtn, self.OnChar) wx.EVT_CHAR(addScriptBtn, self.OnChar) wx.EVT_CHAR(skipBtn, self.OnChar) wx.EVT_CHAR(addGlobalBtn, self.OnChar) wx.EVT_CHAR(suggestBtn, self.OnChar) util.finishWindow(self, vsizer) self.showWord()
def __init__(self, parent, ctrl): wx.Dialog.__init__(self, parent, -1, "Find & Replace", style=wx.DEFAULT_DIALOG_STYLE | wx.WANTS_CHARS) self.ctrl = ctrl self.searchLine = -1 self.searchColumn = -1 self.searchWidth = -1 hsizer = wx.BoxSizer(wx.HORIZONTAL) vsizer = wx.BoxSizer(wx.VERTICAL) gsizer = wx.FlexGridSizer(2, 2, 5, 20) gsizer.AddGrowableCol(1) gsizer.Add(wx.StaticText(self, -1, "Find what:"), 0, wx.ALIGN_CENTER_VERTICAL) self.findEntry = wx.TextCtrl(self, -1, style=wx.TE_PROCESS_ENTER) gsizer.Add(self.findEntry, 0, wx.EXPAND) gsizer.Add(wx.StaticText(self, -1, "Replace with:"), 0, wx.ALIGN_CENTER_VERTICAL) self.replaceEntry = wx.TextCtrl(self, -1, style=wx.TE_PROCESS_ENTER) gsizer.Add(self.replaceEntry, 0, wx.EXPAND) vsizer.Add(gsizer, 0, wx.EXPAND | wx.BOTTOM, 10) hsizer2 = wx.BoxSizer(wx.HORIZONTAL) vsizer2 = wx.BoxSizer(wx.VERTICAL) # wxGTK adds way more space by default than wxMSW between the # items, have to adjust for that pad = 0 if misc.isWindows: pad = 5 self.matchWholeCb = wx.CheckBox(self, -1, "Match whole word only") vsizer2.Add(self.matchWholeCb, 0, wx.TOP, pad) self.matchCaseCb = wx.CheckBox(self, -1, "Match case") vsizer2.Add(self.matchCaseCb, 0, wx.TOP, pad) hsizer2.Add(vsizer2, 0, wx.EXPAND | wx.RIGHT, 10) self.direction = wx.RadioBox(self, -1, "Direction", choices=["Up", "Down"]) self.direction.SetSelection(1) hsizer2.Add(self.direction, 1, 0) vsizer.Add(hsizer2, 0, wx.EXPAND | wx.BOTTOM, 10) self.extraLabel = wx.StaticText(self, -1, "Search in:") vsizer.Add(self.extraLabel) self.elements = wx.CheckListBox(self, -1) # sucky wxMSW doesn't support client data for checklistbox items, # so we have to store it ourselves self.elementTypes = [] for t in config.getTIs(): self.elements.Append(t.name) self.elementTypes.append(t.lt) vsizer.Add(self.elements, 1, wx.EXPAND) hsizer.Add(vsizer, 1, wx.EXPAND) vsizer = wx.BoxSizer(wx.VERTICAL) find = wx.Button(self, -1, "&Find next") vsizer.Add(find, 0, wx.EXPAND | wx.BOTTOM, 5) replace = wx.Button(self, -1, "&Replace") vsizer.Add(replace, 0, wx.EXPAND | wx.BOTTOM, 5) replaceAll = wx.Button(self, -1, " Replace all ") vsizer.Add(replaceAll, 0, wx.EXPAND | wx.BOTTOM, 5) self.moreButton = wx.Button(self, -1, "") vsizer.Add(self.moreButton, 0, wx.EXPAND | wx.BOTTOM, 5) hsizer.Add(vsizer, 0, wx.EXPAND | wx.LEFT, 30) wx.EVT_BUTTON(self, find.GetId(), self.OnFind) wx.EVT_BUTTON(self, replace.GetId(), self.OnReplace) wx.EVT_BUTTON(self, replaceAll.GetId(), self.OnReplaceAll) wx.EVT_BUTTON(self, self.moreButton.GetId(), self.OnMore) gutil.btnDblClick(find, self.OnFind) gutil.btnDblClick(replace, self.OnReplace) wx.EVT_TEXT(self, self.findEntry.GetId(), self.OnText) wx.EVT_TEXT_ENTER(self, self.findEntry.GetId(), self.OnFind) wx.EVT_TEXT_ENTER(self, self.replaceEntry.GetId(), self.OnFind) wx.EVT_CHAR(self, self.OnCharMisc) wx.EVT_CHAR(self.findEntry, self.OnCharEntry) wx.EVT_CHAR(self.replaceEntry, self.OnCharEntry) wx.EVT_CHAR(find, self.OnCharButton) wx.EVT_CHAR(replace, self.OnCharButton) wx.EVT_CHAR(replaceAll, self.OnCharButton) wx.EVT_CHAR(self.moreButton, self.OnCharButton) wx.EVT_CHAR(self.matchWholeCb, self.OnCharMisc) wx.EVT_CHAR(self.matchCaseCb, self.OnCharMisc) wx.EVT_CHAR(self.direction, self.OnCharMisc) wx.EVT_CHAR(self.elements, self.OnCharMisc) util.finishWindow(self, hsizer, center=False) self.loadState() self.findEntry.SetFocus()
def __init__(self, parent, titles, cfg, cfgGl): wx.Dialog.__init__(self, parent, -1, "Title pages", style=wx.DEFAULT_DIALOG_STYLE) self.titles = titles self.cfg = cfg self.cfgGl = cfgGl # whether some events are blocked self.block = False self.setPage(0) vsizer = wx.BoxSizer(wx.VERTICAL) self.pageLabel = wx.StaticText(self, -1, "") vsizer.Add(self.pageLabel, 0, wx.ADJUST_MINSIZE) hsizer = wx.BoxSizer(wx.HORIZONTAL) tmp = wx.Button(self, -1, "Add") hsizer.Add(tmp) self.Bind(wx.EVT_BUTTON, self.OnAddPage, id=tmp.GetId()) gutil.btnDblClick(tmp, self.OnAddPage) self.delPageBtn = wx.Button(self, -1, "Delete") hsizer.Add(self.delPageBtn, 0, wx.LEFT, 10) self.Bind(wx.EVT_BUTTON, self.OnDeletePage, id=self.delPageBtn.GetId()) gutil.btnDblClick(self.delPageBtn, self.OnDeletePage) self.moveBtn = wx.Button(self, -1, "Move") hsizer.Add(self.moveBtn, 0, wx.LEFT, 10) self.Bind(wx.EVT_BUTTON, self.OnMovePage, id=self.moveBtn.GetId()) gutil.btnDblClick(self.moveBtn, self.OnMovePage) self.nextBtn = wx.Button(self, -1, "Next") hsizer.Add(self.nextBtn, 0, wx.LEFT, 10) self.Bind(wx.EVT_BUTTON, self.OnNextPage, id=self.nextBtn.GetId()) gutil.btnDblClick(self.nextBtn, self.OnNextPage) vsizer.Add(hsizer, 0, wx.TOP, 5) vsizer.Add(wx.StaticLine(self, -1), 0, wx.EXPAND | wx.TOP | wx.BOTTOM, 10) hsizer = wx.BoxSizer(wx.HORIZONTAL) vsizer2 = wx.BoxSizer(wx.VERTICAL) tmp = wx.StaticText(self, -1, "Strings:") vsizer2.Add(tmp) self.stringsLb = wx.ListBox(self, -1, size=(200, 150)) vsizer2.Add(self.stringsLb) hsizer2 = wx.BoxSizer(wx.HORIZONTAL) self.addBtn = gutil.createStockButton(self, "Add") hsizer2.Add(self.addBtn) self.Bind(wx.EVT_BUTTON, self.OnAddString, id=self.addBtn.GetId()) gutil.btnDblClick(self.addBtn, self.OnAddString) self.delBtn = gutil.createStockButton(self, "Delete") hsizer2.Add(self.delBtn, 0, wx.LEFT, 10) self.Bind(wx.EVT_BUTTON, self.OnDeleteString, id=self.delBtn.GetId()) gutil.btnDblClick(self.delBtn, self.OnDeleteString) vsizer2.Add(hsizer2, 0, wx.TOP, 5) hsizer.Add(vsizer2) self.previewCtrl = TitlesPreview(self, self, self.cfg) util.setWH(self.previewCtrl, 150, 150) hsizer.Add(self.previewCtrl, 1, wx.EXPAND | wx.LEFT, 10) vsizer.Add(hsizer, 0, wx.EXPAND) hsizer = wx.BoxSizer(wx.HORIZONTAL) hsizer.Add(wx.StaticText(self, -1, "Text:"), 0, wx.ALIGN_CENTER_VERTICAL) self.textEntry = wx.TextCtrl(self, -1, style=wx.TE_MULTILINE | wx.TE_DONTWRAP, size=(200, 75)) hsizer.Add(self.textEntry, 1, wx.LEFT, 10) self.Bind(wx.EVT_TEXT, self.OnMisc, id=self.textEntry.GetId()) vsizer.Add(hsizer, 0, wx.EXPAND | wx.TOP, 20) # TODO: should use FlexGridSizer, like headersdlg, to get neater # layout hsizerTop = wx.BoxSizer(wx.HORIZONTAL) vsizer2 = wx.BoxSizer(wx.VERTICAL) hsizer = wx.BoxSizer(wx.HORIZONTAL) hsizer.Add(wx.StaticText(self, -1, "Alignment:"), 0, wx.ALIGN_CENTER_VERTICAL) self.alignCombo = wx.ComboBox(self, -1, style=wx.CB_READONLY) for it in [("Left", util.ALIGN_LEFT), ("Center", util.ALIGN_CENTER), ("Right", util.ALIGN_RIGHT)]: self.alignCombo.Append(it[0], it[1]) hsizer.Add(self.alignCombo, 0, wx.LEFT, 10) self.Bind(wx.EVT_COMBOBOX, self.OnMisc, id=self.alignCombo.GetId()) vsizer2.Add(hsizer, 0, wx.TOP, 5) hsizer = wx.BoxSizer(wx.HORIZONTAL) hsizer.Add(wx.StaticText(self, -1, "X / Y Pos (mm):"), 0, wx.ALIGN_CENTER_VERTICAL) self.xEntry = wx.TextCtrl(self, -1) hsizer.Add(self.xEntry, 0, wx.LEFT, 10) self.Bind(wx.EVT_TEXT, self.OnMisc, id=self.xEntry.GetId()) self.yEntry = wx.TextCtrl(self, -1) hsizer.Add(self.yEntry, 0, wx.LEFT, 10) self.Bind(wx.EVT_TEXT, self.OnMisc, id=self.yEntry.GetId()) vsizer2.Add(hsizer, 0, wx.TOP, 5) hsizer = wx.BoxSizer(wx.HORIZONTAL) hsizer.Add(wx.StaticText(self, -1, "Font / Size:"), 0, wx.ALIGN_CENTER_VERTICAL) self.fontCombo = wx.ComboBox(self, -1, style=wx.CB_READONLY) for it in [("Courier", pml.COURIER), ("Helvetica", pml.HELVETICA), ("Times-Roman", pml.TIMES_ROMAN)]: self.fontCombo.Append(it[0], it[1]) hsizer.Add(self.fontCombo, 0, wx.LEFT, 10) self.Bind(wx.EVT_COMBOBOX, self.OnMisc, id=self.fontCombo.GetId()) self.sizeEntry = wx.SpinCtrl(self, -1, size=(50, -1)) self.sizeEntry.SetRange(4, 288) self.Bind(wx.EVT_SPINCTRL, self.OnMisc, id=self.sizeEntry.GetId()) self.sizeEntry.Bind(wx.EVT_KILL_FOCUS, self.OnKillFocus) hsizer.Add(self.sizeEntry, 0, wx.LEFT, 10) vsizer2.Add(hsizer, 0, wx.TOP, 10) hsizerTop.Add(vsizer2) bsizer = wx.StaticBoxSizer(wx.StaticBox(self, -1, "Style"), wx.HORIZONTAL) vsizer2 = wx.BoxSizer(wx.VERTICAL) # wxGTK adds way more space by default than wxMSW between the # items, have to adjust for that pad = 0 if misc.isWindows: pad = 5 self.addCheckBox("Bold", self, vsizer2, pad) self.addCheckBox("Italic", self, vsizer2, pad) self.addCheckBox("Underlined", self, vsizer2, pad) bsizer.Add(vsizer2) hsizerTop.Add(bsizer, 0, wx.LEFT, 20) vsizer.Add(hsizerTop, 0, wx.TOP, 10) hsizer = wx.BoxSizer(wx.HORIZONTAL) hsizer.Add((1, 1), 1) self.previewBtn = gutil.createStockButton(self, "Preview") hsizer.Add(self.previewBtn) cancelBtn = gutil.createStockButton(self, "Cancel") hsizer.Add(cancelBtn, 0, wx.LEFT, 10) okBtn = gutil.createStockButton(self, "OK") hsizer.Add(okBtn, 0, wx.LEFT, 10) vsizer.Add(hsizer, 0, wx.EXPAND | wx.TOP, 20) util.finishWindow(self, vsizer) self.Bind(wx.EVT_BUTTON, self.OnPreview, id=self.previewBtn.GetId()) self.Bind(wx.EVT_BUTTON, self.OnCancel, id=cancelBtn.GetId()) self.Bind(wx.EVT_BUTTON, self.OnOK, id=okBtn.GetId()) self.Bind(wx.EVT_LISTBOX, self.OnStringsLb, id=self.stringsLb.GetId()) # list of widgets that are specific to editing the selected string self.widList = [ self.textEntry, self.xEntry, self.alignCombo, self.yEntry, self.fontCombo, self.sizeEntry, self.boldCb, self.italicCb, self.underlinedCb ] self.updateGui() self.textEntry.SetFocus()
def __init__(self, parent, ctrl): wx.Dialog.__init__(self, parent, -1, "Character name database", style = wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER) self.ctrl = ctrl hsizer = wx.BoxSizer(wx.HORIZONTAL) vsizer = wx.BoxSizer(wx.VERTICAL) vsizer.Add(wx.StaticText(self, -1, "Search in:")) self.typeList = wx.ListCtrl(self, -1, style = wx.LC_REPORT | wx.LC_HRULES | wx.LC_VRULES) self.typeList.InsertColumn(0, "Count") self.typeList.InsertColumn(1, "Type") for i in range(len(nameArr.typeNamesById)): typeName = nameArr.typeNamesById[i] self.typeList.InsertStringItem(i, str(nameArr.typeNamesCnt[typeName])) self.typeList.SetStringItem(i, 1, typeName) self.typeList.SetItemData(i, i) self.typeList.SetColumnWidth(0, wx.LIST_AUTOSIZE) self.typeList.SetColumnWidth(1, wx.LIST_AUTOSIZE) w = 0 w += self.typeList.GetColumnWidth(0) w += self.typeList.GetColumnWidth(1) util.setWH(self.typeList, w + 15, 425) self.typeList.SortItems(self.CmpFreq) self.selectAllTypes() vsizer.Add(self.typeList, 1, wx.EXPAND | wx.BOTTOM, 5) selectAllBtn = wx.Button(self, -1, "Select all") vsizer.Add(selectAllBtn) hsizer.Add(vsizer, 0, wx.EXPAND) vsizer = wx.BoxSizer(wx.VERTICAL) hsizer2 = wx.BoxSizer(wx.HORIZONTAL) vsizer2 = wx.BoxSizer(wx.VERTICAL) searchBtn = wx.Button(self, -1, "Search") wx.EVT_BUTTON(self, searchBtn.GetId(), self.OnSearch) vsizer2.Add(searchBtn, 0, wx.BOTTOM | wx.TOP, 10) self.searchEntry = wx.TextCtrl(self, -1, style = wx.TE_PROCESS_ENTER) vsizer2.Add(self.searchEntry, 0, wx.EXPAND) tmp = wx.Button(self, -1, "Insert") wx.EVT_BUTTON(self, tmp.GetId(), self.OnInsertName) vsizer2.Add(tmp, 0, wx.BOTTOM | wx.TOP, 10) hsizer2.Add(vsizer2, 1, wx.RIGHT, 10) self.nameRb = wx.RadioBox(self, -1, "Name", style = wx.RA_SPECIFY_COLS, majorDimension = 1, choices = [ "begins with", "contains", "ends in" ]) hsizer2.Add(self.nameRb) self.sexRb = wx.RadioBox(self, -1, "Sex", style = wx.RA_SPECIFY_COLS, majorDimension = 1, choices = [ "Male", "Female", "Both" ]) self.sexRb.SetSelection(2) hsizer2.Add(self.sexRb, 0, wx.LEFT, 5) vsizer.Add(hsizer2, 0, wx.EXPAND | wx.ALIGN_CENTER) vsizer.Add(wx.StaticText(self, -1, "Results:")) self.list = MyListCtrl(self) vsizer.Add(self.list, 1, wx.EXPAND | wx.BOTTOM, 5) self.foundLabel = wx.StaticText(self, -1, "", style = wx.ALIGN_CENTRE | wx.ST_NO_AUTORESIZE) vsizer.Add(self.foundLabel, 0, wx.EXPAND) hsizer.Add(vsizer, 20, wx.EXPAND | wx.LEFT, 10) wx.EVT_TEXT_ENTER(self, self.searchEntry.GetId(), self.OnSearch) wx.EVT_BUTTON(self, selectAllBtn.GetId(), self.selectAllTypes) wx.EVT_LIST_COL_CLICK(self, self.typeList.GetId(), self.OnHeaderClick) util.finishWindow(self, hsizer) self.OnSearch() self.searchEntry.SetFocus()
def __init__(self, parent, ctrl): wx.Dialog.__init__(self, parent, -1, "Find and Replace", style=wx.DEFAULT_DIALOG_STYLE | wx.WANTS_CHARS) self.ctrl = ctrl self.searchLine = -1 self.searchColumn = -1 self.searchWidth = -1 hsizer = wx.BoxSizer(wx.HORIZONTAL) vsizer = wx.BoxSizer(wx.VERTICAL) gsizer = wx.FlexGridSizer(2, 2, 5, 20) gsizer.AddGrowableCol(1) gsizer.Add(wx.StaticText(self, -1, "Text to Find"), 0, wx.ALIGN_CENTER_VERTICAL) self.findEntry = wx.TextCtrl(self, -1, style=wx.TE_PROCESS_ENTER) gsizer.Add(self.findEntry, 0, wx.EXPAND) gsizer.Add(wx.StaticText(self, -1, "Replace With"), 0, wx.ALIGN_CENTER_VERTICAL) self.replaceEntry = wx.TextCtrl(self, -1, style=wx.TE_PROCESS_ENTER) gsizer.Add(self.replaceEntry, 0, wx.EXPAND) vsizer.Add(gsizer, 0, wx.EXPAND | wx.BOTTOM, 5) hsizer2 = wx.BoxSizer(wx.HORIZONTAL) vsizer2 = wx.BoxSizer(wx.VERTICAL) # wxGTK adds way more space by default than wxMSW between the # items, have to adjust for that pad = 0 if misc.isWindows: pad = 5 self.matchWholeCb = wx.CheckBox(self, -1, "Match Whole Word") vsizer2.Add(self.matchWholeCb, 0, wx.TOP, pad) self.matchCaseCb = wx.CheckBox(self, -1, "Match Case") vsizer2.Add(self.matchCaseCb, 0, wx.TOP, pad) hsizer2.Add(vsizer2, 0, wx.EXPAND | wx.RIGHT, 10) self.direction = wx.RadioBox(self, -1, "Direction", choices=["Backward", "Forward"]) self.direction.SetSelection(1) hsizer2.Add(self.direction, 1, 0) vsizer.Add(hsizer2, 0, wx.EXPAND | wx.BOTTOM, 10) self.extraLabel = wx.StaticText(self, -1, "Search In") vsizer.Add(self.extraLabel) self.elements = wx.CheckListBox(self, -1) # sucky wxMSW doesn't support client data for checklistbox items, # so we have to store it ourselves self.elementTypes = [] for t in config.getTIs(): self.elements.Append(t.name) self.elementTypes.append(t.lt) vsizer.Add(self.elements, 1, wx.EXPAND) hsizer.Add(vsizer, 1, wx.EXPAND) vsizer = wx.BoxSizer(wx.VERTICAL) find = wx.Button(self, -1, "&Find") vsizer.Add(find, 0, wx.EXPAND | wx.BOTTOM, 5) replaceAll = wx.Button(self, -1, " Replace All ") vsizer.Add(replaceAll, 0, wx.EXPAND | wx.BOTTOM, 5) replace = wx.Button(self, -1, "&Replace") vsizer.Add(replace, 0, wx.EXPAND | wx.BOTTOM, 5) self.moreButton = wx.Button(self, -1, "") vsizer.Add(self.moreButton, 0, wx.EXPAND | wx.BOTTOM, 5) hsizer.Add(vsizer, 0, wx.EXPAND | wx.LEFT, 30) wx.EVT_BUTTON(self, find.GetId(), self.OnFind) wx.EVT_BUTTON(self, replaceAll.GetId(), self.OnReplaceAll) wx.EVT_BUTTON(self, replace.GetId(), self.OnReplace) wx.EVT_BUTTON(self, self.moreButton.GetId(), self.OnMore) gutil.btnDblClick(find, self.OnFind) gutil.btnDblClick(replace, self.OnReplace) wx.EVT_TEXT(self, self.findEntry.GetId(), self.OnText) wx.EVT_TEXT_ENTER(self, self.findEntry.GetId(), self.OnFind) wx.EVT_TEXT_ENTER(self, self.replaceEntry.GetId(), self.OnFind) wx.EVT_CHAR(self, self.OnCharMisc) wx.EVT_CHAR(self.findEntry, self.OnCharEntry) wx.EVT_CHAR(self.replaceEntry, self.OnCharEntry) wx.EVT_CHAR(find, self.OnCharButton) wx.EVT_CHAR(replaceAll, self.OnCharButton) wx.EVT_CHAR(replace, self.OnCharButton) wx.EVT_CHAR(self.moreButton, self.OnCharButton) wx.EVT_CHAR(self.matchWholeCb, self.OnCharMisc) wx.EVT_CHAR(self.matchCaseCb, self.OnCharMisc) wx.EVT_CHAR(self.direction, self.OnCharMisc) wx.EVT_CHAR(self.elements, self.OnCharMisc) util.finishWindow(self, hsizer, center=False) self.loadState() self.findEntry.SetFocus()
def __init__(self, parent, id, cfg): wx.Panel.__init__(self, parent, id) self.cfg = cfg vsizer = wx.BoxSizer(wx.VERTICAL) hsizer = wx.BoxSizer(wx.HORIZONTAL) hsizer.Add(wx.StaticText(self, -1, "Element:"), 0, wx.ALIGN_CENTER_VERTICAL | wx.RIGHT, 10) self.elementsCombo = wx.ComboBox(self, -1, style=wx.CB_READONLY) for t in config.getTIs(): self.elementsCombo.Append(t.name, t.lt) hsizer.Add(self.elementsCombo, 0) vsizer.Add(hsizer, 0, wx.EXPAND) vsizer.Add(wx.StaticLine(self, -1), 0, wx.EXPAND | wx.TOP | wx.BOTTOM, 10) hsizer = wx.BoxSizer(wx.HORIZONTAL) hsizer.Add(self.addTextStyles("Screen", "screen", self)) hsizer.Add(self.addTextStyles("Print", "export", self), 0, wx.LEFT, 10) vsizer.Add(hsizer, 0, wx.BOTTOM, 10) gsizer = wx.FlexGridSizer(2, 2, 5, 0) gsizer.Add(wx.StaticText(self, -1, "Empty lines / 10 before:"), 0, wx.ALIGN_CENTER_VERTICAL | wx.RIGHT, 10) tmp = wx.SpinCtrl(self, -1) tmp.SetRange(*self.cfg.getType(screenplay.ACTION).cvars.getMinMax("beforeSpacing")) wx.EVT_SPINCTRL(self, tmp.GetId(), self.OnMisc) wx.EVT_KILL_FOCUS(tmp, self.OnKillFocus) gsizer.Add(tmp) self.beforeSpacingEntry = tmp gsizer.Add(wx.StaticText(self, -1, "Empty lines / 10 between:"), 0, wx.ALIGN_CENTER_VERTICAL | wx.RIGHT, 10) tmp = wx.SpinCtrl(self, -1) tmp.SetRange(*self.cfg.getType(screenplay.ACTION).cvars.getMinMax("intraSpacing")) wx.EVT_SPINCTRL(self, tmp.GetId(), self.OnMisc) wx.EVT_KILL_FOCUS(tmp, self.OnKillFocus) gsizer.Add(tmp) self.intraSpacingEntry = tmp vsizer.Add(gsizer, 0, wx.BOTTOM, 20) gsizer = wx.FlexGridSizer(2, 3, 5, 0) gsizer.Add(wx.StaticText(self, -1, "Indent:"), 0, wx.ALIGN_CENTER_VERTICAL | wx.RIGHT, 10) self.indentEntry = wx.SpinCtrl(self, -1) self.indentEntry.SetRange(*self.cfg.getType(screenplay.ACTION).cvars.getMinMax("indent")) wx.EVT_SPINCTRL(self, self.indentEntry.GetId(), self.OnMisc) wx.EVT_KILL_FOCUS(self.indentEntry, self.OnKillFocus) gsizer.Add(self.indentEntry, 0) gsizer.Add( wx.StaticText(self, -1, "characters (10 characters" " = 1 inch)"), 0, wx.ALIGN_CENTER_VERTICAL | wx.LEFT, 10 ) gsizer.Add(wx.StaticText(self, -1, "Width:"), 0, wx.ALIGN_CENTER_VERTICAL | wx.RIGHT, 10) self.widthEntry = wx.SpinCtrl(self, -1) self.widthEntry.SetRange(*self.cfg.getType(screenplay.ACTION).cvars.getMinMax("width")) wx.EVT_SPINCTRL(self, self.widthEntry.GetId(), self.OnMisc) wx.EVT_KILL_FOCUS(self.widthEntry, self.OnKillFocus) gsizer.Add(self.widthEntry, 0) gsizer.Add( wx.StaticText(self, -1, "characters (10 characters" " = 1 inch)"), 0, wx.ALIGN_CENTER_VERTICAL | wx.LEFT, 10 ) vsizer.Add(gsizer, 0, wx.BOTTOM, 20) util.finishWindow(self, vsizer, center=False) wx.EVT_COMBOBOX(self, self.elementsCombo.GetId(), self.OnElementCombo) self.elementsCombo.SetSelection(0) self.OnElementCombo()
def __init__(self, parent, ctrl): wx.Dialog.__init__(self, parent, -1, "Character name database", style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER) self.ctrl = ctrl hsizer = wx.BoxSizer(wx.HORIZONTAL) vsizer = wx.BoxSizer(wx.VERTICAL) vsizer.Add(wx.StaticText(self, -1, "Search in:")) self.typeList = wx.ListCtrl(self, -1, style=wx.LC_REPORT | wx.LC_HRULES | wx.LC_VRULES) self.typeList.InsertColumn(0, "Count") self.typeList.InsertColumn(1, "Type") for i in range(len(nameArr.typeNamesById)): typeName = nameArr.typeNamesById[i] self.typeList.InsertStringItem(i, str(nameArr.typeNamesCnt[typeName])) self.typeList.SetStringItem(i, 1, typeName) self.typeList.SetItemData(i, i) self.typeList.SetColumnWidth(0, wx.LIST_AUTOSIZE) self.typeList.SetColumnWidth(1, wx.LIST_AUTOSIZE) w = 0 w += self.typeList.GetColumnWidth(0) w += self.typeList.GetColumnWidth(1) util.setWH(self.typeList, w + 15, 425) self.typeList.SortItems(self.CmpFreq) self.selectAllTypes() vsizer.Add(self.typeList, 1, wx.EXPAND | wx.BOTTOM, 5) selectAllBtn = wx.Button(self, -1, "Select all") vsizer.Add(selectAllBtn) hsizer.Add(vsizer, 0, wx.EXPAND) vsizer = wx.BoxSizer(wx.VERTICAL) hsizer2 = wx.BoxSizer(wx.HORIZONTAL) vsizer2 = wx.BoxSizer(wx.VERTICAL) searchBtn = wx.Button(self, -1, "Search") wx.EVT_BUTTON(self, searchBtn.GetId(), self.OnSearch) vsizer2.Add(searchBtn, 0, wx.BOTTOM | wx.TOP, 10) self.searchEntry = wx.TextCtrl(self, -1, style=wx.TE_PROCESS_ENTER) vsizer2.Add(self.searchEntry, 0, wx.EXPAND) tmp = wx.Button(self, -1, "Insert") wx.EVT_BUTTON(self, tmp.GetId(), self.OnInsertName) vsizer2.Add(tmp, 0, wx.BOTTOM | wx.TOP, 10) hsizer2.Add(vsizer2, 1, wx.RIGHT, 10) self.nameRb = wx.RadioBox( self, -1, "Name", style=wx.RA_SPECIFY_COLS, majorDimension=1, choices=["begins with", "contains", "ends in"]) hsizer2.Add(self.nameRb) self.sexRb = wx.RadioBox(self, -1, "Sex", style=wx.RA_SPECIFY_COLS, majorDimension=1, choices=["Male", "Female", "Both"]) self.sexRb.SetSelection(2) hsizer2.Add(self.sexRb, 0, wx.LEFT, 5) vsizer.Add(hsizer2, 0, wx.EXPAND | wx.ALIGN_CENTER) vsizer.Add(wx.StaticText(self, -1, "Results:")) self.list = MyListCtrl(self) vsizer.Add(self.list, 1, wx.EXPAND | wx.BOTTOM, 5) self.foundLabel = wx.StaticText(self, -1, "", style=wx.ALIGN_CENTRE | wx.ST_NO_AUTORESIZE) vsizer.Add(self.foundLabel, 0, wx.EXPAND) hsizer.Add(vsizer, 20, wx.EXPAND | wx.LEFT, 10) wx.EVT_TEXT_ENTER(self, self.searchEntry.GetId(), self.OnSearch) wx.EVT_BUTTON(self, selectAllBtn.GetId(), self.selectAllTypes) wx.EVT_LIST_COL_CLICK(self, self.typeList.GetId(), self.OnHeaderClick) util.finishWindow(self, hsizer) self.OnSearch() self.searchEntry.SetFocus()
def __init__(self, parent, id, cfg): wx.Panel.__init__(self, parent, id) self.cfg = cfg self.blockEvents = 1 self.paperSizes = {"A4": (210.0, 297.0), "Letter": (215.9, 279.4), "Custom": (1.0, 1.0)} vsizer = wx.BoxSizer(wx.VERTICAL) gsizer = wx.FlexGridSizer(3, 2, 5, 5) gsizer.Add(wx.StaticText(self, -1, "Type:"), 0, wx.ALIGN_CENTER_VERTICAL | wx.RIGHT, 10) self.paperCombo = wx.ComboBox(self, -1, style=wx.CB_READONLY) for k, v in self.paperSizes.items(): self.paperCombo.Append(k, v) gsizer.Add(self.paperCombo) gsizer.Add(wx.StaticText(self, -1, "Width:"), 0, wx.ALIGN_CENTER_VERTICAL) hsizer = wx.BoxSizer(wx.HORIZONTAL) self.widthEntry = wx.TextCtrl(self, -1) hsizer.Add(self.widthEntry) hsizer.Add(wx.StaticText(self, -1, "mm"), 0, wx.ALIGN_CENTER_VERTICAL | wx.LEFT, 5) gsizer.Add(hsizer) gsizer.Add(wx.StaticText(self, -1, "Height:"), 0, wx.ALIGN_CENTER_VERTICAL) hsizer = wx.BoxSizer(wx.HORIZONTAL) self.heightEntry = wx.TextCtrl(self, -1) hsizer.Add(self.heightEntry) hsizer.Add(wx.StaticText(self, -1, "mm"), 0, wx.ALIGN_CENTER_VERTICAL | wx.LEFT, 5) gsizer.Add(hsizer) vsizer.Add(gsizer, 0, wx.BOTTOM, 10) bsizer = wx.StaticBoxSizer(wx.StaticBox(self, -1, "Margins"), wx.HORIZONTAL) gsizer = wx.FlexGridSizer(4, 5, 5, 5) self.addMarginCtrl("Top", self, gsizer) self.addMarginCtrl("Bottom", self, gsizer) self.addMarginCtrl("Left", self, gsizer) self.addMarginCtrl("Right", self, gsizer) bsizer.Add(gsizer, 0, wx.EXPAND | wx.ALL, 10) vsizer.Add(bsizer, 0, wx.BOTTOM, 10) vsizer.Add(wx.StaticText(self, -1, "(1 inch = 25.4 mm)"), 0, wx.LEFT, 25) self.linesLabel = wx.StaticText(self, -1, "") # wxwindows doesn't recalculate sizer size correctly at startup so # set initial text self.setLines() vsizer.Add(self.linesLabel, 0, wx.TOP, 20) util.finishWindow(self, vsizer, center=False) ptype = "Custom" for k, v in self.paperSizes.items(): if self.eqFloat(self.cfg.paperWidth, v[0]) and self.eqFloat(self.cfg.paperHeight, v[1]): ptype = k idx = self.paperCombo.FindString(ptype) if idx != -1: self.paperCombo.SetSelection(idx) wx.EVT_COMBOBOX(self, self.paperCombo.GetId(), self.OnPaperCombo) self.OnPaperCombo(None) wx.EVT_TEXT(self, self.widthEntry.GetId(), self.OnMisc) wx.EVT_TEXT(self, self.heightEntry.GetId(), self.OnMisc) self.cfg2mm() self.cfg2inch() self.blockEvents -= 1
def __init__(self, parent, titles, cfg, cfgGl): wx.Dialog.__init__(self, parent, -1, "Title pages", style = wx.DEFAULT_DIALOG_STYLE) self.titles = titles self.cfg = cfg self.cfgGl = cfgGl # whether some events are blocked self.block = False self.setPage(0) vsizer = wx.BoxSizer(wx.VERTICAL) self.pageLabel = wx.StaticText(self, -1, "") vsizer.Add(self.pageLabel, 0, wx.ADJUST_MINSIZE) hsizer = wx.BoxSizer(wx.HORIZONTAL) tmp = wx.Button(self, -1, "Add") hsizer.Add(tmp) wx.EVT_BUTTON(self, tmp.GetId(), self.OnAddPage) gutil.btnDblClick(tmp, self.OnAddPage) self.delPageBtn = wx.Button(self, -1, "Delete") hsizer.Add(self.delPageBtn, 0, wx.LEFT, 10) wx.EVT_BUTTON(self, self.delPageBtn.GetId(), self.OnDeletePage) gutil.btnDblClick(self.delPageBtn, self.OnDeletePage) self.moveBtn = wx.Button(self, -1, "Move") hsizer.Add(self.moveBtn, 0, wx.LEFT, 10) wx.EVT_BUTTON(self, self.moveBtn.GetId(), self.OnMovePage) gutil.btnDblClick(self.moveBtn, self.OnMovePage) self.nextBtn = wx.Button(self, -1, "Next") hsizer.Add(self.nextBtn, 0, wx.LEFT, 10) wx.EVT_BUTTON(self, self.nextBtn.GetId(), self.OnNextPage) gutil.btnDblClick(self.nextBtn, self.OnNextPage) vsizer.Add(hsizer, 0, wx.TOP, 5) vsizer.Add(wx.StaticLine(self, -1), 0, wx.EXPAND | wx.TOP | wx.BOTTOM, 10) hsizer = wx.BoxSizer(wx.HORIZONTAL) vsizer2 = wx.BoxSizer(wx.VERTICAL) tmp = wx.StaticText(self, -1, "Strings:") vsizer2.Add(tmp) self.stringsLb = wx.ListBox(self, -1, size = (200, 150)) vsizer2.Add(self.stringsLb) hsizer2 = wx.BoxSizer(wx.HORIZONTAL) self.addBtn = gutil.createStockButton(self, "Add") hsizer2.Add(self.addBtn) wx.EVT_BUTTON(self, self.addBtn.GetId(), self.OnAddString) gutil.btnDblClick(self.addBtn, self.OnAddString) self.delBtn = gutil.createStockButton(self, "Delete") hsizer2.Add(self.delBtn, 0, wx.LEFT, 10) wx.EVT_BUTTON(self, self.delBtn.GetId(), self.OnDeleteString) gutil.btnDblClick(self.delBtn, self.OnDeleteString) vsizer2.Add(hsizer2, 0, wx.TOP, 5) hsizer.Add(vsizer2) self.previewCtrl = TitlesPreview(self, self, self.cfg) util.setWH(self.previewCtrl, 150, 150) hsizer.Add(self.previewCtrl, 1, wx.EXPAND | wx.LEFT, 10) vsizer.Add(hsizer, 0, wx.EXPAND) hsizer = wx.BoxSizer(wx.HORIZONTAL) hsizer.Add(wx.StaticText(self, -1, "Text:"), 0, wx.ALIGN_CENTER_VERTICAL) self.textEntry = wx.TextCtrl( self, -1, style = wx.TE_MULTILINE | wx.TE_DONTWRAP, size = (200, 75)) hsizer.Add(self.textEntry, 1, wx.LEFT, 10) wx.EVT_TEXT(self, self.textEntry.GetId(), self.OnMisc) vsizer.Add(hsizer, 0, wx.EXPAND | wx.TOP, 20) # TODO: should use FlexGridSizer, like headersdlg, to get neater # layout hsizerTop = wx.BoxSizer(wx.HORIZONTAL) vsizer2 = wx.BoxSizer(wx.VERTICAL) hsizer = wx.BoxSizer(wx.HORIZONTAL) hsizer.Add(wx.StaticText(self, -1, "X-Pos (mm):"), 0, wx.ALIGN_CENTER_VERTICAL) self.xEntry = wx.TextCtrl(self, -1) hsizer.Add(self.xEntry, 0, wx.LEFT, 10) wx.EVT_TEXT(self, self.xEntry.GetId(), self.OnMisc) vsizer2.Add(hsizer, 0, wx.TOP, 5) hsizer = wx.BoxSizer(wx.HORIZONTAL) hsizer.Add(wx.StaticText(self, -1, "Y-Pos (mm):"), 0, wx.ALIGN_CENTER_VERTICAL) self.yEntry = wx.TextCtrl(self, -1) hsizer.Add(self.yEntry, 0, wx.LEFT, 10) wx.EVT_TEXT(self, self.yEntry.GetId(), self.OnMisc) vsizer2.Add(hsizer, 0, wx.TOP, 5) hsizer = wx.BoxSizer(wx.HORIZONTAL) hsizer.Add(wx.StaticText(self, -1, "Alignment:"), 0, wx.ALIGN_CENTER_VERTICAL) self.alignCombo = wx.ComboBox(self, -1, style = wx.CB_READONLY) for it in [ ("Left", util.ALIGN_LEFT), ("Center", util.ALIGN_CENTER), ("Right", util.ALIGN_RIGHT) ]: self.alignCombo.Append(it[0], it[1]) hsizer.Add(self.alignCombo, 0, wx.LEFT, 10) wx.EVT_COMBOBOX(self, self.alignCombo.GetId(), self.OnMisc) vsizer2.Add(hsizer, 0, wx.TOP, 5) hsizer = wx.BoxSizer(wx.HORIZONTAL) hsizer.Add(wx.StaticText(self, -1, "Font:"), 0, wx.ALIGN_CENTER_VERTICAL) self.fontCombo = wx.ComboBox(self, -1, style = wx.CB_READONLY) for it in [ ("Courier", pml.COURIER), ("Helvetica", pml.HELVETICA), ("Times-Roman", pml.TIMES_ROMAN) ]: self.fontCombo.Append(it[0], it[1]) hsizer.Add(self.fontCombo, 0, wx.LEFT, 10) wx.EVT_COMBOBOX(self, self.fontCombo.GetId(), self.OnMisc) vsizer2.Add(hsizer, 0, wx.TOP, 10) hsizer = wx.BoxSizer(wx.HORIZONTAL) hsizer.Add(wx.StaticText(self, -1, "Size:"), 0, wx.ALIGN_CENTER_VERTICAL) self.sizeEntry = wx.SpinCtrl(self, -1) self.sizeEntry.SetRange(4, 288) wx.EVT_SPINCTRL(self, self.sizeEntry.GetId(), self.OnMisc) wx.EVT_KILL_FOCUS(self.sizeEntry, self.OnKillFocus) hsizer.Add(self.sizeEntry, 0, wx.LEFT, 10) vsizer2.Add(hsizer, 0, wx.TOP, 5) hsizerTop.Add(vsizer2) bsizer = wx.StaticBoxSizer(wx.StaticBox(self, -1, "Style"), wx.HORIZONTAL) vsizer2 = wx.BoxSizer(wx.VERTICAL) # wxGTK adds way more space by default than wxMSW between the # items, have to adjust for that pad = 0 if misc.isWindows: pad = 5 self.addCheckBox("Bold", self, vsizer2, pad) self.addCheckBox("Italic", self, vsizer2, pad) self.addCheckBox("Underlined", self, vsizer2, pad) bsizer.Add(vsizer2) hsizerTop.Add(bsizer, 0, wx.LEFT, 20) vsizer.Add(hsizerTop, 0, wx.TOP, 10) hsizer = wx.BoxSizer(wx.HORIZONTAL) hsizer.Add((1, 1), 1) self.previewBtn = gutil.createStockButton(self, "Preview") hsizer.Add(self.previewBtn) cancelBtn = gutil.createStockButton(self, "Cancel") hsizer.Add(cancelBtn, 0, wx.LEFT, 10) okBtn = gutil.createStockButton(self, "OK") hsizer.Add(okBtn, 0, wx.LEFT, 10) vsizer.Add(hsizer, 0, wx.EXPAND | wx.TOP, 20) util.finishWindow(self, vsizer) wx.EVT_BUTTON(self, self.previewBtn.GetId(), self.OnPreview) wx.EVT_BUTTON(self, cancelBtn.GetId(), self.OnCancel) wx.EVT_BUTTON(self, okBtn.GetId(), self.OnOK) wx.EVT_LISTBOX(self, self.stringsLb.GetId(), self.OnStringsLb) # list of widgets that are specific to editing the selected string self.widList = [ self.textEntry, self.xEntry, self.alignCombo, self.yEntry, self.fontCombo, self.sizeEntry, self.boldCb, self.italicCb, self.underlinedCb ] self.updateGui() self.textEntry.SetFocus()
def __init__(self, parent, headers, cfg, cfgGl, applyFunc): wx.Dialog.__init__(self, parent, -1, "Headers", style = wx.DEFAULT_DIALOG_STYLE) self.headers = headers self.cfg = cfg self.cfgGl = cfgGl self.applyFunc = applyFunc # whether some events are blocked self.block = False self.hdrIndex = -1 if len(self.headers.hdrs) > 0: self.hdrIndex = 0 vsizer = wx.BoxSizer(wx.VERTICAL) hsizer = wx.BoxSizer(wx.HORIZONTAL) hsizer.Add(wx.StaticText(self, -1, "Empty lines after headers:"), 0, wx.ALIGN_CENTER_VERTICAL) self.elinesEntry = wx.SpinCtrl(self, -1) self.elinesEntry.SetRange(0, 5) wx.EVT_SPINCTRL(self, self.elinesEntry.GetId(), self.OnMisc) wx.EVT_KILL_FOCUS(self.elinesEntry, self.OnKillFocus) hsizer.Add(self.elinesEntry, 0, wx.LEFT, 10) vsizer.Add(hsizer) vsizer.Add(wx.StaticLine(self, -1), 0, wx.EXPAND | wx.TOP | wx.BOTTOM, 10) tmp = wx.StaticText(self, -1, "Strings:") vsizer.Add(tmp) self.stringsLb = wx.ListBox(self, -1, size = (200, 100)) vsizer.Add(self.stringsLb, 0, wx.EXPAND) hsizer = wx.BoxSizer(wx.HORIZONTAL) self.addBtn = gutil.createStockButton(self, "Add") hsizer.Add(self.addBtn) wx.EVT_BUTTON(self, self.addBtn.GetId(), self.OnAddString) gutil.btnDblClick(self.addBtn, self.OnAddString) self.delBtn = gutil.createStockButton(self, "Delete") hsizer.Add(self.delBtn, 0, wx.LEFT, 10) wx.EVT_BUTTON(self, self.delBtn.GetId(), self.OnDeleteString) gutil.btnDblClick(self.delBtn, self.OnDeleteString) vsizer.Add(hsizer, 0, wx.TOP, 5) hsizer = wx.BoxSizer(wx.HORIZONTAL) hsizer.Add(wx.StaticText(self, -1, "Text:"), 0, wx.ALIGN_CENTER_VERTICAL) self.textEntry = wx.TextCtrl(self, -1) hsizer.Add(self.textEntry, 1, wx.LEFT, 10) wx.EVT_TEXT(self, self.textEntry.GetId(), self.OnMisc) vsizer.Add(hsizer, 0, wx.EXPAND | wx.TOP, 20) vsizer.Add(wx.StaticText(self, -1, "'${PAGE}' will be replaced by the page number."), 0, wx.ALIGN_CENTER | wx.TOP, 5) hsizerTop = wx.BoxSizer(wx.HORIZONTAL) gsizer = wx.FlexGridSizer(3, 2, 5, 0) gsizer.Add(wx.StaticText(self, -1, "Header line:"), 0, wx.ALIGN_CENTER_VERTICAL) self.lineEntry = wx.SpinCtrl(self, -1) self.lineEntry.SetRange(1, 5) wx.EVT_SPINCTRL(self, self.lineEntry.GetId(), self.OnMisc) wx.EVT_KILL_FOCUS(self.lineEntry, self.OnKillFocus) gsizer.Add(self.lineEntry) gsizer.Add(wx.StaticText(self, -1, "X offset (characters):"), 0, wx.ALIGN_CENTER_VERTICAL | wx.RIGHT, 10) self.xoffEntry = wx.SpinCtrl(self, -1) self.xoffEntry.SetRange(-100, 100) wx.EVT_SPINCTRL(self, self.xoffEntry.GetId(), self.OnMisc) wx.EVT_KILL_FOCUS(self.xoffEntry, self.OnKillFocus) gsizer.Add(self.xoffEntry) gsizer.Add(wx.StaticText(self, -1, "Alignment:"), 0, wx.ALIGN_CENTER_VERTICAL) self.alignCombo = wx.ComboBox(self, -1, style = wx.CB_READONLY) for it in [ ("Left", util.ALIGN_LEFT), ("Center", util.ALIGN_CENTER), ("Right", util.ALIGN_RIGHT) ]: self.alignCombo.Append(it[0], it[1]) gsizer.Add(self.alignCombo) wx.EVT_COMBOBOX(self, self.alignCombo.GetId(), self.OnMisc) hsizerTop.Add(gsizer) bsizer = wx.StaticBoxSizer( wx.StaticBox(self, -1, "Style"), wx.HORIZONTAL) vsizer2 = wx.BoxSizer(wx.VERTICAL) # wxGTK adds way more space by default than wxMSW between the # items, have to adjust for that pad = 0 if misc.isWindows: pad = 5 self.addCheckBox("Bold", self, vsizer2, pad) self.addCheckBox("Italic", self, vsizer2, pad) self.addCheckBox("Underlined", self, vsizer2, pad) bsizer.Add(vsizer2) hsizerTop.Add(bsizer, 0, wx.LEFT, 40) vsizer.Add(hsizerTop, 0, wx.TOP, 20) hsizer = wx.BoxSizer(wx.HORIZONTAL) hsizer.Add((1, 1), 1) previewBtn = gutil.createStockButton(self, "Preview") hsizer.Add(previewBtn) applyBtn = gutil.createStockButton(self, "Apply") hsizer.Add(applyBtn, 0, wx.LEFT, 10) cancelBtn = gutil.createStockButton(self, "Cancel") hsizer.Add(cancelBtn, 0, wx.LEFT, 10) okBtn = gutil.createStockButton(self, "OK") hsizer.Add(okBtn, 0, wx.LEFT, 10) vsizer.Add(hsizer, 0, wx.EXPAND | wx.TOP, 20) util.finishWindow(self, vsizer) wx.EVT_BUTTON(self, previewBtn.GetId(), self.OnPreview) wx.EVT_BUTTON(self, applyBtn.GetId(), self.OnApply) wx.EVT_BUTTON(self, cancelBtn.GetId(), self.OnCancel) wx.EVT_BUTTON(self, okBtn.GetId(), self.OnOK) wx.EVT_LISTBOX(self, self.stringsLb.GetId(), self.OnStringsLb) # list of widgets that are specific to editing the selected string self.widList = [ self.textEntry, self.xoffEntry, self.alignCombo, self.lineEntry, self.boldCb, self.italicCb, self.underlinedCb ] self.updateGui() self.textEntry.SetFocus()
def __init__(self, parent, ctrl, sc, gScDict): wx.Dialog.__init__(self, parent, -1, "Spell checker", style = wx.DEFAULT_DIALOG_STYLE | wx.WANTS_CHARS) self.ctrl = ctrl # spellcheck.SpellCheck self.sc = sc # user's global spell checker dictionary self.gScDict = gScDict # have we added any words to global dictionary self.changedGlobalDict = False vsizer = wx.BoxSizer(wx.VERTICAL) hsizer = wx.BoxSizer(wx.HORIZONTAL) hsizer.Add(wx.StaticText(self, -1, "Word:"), 0, wx.ALIGN_CENTER_VERTICAL | wx.RIGHT, 10) self.replaceEntry = wx.TextCtrl(self, -1, style = wx.TE_PROCESS_ENTER) hsizer.Add(self.replaceEntry, 1, wx.EXPAND) vsizer.Add(hsizer, 1, wx.EXPAND | wx.BOTTOM, 15) gsizer = wx.FlexGridSizer(2, 2, 10, 10) gsizer.AddGrowableCol(1) replaceBtn = wx.Button(self, -1, "&Replace") gsizer.Add(replaceBtn) addScriptBtn = wx.Button(self, -1, "Add to &script dictionary") gsizer.Add(addScriptBtn, 0, wx.EXPAND) skipBtn = wx.Button(self, -1, "S&kip") gsizer.Add(skipBtn) addGlobalBtn = wx.Button(self, -1, "Add to &global dictionary") gsizer.Add(addGlobalBtn, 0, wx.EXPAND) vsizer.Add(gsizer, 0, wx.EXPAND, 0) suggestBtn = wx.Button(self, -1, "S&uggest replacement") vsizer.Add(suggestBtn, 0, wx.EXPAND | wx.TOP, 10) wx.EVT_TEXT_ENTER(self, self.replaceEntry.GetId(), self.OnReplace) wx.EVT_BUTTON(self, replaceBtn.GetId(), self.OnReplace) wx.EVT_BUTTON(self, addScriptBtn.GetId(), self.OnAddScript) wx.EVT_BUTTON(self, addGlobalBtn.GetId(), self.OnAddGlobal) wx.EVT_BUTTON(self, skipBtn.GetId(), self.OnSkip) wx.EVT_BUTTON(self, suggestBtn.GetId(), self.OnSuggest) wx.EVT_CHAR(self, self.OnChar) wx.EVT_CHAR(self.replaceEntry, self.OnChar) wx.EVT_CHAR(replaceBtn, self.OnChar) wx.EVT_CHAR(addScriptBtn, self.OnChar) wx.EVT_CHAR(skipBtn, self.OnChar) wx.EVT_CHAR(addGlobalBtn, self.OnChar) wx.EVT_CHAR(suggestBtn, self.OnChar) util.finishWindow(self, vsizer) self.showWord()
def __init__(self, parent, headers, cfg, cfgGl, applyFunc): wx.Dialog.__init__(self, parent, -1, "Headers", style=wx.DEFAULT_DIALOG_STYLE) self.headers = headers self.cfg = cfg self.cfgGl = cfgGl self.applyFunc = applyFunc # whether some events are blocked self.block = False self.hdrIndex = -1 if len(self.headers.hdrs) > 0: self.hdrIndex = 0 vsizer = wx.BoxSizer(wx.VERTICAL) hsizer = wx.BoxSizer(wx.HORIZONTAL) hsizer.Add(wx.StaticText(self, -1, "Empty lines after headers:"), 0, wx.ALIGN_CENTER_VERTICAL) self.elinesEntry = wx.SpinCtrl(self, -1) self.elinesEntry.SetRange(0, 5) wx.EVT_SPINCTRL(self, self.elinesEntry.GetId(), self.OnMisc) wx.EVT_KILL_FOCUS(self.elinesEntry, self.OnKillFocus) hsizer.Add(self.elinesEntry, 0, wx.LEFT, 10) vsizer.Add(hsizer) vsizer.Add(wx.StaticLine(self, -1), 0, wx.EXPAND | wx.TOP | wx.BOTTOM, 10) tmp = wx.StaticText(self, -1, "Strings:") vsizer.Add(tmp) self.stringsLb = wx.ListBox(self, -1, size=(200, 100)) vsizer.Add(self.stringsLb, 0, wx.EXPAND) hsizer = wx.BoxSizer(wx.HORIZONTAL) self.addBtn = gutil.createStockButton(self, "Add") hsizer.Add(self.addBtn) wx.EVT_BUTTON(self, self.addBtn.GetId(), self.OnAddString) gutil.btnDblClick(self.addBtn, self.OnAddString) self.delBtn = gutil.createStockButton(self, "Delete") hsizer.Add(self.delBtn, 0, wx.LEFT, 10) wx.EVT_BUTTON(self, self.delBtn.GetId(), self.OnDeleteString) gutil.btnDblClick(self.delBtn, self.OnDeleteString) vsizer.Add(hsizer, 0, wx.TOP, 5) hsizer = wx.BoxSizer(wx.HORIZONTAL) hsizer.Add(wx.StaticText(self, -1, "Text:"), 0, wx.ALIGN_CENTER_VERTICAL) self.textEntry = wx.TextCtrl(self, -1) hsizer.Add(self.textEntry, 1, wx.LEFT, 10) wx.EVT_TEXT(self, self.textEntry.GetId(), self.OnMisc) vsizer.Add(hsizer, 0, wx.EXPAND | wx.TOP, 20) vsizer.Add( wx.StaticText(self, -1, "'${PAGE}' will be replaced by the page number."), 0, wx.ALIGN_CENTER | wx.TOP, 5) hsizerTop = wx.BoxSizer(wx.HORIZONTAL) gsizer = wx.FlexGridSizer(3, 2, 5, 0) gsizer.Add(wx.StaticText(self, -1, "Header line:"), 0, wx.ALIGN_CENTER_VERTICAL) self.lineEntry = wx.SpinCtrl(self, -1) self.lineEntry.SetRange(1, 5) wx.EVT_SPINCTRL(self, self.lineEntry.GetId(), self.OnMisc) wx.EVT_KILL_FOCUS(self.lineEntry, self.OnKillFocus) gsizer.Add(self.lineEntry) gsizer.Add(wx.StaticText(self, -1, "X offset (characters):"), 0, wx.ALIGN_CENTER_VERTICAL | wx.RIGHT, 10) self.xoffEntry = wx.SpinCtrl(self, -1) self.xoffEntry.SetRange(-100, 100) wx.EVT_SPINCTRL(self, self.xoffEntry.GetId(), self.OnMisc) wx.EVT_KILL_FOCUS(self.xoffEntry, self.OnKillFocus) gsizer.Add(self.xoffEntry) gsizer.Add(wx.StaticText(self, -1, "Alignment:"), 0, wx.ALIGN_CENTER_VERTICAL) self.alignCombo = wx.ComboBox(self, -1, style=wx.CB_READONLY) for it in [("Left", util.ALIGN_LEFT), ("Center", util.ALIGN_CENTER), ("Right", util.ALIGN_RIGHT)]: self.alignCombo.Append(it[0], it[1]) gsizer.Add(self.alignCombo) wx.EVT_COMBOBOX(self, self.alignCombo.GetId(), self.OnMisc) hsizerTop.Add(gsizer) bsizer = wx.StaticBoxSizer(wx.StaticBox(self, -1, "Style"), wx.HORIZONTAL) vsizer2 = wx.BoxSizer(wx.VERTICAL) # wxGTK adds way more space by default than wxMSW between the # items, have to adjust for that pad = 0 if misc.isWindows: pad = 5 self.addCheckBox("Bold", self, vsizer2, pad) self.addCheckBox("Italic", self, vsizer2, pad) self.addCheckBox("Underlined", self, vsizer2, pad) bsizer.Add(vsizer2) hsizerTop.Add(bsizer, 0, wx.LEFT, 40) vsizer.Add(hsizerTop, 0, wx.TOP, 20) hsizer = wx.BoxSizer(wx.HORIZONTAL) hsizer.Add((1, 1), 1) previewBtn = gutil.createStockButton(self, "Preview") hsizer.Add(previewBtn) applyBtn = gutil.createStockButton(self, "Apply") hsizer.Add(applyBtn, 0, wx.LEFT, 10) cancelBtn = gutil.createStockButton(self, "Cancel") hsizer.Add(cancelBtn, 0, wx.LEFT, 10) okBtn = gutil.createStockButton(self, "OK") hsizer.Add(okBtn, 0, wx.LEFT, 10) vsizer.Add(hsizer, 0, wx.EXPAND | wx.TOP, 20) util.finishWindow(self, vsizer) wx.EVT_BUTTON(self, previewBtn.GetId(), self.OnPreview) wx.EVT_BUTTON(self, applyBtn.GetId(), self.OnApply) wx.EVT_BUTTON(self, cancelBtn.GetId(), self.OnCancel) wx.EVT_BUTTON(self, okBtn.GetId(), self.OnOK) wx.EVT_LISTBOX(self, self.stringsLb.GetId(), self.OnStringsLb) # list of widgets that are specific to editing the selected string self.widList = [ self.textEntry, self.xoffEntry, self.alignCombo, self.lineEntry, self.boldCb, self.italicCb, self.underlinedCb ] self.updateGui() self.textEntry.SetFocus()
def __init__(self, parent, indents): wx.Dialog.__init__(self, parent, -1, "Adjust styles", style=wx.DEFAULT_DIALOG_STYLE) indents.sort(lambda i1, i2: -cmp(len(i1.lines), len(i2.lines))) vsizer = wx.BoxSizer(wx.VERTICAL) tmp = wx.StaticText(self, -1, "Input:") vsizer.Add(tmp) self.inputLb = wx.ListBox(self, -1, size=(400, 200)) for it in indents: self.inputLb.Append( "%d lines (indented %d characters)" % (len(it.lines), it.indent), it) vsizer.Add(self.inputLb, 0, wx.EXPAND) hsizer = wx.BoxSizer(wx.HORIZONTAL) hsizer.Add(wx.StaticText(self, -1, "Style:"), 0, wx.ALIGN_CENTER_VERTICAL) self.styleCombo = wx.ComboBox(self, -1, style=wx.CB_READONLY) self.styleCombo.Append("Scene / Action", SCENE_ACTION) for t in config.getTIs(): self.styleCombo.Append(t.name, t.lt) self.styleCombo.Append("Ignore", IGNORE) util.setWH(self.styleCombo, w=150) hsizer.Add(self.styleCombo, 0, wx.LEFT, 10) vsizer.Add(hsizer, 0, wx.TOP | wx.BOTTOM, 10) vsizer.Add(wx.StaticText(self, -1, "Lines:")) self.linesEntry = wx.TextCtrl(self, -1, size=(400, 200), style=wx.TE_MULTILINE | wx.TE_DONTWRAP) vsizer.Add(self.linesEntry, 0, wx.EXPAND) hsizer = wx.BoxSizer(wx.HORIZONTAL) hsizer.Add((1, 1), 1) cancelBtn = gutil.createStockButton(self, "Cancel") hsizer.Add(cancelBtn) okBtn = gutil.createStockButton(self, "OK") hsizer.Add(okBtn, 0, wx.LEFT, 10) vsizer.Add(hsizer, 0, wx.EXPAND | wx.TOP, 10) util.finishWindow(self, vsizer) wx.EVT_COMBOBOX(self, self.styleCombo.GetId(), self.OnStyleCombo) wx.EVT_LISTBOX(self, self.inputLb.GetId(), self.OnInputLb) wx.EVT_BUTTON(self, cancelBtn.GetId(), self.OnCancel) wx.EVT_BUTTON(self, okBtn.GetId(), self.OnOK) self.inputLb.SetSelection(0) self.OnInputLb()
def __init__(self, parent, sp, prefix): wx.Dialog.__init__(self, parent, -1, "Watermarked PDFs generator", style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER) self.frame = parent self.sp = sp vsizer = wx.BoxSizer(wx.VERTICAL) vsizer.Add(wx.StaticText(self, -1, "Directory to save in:"), 0) hsizer = wx.BoxSizer(wx.HORIZONTAL) self.dirEntry = wx.TextCtrl(self, -1) hsizer.Add(self.dirEntry, 1, wx.EXPAND) btn = wx.Button(self, -1, "Browse") wx.EVT_BUTTON(self, btn.GetId(), self.OnBrowse) hsizer.Add(btn, 0, wx.ALIGN_CENTER_VERTICAL | wx.LEFT, 10) vsizer.Add(hsizer, 0, wx.EXPAND | wx.TOP | wx.BOTTOM, 5) vsizer.Add(wx.StaticText(self, -1, "Filename prefix:"), 0) self.filenamePrefix = wx.TextCtrl(self, -1, prefix) vsizer.Add(self.filenamePrefix, 0, wx.EXPAND | wx.BOTTOM, 5) vsizer.Add(wx.StaticText(self, -1, "Watermark font size:"), 0) self.markSize = wx.SpinCtrl(self, -1, size=(60, -1)) self.markSize.SetRange(20, 80) self.markSize.SetValue(40) vsizer.Add(self.markSize, 0, wx.BOTTOM, 5) vsizer.Add(wx.StaticLine(self, -1), 0, wx.EXPAND | wx.TOP | wx.BOTTOM, 5) vsizer.Add(wx.StaticText(self, -1, "Common mark:"), 0) self.commonMark = wx.TextCtrl(self, -1, "Confidential") vsizer.Add(self.commonMark, 0, wx.EXPAND | wx.BOTTOM, 5) vsizer.Add(wx.StaticText(self, -1, "Watermarks (one per line):")) self.itemsEntry = wx.TextCtrl(self, -1, style=wx.TE_MULTILINE | wx.TE_DONTWRAP, size=(300, 200)) vsizer.Add(self.itemsEntry, 1, wx.EXPAND) hsizer = wx.BoxSizer(wx.HORIZONTAL) closeBtn = wx.Button(self, -1, "Close") hsizer.Add(closeBtn, 0) hsizer.Add((1, 1), 1) generateBtn = wx.Button(self, -1, "Generate PDFs") hsizer.Add(generateBtn, 0) vsizer.Add(hsizer, 0, wx.EXPAND | wx.TOP, 10) util.finishWindow(self, vsizer) wx.EVT_BUTTON(self, closeBtn.GetId(), self.OnClose) wx.EVT_BUTTON(self, generateBtn.GetId(), self.OnGenerate) self.dirEntry.SetFocus()
def __init__(self, parent, id, cfg): wx.Panel.__init__(self, parent, id) self.cfg = cfg vsizer = wx.BoxSizer(wx.VERTICAL) bsizer = wx.StaticBoxSizer(wx.StaticBox(self, -1, "Default script directory"), wx.VERTICAL) hsizer = wx.BoxSizer(wx.HORIZONTAL) self.scriptDirEntry = wx.TextCtrl(self, -1) hsizer.Add(self.scriptDirEntry, 1, wx.ALIGN_CENTER_VERTICAL | wx.LEFT, 10) btn = wx.Button(self, -1, "Browse") wx.EVT_BUTTON(self, btn.GetId(), self.OnBrowse) hsizer.Add(btn, 0, wx.ALIGN_CENTER_VERTICAL | wx.LEFT, 10) bsizer.Add(hsizer, 1, wx.EXPAND | wx.TOP | wx.BOTTOM, 5) vsizer.Add(bsizer, 0, wx.EXPAND | wx.BOTTOM, 10) bsizer = wx.StaticBoxSizer(wx.StaticBox(self, -1, "PDF viewer application"), wx.VERTICAL) hsizer = wx.BoxSizer(wx.HORIZONTAL) hsizer.Add(wx.StaticText(self, -1, "Path:"), 0, wx.ALIGN_CENTER_VERTICAL | wx.RIGHT, 10) self.progEntry = wx.TextCtrl(self, -1) hsizer.Add(self.progEntry, 1, wx.ALIGN_CENTER_VERTICAL) btn = wx.Button(self, -1, "Browse") wx.EVT_BUTTON(self, btn.GetId(), self.OnBrowsePDF) hsizer.Add(btn, 0, wx.ALIGN_CENTER_VERTICAL | wx.LEFT, 10) btn = wx.Button(self, -1, "Guess") wx.EVT_BUTTON(self, btn.GetId(), self.OnGuessPDF) hsizer.Add(btn, 0, wx.ALIGN_CENTER_VERTICAL | wx.LEFT, 10) bsizer.Add(hsizer, 1, wx.EXPAND) hsizer = wx.BoxSizer(wx.HORIZONTAL) hsizer.Add(wx.StaticText(self, -1, "Arguments:"), 0, wx.ALIGN_CENTER_VERTICAL | wx.RIGHT, 10) self.argsEntry = wx.TextCtrl(self, -1) hsizer.Add(self.argsEntry, 1, wx.ALIGN_CENTER_VERTICAL) bsizer.Add(hsizer, 1, wx.EXPAND) vsizer.Add(bsizer, 1, wx.EXPAND) # wxGTK adds way more space by default than wxMSW between the # items, have to adjust for that pad = 5 if misc.isWindows: pad = 10 self.checkListItems = [ ("capitalize", "Auto-capitalize sentences"), ("capitalizeI", "Auto-capitalize i -> I"), ("honorSavedPos", "When opening a script, start at last saved position"), ("recenterOnScroll", "Recenter screen on scrolling"), ("overwriteSelectionOnInsert", "Typing replaces selected text"), ("checkOnExport", "Check script for errors before print, export or compare"), ] self.checkList = wx.CheckListBox(self, -1, size=(-1, 120)) for it in self.checkListItems: self.checkList.Append(it[1]) vsizer.Add(self.checkList, 0, wx.TOP | wx.BOTTOM, pad) wx.EVT_LISTBOX(self, self.checkList.GetId(), self.OnMisc) wx.EVT_CHECKLISTBOX(self, self.checkList.GetId(), self.OnMisc) self.addSpin("splashTime", "Show splash screen for X seconds:\n" " (0 = disable)", self, vsizer, "splashTime") self.addSpin( "paginate", "Auto-paginate interval in seconds:\n" " (0 = disable)", self, vsizer, "paginateInterval" ) self.addSpin("wheelScroll", "Lines to scroll per mouse wheel event:", self, vsizer, "mouseWheelLines") self.cfg2gui() util.finishWindow(self, vsizer, center=False) wx.EVT_TEXT(self, self.scriptDirEntry.GetId(), self.OnMisc) wx.EVT_TEXT(self, self.progEntry.GetId(), self.OnMisc) wx.EVT_TEXT(self, self.argsEntry.GetId(), self.OnMisc)