def fmt_filter_helpline(f, fp): nlindentstr = "\n%16s"%(""); # newline, followed by 16 whitespaces return ( " %-13s " %(f) + nlindentstr.join(textwrap.wrap(factory.get_filter_class(f, filterpackage=fp) .getHelpDescription(), (80-16) # 80 line width, -16 indent chars )) )
def makeHelpTopicTab(self, pathitems): if (not len(pathitems)): logger.warning("makeHelpTopicTab(): No Path specified!") return font = settingswidget.get_typewriter_font(self) if (pathitems[0] == 'filters'): if (len(pathitems) < 2): logger.warning("makeHelpTopicTab(): No filter specified!!") return filtname = pathitems[1] tb = QTextBrowser(self.ui.tabs) tb.setFont(font) tb.setText(filters_factory.format_filter_help(filtname)) tb.setProperty('HelpTabTitle', '%s filter' %(filtname)) tb.setProperty('HelpTabToolTip', filters_factory.get_filter_class(filtname).getHelpDescription()) return tb if (pathitems[0] == 'general'): if (len(pathitems) < 2): logger.warning("makeHelpTopicTab(): No help topic general page specified!!") return tb = QTextBrowser(self.ui.tabs) tb.setFont(font) if pathitems[1] == 'welcome': tb.setPlainText(HELP_WELCOME) tb.setProperty('HelpTabTitle', 'Welcome') elif pathitems[1] == 'version': tb.setPlainText(argparseactions.helptext_prolog()) tb.setProperty('HelpTabTitle', 'Version') elif pathitems[1] == 'cmdline': tb.setPlainText(argparseactions.helptext_prolog() + bibolamazimain.get_args_parser().format_help()) tb.setProperty('HelpTabTitle', 'Command-Line Help') elif pathitems[1] == 'filter-list': tb.setPlainText(argparseactions.help_list_filters()) tb.setProperty('HelpTabTitle', 'Filter List') else: tb.setPlainText('<Unknown help page>') tb.setProperty('HelpTabTitle', '<Unknown>') tb.setProperty('HelpTabToolTip', '') return tb logger.warning("makeHelpTopicTab(): Unknown help topic: %r", "/".join(pathitems)) return None
def __init__(self): super(HelpBrowser, self).__init__() self.ui = Ui_HelpBrowser() self.ui.setupUi(self) QObject.connect(self.ui.tabs, SIGNAL('tabCloseRequested(int)'), self.closeTab) self.filterButtons = [] self.openTabs = [] # home buttons # ------------ self.ui.lytHomeButtons.setContentsMargins(60, 30, 60, 30) vspc1 = QSpacerItem(20, 5, QSizePolicy.Fixed, QSizePolicy.Fixed) self.ui.lytHomeButtons.addItem(vspc1, 1, 0) offsetlineno = 2 # start at 1, because the first row has the 'welcome' and 'filter list' buttons. n = 0 # count how many filters we've treated already. ncols = 2 for filt in filterinstanceeditor.get_filter_list(): fbutton = QPushButton('%s' % (filt), self) fbutton.setProperty('helppath', 'filters/%s' %(filt)) fbutton.setProperty('bibolamaziHelpButtonType', 'filter') fbutton.setToolTip(filters_factory.get_filter_class(filt).getHelpDescription()) self.ui.lytHomeButtons.addWidget(fbutton, offsetlineno + int(n / ncols), n % ncols) n += 1 QObject.connect(fbutton, SIGNAL('clicked()'), self.openHelpTopicBySender) newrow = None if n % ncols == 0: newrow = offsetlineno + n / ncols else: newrow = offsetlineno + (1 + int(n / ncols)) vspc3 = QSpacerItem(20, 5, QSizePolicy.Fixed, QSizePolicy.Fixed) self.ui.lytHomeButtons.addItem(vspc3, newrow, 0) self.ui.lytHomeButtons.addWidget(self.ui.btnCmdLineHelp, newrow+1, 0) self.ui.lytHomeButtons.addWidget(self.ui.btnVersion, newrow+1, 1) vspc2 = QSpacerItem(20, 1, QSizePolicy.Minimum, QSizePolicy.Expanding) self.ui.lytHomeButtons.addItem(vspc2, newrow+2, 0) # avoid python garbage collection self.vspcButtons = [vspc1, vspc2] self.ui.tabHome.setStyleSheet(_HOME_TAB_STYLESHEET) static_help_btns = [ self.ui.btnWelcome, self.ui.btnVersion, self.ui.btnFilterList, self.ui.btnCmdLineHelp ] for btn in static_help_btns: QObject.connect(btn, SIGNAL('clicked()'), self.openHelpTopicBySender) self.shortcuts = [ QShortcut(QKeySequence('Ctrl+W'), self, self.closeCurrentTab, self.closeCurrentTab), ]