def __init__(self, parent, fname=None, rst=None, name=None): """ Parameters ---------- parent: QWidget The parent widget fname: str The name of the rst file. If None, specify the `rst` directly rst: str The restructured text to render when this button is clicked. If None, the `fname` has to be provided name: str The name to use for the document in the help_explorer """ if fname is None and rst is None: raise ValueError("Either `fname` or `rst` must be specified!") elif fname is not None and rst is not None: raise ValueError("Either `fname` or `rst` must be specified! " "Not both!") elif rst is not None and name is None: raise ValueError("A title must be specified for the rst document!") self.fname = fname self.rst = rst self.files = doc_files self.name = name QToolButton.__init__(self, parent) self.setIcon(QIcon(get_psy_icon('info.png'))) self.clicked.connect(self.show_docs)
def __init__(self, parent, *fmtos): """ Parameters ---------- parent: psyplot_gui.fmt_widget.FormatoptionWidget The formatoption widget that contains the button ``*fmtos`` Instances of the :class:`psyplot.plotter.Formatoption` for which the links should be created """ QToolButton.__init__(self, parent=parent) self.setText('fmt') self.setPopupMode(QToolButton.InstantPopup) menu = QMenu() for fmto in fmtos: name = parent.get_name(fmto) menu.addAction(name, partial(parent.set_fmto, name)) self.setMenu(menu)