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 setFonts(self): cfgGui = self.getCfgGui() self.scenefont = cfgGui.fonts[pml.BOLD].font h = util.getFontHeight(self.scenefont) i = int(h * 0.1) if i <= 1: smallh = h - 1 else: smallh = h - i self.blurbfont = util.createPixelFont( smallh, wx.FONTFAMILY_DEFAULT, wx.NORMAL, wx.NORMAL) self.annotatedfont = util.createPixelFont( smallh, wx.FONTFAMILY_DEFAULT, wx.NORMAL, wx.BOLD) self.itemheight = h + 2 self.scenecolor = cfgGui.navSceneTextColor self.selscenecolor = cfgGui.navSceneSelectedMarkColor self.notecolor = cfgGui.navNoteTextColor self.blurbcolor = cfgGui.navBlurbTextColor self.transitioncolor = cfgGui.navTransitionTextColor self.bgcolor = cfgGui.navBgColor self.annotatedbgcolor = cfgGui.navAnnotatedBgColor self.separatorpen = cfgGui.tabBorderPen
def OnChangeFont(self, event): fname = self.fontsLb.GetClientData(self.fontsLb.GetSelection()) nfont = getattr(self.cfg, fname) fd = wx.FontData() nfi = wx.NativeFontInfo() nfi.FromString(nfont) font = wx.FontFromNativeInfo(nfi) fd.SetInitialFont(font) dlg = wx.FontDialog(self, fd) if dlg.ShowModal() == wx.ID_OK: font = dlg.GetFontData().GetChosenFont() if util.isFixedWidth(font): setattr(self.cfg, fname, font.GetNativeFontInfo().ToString()) self.cfg.fontYdelta = util.getFontHeight(font) self.cfg2gui() self.updateFontLb() else: wx.MessageBox("The selected font is not fixed width and" " can not be used.", "Error", wx.OK, cfgFrame) dlg.Destroy()
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)