def createLayerToolbar(self):
    """
    TOWRITE
    """
    toolbarLayer = self.toolbarLayer
    actionHash = self.actionHash
    layerSelector = self.layerSelector
    qDebug("MainWindow createLayerToolbar()")

    toolbarLayer.setObjectName("toolbarLayer")
    toolbarLayer.addAction(actionHash["ACTION_makelayercurrent"])
    toolbarLayer.addAction(actionHash["ACTION_layers"])

    icontheme = self.getSettingsGeneralIconTheme()  # QString

    layerSelector.setFocusProxy(self.prompt)
    # NOTE: Qt4.7 wont load icons without an extension...
    # TODO: Create layer pixmaps by concatenating several icons
    layerSelector.addItem(QIcon("icons/" + icontheme + "/" + "linetypebylayer" + ".png"), "0")
    layerSelector.addItem(QIcon("icons/" + icontheme + "/" + "linetypebylayer" + ".png"), "1")
    layerSelector.addItem(QIcon("icons/" + icontheme + "/" + "linetypebylayer" + ".png"), "2")
    layerSelector.addItem(QIcon("icons/" + icontheme + "/" + "linetypebylayer" + ".png"), "3")
    layerSelector.addItem(QIcon("icons/" + icontheme + "/" + "linetypebylayer" + ".png"), "4")
    layerSelector.addItem(QIcon("icons/" + icontheme + "/" + "linetypebylayer" + ".png"), "5")
    layerSelector.addItem(QIcon("icons/" + icontheme + "/" + "linetypebylayer" + ".png"), "6")
    layerSelector.addItem(QIcon("icons/" + icontheme + "/" + "linetypebylayer" + ".png"), "7")
    layerSelector.addItem(QIcon("icons/" + icontheme + "/" + "linetypebylayer" + ".png"), "8")
    layerSelector.addItem(QIcon("icons/" + icontheme + "/" + "linetypebylayer" + ".png"), "9")
    toolbarLayer.addWidget(layerSelector)
    self.connect(layerSelector, SIGNAL("currentIndexChanged(int)"), self, SLOT("layerSelectorIndexChanged(int)"))

    toolbarLayer.addAction(actionHash["ACTION_layerprevious"])

    self.connect(toolbarLayer, SIGNAL("topLevelChanged(bool)"), self, SLOT("floatingChangedToolBar(bool)"))
 def __menu(self, pos):
     u"""Slot d'apparition du menu contextuel"""
     menu = QMenu()
     menu.addAction("Supprimer", self, SLOT("supprimer()"),
                    QKeySequence.Delete)
     menu.addAction("Nouveau", self, SLOT("nouveau()"), QKeySequence.New)
     menu.exec_(self._ui.tv.mapToGlobal(pos))
Exemple #3
0
    def __init__(self):
        super(Main, self).__init__()

        self._world = World(random.randint, self)
        self._world.setN(10)
        # Dodawanie organizmów
        self._world.add_organism(Human((10, 10)))
        org_types = [
            Antelope, Fox, Sheep, Turtle, Wolf, Belladonna, Dandelion, Grass,
            Guarana
        ]
        for org_type in org_types:
            self._init_org(5, org_type, random.randint)
        self._world.add_pending()

        # GUI
        # To okno
        self._menu_bar_h = 20
        x, y, w, h = 300, 50, 870, 600 + self._menu_bar_h
        self.setGeometry(x, y, w, h)
        self.setFixedSize(w, h)
        self.setWindowTitle("Tomasz Stasiak 155197")
        hbox = QtGui.QHBoxLayout(self)
        menu_bar = QtGui.QMenuBar(self)
        menu_bar.setGeometry(0, 0, w, self._menu_bar_h)

        # Akcje w menu
        self._game_start = menu_bar.addAction("Start gry")
        self._next_round = menu_bar.addAction("Następna runda")
        self._next_round.setVisible(False)
        save_game = menu_bar.addAction("Zapisz stan")
        load_game = menu_bar.addAction("Wczytaj stan")

        # Bindowanie kontrolek do akcji
        # Start gry
        QObject.connect(self._game_start, SIGNAL("triggered()"), self,
                        SLOT("start_game()"))
        QObject.connect(self._next_round, SIGNAL("triggered()"),
                        lambda: self._world.nextRound())
        QObject.connect(save_game, SIGNAL("triggered()"), self,
                        SLOT("save_game()"))
        QObject.connect(load_game, SIGNAL("triggered()"), self,
                        SLOT("load_game()"))

        # Insze kontrolki
        # Plansza gry
        self._game_board = GameBoard(self, 0, self._menu_bar_h)

        # Panel informaacyjny
        info_widget = QtGui.QWidget()
        self._info_panel = QtGui.QVBoxLayout(info_widget)
        self._info_panel.setAlignment(Qt.AlignTop)
        info_widget.setLayout(self._info_panel)

        # Dodanie ww. paneli
        hbox.addWidget(self._game_board)
        hbox.addWidget(info_widget)

        self.setLayout(hbox)
Exemple #4
0
    def __init__(self, parent=None):
        """
        Default class constructor.

        :param `parent`: Pointer to a parent widget instance.
        :type `parent`: `QWidget`_
        """
        super(CmdPromptInput, self).__init__(parent)

        qDebug("CmdPromptInput Constructor")
        self.setObjectName("Command Prompt Input")

        self.defaultPrefix = self.tr("Command: ")
        self.prefix = self.defaultPrefix
        self.curText = self.prefix

        self.lastCmd = "help"
        self.curCmd = "help"
        self.cmdActive = False

        self.rapidFireEnabled = False

        self.isBlinking = False

        self.setText(self.prefix)
        self.setFrame(False)
        self.setMaxLength(266)
        self.setMaximumSize(5000, 25)
        self.setDragEnabled(False)

        self.connect(self, SIGNAL("cursorPositionChanged(int, int)"), self, SLOT("checkCursorPosition(int, int)"))
        self.connect(self, SIGNAL("textEdited(QString)"), self, SLOT("checkEditedText(QString)"))
        self.connect(self, SIGNAL("textChanged(QString)"), self, SLOT("checkChangedText(QString)"))
        self.connect(self, SIGNAL("selectionChanged()"), self, SLOT("checkSelection()"))

        self.aliasHash = {}  # new QHash<QString, QString>

        self.installEventFilter(self)
        self.setFocus(Qt.OtherFocusReason)

        self.applyFormatting()

        # self.setCompleter(EmbroiderCommanderAutoCompleter(self))

        #### self.completer = QCompleter(['LINE', 'HEART', 'DOLPHIN', 'CIRCLE', 'STAR', 'six', 'seven', 'eight', 'nine', 'ten'], self)
        #### self.completer.setCompletionMode(QCompleter.PopupCompletion)
        #### self.completer.setCaseSensitivity(Qt.CaseInsensitive)
        #### self.setCompleter(self.completer)

        self.curText          = str()   # QString curText;
        self.defaultPrefix    = str()   # QString defaultPrefix;
        self.prefix           = str()   # QString prefix;

        self.lastCmd          = str()   # QString lastCmd;
        self.curCmd           = str()   # QString curCmd;
        self.cmdActive        = str()   # bool cmdActive;

        self.rapidFireEnabled = bool()  # bool rapidFireEnabled;
        self.isBlinking       = bool()  # bool isBlinking;
def createTextToolbar(self):
    """
    TOWRITE
    """
    toolbarText = self.toolbarText
    actionHash = self.actionHash
    prompt = self.prompt
    textSizeSelector = self.textSizeSelector
    textFontSelector = self.textFontSelector
    qDebug("MainWindow createTextToolbar()")

    toolbarText.setObjectName("toolbarText")

    toolbarText.addWidget(textFontSelector)
    textFontSelector.setCurrentFont(QFont(self.getSettingsTextFont()))
    self.connect(textFontSelector, SIGNAL("currentFontChanged(QFont)"), self, SLOT("textFontSelectorCurrentFontChanged(QFont)"))

    toolbarText.addAction(actionHash["ACTION_textbold"])
    ## print('DEBUG', self.getSettingsTextStyleBold())
    #TODO/PORT TypeError# actionHash["ACTION_textbold"].setChecked(self.getSettingsTextStyleBold())
    toolbarText.addAction(actionHash["ACTION_textitalic"])
    #TODO/PORT TypeError# actionHash["ACTION_textitalic"].setChecked(self.getSettingsTextStyleItalic())
    toolbarText.addAction(actionHash["ACTION_textunderline"])
    #TODO/PORT TypeError# actionHash["ACTION_textunderline"].setChecked(self.getSettingsTextStyleUnderline())
    toolbarText.addAction(actionHash["ACTION_textstrikeout"])
    #TODO/PORT TypeError# actionHash["ACTION_textstrikeout"].setChecked(self.getSettingsTextStyleStrikeOut())
    toolbarText.addAction(actionHash["ACTION_textoverline"])
    #TODO/PORT TypeError# actionHash["ACTION_textoverline"].setChecked(self.getSettingsTextStyleOverline())

    textSizeSelector.setFocusProxy(prompt)
    textSizeSelector.addItem("6 pt",   6)
    textSizeSelector.addItem("8 pt",   8)
    textSizeSelector.addItem("9 pt",   9)
    textSizeSelector.addItem("10 pt", 10)
    textSizeSelector.addItem("11 pt", 11)
    textSizeSelector.addItem("12 pt", 12)
    textSizeSelector.addItem("14 pt", 14)
    textSizeSelector.addItem("18 pt", 18)
    textSizeSelector.addItem("24 pt", 24)
    textSizeSelector.addItem("30 pt", 30)
    textSizeSelector.addItem("36 pt", 36)
    textSizeSelector.addItem("48 pt", 48)
    textSizeSelector.addItem("60 pt", 60)
    textSizeSelector.addItem("72 pt", 72)
    self.setTextSize(self.getSettingsTextSize())
    toolbarText.addWidget(textSizeSelector)
    self.connect(textSizeSelector, SIGNAL("currentIndexChanged(int)"), self, SLOT("textSizeSelectorIndexChanged(int)"))

    self.connect(toolbarText, SIGNAL("topLevelChanged(bool)"), self, SLOT("floatingChangedToolBar(bool)"))
Exemple #6
0
        def testValueChanged(self):
            """Emission of a python signal to QSpinBox setValue(int)"""
            QObject.connect(self.obj, SIGNAL('dummy(int)'), self.spin, SLOT('setValue(int)'))
            self.assertEqual(self.spin.value(), 0)

            self.obj.emit(SIGNAL('dummy(int)'), 4)
            self.assertEqual(self.spin.value(), 4)
Exemple #7
0
def main(argv=None):
    if argv is None:
        argv = sys.argv

    app = QApplication(argv)
    engine = QScriptEngine()

    if HAS_DEBUGGER:
        debugger = QScriptEngineDebugger()
        debugger.attachTo(engine)
        debugWindow = debugger.standardWindow()
        debugWindow.resize(1024, 640)

    scriptFileName = './calculator.js'
    scriptFile = QFile(scriptFileName)
    scriptFile.open(QIODevice.ReadOnly)
    engine.evaluate(unicode(scriptFile.readAll()), scriptFileName)
    scriptFile.close()

    loader = QUiLoader()
    ui = loader.load(':/calculator.ui')

    ctor = engine.evaluate('Calculator')
    scriptUi = engine.newQObject(ui, QScriptEngine.ScriptOwnership)
    calc = ctor.construct([scriptUi])

    if HAS_DEBUGGER:
        display = ui.findChild(QLineEdit, 'display')
        display.connect(display, SIGNAL('returnPressed()'), debugWindow,
                        SLOT('show()'))

    ui.show()
    return app.exec_()
Exemple #8
0
    def testButtonClickClose(self):
        button = QPushButton()
        button.connect(button, SIGNAL('clicked()'), SLOT('close()'))

        button.show()
        self.assert_(button.isVisible())
        button.click()
        self.assert_(not button.isVisible())
Exemple #9
0
 def testWithCppSlot(self):
     '''QMenuBar.addAction(id, object, slot)'''
     menubar = QMenuBar()
     widget = QPushButton()
     widget.setCheckable(True)
     widget.setChecked(False)
     action = menubar.addAction("Accounts", widget, SLOT("toggle()"))
     action.activate(QAction.Trigger)
     self.assert_(widget.isChecked())
Exemple #10
0
        def testShow(self):
            """Emission of a python signal to QWidget slot show()"""
            self.widget.hide()

            QObject.connect(self.obj, SIGNAL('dummy()'), self.widget, SLOT('show()'))
            self.assert_(not self.widget.isVisible())

            self.obj.emit(SIGNAL('dummy()'))
            self.assert_(self.widget.isVisible())
Exemple #11
0
    def testWindowButtonClickClose(self):
        button = QPushButton()
        window = QWidget()
        window.connect(button, SIGNAL('clicked()'), SLOT('close()'))

        window.show()
        self.assert_(window.isVisible())
        button.click()
        self.assert_(not window.isVisible())
Exemple #12
0
    def testWithArgs(self):
        '''Connect python signals to QTimeLine.setCurrentTime(int)'''
        timeline = QTimeLine()
        dummy = Dummy()

        QObject.connect(dummy, SIGNAL('dummy(int)'),
                        timeline, SLOT('setCurrentTime(int)'))

        current = timeline.currentTime()
        dummy.emit(SIGNAL('dummy(int)'), current+42)
        self.assertEqual(timeline.currentTime(), current+42)
Exemple #13
0
    def __init__(self, parent=None):
        """
        Default class constructor.

        :param `parent`: Pointer to a parent widget instance.
        :type `parent`: `QWidget`_
        """
        super(CmdPromptSplitter, self).__init__(parent)

        qDebug("CmdPromptSplitter Constructor")
        self.setObjectName("Command Prompt Splitter")

        self.setOrientation(Qt.Vertical)
        # NOTE: Add two empty widgets just so we have a handle to grab
        self.addWidget(QWidget(self))
        self.addWidget(QWidget(self))

        self.connect(self, SIGNAL("pressResizeHistory(int)"),   parent, SLOT("startResizingTheHistory(int)"))
        self.connect(self, SIGNAL("releaseResizeHistory(int)"), parent, SLOT("stopResizingTheHistory(int)"))
        self.connect(self, SIGNAL("moveResizeHistory(int)"),    parent, SLOT("resizeTheHistory(int)"))
Exemple #14
0
        def testSetValueIndirect(self):
            """Indirect signal emission: QSpinBox using valueChanged(int)/setValue(int)"""
            spinSend = QSpinBox()
            spinRec = QSpinBox()

            spinRec.setValue(5)

            QObject.connect(spinSend, SIGNAL('valueChanged(int)'), spinRec, SLOT('setValue(int)'))
            self.assertEqual(spinRec.value(), 5)
            spinSend.setValue(3)
            self.assertEqual(spinRec.value(), 3)
            self.assertEqual(spinSend.value(), 3)
def createPromptToolbar(self):
    """
    TOWRITE
    """
    toolbarPrompt = self.toolbarPrompt
    prompt = self.prompt
    qDebug("MainWindow createPromptToolbar()")

    toolbarPrompt.setObjectName("toolbarPrompt")
    toolbarPrompt.addWidget(prompt)
    toolbarPrompt.setAllowedAreas(Qt.TopToolBarArea | Qt.BottomToolBarArea)
    self.connect(toolbarPrompt, SIGNAL("topLevelChanged(bool)"), prompt, SLOT("floatingChanged(bool)"))
def createViewToolbar(self):
    """
    TOWRITE
    """
    toolbarView = self.toolbarView
    actionHash = self.actionHash
    qDebug("MainWindow createViewToolbar()")

    toolbarView.setObjectName("toolbarView")
    toolbarView.addAction(actionHash["ACTION_day"])
    toolbarView.addAction(actionHash["ACTION_night"])

    self.connect(toolbarView, SIGNAL("topLevelChanged(bool)"), self, SLOT("floatingChangedToolBar(bool)"))
def createEditToolbar(self):
    """
    TOWRITE
    """
    toolbarEdit = self.toolbarEdit
    actionHash = self.actionHash
    qDebug("MainWindow createEditToolbar()")

    toolbarEdit.setObjectName("toolbarEdit")
    toolbarEdit.addAction(actionHash["ACTION_cut"])
    toolbarEdit.addAction(actionHash["ACTION_copy"])
    toolbarEdit.addAction(actionHash["ACTION_paste"])

    self.connect(toolbarEdit, SIGNAL("topLevelChanged(bool)"), self, SLOT("floatingChangedToolBar(bool)"))
    def createPatch(self, patches):

        if not self.patching:
            self.patching = True
            self.logger.debug(patches)
            thread = createPatch.createPatch(patches, self.db)

            self.connect(thread, SIGNAL("finished()"), thread,
                         SLOT("deleteLater()"))

            thread.finished.connect(self.done)
            thread.start()
            self.threads.append(thread)
            self.logger.debug("starting patch creation")
Exemple #19
0
    def testWithoutArgs(self):
        '''Connect python signal to QTimeLine.toggleDirection()'''
        timeline = QTimeLine()
        dummy = Dummy()
        QObject.connect(dummy, SIGNAL('dummy()'),
                        timeline, SLOT('toggleDirection()'))

        orig_dir = timeline.direction()
        dummy.emit(SIGNAL('dummy()'))
        new_dir = timeline.direction()

        if orig_dir == QTimeLine.Forward:
            self.assertEqual(new_dir, QTimeLine.Backward)
        else:
            self.assertEqual(new_dir, QTimeLine.Forward)
def createIconToolbar(self):
    """
    TOWRITE
    """
    toolbarIcon = self.toolbarIcon
    actionHash = self.actionHash
    qDebug("MainWindow createIconToolbar()")

    toolbarIcon.setObjectName("toolbarIcon")
    toolbarIcon.addAction(actionHash["ACTION_icon16"])
    toolbarIcon.addAction(actionHash["ACTION_icon24"])
    toolbarIcon.addAction(actionHash["ACTION_icon32"])
    toolbarIcon.addAction(actionHash["ACTION_icon48"])
    toolbarIcon.addAction(actionHash["ACTION_icon64"])
    toolbarIcon.addAction(actionHash["ACTION_icon128"])

    self.connect(toolbarIcon, SIGNAL("topLevelChanged(bool)"), self, SLOT("floatingChangedToolBar(bool)"))
def createHelpToolbar(self):
    """
    TOWRITE
    """
    toolbarHelp = self.toolbarHelp
    actionHash = self.actionHash
    qDebug("MainWindow createHelpToolbar()")

    toolbarHelp.setObjectName("toolbarHelp")
    toolbarHelp.addAction(actionHash["ACTION_help"])
    toolbarHelp.addSeparator()
    toolbarHelp.addAction(actionHash["ACTION_changelog"])
    toolbarHelp.addSeparator()
    toolbarHelp.addAction(actionHash["ACTION_about"])
    toolbarHelp.addSeparator()
    toolbarHelp.addAction(actionHash["ACTION_whatsthis"])

    self.connect(toolbarHelp, SIGNAL("topLevelChanged(bool)"), self, SLOT("floatingChangedToolBar(bool)"))
def createPanToolbar(self):
    """
    TOWRITE
    """
    toolbarPan = self.toolbarPan
    actionHash = self.actionHash
    qDebug("MainWindow createPanToolbar()")

    toolbarPan.setObjectName("toolbarPan")
    toolbarPan.addAction(actionHash["ACTION_panrealtime"])
    toolbarPan.addAction(actionHash["ACTION_panpoint"])
    toolbarPan.addSeparator()
    toolbarPan.addAction(actionHash["ACTION_panleft"])
    toolbarPan.addAction(actionHash["ACTION_panright"])
    toolbarPan.addAction(actionHash["ACTION_panup"])
    toolbarPan.addAction(actionHash["ACTION_pandown"])

    self.connect(toolbarPan, SIGNAL("topLevelChanged(bool)"), self, SLOT("floatingChangedToolBar(bool)"))
Exemple #23
0
    def testWithoutArgs(self):
        '''Connect QProcess.started() to QTimeLine.togglePaused()'''
        process = QProcess()
        timeline = QTimeLine()

        QObject.connect(process, SIGNAL('finished(int, QProcess::ExitStatus)'),
                        timeline, SLOT('toggleDirection()'))

        orig_dir = timeline.direction()

        process.start(sys.executable, ['-c', '"print 42"'])
        process.waitForFinished()

        new_dir = timeline.direction()

        if orig_dir == QTimeLine.Forward:
            self.assertEqual(new_dir, QTimeLine.Backward)
        else:
            self.assertEqual(new_dir, QTimeLine.Forward)
Exemple #24
0
        def testSetValue(self):
            """Direct signal emission: QSpinBox using valueChanged(int)/setValue(int)"""
            spinSend = QSpinBox()
            spinRec = QSpinBox()

            spinRec.setValue(5)
            spinSend.setValue(42)

            QObject.connect(spinSend, SIGNAL('valueChanged(int)'), spinRec, SLOT('setValue(int)'))
            self.assertEqual(spinRec.value(), 5)
            self.assertEqual(spinSend.value(), 42)
            spinSend.emit(SIGNAL('valueChanged(int)'), 3)

            self.assertEqual(spinRec.value(), 3)
            #Direct emission shouldn't change the value of the emitter
            self.assertEqual(spinSend.value(), 42)

            spinSend.emit(SIGNAL('valueChanged(int)'), 66)
            self.assertEqual(spinRec.value(), 66)
            self.assertEqual(spinSend.value(), 42)
def createZoomToolbar(self):
    """
    TOWRITE
    """
    toolbarZoom = self.toolbarZoom
    actionHash = self.actionHash
    qDebug("MainWindow createZoomToolbar()")

    toolbarZoom.setObjectName("toolbarZoom")
    toolbarZoom.addAction(actionHash["ACTION_zoomwindow"])
    toolbarZoom.addAction(actionHash["ACTION_zoomdynamic"])
    toolbarZoom.addAction(actionHash["ACTION_zoomscale"])
    toolbarZoom.addSeparator()
    toolbarZoom.addAction(actionHash["ACTION_zoomcenter"])
    toolbarZoom.addAction(actionHash["ACTION_zoomin"])
    toolbarZoom.addAction(actionHash["ACTION_zoomout"])
    toolbarZoom.addSeparator()
    toolbarZoom.addAction(actionHash["ACTION_zoomselected"])
    toolbarZoom.addAction(actionHash["ACTION_zoomall"])
    toolbarZoom.addAction(actionHash["ACTION_zoomextents"])

    self.connect(toolbarZoom, SIGNAL("topLevelChanged(bool)"), self, SLOT("floatingChangedToolBar(bool)"))
def createFileToolbar(self):
    """
    TOWRITE
    """
    toolbarFile = self.toolbarFile
    actionHash = self.actionHash
    qDebug("MainWindow createFileToolbar()")

    toolbarFile.setObjectName("toolbarFile")
    toolbarFile.addAction(actionHash["ACTION_new"])
    toolbarFile.addAction(actionHash["ACTION_open"])
    toolbarFile.addAction(actionHash["ACTION_save"])
    toolbarFile.addAction(actionHash["ACTION_saveas"])
    toolbarFile.addAction(actionHash["ACTION_print"])
    toolbarFile.addAction(actionHash["ACTION_designdetails"])

    toolbarFile.addSeparator()
    toolbarFile.addAction(actionHash["ACTION_undo"])
    toolbarFile.addAction(actionHash["ACTION_redo"])
    toolbarFile.addSeparator()
    toolbarFile.addAction(actionHash["ACTION_help"])

    self.connect(toolbarFile, SIGNAL("topLevelChanged(bool)"), self, SLOT("floatingChangedToolBar(bool)"))
Exemple #27
0
def main(argv):
    """
    TOWRITE

    :param `argc`: TOWRITE
    :type `argc`: int
    :param `argv`: TOWRITE
    :type `argv`: char
    :rtype: int
    """

    filesToOpen = []  # QStringList filesToOpen;
    filesToCheck = []

    bindings = defaultBindings
    bindings_flag = False
    for arg in argv[1:]:
        if bindings_flag:
            bindings_flag = False
            if not arg in ("pyside", "pyqt4"):
                usage()
            else:
                bindings = arg
        elif arg == "-d" or arg == "--debug":
            pass
        elif arg == "-h" or arg == "--help":
            usage()
        elif arg == "-v" or arg == "--version":
            version()
        elif arg == "-b" or arg == "--bindings":
            bindings_flag = True
        else:
            filesToCheck.append(arg)

    if exitApp:
        return 1

    # make global to all modules
    if bindings == "pyside":
        builtins.PYSIDE = True
        builtins.PYQT4 = False
    elif bindings == "pyqt4":
        builtins.PYSIDE = False
        builtins.PYQT4 = True

    if PYSIDE:
        from PySide.QtScript import QScriptEngine
        if not hasattr(QScriptEngine, "newFunction"):
            raise ImportError(
                'You need a patched version of PySide.\n'
                'see: https://codereview.qt-project.org/112333')

    #--PySide Imports.
    if PYSIDE:
        from PySide.QtCore import QObject, SIGNAL, SLOT, QFile
        from PySide.QtGui import QApplication
    elif PYQT4:
        import sip
        sip.setapi('QString', 2)
        sip.setapi('QVariant', 2)
        from PyQt4.QtCore import QObject, SIGNAL, SLOT, QFile
        from PyQt4.QtGui import QApplication

    from mainwindow import MainWindow

    for file_ in filesToCheck:
        if QFile.exists(file_) and MainWindow.validFileFormat(file_):
            filesToOpen.append(file_)
        else:
            usage()
            break

    if exitApp:
        return 1

    app = QApplication(argv)
    app.setApplicationName(_appName_)
    app.setApplicationVersion(_appVer_)

    mainWin = MainWindow()  # MainWindow* 

    QObject.connect(app, SIGNAL("lastWindowClosed()"), mainWin, SLOT("quit()"))

    mainWin.setWindowTitle(app.applicationName() + " " + app.applicationVersion())
    mainWin.show()

    # NOTE: If openFilesSelected() is called from within the mainWin constructor, slot commands wont work and the window menu will be screwed
    if filesToOpen:  # if(!filesToOpen.isEmpty())
        mainWin.openFilesSelected(filesToOpen)

    # return app.exec_()
    return app.exec_()
Exemple #28
0
    def __init__(self):
        QMainWindow.__init__(self)
        self.resize(800, 600)
        self.setWindowTitle('PDF Merger')

        about = QAction('About', self)
        self.connect(about, SIGNAL('triggered()'), self.show_about)
        exit = QAction('Exit', self)
        exit.setShortcut('Ctrl+Q')
        self.connect(exit, SIGNAL('triggered()'), SLOT('close()'))

        self.statusBar()
        menubar = self.menuBar()
        file = menubar.addMenu('File')
        file.addAction(about)
        file.addAction(exit)

        self.main_widget = QWidget(self)
        self.setCentralWidget(self.main_widget)
        self.up_down_widget = QWidget(self)
        self.options_widget = QWidget(self)

        input_files_label = QLabel(
            "Input PDFs\nThis is the order in which the files will be merged too"
        )
        self.files_list = QListWidget()
        self.files_list.setSelectionMode(QAbstractItemView.ExtendedSelection)
        add_button = QPushButton("Add PDF(s) to merge...")
        add_button.clicked.connect(self.clicked_add)
        up_button = QPushButton("Up")
        up_button.clicked.connect(self.move_file_up)
        down_button = QPushButton("Down")
        down_button.clicked.connect(self.move_file_down)
        remove_button = QPushButton("Remove PDF")
        remove_button.clicked.connect(self.remove_file)
        select_path_label = QLabel("Output PDF")
        self.dest_path_edit = QLineEdit()
        self.dest_path_edit.setReadOnly(True)
        select_path = QPushButton("Select...")
        select_path.clicked.connect(self.select_save_path)
        start = QPushButton("Start")
        start.clicked.connect(self.merge_pdf)

        up_down_vbox = QVBoxLayout(self.up_down_widget)
        up_down_vbox.addWidget(up_button)
        up_down_vbox.addWidget(down_button)
        up_down_vbox.addWidget(remove_button)
        self.up_down_widget.setLayout(up_down_vbox)

        group_input = QGroupBox()
        grid_input = QGridLayout()
        grid_input.addWidget(add_button, 0, 0)
        grid_input.addWidget(input_files_label, 1, 0)
        grid_input.addWidget(self.files_list, 2, 0)
        grid_input.addWidget(self.up_down_widget, 2, 1)
        group_input.setLayout(grid_input)

        group_output = QGroupBox()
        grid_output = QGridLayout()
        grid_output.addWidget(select_path_label, 0, 0)
        grid_output.addWidget(self.dest_path_edit, 1, 0)
        grid_output.addWidget(select_path, 1, 1)
        group_output.setLayout(grid_output)

        vbox_options = QVBoxLayout(self.options_widget)
        vbox_options.addWidget(group_input)
        vbox_options.addWidget(group_output)
        vbox_options.addWidget(start)
        self.options_widget.setLayout(vbox_options)

        splitter_filelist = QSplitter()
        splitter_filelist.setOrientation(Qt.Vertical)
        splitter_filelist.addWidget(self.options_widget)
        vbox_main = QVBoxLayout(self.main_widget)
        vbox_main.addWidget(splitter_filelist)
        vbox_main.setContentsMargins(0, 0, 0, 0)
Exemple #29
0
 def testEmission(self):
     o = MyObject()
     o.connect(SIGNAL("mySignal()"), o, SLOT("mySlot()"))
     o.emit(SIGNAL("mySignal()"))
     self.assertTrue(o._slotCalledCount == 1)
Exemple #30
0
def createAction(self, icon, toolTip, statusTip, scripted=False):
    """
    TOWRITE

    :param `icon`: TOWRITE
    :type `icon`: QString
    :param `toolTip`: TOWRITE
    :type `toolTip`: QString
    :param `statusTip`: TOWRITE
    :type `statusTip`: QString
    :param `scripted`: TOWRITE
    :type `scripted`: bool
    :rtype: `QAction`_

    .. TODO:: send the global Icon, Image, Commands Dirs in to be used.

    """
    connect = self.connect  # NOT local optimization, but for ease of the code looking similar to the C++ whash
    mdiArea = self.mdiArea  # ditto

    ACTION = QAction(
        QIcon(self.gIconDir + os.sep + self.getSettingsGeneralIconTheme() +
              "/" + icon + ".png"), toolTip, self
    )  # QAction *  # TODO: Qt4.7 wont load icons without an extension...
    ACTION.setStatusTip(statusTip)
    ACTION.setObjectName(icon)
    # TODO: Set What's This Context Help to statusTip for now so there is some infos there.
    # Make custom whats this context help popup with more descriptive help than just
    # the status bar/tip one liner(short but not real long) with a hyperlink in the custom popup
    # at the bottom to open full help file description. Ex: like wxPython AGW's SuperToolTip.
    ACTION.setWhatsThis(statusTip)
    # TODO: Finish All Commands ... <.<

    if icon == "donothing":
        connect(ACTION, SIGNAL("triggered()"), self, SLOT("doNothing()"))
    elif icon == "new":
        ACTION.setShortcut(QKeySequence.New)
        connect(ACTION, SIGNAL("triggered()"), self, SLOT("newFile()"))
    elif icon == "open":
        ACTION.setShortcut(QKeySequence.Open)
        connect(ACTION, SIGNAL("triggered()"), self, SLOT("openFile()"))
    elif icon == "save":
        ACTION.setShortcut(QKeySequence.Save)
        connect(ACTION, SIGNAL("triggered()"), self, SLOT("savefile()"))
    elif icon == "saveas":
        ACTION.setShortcut(QKeySequence.SaveAs)
        connect(ACTION, SIGNAL("triggered()"), self, SLOT("saveasfile()"))
    elif icon == "print":
        ACTION.setShortcut(QKeySequence.Print)
        connect(ACTION, SIGNAL("triggered()"), self, SLOT("print_()"))
    elif icon == "designdetails":
        ACTION.setShortcut(QKeySequence("Ctrl+D"))
        connect(ACTION, SIGNAL("triggered()"), self, SLOT("designDetails()"))
    elif icon == "exit":
        ACTION.setShortcut(QKeySequence("Ctrl+Q"))
        connect(ACTION, SIGNAL("triggered()"), self, SLOT("exit()"))

    elif icon == "cut":
        ACTION.setShortcut(QKeySequence.Cut)
        connect(ACTION, SIGNAL("triggered()"), self, SLOT("cut()"))
    elif icon == "copy":
        ACTION.setShortcut(QKeySequence.Copy)
        connect(ACTION, SIGNAL("triggered()"), self, SLOT("copy()"))
    elif icon == "paste":
        ACTION.setShortcut(QKeySequence.Paste)
        connect(ACTION, SIGNAL("triggered()"), self, SLOT("paste()"))

    elif icon == "windowcascade":
        connect(ACTION, SIGNAL("triggered()"), mdiArea, SLOT("cascade()"))
    elif icon == "windowtile":
        connect(ACTION, SIGNAL("triggered()"), mdiArea, SLOT("tile()"))
    elif icon == "windowclose":
        ACTION.setShortcut(QKeySequence.Close)
        connect(ACTION, SIGNAL("triggered()"), self, SLOT("onCloseWindow()"))
    elif icon == "windowcloseall":
        connect(ACTION, SIGNAL("triggered()"), mdiArea,
                SLOT("closeAllSubWindows()"))
    elif icon == "windownext":
        ACTION.setShortcut(QKeySequence.NextChild)
        connect(ACTION, SIGNAL("triggered()"), mdiArea,
                SLOT("activateNextSubWindow()"))
    elif icon == "windowprevious":
        ACTION.setShortcut(QKeySequence.PreviousChild)
        connect(ACTION, SIGNAL("triggered()"), mdiArea,
                SLOT("activatePreviousSubWindow()"))

    elif icon == "help":
        connect(ACTION, SIGNAL("triggered()"), self, SLOT("help()"))
    elif icon == "changelog":
        connect(ACTION, SIGNAL("triggered()"), self, SLOT("changelog()"))
    elif icon == "tipoftheday":
        connect(ACTION, SIGNAL("triggered()"), self, SLOT("tipOfTheDay()"))
    elif icon == "about":
        connect(ACTION, SIGNAL("triggered()"), self, SLOT("about()"))
    elif icon == "whatsthis":
        connect(ACTION, SIGNAL("triggered()"), self,
                SLOT("whatsThisContextHelp()"))

    elif icon == "icon16":
        connect(ACTION, SIGNAL("triggered()"), self, SLOT("icon16()"))
    elif icon == "icon24":
        connect(ACTION, SIGNAL("triggered()"), self, SLOT("icon24()"))
    elif icon == "icon32":
        connect(ACTION, SIGNAL("triggered()"), self, SLOT("icon32()"))
    elif icon == "icon48":
        connect(ACTION, SIGNAL("triggered()"), self, SLOT("icon48()"))
    elif icon == "icon64":
        connect(ACTION, SIGNAL("triggered()"), self, SLOT("icon64()"))
    elif icon == "icon128":
        connect(ACTION, SIGNAL("triggered()"), self, SLOT("icon128()"))

    elif icon == "settingsdialog":
        connect(ACTION, SIGNAL("triggered()"), self, SLOT("settingsDialog()"))

    elif icon == "undo":
        connect(ACTION, SIGNAL("triggered()"), self, SLOT("undo()"))
    elif icon == "redo":
        connect(ACTION, SIGNAL("triggered()"), self, SLOT("redo()"))

    elif icon == "makelayercurrent":
        connect(ACTION, SIGNAL("triggered()"), self, SLOT("makeLayerActive()"))
    elif icon == "layers":
        connect(ACTION, SIGNAL("triggered()"), self, SLOT("layerManager()"))
    elif icon == "layerprevious":
        connect(ACTION, SIGNAL("triggered()"), self, SLOT("layerPrevious()"))

    elif icon == "textbold":
        ACTION.setCheckable(True)
        connect(ACTION, SIGNAL("toggled(bool)"), self,
                SLOT("setTextBold(bool)"))
    elif icon == "textitalic":
        ACTION.setCheckable(True)
        connect(ACTION, SIGNAL("toggled(bool)"), self,
                SLOT("setTextItalic(bool)"))
    elif icon == "textunderline":
        ACTION.setCheckable(True)
        connect(ACTION, SIGNAL("toggled(bool)"), self,
                SLOT("setTextUnderline(bool)"))
    elif icon == "textstrikeout":
        ACTION.setCheckable(True)
        connect(ACTION, SIGNAL("toggled(bool)"), self,
                SLOT("setTextStrikeOut(bool)"))
    elif icon == "textoverline":
        ACTION.setCheckable(True)
        connect(ACTION, SIGNAL("toggled(bool)"), self,
                SLOT("setTextOverline(bool)"))

    elif icon == "zoomrealtime":
        connect(ACTION, SIGNAL("triggered()"), self, SLOT("zoomRealtime()"))
    elif icon == "zoomprevious":
        connect(ACTION, SIGNAL("triggered()"), self, SLOT("zoomPrevious()"))
    elif icon == "zoomwindow":
        connect(ACTION, SIGNAL("triggered()"), self, SLOT("zoomWindow()"))
    elif icon == "zoomdynamic":
        connect(ACTION, SIGNAL("triggered()"), self, SLOT("zoomDynamic()"))
    elif icon == "zoomscale":
        connect(ACTION, SIGNAL("triggered()"), self, SLOT("zoomScale()"))
    elif icon == "zoomcenter":
        connect(ACTION, SIGNAL("triggered()"), self, SLOT("zoomCenter()"))
    elif icon == "zoomin":
        connect(ACTION, SIGNAL("triggered()"), self, SLOT("zoomIn()"))
    elif icon == "zoomout":
        connect(ACTION, SIGNAL("triggered()"), self, SLOT("zoomOut()"))
    elif icon == "zoomselected":
        connect(ACTION, SIGNAL("triggered()"), self, SLOT("zoomSelected()"))
    elif icon == "zoomall":
        connect(ACTION, SIGNAL("triggered()"), self, SLOT("zoomAll()"))
    elif icon == "zoomextents":
        connect(ACTION, SIGNAL("triggered()"), self, SLOT("zoomExtents()"))

    elif icon == "panrealtime":
        connect(ACTION, SIGNAL("triggered()"), self, SLOT("panrealtime()"))
    elif icon == "panpoint":
        connect(ACTION, SIGNAL("triggered()"), self, SLOT("panpoint()"))
    elif icon == "panleft":
        connect(ACTION, SIGNAL("triggered()"), self, SLOT("panLeft()"))
    elif icon == "panright":
        connect(ACTION, SIGNAL("triggered()"), self, SLOT("panRight()"))
    elif icon == "panup":
        connect(ACTION, SIGNAL("triggered()"), self, SLOT("panUp()"))
    elif icon == "pandown":
        connect(ACTION, SIGNAL("triggered()"), self, SLOT("panDown()"))

    elif icon == "day":
        connect(ACTION, SIGNAL("triggered()"), self, SLOT("dayVision()"))
    elif icon == "night":
        connect(ACTION, SIGNAL("triggered()"), self, SLOT("nightVision()"))

    elif scripted:
        ACTION.setIcon(
            QIcon(self.gAppDir + os.sep + "commands/" + icon + "/" + icon +
                  ".png"))
        connect(ACTION, SIGNAL("triggered()"), self, SLOT("runCommand()"))

    else:
        ACTION.setEnabled(False)
        connect(ACTION, SIGNAL("triggered()"), self, SLOT("stub_implement()"))

    return ACTION