def addList(self, descr, parent, sizer, items, doBtns, isFirst, pad=0): sizer.Add(wx.StaticText(parent, -1, descr), 0, wx.TOP, pad) if doBtns: hsizer = wx.BoxSizer(wx.HORIZONTAL) if isFirst: funcs = [self.OnSet1, self.OnClear1, self.OnToggle1] else: funcs = [self.OnSet2, self.OnClear2, self.OnToggle2] tmp = wx.Button(parent, -1, "Set") hsizer.Add(tmp) wx.EVT_BUTTON(self, tmp.GetId(), funcs[0]) tmp = wx.Button(parent, -1, "Clear") hsizer.Add(tmp, 0, wx.LEFT, 10) wx.EVT_BUTTON(self, tmp.GetId(), funcs[1]) tmp = wx.Button(parent, -1, "Toggle") hsizer.Add(tmp, 0, wx.LEFT, 10) wx.EVT_BUTTON(self, tmp.GetId(), funcs[2]) sizer.Add(hsizer, 0, wx.TOP | wx.BOTTOM, 5) tmp = wx.CheckListBox(parent, -1) longest = -1 for i in range(len(items)): it = items[i] tmp.Append(it.text) tmp.Check(i, it.selected) if isFirst: if longest != -1: if len(it.text) > len(items[longest].text): longest = i else: longest = 0 w = -1 if isFirst: h = len(items) if longest != -1: w = util.getTextExtent(tmp.GetFont(), "[x] " + items[longest].text)[0] + 15 else: h = min(10, len(items)) # don't know of a way to get the vertical spacing of items in a # wx.CheckListBox, so estimate it at font height + 5 pixels, which # is close enough on everything I've tested. h *= util.getFontHeight(tmp.GetFont()) + 5 h += 5 h = max(25, h) util.setWH(tmp, w, h) sizer.Add(tmp, 0, wx.EXPAND) return tmp
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, delay): wx.Frame.__init__(self, parent, -1, "Splash", style=wx.FRAME_FLOAT_ON_PARENT | wx.NO_BORDER) if not SplashWindow.inited: SplashWindow.inited = True wx.Image_AddHandler(wx.JPEGHandler()) self.loadQuotes(parent) self.pickRandomQuote() self.pic = misc.getBitmap("resources/logo.jpg") if self.pic.Ok(): w, h = (self.pic.GetWidth(), self.pic.GetHeight()) else: w, h = (375, 300) util.setWH(self, w, h) self.CenterOnScreen() self.textColor = wx.Colour(255, 255, 255) self.font = util.createPixelFont(14, wx.FONTFAMILY_MODERN, wx.NORMAL, wx.NORMAL) self.quoteFont = util.createPixelFont(16, wx.FONTFAMILY_DEFAULT, wx.NORMAL, wx.NORMAL) self.sourceFont = util.createPixelFont(15, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_ITALIC, wx.NORMAL) if delay != -1: self.timer = wx.Timer(self) wx.EVT_TIMER(self, -1, self.OnTimer) self.timer.Start(delay, True) wx.EVT_LEFT_DOWN(self, self.OnClick) wx.EVT_PAINT(self, self.OnPaint) wx.EVT_CLOSE(self, self.OnCloseWindow)
def addCombo(self, name, descr, parent, sizer, items, sel): al = wx.ALIGN_CENTER_VERTICAL | wx.RIGHT if sel == 1: al |= wx.ALIGN_RIGHT sizer.Add(wx.StaticText(parent, -1, descr), 0, al, 10) combo = wx.ComboBox(parent, -1, style=wx.CB_READONLY) util.setWH(combo, w=200) for s in items: combo.Append(s) combo.SetSelection(sel) sizer.Add(combo) setattr(self, name + "Combo", combo)
def addCombo(self, name, descr, parent, sizer, items, sel): al = wx.ALIGN_CENTER_VERTICAL | wx.RIGHT if sel == 1: al |= wx.ALIGN_RIGHT sizer.Add(wx.StaticText(parent, -1, descr), 0, al, 10) combo = wx.ComboBox(parent, -1, style = wx.CB_READONLY) util.setWH(combo, w = 200) for s in items: combo.Append(s) combo.SetSelection(sel) sizer.Add(combo) setattr(self, name + "Combo", combo)
def __init__(self, parent): wx.ListCtrl.__init__(self, parent, -1, style = wx.LC_REPORT | wx.LC_VIRTUAL | wx.LC_SINGLE_SEL | wx.LC_HRULES | wx.LC_VRULES) self.sex = ["Female", "Male"] self.InsertColumn(0, "Name") self.InsertColumn(1, "Type") self.InsertColumn(2, "Sex") self.SetColumnWidth(0, 120) self.SetColumnWidth(1, 120) # we can't use wx.LIST_AUTOSIZE since this is a virtual control, # so calculate the size ourselves since we know the longest string # possible. w = util.getTextExtent(self.GetFont(), "Female")[0] + 15 self.SetColumnWidth(2, w) util.setWH(self, w = 120*2 + w + 25)
def __init__(self, parent): wx.Window.__init__(self, parent, -1) self.selected = None # all valid characters self.chars = "" for i in xrange(256): if util.isValidInputChar(i): self.chars += chr(i) self.cols = 16 self.rows = len(self.chars) // self.cols if len(self.chars) % 16: self.rows += 1 # offset of grid self.offset = 5 # size of a single character cell self.cellSize = 32 # size of the zoomed-in character boxes self.boxSize = 60 self.smallFont = util.createPixelFont(18, wx.FONTFAMILY_SWISS, wx.NORMAL, wx.NORMAL) self.normalFont = util.createPixelFont(self.cellSize - 2, wx.FONTFAMILY_MODERN, wx.NORMAL, wx.BOLD) self.bigFont = util.createPixelFont(self.boxSize - 2, wx.FONTFAMILY_MODERN, wx.NORMAL, wx.BOLD) wx.EVT_PAINT(self, self.OnPaint) wx.EVT_LEFT_DOWN(self, self.OnLeftDown) wx.EVT_MOTION(self, self.OnMotion) wx.EVT_SIZE(self, self.OnSize) util.setWH(self, self.cols * self.cellSize + 2 * self.offset, 460)
def __init__(self, parent): wx.ListCtrl.__init__(self, parent, -1, style=wx.LC_REPORT | wx.LC_VIRTUAL | wx.LC_SINGLE_SEL | wx.LC_HRULES | wx.LC_VRULES) self.sex = ["Female", "Male"] self.InsertColumn(0, "Name") self.InsertColumn(1, "Type") self.InsertColumn(2, "Sex") self.SetColumnWidth(0, 120) self.SetColumnWidth(1, 120) # we can't use wx.LIST_AUTOSIZE since this is a virtual control, # so calculate the size ourselves since we know the longest string # possible. w = util.getTextExtent(self.GetFont(), "Female")[0] + 15 self.SetColumnWidth(2, w) util.setWH(self, w=120 * 2 + w + 25)
def __init__(self, parent, delay): wx.Frame.__init__(self, parent, -1, "Splash", style=wx.FRAME_FLOAT_ON_PARENT | wx.NO_BORDER) if not SplashWindow.inited: SplashWindow.inited = True wx.Image_AddHandler(wx.JPEGHandler()) self.loadQuotes(parent) self.pickRandomQuote() self.pic = misc.getBitmap("resources/logo.jpg") if self.pic.Ok(): w, h = (self.pic.GetWidth(), self.pic.GetHeight()) else: w, h = (375, 300) util.setWH(self, w, h) self.CenterOnScreen() self.textColor = wx.Colour(0, 0, 0) self.font = util.createPixelFont(14, wx.FONTFAMILY_MODERN, wx.NORMAL, wx.NORMAL) self.quoteFont = util.createPixelFont(16, wx.FONTFAMILY_DEFAULT, wx.NORMAL, wx.NORMAL) self.sourceFont = util.createPixelFont(15, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_ITALIC, wx.NORMAL) if delay != -1: self.timer = wx.Timer(self) wx.EVT_TIMER(self, -1, self.OnTimer) self.timer.Start(delay, True) wx.EVT_LEFT_DOWN(self, self.OnClick) wx.EVT_PAINT(self, self.OnPaint) wx.EVT_CLOSE(self, self.OnCloseWindow)
def showExtra(self, flag): self.extraLabel.Show(flag) self.elements.Show(flag) self.useExtra = flag if flag: self.moreButton.SetLabel(" ^ ") pos = self.elements.GetPosition() # don't know of a way to get the vertical spacing of items in # a wx.CheckListBox, so estimate it at font height + 5 pixels, # which is close enough on everything I've tested. h = pos.y + len(self.elementTypes) * \ (util.getFontHeight(self.elements.GetFont()) + 5) + 15 else: self.moreButton.SetLabel("More") h = max(self.extraLabel.GetPosition().y, self.moreButton.GetPosition().y + self.moreButton.GetClientSize().height + 5) self.SetSizeHints(self.GetClientSize().width, h) util.setWH(self, h=h)
def showExtra(self, flag): self.extraLabel.Show(flag) self.elements.Show(flag) self.useExtra = flag if flag: self.moreButton.SetLabel("<<< Less") pos = self.elements.GetPosition() # don't know of a way to get the vertical spacing of items in # a wx.CheckListBox, so estimate it at font height + 5 pixels, # which is close enough on everything I've tested. h = pos.y + len(self.elementTypes) * \ (util.getFontHeight(self.elements.GetFont()) + 5) + 15 else: self.moreButton.SetLabel("More >>>") h = max( self.extraLabel.GetPosition().y, self.moreButton.GetPosition().y + self.moreButton.GetClientSize().height + 5) self.SetSizeHints(self.GetClientSize().width, h) util.setWH(self, h=h)
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, 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, 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, "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, 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, cfg, applyFunc, isGlobal): wx.Dialog.__init__(self, parent, -1, "", style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER) self.cfg = cfg self.applyFunc = applyFunc global cfgFrame cfgFrame = self vsizer = wx.BoxSizer(wx.VERTICAL) hsizer = wx.BoxSizer(wx.HORIZONTAL) self.listbook = MyListBook(self) w = util.getTextExtent(self.listbook.GetFont(), "Formatting")[0] util.setWH(self.listbook, w + 20, 200) hsizer.Add(self.listbook, 0, wx.EXPAND) self.panel = wx.Panel(self, -1) hsizer.Add(self.panel, 1, wx.EXPAND) if isGlobal: self.SetTitle("Settings dialog") self.AddPage(GlobalAboutPanel, "About") self.AddPage(ColorsPanel, "Colors") self.AddPage(DisplayPanel, "Display") self.AddPage(ElementsGlobalPanel, "Elements") self.AddPage(KeyboardPanel, "Keyboard") self.AddPage(MiscPanel, "Misc") else: self.SetTitle("Script settings dialog") self.AddPage(ScriptAboutPanel, "About") self.AddPage(ElementsPanel, "Elements") self.AddPage(FormattingPanel, "Formatting") self.AddPage(PaperPanel, "Paper") self.AddPage(PDFPanel, "PDF") self.AddPage(PDFFontsPanel, "PDF/Fonts") self.AddPage(StringsPanel, "Strings") size = self.listbook.GetContainingSize() hsizer.SetItemMinSize(self.panel, *size) self.listbook.SetPageSizes(*size) self.listbook.SetSelection(0) # it's unclear whether SetSelection sends an event on all # platforms or not, so force correct action. self.listbook.OnPageChange() vsizer.Add(hsizer, 1, wx.EXPAND) vsizer.Add(wx.StaticLine(self, -1), 0, wx.EXPAND | wx.TOP | wx.BOTTOM, 5) hsizer = wx.BoxSizer(wx.HORIZONTAL) hsizer.Add((1, 1), 1) applyBtn = gutil.createStockButton(self, "Apply") hsizer.Add(applyBtn, 0, wx.ALL, 5) cancelBtn = gutil.createStockButton(self, "Cancel") hsizer.Add(cancelBtn, 0, wx.ALL, 5) okBtn = gutil.createStockButton(self, "OK") hsizer.Add(okBtn, 0, wx.ALL, 5) vsizer.Add(hsizer, 0, wx.EXPAND) self.SetSizerAndFit(vsizer) self.Layout() self.Center() wx.EVT_BUTTON(self, applyBtn.GetId(), self.OnApply) wx.EVT_BUTTON(self, cancelBtn.GetId(), self.OnCancel) wx.EVT_BUTTON(self, okBtn.GetId(), self.OnOK)