def __init__(self, scene, *args, **kwargs): super(MainWindow, self).__init__(*args, **kwargs) # self.windowTitleChanged.connect(self.onWindowTitleChange) self.setWindowTitle("timeline0") toolbar = QToolBar("och") toolbar.setIconSize(QSize(20, 20)) self.addToolBar(toolbar) button_action = QAction(QIcon("balance.png"), "ochtuse", self) button_action.setStatusTip("och, just do something") button_action.triggered.connect(self.onMyToolBarButtonClick) button_action.setCheckable(True) # button_action.setShortcut(QKeySequence("Ctrl+p")) # button_action.setShortcut(QKeySequence(Qt.CTRL + Qt.Key_P)) button_action.setShortcut(QKeySequence.Print) toolbar.addAction(button_action) toolbar.addWidget(QLabel("OCH")) toolbar.addWidget(QCheckBox()) self.setStatusBar(QStatusBar(self)) menu = self.menuBar() file_menu = menu.addMenu("&File") file_menu.addAction(button_action) file_menu.addSeparator() file_menu.addMenu("Do not push") # file_menu.addAction() self._scene = scene gfx = self._gfx = QGraphicsView(self) # label = QLabel("och!") # label.setAlignment(Qt.AlignCenter) # ref https://doc.qt.io/archives/qq/qq26-openglcanvas.html self.setCentralWidget(gfx) fmt = QGLFormat(QGL.SampleBuffers) wdgt = QGLWidget(fmt) assert (wdgt.isValid()) gfx.setViewport(wdgt) gfx.setViewportUpdateMode(QGraphicsView.FullViewportUpdate) gfx.setScene(scene) # populate fills the scene with interesting stuff. self.populate() # Make it bigger self.setWindowState(Qt.WindowMaximized) # Well... it's going to have an animation, ok? # So, I set a timer to 1 second self.animator = QTimer() # And when it triggers, it calls the animate method self.animator.timeout.connect(self.animate) # And I animate it once manually. self.animate()
def __init__(self, helper, parent): super(GLWidget, self).__init__(QGLFormat(QGL.SampleBuffers), parent) self.helper = helper self.elapsed = 0 self.setFixedSize(200, 200) self.setAutoFillBackground(False)
def __init__(self, parent=None): super(GLWidget, self).__init__(QGLFormat(QGL.SampleBuffers), parent) midnight = QTime(0, 0, 0) random.seed(midnight.secsTo(QTime.currentTime())) self.object = 0 self.xRot = 0 self.yRot = 0 self.zRot = 0 self.image = QImage() self.bubbles = [] self.lastPos = QPoint() self.trolltechGreen = QColor.fromCmykF(0.40, 0.0, 1.0, 0.0) self.trolltechPurple = QColor.fromCmykF(0.39, 0.39, 0.0, 0.0) self.animationTimer = QTimer() self.animationTimer.setSingleShot(False) self.animationTimer.timeout.connect(self.animate) self.animationTimer.start(25) self.setAutoFillBackground(False) self.setMinimumSize(200, 200) self.setWindowTitle("Overpainting a Scene")
def __init__(self, parent = None): self.stimulusWindow = self format = QGLFormat() format.setSwapInterval(1) super().__init__(format, parent) #super().__init__(parent) self.setFocusPolicy(Qt.NoFocus) self.updateSignal.connect(self.updateGL) self.setStyleSheet(""" QWidget{ background-color: black; border-color: red; border-style: solid; border-width: 1px; border-radius: 0px; font: bold 14px; color: red; padding: 0px; font-family: "Candara"; font-size: 14px; } """ ) self.setCursor(Qt.BlankCursor) self.fpsWarningSound = QSound("./Project/Media/airhorn.wav") self.finishedSound = QSound("./Project/Media/FANFARE.WAV") self.handle = None self.dllref = None
def __init__(self, parent): # OpenGL Widget setup f = QGLFormat() f.setSampleBuffers(True) f.setVersion(3,3) f.setProfile(QGLFormat.CoreProfile) QGLFormat.setDefaultFormat(f) if not QGLFormat.hasOpenGL(): QMessageBox.information(None, "OpenGL samplebuffers", "This system does not support OpenGL.") sys.exit(0) super(GLWidget, self).__init__(f, parent) self.setFocusPolicy(Qt.StrongFocus) self.list_ = [] self.width = 640.0 self.height = 480.0 self.startTimer(40) self.setWindowTitle("Sample Buffers") self.fov = 60.0 self.deltaTime = 0.0 self.lastFrame = None self.sketching = False self.sketchType = 0 self.sketchPoints = []
def __init__(self, parent): super(GLWidget, self).__init__(QGLFormat(QGL.SampleBuffers), parent) self.list_ = [] self.startTimer(40) self.setWindowTitle("Sample Buffers")
def __init_ui(self): # set up the scene self.scene = QGraphicsScene() self.scene.setSceneRect(0, 0, 650, 560) self.scene.setBackgroundBrush(Qt.darkGray) # set up the view self.setScene(self.scene) # these 10 additional pixels are for the margin self.setFixedSize(660, 570) # optimization self.setOptimizationFlag(QGraphicsView.DontAdjustForAntialiasing) self.setOptimizationFlag(QGraphicsView.DontSavePainterState) self.setCacheMode(QGraphicsView.CacheBackground) self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.setInteractive(False) self.setViewport(QGLWidget(QGLFormat())) self.setViewportUpdateMode(QGraphicsView.FullViewportUpdate) # set the background backgroundPixmap = QPixmap(self.texture) background = QGraphicsPixmapItem(backgroundPixmap) self.scene.addItem(background) # menu selector selectorPixmap = QPixmap(self.config.mainMenuSelector) self.selector = QGraphicsPixmapItem(selectorPixmap) self.selector.setPos(self.selectorPositions[self.selectedOption]) self.scene.addItem(self.selector)
def start(): # Start the Qt main object app = QApplication([]) # Start the bluesky network client client = GuiClient() # Enable HiDPI support (Qt5 only) if QT_VERSION >= 0x050000: app.setAttribute(Qt.AA_UseHighDpiPixmaps) splash = Splash() # Register our custom pan/zoom event for etype in range(1000, 1000 + NUMCUSTOMEVENTS): reg_etype = QEvent.registerEventType(etype) if reg_etype != etype: print(( 'Warning: Registered event type differs from requested type id (%d != %d)' % (reg_etype, etype))) splash.show() # Install error message handler handler = QErrorMessage.qtHandler() handler.setWindowFlags(Qt.WindowStaysOnTopHint) # Check and set OpenGL capabilities if not QGLFormat.hasOpenGL(): raise RuntimeError('No OpenGL support detected for this system!') else: f = QGLFormat() f.setVersion(3, 3) f.setProfile(QGLFormat.CoreProfile) f.setDoubleBuffer(True) QGLFormat.setDefaultFormat(f) print(('QGLWidget initialized for OpenGL version %d.%d' % (f.majorVersion(), f.minorVersion()))) splash.showMessage('Constructing main window') app.processEvents() win = MainWindow() win.show() splash.showMessage('Done!') app.processEvents() splash.finish(win) # If this instance of the gui is started in client-only mode, show # server selection dialog if bs.settings.is_client: dialog = DiscoveryDialog(win) dialog.show() bs.net.start_discovery() else: client.connect(event_port=bs.settings.event_port, stream_port=bs.settings.stream_port) # Start the Qt main loop app.exec_()
def init(self): """Initialize GL context.""" if not self.glcontext: self.glformat = QGLFormat() self.glcontext = self.widget.context() self.glcontext.setFormat(self.glformat) self.glcontext.create() return M64ERR_SUCCESS
def setRenderer(self, renderer): self.renderer = renderer if self.renderer == SvgView.OpenGL: if QGLFormat.hasOpenGL(): self.setViewport(QGLWidget(QGLFormat(QGL.SampleBuffers))) else: self.setViewport(QWidget())
def __init__(self, parent, launcher): format = QGLFormat() format.setSwapInterval(1) super().__init__(format, parent) self.makeCurrent() gears.shareCurrent() #super().__init__(parent) self.launcher = launcher
def __init__(self, parent): super(GLWidget, self).__init__(QGLFormat(QGL.SampleBuffers), parent) self.test_option = gl.GL_SCISSOR_TEST self.func_option = gl.GL_GREATER self.sfactor_option = gl.GL_SRC_ALPHA self.dfactor_option = gl.GL_ONE_MINUS_SRC_ALPHA self.ref = 0.2 self.move(0, 0) self.resize(canvas_width, canvas_height)
def __init__(self, parent, editor): format = QGLFormat() format.setSwapInterval(1) super().__init__(format, parent) self.makeCurrent() gears.shareCurrent() self.sFrame = 0 self.editor = editor self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
def __init__(self, *args, **kwargs): super(QFramesInTracksView, self).__init__(*args, **kwargs) fmt = QGLFormat(QGL.SampleBuffers) wdgt = QGLWidget(fmt) assert (wdgt.isValid()) self.setViewport(wdgt) self.setViewportUpdateMode(QGraphicsView.FullViewportUpdate) self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOn) self.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded) self.setRenderHints(QPainter.Antialiasing)
def __init__(self, parent=None): self.first = True f = QGLFormat() f.setVersion(3, 3) f.setProfile(QGLFormat.OpenGLContextProfile.CoreProfile) f.setDoubleBuffer(True) QGLWidget.__init__(self, QGLContext(f), parent) print(('QGLWidget initialized for OpenGL version %d.%d' % (f.majorVersion(), f.minorVersion()))) print("This script creates a file called 'opengl-test.txt', containing information about the opengl support of your computer. Useful when debugging problems with the opengl version of BlueSky.")
def __init__(self, renderer, title): QApplication.__init__(self, sys.argv) self.window = QMainWindow() self.window.setWindowTitle(title) self.window.resize(800,600) # Get OpenGL 4.1 context glformat = QGLFormat() glformat.setVersion(4, 1) glformat.setProfile(QGLFormat.CoreProfile) glformat.setDoubleBuffer(False) self.glwidget = MyGlWidget(renderer, glformat, self) self.window.setCentralWidget(self.glwidget) self.window.show()
def __init__(self): super().__init__() self.setViewport(QGLWidget(QGLFormat(QGL.SampleBuffers))) scene = QGraphicsScene(self) self.setScene(scene) self.setSceneRect(0, 0, 600, 600) # self.setStyleSheet('background-color: rgba(255, 0, 0, 255)') for _ in range(10): pos = random.sample(range(0, 600), 2) circle = Circle(*pos, 100) circle.create_random_point() self.scene().addItem(circle)
def __init__(self): super(Gui, self).__init__([]) self.acdata = ACDataEvent() self.birddata = BirdDataEvent() self.navdb = None self.radarwidget = [] self.command_history = [] self.cmd = '' self.args = [] self.history_pos = 0 self.command_mem = '' self.command_line = '' self.prev_cmdline = '' self.mousedragged = False self.mousepos = (0, 0) self.prevmousepos = (0, 0) self.panzoomchanged = False self.simt = 0.0 # Register our custom pan/zoom event for etype in range(1000, 1000 + NUMEVENTS): reg_etype = QEvent.registerEventType(etype) if reg_etype != etype: print( 'Warning: Registered event type differs from requested type id (%d != %d)' % (reg_etype, etype)) self.splash = Splash() self.splash.show() # Install error message handler handler = QErrorMessage.qtHandler() handler.setWindowFlags(Qt.WindowStaysOnTopHint) # Check and set OpenGL capabilities if not QGLFormat.hasOpenGL(): raise RuntimeError('No OpenGL support detected for this system!') else: f = QGLFormat() f.setVersion(3, 3) f.setProfile(QGLFormat.CoreProfile) f.setDoubleBuffer(True) QGLFormat.setDefaultFormat(f) print('QGLWidget initialized for OpenGL version %d.%d' % (f.majorVersion(), f.minorVersion())) # Enable HiDPI support (Qt5 only) if QT_VERSION == 5: self.setAttribute(Qt.AA_UseHighDpiPixmaps)
def __init__(self, parent=None): super(GLWidget, self).__init__(QGLFormat(QGL.SampleBuffers), parent) self.setFocusPolicy(Qt.StrongFocus) #keyboard support self.startTimer(1000 / 144) self.camera = True self.w = self.width() self.h = self.height() self.zoom = 20 self.xRot = 0 # roll self.yRot = 0 # pitch self.zRot = 0 # yaw self.R_MIN = 4.5 self.R_MAX = 60 self.lastPos = QPoint()
def __init__(self, parent) -> None: """ CONSTRUCTOR """ super().__init__(parent) self.ui = frm_lego_designer.Ui_Dialog(self) self.setWindowTitle("Lego Diagram Editor") # # Graphics view # self.ctrl_graphics_view = InteractiveGraphicsView() v = self.ctrl_graphics_view sizePolicy = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) sizePolicy.setHeightForWidth(v.sizePolicy().hasHeightForWidth()) v.setSizePolicy(sizePolicy) v.setObjectName("graphicsView") v.setBackgroundBrush(QBrush(QColor(255, 255, 255))) v.setInteractive(True) layout = QGridLayout() self.ui.FRA_MAIN.setLayout(layout) layout.addWidget(v) # Open GL rendering if groot.data.config.options().opengl: v.setViewport(QGLWidget(QGLFormat(QGL.SampleBuffers))) # Default (empty) scene scene = QGraphicsScene() scene.addRect(QRectF(-10, -10, 20, 20)) v.setScene(scene) # # Create our model view! # self.model_view: ModelView = None self.update_view() self.toggle_show_edit(False) # Button clicks for x in (self.ui.BTN_S_EDGES_, self.ui.BTN_S_COMPS_, self.ui.BTN_S_GENES_, self.ui.BTN_S_MINCOMPS_, self.ui.BTN_S_DOMAINS_): x.clicked[bool].connect(self.on_btn_click)
def __init__(self): super(StimCanvas, self).__init__() self.control = TrialControl() self.control.show() self.t = time.time() glformat = QGLFormat() glformat.setVersion(4, 1) glformat.setProfile(QGLFormat.CoreProfile) glformat.setDoubleBuffer(True) self.drawtimer = QTimer(self) self.drawtimer.timeout.connect(self.update) self.drawtimer.start(1000 / 60) self.curframe = 0 self.curtrial = 0 self.trial_seq = [0]
def __init__(self, parent=None): """ On initialization, we need to bind the Ctrl/command key to enable manipulation of the view. """ QGraphicsView.__init__(self, parent) self.setTransformationAnchor(QGraphicsView.AnchorUnderMouse) self.setRubberBandSelectionMode(Qt.IntersectsItemShape) self.setStyleSheet( "QGraphicsView { background-color: rgb(96.5%, 96.5%, 96.5%); }") self._no_drag = QGraphicsView.RubberBandDrag self._yes_drag = QGraphicsView.ScrollHandDrag # reset things that are state dependent self.clearGraphicsView() self._x0 = 0 self._y0 = 0 self._scale_size = 1.0 self._scale_limit_max = 3.0 self._scale_limit_min = 0.41 self._scale_up_rate = 0.01 self._scale_down_rate = 0.01 self._scale_fit_factor = 1 # sets initial zoom level self._show_details = True self._last_scale_factor = 0.0 self.scene_root_item = None # the item to transform # Keyboard panning self._key_pan_delta_x = styles.PATH_BASE_WIDTH * 21 self._key_pan_delta_y = styles.PATH_HELIX_HEIGHT + styles.PATH_HELIX_PADDING / 2 # Modifier keys and buttons self._key_mod = Qt.Key_Control self._button_pan = Qt.LeftButton self._button_pan_alt = Qt.MidButton self._button_zoom = Qt.RightButton self.toolbar = None # custom hack for the paint tool palette self._name = None if GL: self.setViewport(QGLWidget(QGLFormat(QGL.SampleBuffers))) self.setViewportUpdateMode(QGraphicsView.FullViewportUpdate) else: self.setViewportUpdateMode(QGraphicsView.MinimalViewportUpdate)
def initWindow(self): self.window = MainWindow(self) self.window.setWindowTitle('CS791a') glFormat = QGLFormat() glFormat.setDoubleBuffer(True) glFormat.setDirectRendering(True) glFormat.setProfile(QGLFormat.CoreProfile) glFormat.setVersion(3,3) QGLFormat.setDefaultFormat(glFormat) #glFormat.setOption(QGLFormat.OpenGL_Version_3_3) self.graphics = GraphicsManager(self) self.graphics.makeCurrent() self.window.setCentralWidget(self.graphics) self.window.resize(1600,900) print(glGetString(GL_VERSION))
def __init__(self, parent): super(GLWidget, self).__init__(QGLFormat(QGL.SampleBuffers), parent) self.move(0, 0) self.resize(int(parent.width() / 1.61803398875), parent.height()) self.fig = Figure(self)
self.selValues[4] += int(val) * increment self.remainder = val - int(val) self.update_lcd() if self.btn_pressed is not None: QTimer.singleShot(200, self.updateAPValues) if __name__ == "__main__": qapp = QApplication([]) # Check and set OpenGL capabilities if not QGLFormat.hasOpenGL(): raise RuntimeError('No OpenGL support detected for this system!') else: f = QGLFormat() f.setVersion(3, 3) f.setProfile(QGLFormat.CoreProfile) f.setDoubleBuffer(True) QGLFormat.setDefaultFormat(f) print('QGLWidget initialized for OpenGL version %d.%d' % (f.majorVersion(), f.minorVersion())) blip = BlipDriver() blip.show() gltimer = QTimer(qapp) gltimer.timeout.connect(blip.updateGL) gltimer.start(50) qapp.exec_()
def __init_ui(self): # set up the scene self.scene = QGraphicsScene() self.scene.setSceneRect(0, 0, 650, 560) self.scene.setBackgroundBrush(Qt.darkGray) # set up the view self.setScene(self.scene) # these 10 additional pixels are for the margin self.setFixedSize(660, 570) # optimization self.setOptimizationFlag(QGraphicsView.DontAdjustForAntialiasing) self.setOptimizationFlag(QGraphicsView.DontSavePainterState) self.setCacheMode(QGraphicsView.CacheBackground) self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.setInteractive(False) self.setViewport(QGLWidget(QGLFormat())) self.setViewportUpdateMode(QGraphicsView.FullViewportUpdate) for imgUrl in self.config.hiscoreAnimation: pixmap = QPixmap(imgUrl) pixmapItem = QGraphicsPixmapItem(pixmap) pixmapItem.setZValue(-1) pixmapItem.hide() self.scene.addItem(pixmapItem) self.hiscoreAnimationItems.append(pixmapItem) for imgUrl in self.config.winnerScreenTieAnimation: pixmap = QPixmap(imgUrl) pixmapItem = QGraphicsPixmapItem(pixmap) pixmapItem.setZValue(-1) pixmapItem.hide() self.scene.addItem(pixmapItem) self.winnerScreenTieAnimationItems.append(pixmapItem) for imgUrl in self.config.winnerScreenPlayer1Animation: pixmap = QPixmap(imgUrl) pixmapItem = QGraphicsPixmapItem(pixmap) pixmapItem.setZValue(-1) pixmapItem.hide() self.scene.addItem(pixmapItem) self.player1AnimationItems.append(pixmapItem) for imgUrl in self.config.winnerScreenPlayer2Animation: pixmap = QPixmap(imgUrl) pixmapItem = QGraphicsPixmapItem(pixmap) pixmapItem.setZValue(-1) pixmapItem.hide() self.scene.addItem(pixmapItem) self.player2AnimationItems.append(pixmapItem) # points animation used when single player is played self.hudHiscorePlayerTotalPointsWhite = HudHiscoreTotalPlayerPointsContainer( self.config, "white", self.firstPlayerTotalPoints) self.hudHiscorePlayerTotalPointsWhite.setPos(45, 235) self.hudHiscorePlayerTotalPointsWhite.hide() self.scene.addItem(self.hudHiscorePlayerTotalPointsWhite) self.hudHiscorePlayerTotalPointsList.append( self.hudHiscorePlayerTotalPointsWhite) self.hudHiscorePlayerTotalPointsGray = HudHiscoreTotalPlayerPointsContainer( self.config, "gray", self.firstPlayerTotalPoints) self.hudHiscorePlayerTotalPointsGray.setPos(45, 235) self.hudHiscorePlayerTotalPointsGray.hide() self.scene.addItem(self.hudHiscorePlayerTotalPointsGray) self.hudHiscorePlayerTotalPointsList.append( self.hudHiscorePlayerTotalPointsGray) self.hudHiscorePlayerTotalPointsDarkGray = HudHiscoreTotalPlayerPointsContainer( self.config, "darkGray", self.firstPlayerTotalPoints) self.hudHiscorePlayerTotalPointsDarkGray.setPos(45, 235) self.hudHiscorePlayerTotalPointsDarkGray.hide() self.scene.addItem(self.hudHiscorePlayerTotalPointsDarkGray) self.hudHiscorePlayerTotalPointsList.append( self.hudHiscorePlayerTotalPointsDarkGray) self.hudHiscorePlayerTotalPointsBlue = HudHiscoreTotalPlayerPointsContainer( self.config, "blue", self.firstPlayerTotalPoints) self.hudHiscorePlayerTotalPointsBlue.setPos(45, 235) self.hudHiscorePlayerTotalPointsBlue.hide() self.scene.addItem(self.hudHiscorePlayerTotalPointsBlue) self.hudHiscorePlayerTotalPointsList.append( self.hudHiscorePlayerTotalPointsBlue) self.hudHiscorePlayerTotalPointsDarkBlue = HudHiscoreTotalPlayerPointsContainer( self.config, "darkBlue", self.firstPlayerTotalPoints) self.hudHiscorePlayerTotalPointsDarkBlue.setPos(45, 235) self.hudHiscorePlayerTotalPointsDarkBlue.hide() self.scene.addItem(self.hudHiscorePlayerTotalPointsDarkBlue) self.hudHiscorePlayerTotalPointsList.append( self.hudHiscorePlayerTotalPointsDarkBlue) # used when there are two players playing self.hudFirstPlayerTotalPoints = HudEndOfStageTotalPlayerPointsContainer( self.config, self.firstPlayerTotalPoints) self.hudFirstPlayerTotalPoints.setPos(85, 205) self.hudFirstPlayerTotalPoints.hide() self.scene.addItem(self.hudFirstPlayerTotalPoints) self.hudSecondPlayerTotalPoints = HudEndOfStageTotalPlayerPointsContainer( self.config, self.secondPlayerTotalPoints) self.hudSecondPlayerTotalPoints.setPos(450, 205) self.hudSecondPlayerTotalPoints.hide() self.scene.addItem(self.hudSecondPlayerTotalPoints)
def setupUi(self, MainWindow): self.MainWindow = MainWindow self.sequence = QSequentialAnimationGroup() self.sequence.finished.connect(self.animation_finished) self.scene = QGraphicsScene() MainWindow.setObjectName("MainWindow") #MainWindow.setWindowIcon(QtGui.QIcon("icon.png")) MainWindow.resize(self.width, self.height) #qt designer generated code self.centralwidget = QtWidgets.QWidget(MainWindow) self.centralwidget.setObjectName("centralwidget") self.gridLayout = QtWidgets.QGridLayout(self.centralwidget) self.gridLayout.setObjectName("gridLayout") self.graphicsView = QtWidgets.QGraphicsView(self.centralwidget) self.graphicsView.setEnabled(True) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding) sizePolicy.setHorizontalStretch(1) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.graphicsView.sizePolicy().hasHeightForWidth()) self.graphicsView.setSizePolicy(sizePolicy) self.graphicsView.setObjectName("graphicsView") self.gridLayout.addWidget(self.graphicsView, 3, 1, 1, 1) self.gridLayout_2 = QtWidgets.QGridLayout() self.gridLayout_2.setObjectName("gridLayout_2") self.pushButton_1 = QtWidgets.QPushButton(self.centralwidget) self.pushButton_1.setObjectName("pushButton_1") self.gridLayout_2.addWidget(self.pushButton_1, 3, 0, 1, 1) self.pushButton_2 = QtWidgets.QPushButton(self.centralwidget) self.pushButton_2.setObjectName("pushButton_2") self.gridLayout_2.addWidget(self.pushButton_2, 5, 0, 1, 1) self.pushButton_4 = QtWidgets.QPushButton(self.centralwidget) self.pushButton_4.setObjectName("pushButton_4") self.gridLayout_2.addWidget(self.pushButton_4, 9, 0, 1, 1) self.lineEdit_3 = QtWidgets.QLineEdit(self.centralwidget) self.lineEdit_3.setObjectName("lineEdit_3") self.gridLayout_2.addWidget(self.lineEdit_3, 6, 0, 1, 1) self.pushButton_0 = QtWidgets.QPushButton(self.centralwidget) self.pushButton_0.setObjectName("pushButton_0") self.gridLayout_2.addWidget(self.pushButton_0, 1, 0, 1, 1) self.lineEdit_1 = QtWidgets.QLineEdit(self.centralwidget) self.lineEdit_1.setObjectName("lineEdit_1") self.gridLayout_2.addWidget(self.lineEdit_1, 2, 0, 1, 1) self.pushButton_3 = QtWidgets.QPushButton(self.centralwidget) self.pushButton_3.setObjectName("pushButton_3") self.gridLayout_2.addWidget(self.pushButton_3, 7, 0, 1, 1) self.pushButton_6 = QtWidgets.QPushButton(self.centralwidget) self.pushButton_6.setObjectName("pushButton_6") self.gridLayout_2.addWidget(self.pushButton_6, 14, 0, 1, 1) self.pushButton_7 = QtWidgets.QPushButton(self.centralwidget) self.pushButton_7.setObjectName("pushButton_7") self.gridLayout_2.addWidget(self.pushButton_7, 19, 0, 1, 1) self.lineEdit_4 = QtWidgets.QLineEdit(self.centralwidget) self.lineEdit_4.setObjectName("lineEdit_4") self.gridLayout_2.addWidget(self.lineEdit_4, 8, 0, 1, 1) self.lineEdit_0 = QtWidgets.QLineEdit(self.centralwidget) self.lineEdit_0.setObjectName("lineEdit_0") self.gridLayout_2.addWidget(self.lineEdit_0, 0, 0, 1, 1) self.lineEdit_2 = QtWidgets.QLineEdit(self.centralwidget) self.lineEdit_2.setObjectName("lineEdit_2") self.gridLayout_2.addWidget(self.lineEdit_2, 4, 0, 1, 1) self.pushButton_5 = QtWidgets.QPushButton(self.centralwidget) self.pushButton_5.setObjectName("pushButton_5") self.gridLayout_2.addWidget(self.pushButton_5, 11, 0, 1, 1) self.lineEdit_7 = QtWidgets.QLineEdit(self.centralwidget) self.lineEdit_7.setObjectName("lineEdit_7") self.gridLayout_2.addWidget(self.lineEdit_7, 17, 0, 1, 1) self.lineEdit_5 = QtWidgets.QLineEdit(self.centralwidget) self.lineEdit_5.setObjectName("lineEdit_5") self.gridLayout_2.addWidget(self.lineEdit_5, 10, 0, 1, 1) self.lineEdit_6 = QtWidgets.QLineEdit(self.centralwidget) self.lineEdit_6.setObjectName("lineEdit_6") self.gridLayout_2.addWidget(self.lineEdit_6, 12, 0, 1, 1) self.gridLayout.addLayout(self.gridLayout_2, 3, 0, 1, 1) MainWindow.setCentralWidget(self.centralwidget) self.statusbar = QtWidgets.QStatusBar(MainWindow) self.statusbar.setObjectName("statusbar") MainWindow.setStatusBar(self.statusbar) self.retranslateUi(MainWindow) QtCore.QMetaObject.connectSlotsByName(MainWindow) #end of eq designer generated code self.lineEdits = [] self.lineEdits.append(self.lineEdit_0) self.lineEdits.append(self.lineEdit_1) self.lineEdits.append(self.lineEdit_2) self.lineEdits.append(self.lineEdit_3) self.lineEdits.append(self.lineEdit_4) self.lineEdits.append(self.lineEdit_5) self.lineEdits.append(self.lineEdit_6) self.lineEdits.append(self.lineEdit_7) self.pushButtons = [] self.pushButtons.append(self.pushButton_0) self.pushButtons.append(self.pushButton_1) self.pushButtons.append(self.pushButton_2) self.pushButtons.append(self.pushButton_3) self.pushButtons.append(self.pushButton_4) self.pushButtons.append(self.pushButton_5) self.pushButtons.append(self.pushButton_6) self.pushButtons.append(self.pushButton_7) self.graphicsView.setScene(self.scene) self.graphicsView.setSceneRect(0, 0, 0, 0) self.graphicsView.setRenderHints(QPainter.Antialiasing) # self.graphicsView.fitInView(self.scene.sceneRect(), Qt.KeepAspectRatio) self.graphicsView.setViewport(QGLWidget(QGLFormat(QGL.SampleBuffers))) self.graphicsView.scale(self.zoom, -self.zoom) self.graphicsView.setDragMode(1)
def start(mode): # Install message handler for Qt messages qInstallMessageHandler(gui_msg_handler) # Start the Qt main object app = QApplication([]) # Start the bluesky network client client = GuiClient() # Enable HiDPI support (Qt5 only) if QT_VERSION >= 0x050000: app.setAttribute(Qt.AA_UseHighDpiPixmaps) splash = Splash() # Register our custom pan/zoom event for etype in range(1000, 1000 + NUMCUSTOMEVENTS): reg_etype = QEvent.registerEventType(etype) if reg_etype != etype: print(( 'Warning: Registered event type differs from requested type id (%d != %d)' % (reg_etype, etype))) splash.show() # Install error message handler handler = QErrorMessage.qtHandler() handler.setWindowFlags(Qt.WindowStaysOnTopHint) # Check and set OpenGL capabilities if not QGLFormat.hasOpenGL(): raise RuntimeError('No OpenGL support detected for this system!') else: f = QGLFormat() f.setVersion(3, 3) f.setProfile(QGLFormat.CoreProfile) f.setDoubleBuffer(True) QGLFormat.setDefaultFormat(f) print(('QGLWidget initialized for OpenGL version %d.%d' % (f.majorVersion(), f.minorVersion()))) splash.showMessage('Constructing main window') app.processEvents() win = MainWindow(mode) splash.showMessage('Done!') app.processEvents() splash.finish(win) # Quick hack to connect to a remote simulation import sys arg = '--bluesky_host=' host = next((x for x in sys.argv if x.startswith(arg)), None) if host is not None: host = host[len(arg):] try: print('Attempting connection to BlueSky at: {}'.format(host)) client.connect(hostname=host, event_port=bs.settings.event_port, stream_port=bs.settings.stream_port, timeout=5) except TimeoutError: print('Failed to connect to BlueSky server at {}, exiting'.format( host)) QApplication.quit() sys.exit(0) win.show() app.exec_() return win.show() # If this instance of the gui is started in client-only mode, show # server selection dialog if mode == 'client': dialog = DiscoveryDialog(win) dialog.show() bs.net.start_discovery() else: client.connect(event_port=bs.settings.event_port, stream_port=bs.settings.stream_port) # Start the Qt main loop app.exec_()
def set_default_context(major_version, minor_version, profile): f = QGLFormat() f.setVersion(major_version, minor_version) f.setProfile(profile) QGLFormat.setDefaultFormat(f)
def __init__(self, size, parent=None): super(PadNavigator, self).__init__(parent) self.form = Ui_Form() splash = SplashItem() splash.setZValue(1) pad = FlippablePad(size) flipRotation = QGraphicsRotation(pad) xRotation = QGraphicsRotation(pad) yRotation = QGraphicsRotation(pad) flipRotation.setAxis(Qt.YAxis) xRotation.setAxis(Qt.YAxis) yRotation.setAxis(Qt.XAxis) pad.setTransformations([flipRotation, xRotation, yRotation]) backItem = QGraphicsProxyWidget(pad) widget = QWidget() self.form.setupUi(widget) self.form.hostName.setFocus() backItem.setWidget(widget) backItem.setVisible(False) backItem.setFocus() backItem.setCacheMode(QGraphicsItem.ItemCoordinateCache) r = backItem.rect() backItem.setTransform(QTransform().rotate(180, Qt.YAxis).translate( -r.width() / 2, -r.height() / 2)) selectionItem = RoundRectItem(QRectF(-60, -60, 120, 120), QColor(Qt.gray), pad) selectionItem.setZValue(0.5) smoothSplashMove = QPropertyAnimation(splash) smoothSplashOpacity = QPropertyAnimation(splash) smoothSplashMove.setEasingCurve(QEasingCurve.InQuad) smoothSplashMove.setDuration(250) smoothSplashOpacity.setDuration(250) smoothXSelection = QPropertyAnimation(selectionItem) smoothYSelection = QPropertyAnimation(selectionItem) smoothXRotation = QPropertyAnimation(xRotation) smoothYRotation = QPropertyAnimation(yRotation) smoothXSelection.setDuration(125) smoothYSelection.setDuration(125) smoothXRotation.setDuration(125) smoothYRotation.setDuration(125) smoothXSelection.setEasingCurve(QEasingCurve.InOutQuad) smoothYSelection.setEasingCurve(QEasingCurve.InOutQuad) smoothXRotation.setEasingCurve(QEasingCurve.InOutQuad) smoothYRotation.setEasingCurve(QEasingCurve.InOutQuad) smoothFlipRotation = QPropertyAnimation(flipRotation) smoothFlipScale = QPropertyAnimation(pad) smoothFlipXRotation = QPropertyAnimation(xRotation) smoothFlipYRotation = QPropertyAnimation(yRotation) flipAnimation = QParallelAnimationGroup(self) smoothFlipScale.setDuration(500) smoothFlipRotation.setDuration(500) smoothFlipXRotation.setDuration(500) smoothFlipYRotation.setDuration(500) smoothFlipScale.setEasingCurve(QEasingCurve.InOutQuad) smoothFlipRotation.setEasingCurve(QEasingCurve.InOutQuad) smoothFlipXRotation.setEasingCurve(QEasingCurve.InOutQuad) smoothFlipYRotation.setEasingCurve(QEasingCurve.InOutQuad) smoothFlipScale.setKeyValueAt(0, 1.0) smoothFlipScale.setKeyValueAt(0.5, 0.7) smoothFlipScale.setKeyValueAt(1, 1.0) flipAnimation.addAnimation(smoothFlipRotation) flipAnimation.addAnimation(smoothFlipScale) flipAnimation.addAnimation(smoothFlipXRotation) flipAnimation.addAnimation(smoothFlipYRotation) setVariablesSequence = QSequentialAnimationGroup() setFillAnimation = QPropertyAnimation(pad) setBackItemVisibleAnimation = QPropertyAnimation(backItem) setSelectionItemVisibleAnimation = QPropertyAnimation(selectionItem) setFillAnimation.setDuration(0) setBackItemVisibleAnimation.setDuration(0) setSelectionItemVisibleAnimation.setDuration(0) setVariablesSequence.addPause(250) setVariablesSequence.addAnimation(setBackItemVisibleAnimation) setVariablesSequence.addAnimation(setSelectionItemVisibleAnimation) setVariablesSequence.addAnimation(setFillAnimation) flipAnimation.addAnimation(setVariablesSequence) stateMachine = QStateMachine(self) splashState = QState(stateMachine) frontState = QState(stateMachine) historyState = QHistoryState(frontState) backState = QState(stateMachine) frontState.assignProperty(pad, "fill", False) frontState.assignProperty(splash, "opacity", 0.0) frontState.assignProperty(backItem, "visible", False) frontState.assignProperty(flipRotation, "angle", 0.0) frontState.assignProperty(selectionItem, "visible", True) backState.assignProperty(pad, "fill", True) backState.assignProperty(backItem, "visible", True) backState.assignProperty(xRotation, "angle", 0.0) backState.assignProperty(yRotation, "angle", 0.0) backState.assignProperty(flipRotation, "angle", 180.0) backState.assignProperty(selectionItem, "visible", False) stateMachine.addDefaultAnimation(smoothXRotation) stateMachine.addDefaultAnimation(smoothYRotation) stateMachine.addDefaultAnimation(smoothXSelection) stateMachine.addDefaultAnimation(smoothYSelection) stateMachine.setInitialState(splashState) anyKeyTransition = QEventTransition(self, QEvent.KeyPress, splashState) anyKeyTransition.setTargetState(frontState) anyKeyTransition.addAnimation(smoothSplashMove) anyKeyTransition.addAnimation(smoothSplashOpacity) enterTransition = QKeyEventTransition(self, QEvent.KeyPress, Qt.Key_Enter, backState) returnTransition = QKeyEventTransition(self, QEvent.KeyPress, Qt.Key_Return, backState) backEnterTransition = QKeyEventTransition(self, QEvent.KeyPress, Qt.Key_Enter, frontState) backReturnTransition = QKeyEventTransition(self, QEvent.KeyPress, Qt.Key_Return, frontState) enterTransition.setTargetState(historyState) returnTransition.setTargetState(historyState) backEnterTransition.setTargetState(backState) backReturnTransition.setTargetState(backState) enterTransition.addAnimation(flipAnimation) returnTransition.addAnimation(flipAnimation) backEnterTransition.addAnimation(flipAnimation) backReturnTransition.addAnimation(flipAnimation) columns = size.width() rows = size.height() stateGrid = [] for y in range(rows): stateGrid.append([QState(frontState) for _ in range(columns)]) frontState.setInitialState(stateGrid[0][0]) selectionItem.setPos(pad.iconAt(0, 0).pos()) for y in range(rows): for x in range(columns): state = stateGrid[y][x] rightTransition = QKeyEventTransition(self, QEvent.KeyPress, Qt.Key_Right, state) leftTransition = QKeyEventTransition(self, QEvent.KeyPress, Qt.Key_Left, state) downTransition = QKeyEventTransition(self, QEvent.KeyPress, Qt.Key_Down, state) upTransition = QKeyEventTransition(self, QEvent.KeyPress, Qt.Key_Up, state) rightTransition.setTargetState(stateGrid[y][(x + 1) % columns]) leftTransition.setTargetState( stateGrid[y][((x - 1) + columns) % columns]) downTransition.setTargetState(stateGrid[(y + 1) % rows][x]) upTransition.setTargetState(stateGrid[((y - 1) + rows) % rows][x]) icon = pad.iconAt(x, y) state.assignProperty(xRotation, "angle", -icon.x() / 6.0) state.assignProperty(yRotation, "angle", icon.y() / 6.0) state.assignProperty(selectionItem, "x", icon.x()) state.assignProperty(selectionItem, "y", icon.y()) frontState.assignProperty(icon, "visible", True) backState.assignProperty(icon, "visible", False) setIconVisibleAnimation = QPropertyAnimation(icon) setIconVisibleAnimation.setDuration(0) setVariablesSequence.addAnimation(setIconVisibleAnimation) scene = QGraphicsScene(self) scene.setBackgroundBrush( QBrush(QPixmap(":/images/blue_angle_swirl.jpg"))) scene.setItemIndexMethod(QGraphicsScene.NoIndex) scene.addItem(pad) scene.setSceneRect(scene.itemsBoundingRect()) self.setScene(scene) sbr = splash.boundingRect() splash.setPos(-sbr.width() / 2, scene.sceneRect().top() - 2) frontState.assignProperty(splash, "y", splash.y() - 100.0) scene.addItem(splash) self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.setMinimumSize(50, 50) self.setViewportUpdateMode(QGraphicsView.FullViewportUpdate) self.setCacheMode(QGraphicsView.CacheBackground) self.setRenderHints(QPainter.Antialiasing | QPainter.SmoothPixmapTransform | QPainter.TextAntialiasing) if QGLFormat.hasOpenGL(): self.setViewport(QGLWidget(QGLFormat(QGL.SampleBuffers))) stateMachine.start()