コード例 #1
0
    def enterEvent(self, event):
        """
        Overrides base QFrame enterEvenet function
        :param event: QEvent
        """

        QApplication.setOverrideCursor(Qt.SizeHorCursor)
コード例 #2
0
ファイル: decorators.py プロジェクト: tpDcc/tpDcc-libs-qt
 def wrapper(*args, **kwargs):
     cursor = QCursor(Qt.ArrowCursor)
     QApplication.setOverrideCursor(cursor)
     try:
         return fn(*args, **kwargs)
     finally:
         QApplication.restoreOverrideCursor()
コード例 #3
0
ファイル: interface.py プロジェクト: tfart/Simplex
    def buildFromAbc(self, thing, abcPath, pBar=None):
        """ Load a system from an exported
		abc file onto the current system """
        if pBar is not None:
            pBar.show()
            pBar.setMaximum(100)
            pBar.setValue(0)
            pBar.setLabelText("Loading Smpx")
            QApplication.processEvents()

        iarch = IArchive(str(abcPath))  # because alembic hates unicode
        try:
            top = iarch.getTop()
            par = top.children[0]
            par = IXform(top, par.getName())
            abcMesh = par.children[0]
            abcMesh = IPolyMesh(par, abcMesh.getName())

            systemSchema = par.getSchema()
            props = systemSchema.getUserProperties()
            prop = props.getProperty("simplex")
            jsString = prop.getValue()
            js = json.loads(jsString)

            system = self.buildFromDict(thing, js, True, pBar)
            self.DCC.loadABC(abcMesh, js, pBar)
        finally:
            del iarch

        return system
コード例 #4
0
    def show_already_existing_dialog(self):
        """
        Shows a warning dialog if the item already exists on save
        """

        if not self.library_window():
            raise exceptions.ItemSaveError('Item already exists!')

        buttons = QDialogButtonBox.Yes | QDialogButtonBox.Cancel
        try:
            QApplication.setOverrideCursor(Qt.ArrowCursor)
            button = self.library_window().show_question_dialog(
                'Item already exists',
                'Would you like to move the existing item "{}" to trash?'.format(os.path.basename(self.path())), buttons
            )
        finally:
            QApplication.restoreOverrideCursor()

        if button == QDialogButtonBox.Yes:
            self._move_to_trash()
        elif button == QMessageBox.Cancel:
            return button
        else:
            raise exceptions.ItemSaveError('You cannot save over an existing item.')

        return button
コード例 #5
0
 def setUp(self):
     try:
         self.qtApp = QApplication([])
     except RuntimeError:
         self.qtApp = QApplication.instance()
     self.gui = SimpleGui()
     QApplication.processEvents()
コード例 #6
0
ファイル: pyblish_lite_nuke.py プロジェクト: tws0002/Nuke-2
def _pyblish_action(name, is_reset=True):

    if nuke.value('root.name', None):
        Window.dock()

    window_ = Window.instance
    assert isinstance(window_, Window)
    controller = window_.controller
    assert isinstance(controller, control.Controller)

    start = getattr(window_, name)
    signal = {'publish': controller.was_published,
              'validate': controller.was_validated}[name]

    finish_event = multiprocessing.Event()
    _after_signal(signal, finish_event.set)

    if is_reset:
        # Run after reset finish.
        _after_signal(controller.was_reset, start)
        window_.reset()
    else:
        # Run directly.
        start()

    # Wait finish.
    while (not finish_event.is_set()
           or controller.is_running):
        QApplication.processEvents()
コード例 #7
0
    def leaveEvent(self, event):
        """
        Overrides base QFrame leaveEvent function
        :param event: QEvent
        """

        QApplication.restoreOverrideCursor()
コード例 #8
0
ファイル: correctiveInterface.py プロジェクト: tfart/Simplex
def outputCorrectiveReferences(outNames, outRefs, simplex, mesh, poses, sliders, pBar=None):
	'''
	Output the proper files for an external corrective application

	Arguments:
		outNames: The filepath for the output shape and reference indices
		outRefs: The filepath for the deformation references
		simplex: A simplex system
		mesh: The mesh object to deform
		poses: Lists of parameter/value pairs. Each list corresponds to a slider
		sliders: The simplex sliders that correspond to the poses
	'''
	refs, shapes, refIdxs = buildCorrectiveReferences(mesh, simplex, poses, sliders, pBar)

	if pBar is not None:
		pBar.setLabelText('Writing Names')
		QApplication.processEvents()
	nameWrite = ['{};{}'.format(s.name, r) for s, r, in zip(shapes, refIdxs)]
	with open(outNames, 'w') as f:
		f.write('\n'.join(nameWrite))

	if pBar is not None:
		pBar.setLabelText('Writing References')
		QApplication.processEvents()
	refs.dump(outRefs)
コード例 #9
0
ファイル: __main__.py プロジェクト: ZedThree/pyxpad
def main():
    """
    Data visualisation and analysis tool in Python,
    intended to be familiar to users of XPAD.

    Primarily for IDAM data from the MAST tokamak experiment,
    but can be used to view NetCDF files currently.
    """
    # Add command line arguments
    parser = argparse.ArgumentParser(description=main.__doc__)
    parser.add_argument("-c",
                        "--config",
                        nargs=1,
                        help="Config file to load",
                        default=None)
    parser.add_argument(
        "-i",
        "--ignore-config",
        help="Ignore existing config files",
        action="store_true",
        default=False,
    )
    parser.add_argument("-v",
                        "--version",
                        action="version",
                        version="%(prog)s {}".format(version))
    args = parser.parse_args()

    loadfile = args.config[0] if args.config is not None else None

    app = QApplication(sys.argv)
    window = PyXPad(loadfile=loadfile, ignoreconfig=args.ignore_config)
    window.show()
    sys.exit(app.exec_())
コード例 #10
0
ファイル: main.py プロジェクト: eyllanesc/QtExamples
def main():
    import sys

    app = QApplication(sys.argv)

    layout = QVBoxLayout()

    infos = QSerialPortInfo.availablePorts()
    for info in infos:
        s = (
            f"Port: {info.portName()}",
            f"Location: {info.systemLocation()}",
            f"Description: {info.description()}",
            f"Manufacturer: {info.manufacturer()}",
            f"Serial number: {info.serialNumber()}",
            "Vendor Identifier: " + f"{info.vendorIdentifier():x}"
            if info.hasVendorIdentifier()
            else "",
            "Product Identifier: " + f"{info.productIdentifier():x}"
            if info.hasProductIdentifier()
            else "",
        )
        label = QLabel("\n".join(s))
        layout.addWidget(label)

    workPage = QWidget()
    workPage.setLayout(layout)

    area = QScrollArea()
    area.setWindowTitle("Info about all available serial ports.")
    area.setWidget(workPage)
    area.show()

    sys.exit(app.exec_())
コード例 #11
0
def main():
    import sys

    app = QApplication(sys.argv)
    dialog = Dialog()
    dialog.show()
    sys.exit(app.exec_())
コード例 #12
0
ファイル: xsiInterface.py プロジェクト: phmongeau/Simplex
	def exportABC(self, dccMesh, abcMesh, js, pBar=None):
		# dccMesh doesn't work in XSI, so just ignore it
		# export the data to alembic
		shapeDict = {i.name:i for i in self.simplex.shapes}
		shapes = [shapeDict[i] for i in js["shapes"]]
		faces, counts = self._exportABCFaces(self.mesh)
		schema = abcMesh.getSchema()

		if pBar is not None:
			pBar.show()
			pBar.setMaximum(len(shapes))

		#deactivate evaluation above modeling to insure no deformations are present
		dcc.xsi.DeactivateAbove("%s.modelingmarker" %self.mesh.ActivePrimitive, True)

		for i, shape in enumerate(shapes):
			if pBar is not None:
				pBar.setValue(i)
				QApplication.processEvents()
				if pBar.wasCanceled():
					return
			verts = self._exportABCVertices(self.mesh, shape)
			abcSample = OPolyMeshSchemaSample(verts, faces, counts)
			schema.set(abcSample)

		dcc.xsi.DeactivateAbove("%s.modelingmarker" %self.mesh.ActivePrimitive, "")
コード例 #13
0
ファイル: applyCorrectives.py プロジェクト: tfart/Simplex
def readAndApplyCorrectives(inPath, namePath, refPath, outPath, pBar=None):
    '''
	Read the provided files, apply the correctives, then output a new file

	Arguments:
		inPath: The input .smpx file
		namePath: A file correlating the shape names, and the reference
			indices. Separated by ; with one entry per line
		refPath: The reference matrices per point of deformation.
			Created by npArray.dump(refPath)
		outPath: The output .smpx filepath
	'''

    if pBar is not None:
        pBar.setLabelText("Reading reference data")
        QApplication.processEvents()

    jsString, simplex, solver, allShapePts, restPts = loadSimplex(inPath)
    with open(namePath, 'r') as f:
        nr = f.read()
    nr = [i.split(';') for i in nr.split('\n') if i]
    names, refIdxs = zip(*nr)
    refIdxs = map(int, refIdxs)
    refs = np.load(refPath)
    simplex = Simplex()
    simplex.loadJSON(jsString)

    shapeByName = {i.name: i for i in simplex.shapes}
    shapes = [shapeByName[n] for n in names]
    newPts = applyCorrectives(simplex, allShapePts, restPts, solver, shapes,
                              refIdxs, refs, pBar)
    writeSimplex(inPath, outPath, newPts, pBar=pBar)
    print "DONE"
コード例 #14
0
ファイル: applyCorrectives.py プロジェクト: tfart/Simplex
def _writeSimplex(oarch, name, jsString, faces, counts, newShapes, pBar=None):
    ''' Separate the writer from oarch creation so garbage
	collection *hopefully* works as expected
	'''
    par = OXform(oarch.getTop(), name)
    props = par.getSchema().getUserProperties()
    prop = OStringProperty(props, "simplex")
    prop.setValue(str(jsString))
    abcMesh = OPolyMesh(par, name)
    schema = abcMesh.getSchema()

    if pBar is not None:
        pBar.setLabelText('Writing Corrected Simplex')
        pBar.setMaximum(len(newShapes))

    for i, newShape in enumerate(newShapes):
        if pBar is not None:
            pBar.setValue(i)
            QApplication.processEvents()
        else:
            print "Writing {0: 3d} of {1}\r".format(i, len(newShapes)),

        verts = mkSampleVertexPoints(newShape)
        abcSample = OPolyMeshSchemaSample(verts, faces, counts)
        schema.set(abcSample)
    if pBar is None:
        print "Writing {0: 3d} of {1}".format(len(newShapes), len(newShapes))
コード例 #15
0
def main():

    app = QApplication(sys.argv)

    w = MainWindow()
    w.show()
    sys.exit(app.exec_())
コード例 #16
0
def main():
    """ Main """

    # Process command-line arguments
    filename = None
    for arg in sys.argv[1:]:
        if arg in ('-h', '--help'):
            print(__doc__)
            sys.exit(0)

        filename = arg

    # Start up the QApplication
    app = QApplication([])
    from minibar.gui import mbWidgetStyling
    mbWidgetStyling.styleTheApplication()
    window = PartEdit()

    # Open file if provided
    if filename:
        window.open(filename)

    window.show()

    # Configure ctrl-q to quit
    QShortcut(QKeySequence(Qt.CTRL + Qt.Key_Q), window, window.close)

    # Go
    app.exec_()
コード例 #17
0
 def mousePressEvent(self, event):
     if event.button() == Qt.LeftButton and self.can_scroll():
         self._scrolling = True
         self._scroll_init_y = event.globalY()
         self._scroll_init_val = self.verticalScrollBar().value()
         QApplication.setOverrideCursor(Qt.ClosedHandCursor)
     event.accept()
コード例 #18
0
 def mouseReleaseEvent(self, event):
     if self._scrolling:
         QApplication.restoreOverrideCursor()
     self._scrolling = False
     self._scroll_init_y = 0
     self._scroll_init_val = 0
     event.accept()
コード例 #19
0
    def startDrag(self, o, e):
        if self._dragStart is None:
            self._dragStart = e.pos()
            dtop = QApplication.desktop()
            sn = dtop.screenNumber(o.mapToGlobal(e.pos()))
            self._screen = dtop.availableGeometry(sn)

        if abs(e.x() - self._dragStart.x()) > self.startSensitivity:
            self._dragType = self.DRAG_HORIZONTAL
        elif abs(e.y() - self._dragStart.y()) > self.startSensitivity:
            self._dragType = self.DRAG_VERTICAL

        if self._dragType:
            self._leftover = 0
            self._lastPos = e.pos()
            self._firstDrag = True

            self.dragPressed.emit()
            self.doOverrideCursor()

            if self.isSpinbox:
                if e.buttons() & self.dragButton:
                    # Send mouseRelease to spin buttons when dragging
                    # otherwise the spinbox will keep ticking.  @longClickFix
                    # There's gotta be a better way to do this :-/
                    mouseup = QMouseEvent(QEvent.MouseButtonRelease, e.pos(),
                                          self.dragButton, e.buttons(),
                                          e.modifiers())
                    QApplication.sendEvent(o, mouseup)
コード例 #20
0
	def exportABC(self, dccMesh, abcMesh, js, world=False, pBar=None):
		# export the data to alembic
		if dccMesh is None:
			dccMesh = self.mesh

		shapeDict = {i.name:i for i in self.simplex.shapes}
		shapes = [shapeDict[i] for i in js["shapes"]]
		faces, counts = self._exportABCFaces(dccMesh)
		schema = abcMesh.getSchema()

		if pBar is not None:
			pBar.show()
			pBar.setMaximum(len(shapes))

		with disconnected(self.shapeNode) as cnx:
			shapeCnx = cnx[self.shapeNode]
			for v in shapeCnx.itervalues():
				cmds.setAttr(v, 0.0)
			for i, shape in enumerate(shapes):
				if pBar is not None:
					pBar.setValue(i)
					QApplication.processEvents()
					if pBar.wasCanceled():
						return
				cmds.setAttr(shape.thing, 1.0)
				verts = self._exportABCVertices(dccMesh, world=world)
				abcSample = OPolyMeshSchemaSample(verts, faces, counts)
				schema.set(abcSample)
				cmds.setAttr(shape.thing, 0.0)
コード例 #21
0
ファイル: partedit.py プロジェクト: wdas/partio
def main():
    """ Main """

    # Process command-line arguments
    filename = None
    for arg in sys.argv[1:]:
        if arg in ('-h', '--help'):
            print __doc__
            sys.exit(0)

        filename = arg

    # Start up the QApplication
    app = QApplication([])
    from minibar.gui import mbWidgetStyling
    mbWidgetStyling.styleTheApplication()
    window = PartEdit()

    # Open file if provided
    if filename:
        window.open(filename)

    window.show()

    # Configure ctrl-q to quit
    QShortcut( QKeySequence(Qt.CTRL + Qt.Key_Q), window, window.close )

    # Go
    app.exec_()
コード例 #22
0
def main():
    import sys

    QCoreApplication.setOrganizationName("QtExamples")
    QCoreApplication.setAttribute(Qt.AA_EnableHighDpiScaling)
    # QtWebEngine::initialize()

    if QT_NO_WIDGETS:
        app = QApplication(sys.argv)
    else:
        app = QGuiApplication(sys.argv)

    engine = QQmlApplicationEngine()
    server = Server(engine)

    engine.load(QUrl("qrc:/main.qml"))
    QTimer.singleShot(0, server.run)

    proxy = QNetworkProxy()
    proxy.setType(QNetworkProxy.HttpProxy)
    proxy.setHostName("localhost")
    proxy.setPort(5555)
    QNetworkProxy.setApplicationProxy(proxy)

    sys.exit(app.exec_())
コード例 #23
0
def autoCrawlMeshes(orderMesh,
                    shapeMesh,
                    skipMismatchedIslands=False,
                    pBar=None):
    """
	Crawl both the order and shape meshes using my heuristics to find
	any matching islands
	"""
    if pBar is not None:
        pBar.setLabelText("Finding Islands")
        pBar.setValue(66)
        QApplication.processEvents()

    fmg = fullMatchCoProcess(orderMesh,
                             shapeMesh,
                             skipMismatchedIslands=skipMismatchedIslands)
    matches = []
    errors = {}
    matchCount = 0
    check = 0
    found = False
    try:
        # Execute the generator up to the first yield, and get the data from it
        sm, curIdx = fmg.send(None)  #Send nothing the first time
        idxErrors = []
        while True:
            if pBar is not None:
                pBar.setLabelText("Crawling iteration {0}".format(check))
                pBar.setValue(0)
                QApplication.processEvents()
            check += 1
            try:
                print
                print "Checking Vertex Match", zip(*sm)
                match = matchByTopology(orderMesh,
                                        shapeMesh,
                                        sm,
                                        matchedNum=matchCount,
                                        vertNum=len(orderMesh.vertArray),
                                        pBar=pBar)
            except TopologyMismatch as err:
                idxErrors.append(str(err))
            else:
                matches.append(match)
                found = True
                matchCount += len(match)
            # send the return value into the generator,
            # execute up until the next yield and get the data from it
            sm, idx = fmg.send(found)
            if curIdx != idx:
                if not found:
                    errors[curIdx] = idxErrors
                idxErrors = []
                curIdx = idx
            found = False
    except StopIteration:
        if not found:
            raise TopologyMismatch("No Match Found")
    return matches
コード例 #24
0
def uvTransfer(
    srcFaces,
    srcUvFaces,
    srcVerts,
    srcUvs,
    tarFaces,
    tarUvFaces,
    tarVerts,
    tarUvs,
    tol=0.0001,
    pBar=None,
):
    """A helper function that transfers pre-loaded data.
        The source data will be transferred onto the tar data

    Parameters
    ----------
    srcFaces : [[int, ...], ...]
        The source vertex face list
    srcUvFaces : [[int, ...], ...]
        The source uv face list
    srcUvs : np.array
        The source UV positions
    tarFaces : [[int, ...], ...]
        The target vertex face list
    tarUvFaces : [[int, ...], ...]
        The target uv face list
    tarUvs : np.array
        The Target UV Positions
    srcVerts : np.array
        The source Vertex positions
    tarVerts : np.array
        The target Vertex positions
    tol : float
        A small tolerance value, defaulting to the global EPS
    pBar : QProgressDialog, optional
        An optional progress dialog

    Returns
    -------
    : np.array
        The new target vert positions

    """
    corr = getVertCorrelation(srcUvFaces,
                              srcUvs,
                              tarFaces,
                              tarUvFaces,
                              tarUvs,
                              tol=tol,
                              pBar=pBar)
    if pBar is not None:
        pBar.setValue(0)
        pBar.setLabelText("Apply Transfer")
        from Qt.QtWidgets import QApplication

        QApplication.processEvents()

    return applyTransfer(srcVerts, srcFaces, corr, len(tarVerts))
コード例 #25
0
    def on_transparentStyle_clicked(self):
        styleSheet = QFile(":/files/transparent.qss")

        if not styleSheet.open(QIODevice.ReadOnly):
            print("Unable to open :/files/transparent.qss")
            return

        QApplication.instance().setStyleSheet(styleSheet.readAll().data().decode())
コード例 #26
0
def application():
    """Get QApplication instance, create one if needed.  """

    app = QApplication.instance()

    if not app:
        app = QApplication(sys.argv)
    return app
コード例 #27
0
ファイル: main.py プロジェクト: mrals2018/QtExamples
def main():
    import sys

    app = QApplication(sys.argv)
    server = Server()
    QGuiApplication.setApplicationDisplayName(
        server.tr("Local Fortune Server"))
    server.show()
    sys.exit(app.exec_())
コード例 #28
0
def main():
    import sys

    app = QApplication(sys.argv)

    w = View()
    w.show()

    sys.exit(app.exec_())
コード例 #29
0
def main():
    app = QApplication([])
    Col = MainWindow.MainController()

    runAnimation()

    Col.view.showMaximized()

    app.exec_()
コード例 #30
0
ファイル: qtutils.py プロジェクト: tpDcc/tpDcc-libs-qt
def set_wait_cursor(state=True):
    """
    Sets the wait cursor as the cursor for current Qt application
    """

    if state:
        QApplication.setOverrideCursor(Qt.WaitCursor)
    else:
        restore_cursor()
コード例 #31
0
def main():
    """Entry point"""
    # Just starting the app returns in a sigsegv on close :/
    app = QApplication(sys.argv)
    #label = QLabel("<font color=red size=40>Hello World</font>")
    #label.show()
    editor = Editor()
    editor.show()
    res = app.exec_()
コード例 #32
0
ファイル: qt.py プロジェクト: renemilk/pyMor
 def _doit(factory):
     try:
         app = QApplication([])
     except RuntimeError:
         app = QCoreApplication.instance()
     main_window = factory()
     if getattr(sys, '_called_from_test', False) and is_windows_platform():
         QTimer.singleShot(500, app, Slot('quit()'))
     main_window.show()
     app.exec_()