当前位置: 首页>>代码示例>>Python>>正文


Python QGraphicsView.setScene方法代码示例

本文整理汇总了Python中PyQt5.QtWidgets.QGraphicsView.setScene方法的典型用法代码示例。如果您正苦于以下问题:Python QGraphicsView.setScene方法的具体用法?Python QGraphicsView.setScene怎么用?Python QGraphicsView.setScene使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PyQt5.QtWidgets.QGraphicsView的用法示例。


在下文中一共展示了QGraphicsView.setScene方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from PyQt5.QtWidgets import QGraphicsView [as 别名]
# 或者: from PyQt5.QtWidgets.QGraphicsView import setScene [as 别名]
 def __init__(self, conf, defeat):
     self.config = conf
     super().__init__()
     self.setWindowTitle(conf.get_text('victory'))
     self.setFixedSize(QSize(640, 480))
     self.setWindowFlags(Qt.WindowStaysOnTopHint | Qt.WindowTitleHint | Qt.FramelessWindowHint)
     button = QPushButton(conf.get_text('close'), self)
     button.setCheckable(True)
     button.setFixedSize(QSize(640, 30))
     button.move(0, 450)
     # noinspection PyUnresolvedReferences
     button.clicked.connect(self.close)
     result_output = QTextEdit(self)
     result_output.setReadOnly(True)
     result_output.setFixedSize(QSize(640, 200))
     result_output.move(0, 250)
     result_output.setLineWrapMode(QTextEdit.NoWrap)
     result_output.insertHtml(self.generate_result_text())
     gview = QGraphicsView(self)
     scene = QGraphicsScene()
     if defeat:
         img = conf.theme_selected.get_defeat_pixmap()
         text = conf.get_text('defeat')
     else:
         img = conf.theme_selected.get_victory_pixmap()
         text = conf.get_text('victory')
     scene.addPixmap(img.scaled(QSize(640, 220)))
     gview.move(0, 30)
     gview.setScene(scene)
     label_title = QLabel(self)
     label_title.setText(text)
     label_title.setFixedSize(QSize(640, 30))
     label_title.setAlignment(Qt.AlignCenter)
     label_title.setFont(self.get_font_title())
开发者ID:Trilarion,项目名称:imperialism-remake,代码行数:36,代码来源:landBattleResultView.py

示例2: __init__

# 需要导入模块: from PyQt5.QtWidgets import QGraphicsView [as 别名]
# 或者: from PyQt5.QtWidgets.QGraphicsView import setScene [as 别名]
    def __init__(self, *args):
        super(Demo, self).__init__(*args)
  
        loadUi('MainWindow.ui', self)
        scene = QGraphicsScene()

        rectItem = QGraphicsRectItem(QRectF(0, 0, 320, 240))
        rectItem.setBrush(Qt.red)
        #rectItem.setPen(Qt.NoPen)
        rectItem.setFlag(QGraphicsItem.ItemIsMovable)
        scene.addItem(rectItem)

        ellipseItem = QGraphicsEllipseItem(QRectF(0, 0, 200, 200))
        ellipseItem.setBrush(Qt.blue)
        #ellipseItem.setPen(Qt.NoPen)
        ellipseItem.setFlag(QGraphicsItem.ItemIsMovable)
        scene.addItem(ellipseItem)

        rectSizeGripItem = SizeGripItem(SimpleResizer(rectItem), rectItem)
        ellipseSizeGripItem = SizeGripItem(SimpleResizer(ellipseItem), ellipseItem)

        graphicsView = QGraphicsView(self)
        graphicsView.setScene(scene)

        self.setCentralWidget(graphicsView)
开发者ID:felipesanches,项目名称:sizegripitem_python,代码行数:27,代码来源:SizeGripItem_demo.py

示例3: main

# 需要导入模块: from PyQt5.QtWidgets import QGraphicsView [as 别名]
# 或者: from PyQt5.QtWidgets.QGraphicsView import setScene [as 别名]
def main(argv):
    signal.signal(signal.SIGINT, signal.SIG_DFL)

    app = QApplication([])
    scene = QGraphicsScene()
    view = QGraphicsView()

    thumbnails = []
    for filename in os.listdir(argv[1]):
        filename = os.path.join(argv[1], filename)
        print(filename)
        thumbnails.append(DBusThumbnailer.thumbnail_from_filename(filename, "large"))

    count = 0
    items = []
    for y in range(0, 100000, 150):
        for x in range(0, 2500, 150):
            scene.addRect(x, y, 128, 128)

            # image = QImage(128, 128, QImage.Format_RGB32)
            if count < len(thumbnails):
                print(thumbnails[count])
                image = QImage(thumbnails[count])
            else:
                arr = numpy.random.randint(0, 2**32, (128, 128), dtype=numpy.uint32)
                image = QImage(arr, 128, 128, 128 * 4, QImage.Format_ARGB32)
            pixmap = QPixmap.fromImage(image)

            item = QGraphicsPixmapItem(pixmap)
            scene.addItem(item)

            text = scene.addText("Test Textual: {}".format(count))
            item.setPos(x, y)
            text.setPos(x, y + 128)
            count += 1

            item.setFlags(QGraphicsItem.ItemIsSelectable)
            item.setAcceptHoverEvents(True)

            items.append([item, text])
    print(count)

    if False:
        random.shuffle(items)
        i = 0
        for y in range(0, 100000, 150):
            for x in range(0, 2500, 150):
                for item in items[i]:
                        item.setPos(x, y)
                i += 1

    view.setScene(scene)
    view.resize(800, 600)
    view.show()
    app.exec()
开发者ID:Grumbel,项目名称:dirtool,代码行数:57,代码来源:qgraphicperf.py

示例4: QNEMainWindow

# 需要导入模块: from PyQt5.QtWidgets import QGraphicsView [as 别名]
# 或者: from PyQt5.QtWidgets.QGraphicsView import setScene [as 别名]
class QNEMainWindow(QMainWindow):
    def __init__(self, parent):
        super(QNEMainWindow, self).__init__(parent)

        quitAct = QAction("&Quit", self, shortcut="Ctrl+Q",
            statusTip="Exit the application", triggered=self.close)

        addAct = QAction("&Add", self, statusTip="Add a block", triggered=self.addBlock)

        fileMenu = self.menuBar().addMenu("&File")
        fileMenu.addAction(addAct)
        fileMenu.addSeparator()
        fileMenu.addAction(quitAct)

        self.setWindowTitle("Node Editor")

        self.scene = QGraphicsScene(self)
        self.view = QGraphicsView(self)
        self.view.setScene(self.scene)
        self.view.setRenderHint(QPainter.Antialiasing)
        self.setCentralWidget(self.view)

        self.nodesEditor = QNodesEditor(self)
        self.nodesEditor.install(self.scene)

        block = QNEBlock(None)
        self.scene.addItem(block)
        block.addPort("test", 0, QNEPort.NamePort)
        block.addPort("TestBlock", 0, QNEPort.TypePort)
        block.addInputPort("in1");
        block.addInputPort("in2");
        block.addInputPort("in3");
        block.addOutputPort("out1");
        block.addOutputPort("out2");
        block.addOutputPort("out3");

        block = block.clone()
        block.setPos(150,0)

        block = block.clone()
        block.setPos(150,150)


    def addBlock(self):
        import random
        import math

        block = QNEBlock(None)

        self.scene.addItem(block)
        names = ["Vin", "Voutsadfasdf", "Imin", "Imax", "mul", "add", "sub", "div", "Conv", "FFT"]
        for i in range(0,math.floor(random.uniform(3,8))):
            block.addPort(random.choice(names), random.random()>0.5)
        block.setPos(self.view.sceneRect().center().toPoint())
开发者ID:sphaero,项目名称:pyQNodesEditor,代码行数:56,代码来源:qnemainwindow.py

示例5: actionPrintSlot

# 需要导入模块: from PyQt5.QtWidgets import QGraphicsView [as 别名]
# 或者: from PyQt5.QtWidgets.QGraphicsView import setScene [as 别名]
 def actionPrintSlot(self) -> None:
     printer = QPrinter()
     printer.setPageOrientation(QPageLayout.Landscape)
     if QPrintDialog(printer).exec_():
         painter = QPainter(printer)
         painter.setRenderHint(QPainter.Antialiasing)
         view = QGraphicsView()
         view.setScene(self.scene)
         view.setSceneRect(QRectF(0, 0, 290, 200))
         view.fitInView(QRectF(0, 0, 290, 200), Qt.KeepAspectRatio)
         view.scale(1, -1)
         view.render(painter)
         del painter  # necessary, thanks Qt
开发者ID:Longhanks,项目名称:QGVisualizer,代码行数:15,代码来源:mainwindow.py

示例6: MainWindow

# 需要导入模块: from PyQt5.QtWidgets import QGraphicsView [as 别名]
# 或者: from PyQt5.QtWidgets.QGraphicsView import setScene [as 别名]
class MainWindow(QWidget):
    # 定数
    WINDOW_WIDTH = 160
    WINDOW_HEIGHT = 144
    FPS = 60
    
    def __init__(self, parent=None):
        super(MainWindow, self).__init__(parent)
        
        self.graphicsView = QGraphicsView()
        
        scene = QGraphicsScene(self.graphicsView)
        scene.setSceneRect(0, 0, MainWindow.WINDOW_WIDTH, MainWindow.WINDOW_HEIGHT)
         
        self.graphicsView.setScene(scene)
        self.screen = Screen(MainWindow.WINDOW_WIDTH, MainWindow.WINDOW_HEIGHT)
        
        scene.addItem(self.screen)

        mainLayout = QHBoxLayout()
        mainLayout.setAlignment(Qt.AlignTop)
        mainLayout.addWidget(self.graphicsView)

        self.setLayout(mainLayout)
        self.setWindowTitle("Coup")
        self.updating_rule = False
        self.show()
        
        # タイマースタート
        self.timer = QTimer()
        self.timer.setInterval(int(1000 / MainWindow.FPS))
        self.timer.timeout.connect(self.timeout)
        self.timer.start()
        
    def timeout(self):
        self.screen.gameObj.run()
        self.screen.update()
        self.screen.gameObj.gameTime += 1

    def reset(self):
        self.screen.gameObj.reset()
        self.screen.update()
        
    def keyPressEvent(self, e):
        self.screen.gameObj.keyPressEvent(e)
开发者ID:fluffyOkitsune,项目名称:Coup,代码行数:47,代码来源:coup.py

示例7: main

# 需要导入模块: from PyQt5.QtWidgets import QGraphicsView [as 别名]
# 或者: from PyQt5.QtWidgets.QGraphicsView import setScene [as 别名]
def main():

    app = QApplication(sys.argv)

    grview = QGraphicsView()
    scene = QGraphicsScene()
    scene.setSceneRect(0, 0, 680, 459)

    scene.addPixmap(QPixmap('../images/phototest.tif'))
    grview.setScene(scene)

    item = AreaItem(0, 0, 300, 150)
    item.areaColor = QColor(155, 155, 0, 75)
    scene.addItem(item)

    grview.fitInView(scene.sceneRect(), Qt.KeepAspectRatio)
    grview.show()
    sys.exit(app.exec_())
开发者ID:zdenop,项目名称:pyTesseractDemo,代码行数:20,代码来源:areaitem.py

示例8: addItem

# 需要导入模块: from PyQt5.QtWidgets import QGraphicsView [as 别名]
# 或者: from PyQt5.QtWidgets.QGraphicsView import setScene [as 别名]
    def addItem(self, graphicsView: QGraphicsView, item: CharItem) -> QGraphicsScene:
        """ Add Item to one of the 2 windows

            Args:
                graphicsView (QGraphicsView): The graphics view to put the item in
                item         (CharItem)     : The char item to put in the view

            Returns:
                QGraphicsScene  : The graphics scene created for the view
        """

        scene = QGraphicsScene()
        graphicsView.setScene(scene)
        newItem = CharItem(QRectF(0, 0, mainItemWidth, mainItemHeight), QPointF(mainItemPadding, mainItemPadding))
        copiedItem = QByteArray()
        stream = QDataStream(copiedItem, QIODevice.WriteOnly)
        item.save(stream, item.filename)
        stream = QDataStream(copiedItem, QIODevice.ReadOnly)
        newItem.load(stream, item.filename)
        scene.addItem(newItem)
        scene.setSceneRect(0, 0, mainItemWidth + 2 * mainItemPadding + 6, mainItemHeight + 2 * mainItemPadding)
        return scene
开发者ID:IlanHindy,项目名称:AI-Learn,代码行数:24,代码来源:CharacterIdentifier.py

示例9: CarlaPatchbayW

# 需要导入模块: from PyQt5.QtWidgets import QGraphicsView [as 别名]
# 或者: from PyQt5.QtWidgets.QGraphicsView import setScene [as 别名]
class CarlaPatchbayW(QFrame, PluginEditParentMeta, HostWidgetMeta):
#class CarlaPatchbayW(QFrame, PluginEditParentMeta, HostWidgetMeta, metaclass=PyQtMetaClass):
    def __init__(self, parent, host, doSetup = True, onlyPatchbay = True, is3D = False):
        QFrame.__init__(self, parent)
        self.host = host

        if False:
            # kdevelop likes this :)
            host = CarlaHostMeta()
            self.host = host

        # -------------------------------------------------------------

        self.fLayout = QGridLayout(self)
        self.fLayout.setContentsMargins(0, 0, 0, 0)
        self.fLayout.setSpacing(1)
        self.setLayout(self.fLayout)

        self.fView = QGraphicsView(self)
        self.fKeys = PixmapKeyboardHArea(self)

        self.fPeaksIn  = DigitalPeakMeter(self)
        self.fPeaksOut = DigitalPeakMeter(self)
        self.fPeaksCleared = True

        self.fPeaksIn.setColor(DigitalPeakMeter.BLUE)
        self.fPeaksIn.setChannels(2)
        self.fPeaksIn.setOrientation(DigitalPeakMeter.VERTICAL)
        self.fPeaksIn.setFixedWidth(25)

        self.fPeaksOut.setColor(DigitalPeakMeter.GREEN)
        self.fPeaksOut.setChannels(2)
        self.fPeaksOut.setOrientation(DigitalPeakMeter.VERTICAL)
        self.fPeaksOut.setFixedWidth(25)

        self.fLayout.addWidget(self.fPeaksIn, 0, 0)
        self.fLayout.addWidget(self.fView, 0, 1) # self.fViewWidget if is3D else
        self.fLayout.addWidget(self.fPeaksOut, 0, 2)
        self.fLayout.addWidget(self.fKeys, 1, 0, 1, 0)

        # -------------------------------------------------------------
        # Internal stuff

        self.fParent      = parent
        self.fPluginCount = 0
        self.fPluginList  = []

        self.fExternalPatchbay = False
        self.fIsOnlyPatchbay   = onlyPatchbay
        self.fSelectedPlugins  = []

        self.fCanvasWidth  = 0
        self.fCanvasHeight = 0

        # -------------------------------------------------------------
        # Set-up Canvas Preview

        self.fMiniCanvasPreview = self.fParent.ui.miniCanvasPreview
        self.fMiniCanvasPreview.setRealParent(self)
        self.fMovingViaMiniCanvas = False

        # -------------------------------------------------------------
        # Set-up Canvas

        self.scene = patchcanvas.PatchScene(self, self.fView)
        self.fView.setScene(self.scene)
        self.fView.setRenderHint(QPainter.Antialiasing, bool(parent.fSavedSettings[CARLA_KEY_CANVAS_ANTIALIASING] == patchcanvas.ANTIALIASING_FULL))

        if parent.fSavedSettings[CARLA_KEY_CANVAS_USE_OPENGL] and hasGL: # and not is3D:
            self.fViewWidget = QGLWidget(self)
            self.fView.setViewport(self.fViewWidget)
            self.fView.setRenderHint(QPainter.HighQualityAntialiasing, parent.fSavedSettings[CARLA_KEY_CANVAS_HQ_ANTIALIASING])

        self.setupCanvas()

        QTimer.singleShot(100, self.slot_restoreScrollbarValues)

        # -------------------------------------------------------------
        # Connect actions to functions

        parent.ui.act_settings_show_meters.toggled.connect(self.slot_showCanvasMeters)
        parent.ui.act_settings_show_keyboard.toggled.connect(self.slot_showCanvasKeyboard)

        self.fView.horizontalScrollBar().valueChanged.connect(self.slot_horizontalScrollBarChanged)
        self.fView.verticalScrollBar().valueChanged.connect(self.slot_verticalScrollBarChanged)

        self.scene.scaleChanged.connect(self.slot_canvasScaleChanged)
        self.scene.sceneGroupMoved.connect(self.slot_canvasItemMoved)
        self.scene.pluginSelected.connect(self.slot_canvasPluginSelected)

        self.fMiniCanvasPreview.miniCanvasMoved.connect(self.slot_miniCanvasMoved)

        self.fKeys.keyboard.noteOn.connect(self.slot_noteOn)
        self.fKeys.keyboard.noteOff.connect(self.slot_noteOff)

        # -------------------------------------------------------------
        # Load Settings

        settings = QSettings()

#.........这里部分代码省略.........
开发者ID:denisfitz57,项目名称:Carla,代码行数:103,代码来源:carla_patchbay.py

示例10: RunTimeGui

# 需要导入模块: from PyQt5.QtWidgets import QGraphicsView [as 别名]
# 或者: from PyQt5.QtWidgets.QGraphicsView import setScene [as 别名]
class RunTimeGui(QMainWindow):

    activeStateChanged = pyqtSignal(int)
    runningStateChanged = pyqtSignal(int)
    loadFromRoot = pyqtSignal(int)

    def __init__(self, parent=None):
        super(QMainWindow, self).__init__()

        self.setWindowTitle("VisualStates RunTime GUI")

        self.rootState = None

        # create status bar
        self.statusBar()

        self.createTreeView()
        self.createStateCanvas()

        self.setGeometry(0, 0, 800, 600)
        self.show()

        self.states = {}
        self.transitions = {}

        self.activeState = None

        self.activeStateChanged.connect(self.activeStateChangedHandle)
        self.runningStateChanged.connect(self.runningStateChangedHandle)
        self.loadFromRoot.connect(self.loadFromRootHandle)

        self.memory = None
        self.ipcThread = None

    def createTreeView(self):
        dockWidget = QDockWidget()
        dockWidget.setAllowedAreas(Qt.LeftDockWidgetArea)
        dockWidget.setFeatures(QDockWidget.NoDockWidgetFeatures)
        dockWidget.setTitleBarWidget(QWidget())
        self.treeView = QTreeView()
        self.treeView.clicked.connect(self.treeItemClicked)
        self.treeModel = TreeModel()
        self.treeView.setModel(self.treeModel)

        self.logo = QLabel()
        logoPixmap = QPixmap(CMAKE_INSTALL_PREFIX + '/share/jderobot/resources/jderobot.png')
        self.logo.setPixmap(logoPixmap)

        self.upButton = QPushButton()
        self.upButton.setText('Up')
        self.upButton.clicked.connect(self.upButtonClicked)

        leftContainer = QWidget()
        leftLayout = QVBoxLayout()
        leftLayout.addWidget(self.treeView)
        leftLayout.addWidget(self.upButton)
        leftLayout.addWidget(self.logo)
        leftContainer.setLayout(leftLayout)

        dockWidget.setWidget(leftContainer)
        self.addDockWidget(Qt.LeftDockWidgetArea, dockWidget)

    def createStateCanvas(self):
        self.stateCanvas = QGraphicsView()
        self.scene = QGraphicsScene()
        self.scene.setSceneRect(0, 0, 2000, 2000)

        self.setCentralWidget(self.stateCanvas)
        self.stateCanvas.setScene(self.scene)
        self.stateCanvas.setRenderHint(QPainter.Antialiasing)


    def addState(self, id, name, initial, x, y, parentId):
        if parentId is not None:
            self.states[id] = State(id, name, initial, self.states[parentId])
            self.states[parentId].addChild(self.states[id])
            parentItem = self.treeModel.getByDataId(parentId)
            # print('parent:' + str(parentItem))
        else:
            self.states[id] = State(id, name, initial, None)
        if id == 0:
            self.rootState = self.states[id]

        self.states[id].setPos(x, y)

    def addTransition(self, id, name, originId, destinationId, x, y):
        self.transitions[id] = Transition(id, name, self.states[originId], self.states[destinationId])
        self.transitions[id].setPos(x, y)

    def emitRunningStateById(self, id):
        # print('emit running state:' + str(id))
        self.runningStateChanged.emit(id)

    def runningStateChangedHandle(self, id):
        # print('running state:' + str(id))
        if id not in self.states:
            return

        runningState = self.states[id]

#.........这里部分代码省略.........
开发者ID:reysam93,项目名称:JdeRobot,代码行数:103,代码来源:runtimegui.py

示例11: MainWindow

# 需要导入模块: from PyQt5.QtWidgets import QGraphicsView [as 别名]
# 或者: from PyQt5.QtWidgets.QGraphicsView import setScene [as 别名]
class MainWindow(QWidget):
    def __init__(self, parent=None):
        super(MainWindow, self).__init__(parent)

        self.graphicsView = QGraphicsView()
        scene = QGraphicsScene(self.graphicsView)
        scene.setSceneRect(0, 0, 400, 400)
        self.graphicsView.setScene(scene)
        self.celluarAutomaton = CelllarAutomaton(400,400)
        scene.addItem(self.celluarAutomaton)

        validator = QIntValidator(0,1)
        ruleLayout = QGridLayout()
        ruleLayout.setAlignment(Qt.AlignTop)
        self.ruleEdits = []
        for i in range(7,-1,-1):
            ruleEdit = QLineEdit()
            ruleEdit.setValidator(validator)
            ruleEdit.setText("0")
            ruleEdit.setFixedWidth(30)
            ruleEdit.textEdited.connect(self.update_rule)
            ruleLayout.addWidget(QLabel("{0:03b}".format(i)), 0, 7-i)
            ruleLayout.addWidget(ruleEdit, 1,7-i)
            self.ruleEdits.append(ruleEdit)

        validator2 = QIntValidator(0,255)
        self.rule10Edit = QLineEdit()
        self.rule10Edit.setValidator(validator2)
        self.rule10Edit.textEdited.connect(self.update_rule10)
        rule10Layout = QHBoxLayout()
        rule10Layout.addWidget(QLabel("Rule"))
        rule10Layout.addWidget(self.rule10Edit)

        self.resetButton = QPushButton("&Reset")
        self.resetButton.clicked.connect(self.reset)
        self.randomInitButton = QPushButton("&Random init")
        self.randomInitButton.clicked.connect(self.randomInit)
        self.nextButton = QPushButton("&Next")
        self.nextButton.clicked.connect(self.do_next)
        self.prevButton = QPushButton("&Prev")
        self.prevButton.clicked.connect(self.do_prev)
        self.autoButton = QPushButton("&Auto")
        self.autoButton.clicked.connect(self.auto)
        self.stopButton = QPushButton("&Stop")
        self.stopButton.clicked.connect(self.stop)
        buttonLayout = QVBoxLayout()
        buttonLayout.addWidget(self.resetButton)
        buttonLayout.addWidget(self.randomInitButton)
        buttonLayout.addWidget(self.nextButton)
        buttonLayout.addWidget(self.prevButton)
        buttonLayout.addWidget(self.autoButton)
        buttonLayout.addWidget(self.stopButton)

        propertyLayout = QVBoxLayout()
        propertyLayout.setAlignment(Qt.AlignTop)
        propertyLayout.addLayout(ruleLayout)
        propertyLayout.addLayout(rule10Layout)
        propertyLayout.addLayout(buttonLayout)

        mainLayout = QHBoxLayout()
        mainLayout.setAlignment(Qt.AlignTop)
        mainLayout.addWidget(self.graphicsView)
        mainLayout.addLayout(propertyLayout)

        self.setLayout(mainLayout)
        self.setWindowTitle("Cellular Automaton")
        self.updating_rule = False
        self.rule10Edit.setText("90")
        self.update_rule10()
        self.timer = None

    def update_rule(self):
        if self.updating_rule: return
        rule = 0
        for i in range(8):
            n = self.ruleEdits[i].text()
            if n == "": return
            rule = (rule << 1) + int(n)
        self.updating_rule = True
        self.rule10Edit.setText(str(rule))
        self.updating_rule = False

    def update_rule10(self):
        n = self.rule10Edit.text()
        if n == "": return
        rule = int(n)
        self.updating_rule = True
        for i in range(7,-1,-1):
            self.ruleEdits[i].setText(str(rule & 0b1))
            rule >>= 1
        self.updating_rule = False

    def do_next(self):
        n = self.rule10Edit.text()
        return self.celluarAutomaton.do_next(int(n))

    def do_prev(self):
        self.celluarAutomaton.do_prev()

    def reset(self):
#.........这里部分代码省略.........
开发者ID:mmisono,项目名称:pyqt5-example,代码行数:103,代码来源:cellular_automaton.py

示例12: QGraphicsView

# 需要导入模块: from PyQt5.QtWidgets import QGraphicsView [as 别名]
# 或者: from PyQt5.QtWidgets.QGraphicsView import setScene [as 别名]
    w = QtWidgets.QWidget()
    v = QGraphicsView()

    def quit():
        print("Connection closed by server")
        app.quit()

    iface = NetworkInterface()
    t = QtCore.QThread()
    iface.moveToThread(t)
    t.start()
    QtCore.QMetaObject.invokeMethod(iface, "run", Qt.QueuedConnection)

    scene = QGraphicsScene(v)
    v.setRenderHints(QtGui.QPainter.HighQualityAntialiasing)
    v.setScene(scene)

    size = blobs.BOARD_SIZE
    v.fitInView(0, 0, size, size)
    field = GameField(size, scene)
    iface.dataReceived.connect(field.update, Qt.QueuedConnection)
    iface.connectionClosed.connect(quit)

    w.setLayout(QtWidgets.QHBoxLayout())
    w.resize(800, 600)
    w.layout().addWidget(v)
    w.setWindowFlags(Qt.Dialog)
    w.show()
    
    app.exec_()
开发者ID:scummos,项目名称:blobs,代码行数:32,代码来源:paint.py

示例13: Spectrum

# 需要导入模块: from PyQt5.QtWidgets import QGraphicsView [as 别名]
# 或者: from PyQt5.QtWidgets.QGraphicsView import setScene [as 别名]

#.........这里部分代码省略.........
        This function is necessary it reads the data and it sends it to
        self.display. When the user selects a smaller chunk of data from the
        visible traces, then we don't need to call this function.
        """
        if self.idx_chan.count() == 0:
            self.update()

        chan_name = self.idx_chan.currentText()
        lg.info('Power spectrum for channel ' + chan_name)

        if chan_name:
            trial = 0
            data = self.parent.traces.data(trial=trial, chan=chan_name)
            self.display(data)
        else:
            self.scene.clear()

    def display(self, data):
        """Make graphicsitem for spectrum figure.

        Parameters
        ----------
        data : ndarray
            1D vector containing the data only

        This function can be called by self.display_window (which reads the
        data for the selected channel) or by the mouse-events functions in
        traces (which read chunks of data from the user-made selection).
        """
        value = self.config.value
        self.scene = QGraphicsScene(value['x_min'], value['y_min'],
                                    value['x_max'] - value['x_min'],
                                    value['y_max'] - value['y_min'])
        self.idx_fig.setScene(self.scene)

        self.add_grid()
        self.resizeEvent(None)

        s_freq = self.parent.traces.data.s_freq
        f, Pxx = welch(data, fs=s_freq,
                       nperseg=int(min((s_freq, len(data)))))  # force int

        freq_limit = (value['x_min'] <= f) & (f <= value['x_max'])

        if self.config.value['log']:
            Pxx_to_plot = log(Pxx[freq_limit])
        else:
            Pxx_to_plot = Pxx[freq_limit]

        self.scene.addPath(Path(f[freq_limit], Pxx_to_plot),
                           QPen(QColor(LINE_COLOR), LINE_WIDTH))

    def add_grid(self):
        """Add axis and ticks to figure.

        Notes
        -----
        I know that visvis and pyqtgraphs can do this in much simpler way, but
        those packages create too large a padding around the figure and this is
        pretty fast.

        """
        value = self.config.value

        # X-AXIS
        # x-bottom
开发者ID:gpiantoni,项目名称:phypno,代码行数:70,代码来源:spectrum.py

示例14: MainWindow

# 需要导入模块: from PyQt5.QtWidgets import QGraphicsView [as 别名]
# 或者: from PyQt5.QtWidgets.QGraphicsView import setScene [as 别名]

#.........这里部分代码省略.........
        #     try:
        #         with open(infile, 'w+') as in_f:
        #             for line in in_f:
        #                 line = line.replace(u":",":")
        #                 in_f.write(line)
        #     except Exception,inst:
        #         print infile

        self.process_thread = WorkThread()
        self.process_thread.trigger.connect(self.finished)
        self.process_thread.beginRun(self.in_parameters)

    def finished(self):

        #绘制闪电密度图
        ##清除上一次的QGraphicsView对象,防止其记录上一次图片结果,影响显示效果
        self.density_view.setAttribute(Qt.WA_DeleteOnClose)
        self.verticalLayout_2.removeWidget(self.density_view)
        size = self.density_view.size()
        self.density_view.close()

        self.density_view = QGraphicsView(self.density_tab)
        self.density_view.setObjectName("density_view")
        self.density_view.resize(size)
        self.verticalLayout_2.addWidget(self.density_view)

        densityPic = ''.join([cwd,u'/bulletinTemp/',
            self.in_parameters[u'datetime'],u'/',self.in_parameters[u'datetime'],
            self.in_parameters[u'target_area'],u'闪电密度空间分布.tif'])

        scene = QGraphicsScene()
        pixmap_density = QPixmap(densityPic)
        scene.addPixmap(pixmap_density)
        self.density_view.setScene(scene)
        scale = float(self.density_view.width()) / pixmap_density.width()
        self.density_view.scale(scale, scale)

        #绘制雷暴日图
        self.day_view.setAttribute(Qt.WA_DeleteOnClose)
        self.verticalLayout.removeWidget(self.day_view)
        size = self.day_view.size()
        self.day_view.close()

        self.day_view = QGraphicsView(self.day_tab)
        self.day_view.setObjectName("day_view")
        self.day_view.resize(size)
        self.verticalLayout.addWidget(self.day_view)

        dayPic = ''.join([cwd,u'/bulletinTemp/',
            self.in_parameters[u'datetime'],u'/',self.in_parameters[u'datetime'],
            self.in_parameters[u'target_area'],u'地闪雷暴日空间分布.tif'])

        pixmap_day = QPixmap(dayPic)
        scene = QGraphicsScene()
        scene.addPixmap(pixmap_day)
        self.day_view.resize(self.density_view.width(),self.density_view.height())
        self.day_view.setScene(scene)
        scale = float(self.day_view.width()) / pixmap_day.width()
        self.day_view.scale(scale, scale)

        #处理进度条和执行按钮状态
        self.progressBar.setMinimum(0)
        self.progressBar.setMaximum(100)
        self.progressBar.setValue(100)
        self.progressBar.setFormat(u'完成!')
        self.execute_button.setDisabled(False)
开发者ID:LuckyBoy314,项目名称:LightningBulletin_v1,代码行数:70,代码来源:UI.py

示例15: MainWindow

# 需要导入模块: from PyQt5.QtWidgets import QGraphicsView [as 别名]
# 或者: from PyQt5.QtWidgets.QGraphicsView import setScene [as 别名]
class MainWindow(QWidget):
    def __init__(self, parent=None):
        super(MainWindow, self).__init__(parent)

        self.graphicsView = QGraphicsView()
        scene = QGraphicsScene(self.graphicsView)
        scene.setSceneRect(-10, 0, 700, 480)
        self.graphicsView.setScene(scene)
        self.searchrobot = search_robot(680,480, 40)
        scene.addItem(self.searchrobot)

        self.graphicsView2 = QGraphicsView()
        gscene = QGraphicsScene(self.graphicsView2)
        gscene.setSceneRect(0, 0, 300, 300)
        self.graphicsView2.setScene(gscene)
        #gscene.addItem(self.searchrobot)

        self.intervalcombo = QComboBox(self)
        intervalLayout = QHBoxLayout()
        intervalLayout.addWidget(QLabel("Interval:"))
        intervalLayout.addWidget(self.intervalcombo)
        self.agentcombo = QComboBox(self)
        agentLayout = QHBoxLayout()
        agentLayout.addWidget(QLabel("Agent Mode:"))
        agentLayout.addWidget(self.agentcombo)
        self.searchmodecombo = QComboBox(self)
        smodeLayout = QHBoxLayout()
        smodeLayout.addWidget(QLabel("Search Mode:"))
        smodeLayout.addWidget(self.searchmodecombo)
        self.resetButton = QPushButton("&Reset")
        self.resetButton.clicked.connect(self.reset)
        self.nextButton = QPushButton("&Next")
        self.nextButton.clicked.connect(self.do_next)
        self.autoButton = QPushButton("&Auto")
        self.autoButton.clicked.connect(self.auto)
        self.loopButton = QPushButton("&Loop")
        self.loopButton.clicked.connect(self.loop)
        self.resetmemButton = QPushButton("&ResetMemory")
        self.resetmemButton.clicked.connect(self.resetmemory)
        self.stopButton = QPushButton("&Stop")
        self.stopButton.clicked.connect(self.stop)
        buttonLayout = QVBoxLayout()
        buttonLayout.addLayout(intervalLayout)
        buttonLayout.addLayout(agentLayout)
        buttonLayout.addLayout(smodeLayout)
        buttonLayout.addWidget(self.resetButton)
        buttonLayout.addWidget(self.nextButton)
        buttonLayout.addWidget(self.autoButton)
        buttonLayout.addWidget(self.loopButton)
        buttonLayout.addWidget(self.resetmemButton)
        buttonLayout.addWidget(self.stopButton)

        self.interval = 5
        for i in ("5", "10", "30", "50", "100"):
            self.intervalcombo.addItem(i)
        self.intervalcombo.activated.connect(self.set_interval)

        for i in ("UniformCost", "A*", "LRTA*"):
            self.agentcombo.addItem(i)
        self.agentcombo.activated.connect(self.reset)

        for i in ("random", "UpDownLeftRight", "LeftRightUpDown", "RightLeftDownUp"):
            self.searchmodecombo.addItem(i)
        self.searchmodecombo.activated.connect(self.reset)

        self.costtext = QLabel("0")
        showcostLayout = QHBoxLayout()
        showcostLayout.addWidget(QLabel("Last cost:"))
        showcostLayout.addWidget(self.costtext)

        propertyLayout = QVBoxLayout()
        propertyLayout.setAlignment(Qt.AlignTop)
        propertyLayout.addLayout(buttonLayout)
        propertyLayout.addLayout(showcostLayout)
        propertyLayout.addWidget(self.graphicsView2)

        mainLayout = QHBoxLayout()
        mainLayout.setAlignment(Qt.AlignTop)
        mainLayout.addWidget(self.graphicsView)
        mainLayout.addLayout(propertyLayout)

        self.setLayout(mainLayout)
        #self.resize(1000,600)
        self.setWindowTitle("Seach Squares Simulation")
        self.updating_rule = False
        self.timer = None
        self.loopflag = False

    def update_rule(self):
        if self.updating_rule: return
        rule = 0
        for i in range(8):
            n = self.ruleEdits[i].text()
            if n == "": return
            rule = (rule << 1) + int(n)
        self.updating_rule = True
        self.updating_rule = False

    def set_interval(self):
        self.stop()
#.........这里部分代码省略.........
开发者ID:tapioka1027,项目名称:search_squares_sim,代码行数:103,代码来源:search_squares_sim.py


注:本文中的PyQt5.QtWidgets.QGraphicsView.setScene方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。