예제 #1
0
    def __init__(self, parent):
        super(ShowInfoAction, self).__init__('Show Info', parent)

        self.p = parent
        self.setIcon(QtGui.QIcon(icon_path('help')))
        self.triggered.connect(self.showInfoDialog)
        self.setEnabled(True)
예제 #2
0
def newButton(text, icon=None, slot=None):
    b = QtWidgets.QPushButton(text)
    if icon is not None:
        b.setIcon(QtGui.QIcon(icon_path(icon)))
    if slot is not None:
        b.clicked.connect(slot)
    return b
예제 #3
0
    def __init__(self, parent):
        super(SaveAction, self).__init__('Save', parent)
        self.p = parent

        self.setIcon(QIcon(icon_path('save')))
        self.setShortcut('Ctrl+S')
        self.triggered.connect(self.save)
        self.setEnabled(False)
예제 #4
0
    def __init__(self, parent):
        super(CloseAction, self).__init__('Close', parent)
        self.p = parent

        self.setIcon(QIcon(icon_path('close')))
        self.setShortcut('Ctrl+W')
        self.triggered.connect(self._close)
        self.setEnabled(True)
예제 #5
0
    def __init__(self, parent):
        super(OpenImageDirAction, self).__init__('Open Image Dir', parent)
        self.p = parent

        self.setIcon(QIcon(icon_path('open')))
        self.setShortcut('Ctrl+u')
        self.triggered.connect(self.openImageDir)
        self.setEnabled(True)
예제 #6
0
    def __init__(self, parent):
        super(OpenNextViewAction, self).__init__('Open Next View', parent)
        self.p = parent

        self.setIcon(QIcon(icon_path('next')))
        self.setShortcut('d')
        self.triggered.connect(self.openNextView)
        self.setEnabled(True)
예제 #7
0
    def __init__(self, parent):
        super(QuitAppAction, self).__init__('Quit App', parent)

        self.parent = parent
        self.setIcon(QtGui.QIcon(icon_path('quit')))
        self.setShortcut('Ctrl+Q')
        self.triggered.connect(self.parent.close)
        self.setEnabled(True)
예제 #8
0
def main():
    argparser = argparse.ArgumentParser()
    args = argparser.parse_args()

    app = QApplication([])
    app.setApplicationName(__appname__)
    app.setWindowIcon(QIcon(icon_path('app')))
    win = MainWindow()
    win.show()
    return app.exec_()
예제 #9
0
def newAction(
        parent, text,
        slot=None, shortcut=None, icon=None,
        tip=None, checkable=False, enabled=True):
    """Create a new action and assign callbacks, shortcuts, etc."""
    a = QtWidgets.QAction(text, parent)
    if icon is not None:
        a.setIcon(QtGui.QIcon(icon_path(icon)))
    if shortcut is not None:
        if isinstance(shortcut, (list, tuple)):
            a.setShortcuts(shortcut)
        else:
            a.setShortcut(shortcut)
    if tip is not None:
        a.setToolTip(tip)
        a.setStatusTip(tip)
    if slot is not None:
        a.triggered.connect(slot)
    if checkable:
        a.setCheckable(True)
    a.setEnabled(enabled)
    return a