Python PyQt5.QtWidgets.QGraphicsScene() Examples
The following are 30
code examples of PyQt5.QtWidgets.QGraphicsScene().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
PyQt5.QtWidgets
, or try the search function
.
Example #1
Source File: Test.py From DeepLearning_Wavelet-LSTM with MIT License | 6 votes |
def ok(self): self.gridLayoutWidget = QtWidgets.QWidget() self.gridLayoutWidget.setGeometry(QtCore.QRect(180, 10, 1100, 500)) # 定义gridLayout控件的大小和位置,4个数字分别为左边坐标,上边坐标,长,宽 self.gridLayoutWidget.setObjectName("gridLayoutWidget") self.gridLayout_2 = QtWidgets.QGridLayout(self.gridLayoutWidget) self.gridLayout_2.setContentsMargins(0, 0, 0, 0) # 在gridLayoutWidget 上创建一个网格Layout,注意以gridLayoutWidget为参 self.gridLayout_2.setObjectName("gridLayout_2") # ===通过graphicview来显示图形 self.graphicview = QtWidgets.QGraphicsView(self.gridLayoutWidget) # 第一步,创建一个QGraphicsView,注意同样以gridLayoutWidget为参 self.graphicview.setObjectName("graphicview") self.gridLayout_2.addWidget(self.graphicview, 0, 0) #第二步,将该QGraphicsView放入Layout中 dr = Figure_Canvas() #实例化一个FigureCanvas dr.test() # 画图 graphicscene = QtWidgets.QGraphicsScene() # 第三步,创建一个QGraphicsScene,因为加载的图形(FigureCanvas)不能直接放到graphicview控件中,必须先放到graphicScene,然后再把graphicscene放到graphicview中 graphicscene.addWidget(dr) # 第四步,把图形放到QGraphicsScene中,注意:图形是作为一个QWidget放到QGraphicsScene中的 self.graphicview.setScene(graphicscene) # 第五步,把QGraphicsScene放入QGraphicsView self.graphicview.show() # 最后,调用show方法呈现图形!Voila!!
Example #2
Source File: ayab.py From ayab-desktop with GNU General Public License v3.0 | 6 votes |
def load_image_from_string(self, image_str): '''Loads an image into self.ui.image_pattern_view using a temporary QGraphicsScene''' # TODO Check for maximum width before loading the image self.pil_image = Image.open(image_str) self.pil_image = self.pil_image.convert("RGBA") self.refresh_scene() self.statusBar().showMessage(image_str) # Enable plugin elements after first load of image self.ui.widget_optionsdock.setEnabled(True) self.ui.menuImage_Actions.setEnabled(True) # Tell loaded plugin elements about changed parameters width, height = self.pil_image.size self.enabled_plugin.slotSetImageDimensions(width, height)
Example #3
Source File: SymbolScene.py From CodeAtlasSublime with Eclipse Public License 1.0 | 6 votes |
def __init__(self, *args): super(SymbolScene, self).__init__(*args) self.symbolRoot = None self.symbolDict = {} self.baseRadius = 200 self.totalRadius = 20 self.unpinnedAngle = 1 self.pinnedAngle = 1 self.highPosList = [] self.normalPosList = [] self.lowPosList = [] self.callRef = {} from db.SymbolNode import SymbolNode self.widthDict = {SymbolNode.KIND_NAMESPACE: 10, SymbolNode.KIND_FUNCTION: 30, SymbolNode.KIND_VARIABLE: 10, SymbolNode.KIND_CLASS: 10, SymbolNode.KIND_UNKNOWN: 10} self.setItemIndexMethod(QtWidgets.QGraphicsScene.BspTreeIndex)
Example #4
Source File: nozzlePreviewWidget.py From openMotor with GNU General Public License v3.0 | 6 votes |
def __init__(self): super().__init__() self.ui = Ui_NozzlePreview() self.ui.setupUi(self) self.brush = QBrush() self.brush.setStyle(1) self.scene = QGraphicsScene(self) self.upper = QGraphicsPolygonItem() self.lower = QGraphicsPolygonItem() self.upper.setBrush(self.brush) self.lower.setBrush(self.brush) self.scene.addItem(self.upper) self.scene.addItem(self.lower) self.ui.tabCrossSection.setScene(self.scene) self.ui.tabWidget.currentChanged.connect(self.rescale)
Example #5
Source File: Modulator.py From urh with GNU General Public License v3.0 | 6 votes |
def data_scene(self) -> QGraphicsScene: n = self.samples_per_symbol * len(self.display_bits) y = np.ones(n, dtype=np.float32) for i, bit in enumerate(self.display_bits): if bit == "0": y[i*self.samples_per_symbol:(i + 1) * self.samples_per_symbol] = -1.0 x = np.arange(0, n).astype(np.int64) scene = ZoomableScene() scene.setSceneRect(0, -1.25, n, 2.5) scene.setBackgroundBrush(settings.BGCOLOR) scene.addLine(0, 0, n, 0, QPen(settings.AXISCOLOR, 0)) path = path_creator.array_to_QPath(x, y) scene.addPath(path, QPen(settings.LINECOLOR, 0)) return scene
Example #6
Source File: main.py From BeautyCamera with MIT License | 6 votes |
def show_grayimage(self): img_cv = self.gray_image img_width, img_height = img_cv.shape ratio_img = img_width/img_height ratio_scene = self.ui.graphicsView.width()/self.ui.graphicsView.height() if ratio_img > ratio_scene: width = int(self.ui.graphicsView.width()) height = int(self.ui.graphicsView.width() / ratio_img) else: width = int(self.ui.graphicsView.height() * ratio_img) height = int(self.ui.graphicsView.height()) img_resize = cv2.resize(img_cv, (height-5, width-5), interpolation=cv2.INTER_AREA) h, w = img_resize.shape qimg = QImage(img_resize.data, w, h, w, QImage.Format_Grayscale8) self.scene = QGraphicsScene() pix = QPixmap(qimg) self.scene.addPixmap(pix) self.ui.graphicsView.setScene(self.scene) # 显示直方图
Example #7
Source File: main.py From BeautyCamera with MIT License | 6 votes |
def show_image(self): img_cv = cv2.cvtColor(self.current_img, cv2.COLOR_RGB2BGR) img_width, img_height, a = img_cv.shape ratio_img = img_width/img_height ratio_scene = self.ui.graphicsView.width()/self.ui.graphicsView.height() if ratio_img > ratio_scene: width = int(self.ui.graphicsView.width()) height = int(self.ui.graphicsView.width() / ratio_img) else: width = int(self.ui.graphicsView.height() * ratio_img) height = int(self.ui.graphicsView.height()) img_resize = cv2.resize(img_cv, (height-5, width-5), interpolation=cv2.INTER_AREA) h, w, c = img_resize.shape bytesPerLine = w * 3 qimg = QImage(img_resize.data, w, h, bytesPerLine, QImage.Format_RGB888) self.scene = QGraphicsScene() pix = QPixmap(qimg) self.scene.addPixmap(pix) self.ui.graphicsView.setScene(self.scene) # 显示灰度图像
Example #8
Source File: pyqt_backend.py From ezdxf with MIT License | 6 votes |
def __init__(self, scene: qw.QGraphicsScene, point_radius: float = 0.5, *, draw_individual_polyline_elements: bool = False, debug_draw_rect: bool = False): super().__init__() self.scene = scene self._color_cache = {} self.point_radius = point_radius self.draw_individual_polyline_elements = draw_individual_polyline_elements self._no_line = qg.QPen(qc.Qt.NoPen) self._no_fill = qg.QBrush(qc.Qt.NoBrush) self._font = qg.QFont() self._font_measurements = _get_font_measurements(self._font) self._debug_draw_rect = debug_draw_rect self._polyline_components: List[Union[_BufferedLineSegment, _BufferedArc]] = []
Example #9
Source File: Test.py From DeepLearning_Wavelet-LSTM with MIT License | 6 votes |
def ok(self): self.gridLayoutWidget = QtWidgets.QWidget() self.gridLayoutWidget.setGeometry(QtCore.QRect(180, 10, 1100, 500)) # 定义gridLayout控件的大小和位置,4个数字分别为左边坐标,上边坐标,长,宽 self.gridLayoutWidget.setObjectName("gridLayoutWidget") self.gridLayout_2 = QtWidgets.QGridLayout(self.gridLayoutWidget) self.gridLayout_2.setContentsMargins(0, 0, 0, 0) # 在gridLayoutWidget 上创建一个网格Layout,注意以gridLayoutWidget为参 self.gridLayout_2.setObjectName("gridLayout_2") # ===通过graphicview来显示图形 self.graphicview = QtWidgets.QGraphicsView(self.gridLayoutWidget) # 第一步,创建一个QGraphicsView,注意同样以gridLayoutWidget为参 self.graphicview.setObjectName("graphicview") self.gridLayout_2.addWidget(self.graphicview, 0, 0) #第二步,将该QGraphicsView放入Layout中 dr = Figure_Canvas() #实例化一个FigureCanvas dr.test() # 画图 graphicscene = QtWidgets.QGraphicsScene() # 第三步,创建一个QGraphicsScene,因为加载的图形(FigureCanvas)不能直接放到graphicview控件中,必须先放到graphicScene,然后再把graphicscene放到graphicview中 graphicscene.addWidget(dr) # 第四步,把图形放到QGraphicsScene中,注意:图形是作为一个QWidget放到QGraphicsScene中的 self.graphicview.setScene(graphicscene) # 第五步,把QGraphicsScene放入QGraphicsView self.graphicview.show() # 最后,调用show方法呈现图形!Voila!!
Example #10
Source File: Test.py From DeepLearning_Wavelet-LSTM with MIT License | 6 votes |
def ok(self): self.gridLayoutWidget = QtWidgets.QWidget() self.gridLayoutWidget.setGeometry(QtCore.QRect(180, 10, 1100, 500)) # 定义gridLayout控件的大小和位置,4个数字分别为左边坐标,上边坐标,长,宽 self.gridLayoutWidget.setObjectName("gridLayoutWidget") self.gridLayout_2 = QtWidgets.QGridLayout(self.gridLayoutWidget) self.gridLayout_2.setContentsMargins(0, 0, 0, 0) # 在gridLayoutWidget 上创建一个网格Layout,注意以gridLayoutWidget为参 self.gridLayout_2.setObjectName("gridLayout_2") # ===通过graphicview来显示图形 self.graphicview = QtWidgets.QGraphicsView(self.gridLayoutWidget) # 第一步,创建一个QGraphicsView,注意同样以gridLayoutWidget为参 self.graphicview.setObjectName("graphicview") self.gridLayout_2.addWidget(self.graphicview, 0, 0) #第二步,将该QGraphicsView放入Layout中 dr = Figure_Canvas() #实例化一个FigureCanvas dr.test() # 画图 graphicscene = QtWidgets.QGraphicsScene() # 第三步,创建一个QGraphicsScene,因为加载的图形(FigureCanvas)不能直接放到graphicview控件中,必须先放到graphicScene,然后再把graphicscene放到graphicview中 graphicscene.addWidget(dr) # 第四步,把图形放到QGraphicsScene中,注意:图形是作为一个QWidget放到QGraphicsScene中的 self.graphicview.setScene(graphicscene) # 第五步,把QGraphicsScene放入QGraphicsView self.graphicview.show() # 最后,调用show方法呈现图形!Voila!!
Example #11
Source File: playerconditionwidget.py From PyPipboyApp with GNU General Public License v3.0 | 6 votes |
def init(self, app, datamanager): super().init(app, datamanager) self.statsColor = QtGui.QColor.fromRgb(20,255,23) self.dataManager = datamanager self.dataManager.registerRootObjectListener(self._onPipRootObjectEvent) self.statsView = self.widget.graphicsView self.statsScene = QtWidgets.QGraphicsScene() self.statsScene.setBackgroundBrush(QtGui.QBrush(QtGui.QColor.fromRgb(0,0,0))) self.statsView.setScene(self.statsScene) self.bodyCondFilePath = os.path.join('res', 'body_condition_0.svg') self.headCondFilePath = os.path.join('res', 'head_condition_0.svg') self.headCondition = 0 headPixmap = self.imageFactory.getPixmap(self.headCondFilePath, height=50, color=self.statsColor) self.statsHeadItem = self.statsScene.addPixmap(headPixmap) self.statsHeadItem.setPos(-headPixmap.width()/2, 0) self.bodyCondition = 0 bodyPixmap = self.imageFactory.getPixmap(self.bodyCondFilePath, height=100, color=self.statsColor) self.statsBodyItem = self.statsScene.addPixmap(bodyPixmap) self.statsBodyItem.setPos(-bodyPixmap.width()/2, 42)
Example #12
Source File: editor.py From imperialism-remake with GNU General Public License v3.0 | 6 votes |
def __init__(self, column, row): super().__init__() self.scene = QtWidgets.QGraphicsScene() self.setScene(self.scene) self.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff) self.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff) # TODO see EditorMap redraw brushes = {0: QtGui.QBrush(QtGui.QColor(64, 64, 255)), 1: QtGui.QBrush(QtGui.QColor(64, 255, 64)), 2: QtGui.QBrush(QtGui.QColor(64, 255, 64)), 3: QtGui.QBrush(QtGui.QColor(64, 255, 64)), 4: QtGui.QBrush(QtGui.QColor(222, 222, 222)), 5: QtGui.QBrush(QtGui.QColor(0, 128, 0)), 6: QtGui.QBrush(QtGui.QColor(222, 222, 0))} # TODO hardcore tile size somewhere else (and a bit less hard) self.TILE_SIZE = 80 for i in range(0, 6): y = i // 4 x = i % 4 self.scene.addRect(x * self.TILE_SIZE, y * self.TILE_SIZE, self.TILE_SIZE, self.TILE_SIZE, brush=brushes[i], pen=qt.TRANSPARENT_PEN)
Example #13
Source File: breathing_dlg.py From mindfulness-at-the-computer with GNU General Public License v3.0 | 6 votes |
def __init__(self): super().__init__() self.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff) self.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff) self.setFixedWidth(VIEW_WIDTH_INT) self.setFixedHeight(VIEW_HEIGHT_INT) t_brush = QtGui.QBrush(QtGui.QColor(mc.mc_global.MC_WHITE_COLOR_STR)) self.setBackgroundBrush(t_brush) self.setRenderHints( QtGui.QPainter.Antialiasing | QtGui.QPainter.SmoothPixmapTransform ) self.setAlignment(QtCore.Qt.AlignCenter) self._graphics_scene = QtWidgets.QGraphicsScene() self.setScene(self._graphics_scene) # Custom dynamic breathing graphic (may be possible to change this in the future) self._breathing_gi = BreathingGraphicsObject() self._graphics_scene.addItem(self._breathing_gi) self._breathing_gi.update_pos_and_origin_point(VIEW_WIDTH_INT, VIEW_HEIGHT_INT) self._breathing_gi.hover_signal.connect(self._breathing_gi_hover) # -Please note that for breathing in we use a static sized rectangle (instead of the one the user sees), # this is the reason for using "hover" instead of "enter above" self._breathing_gi.leave_signal.connect(self._breathing_gi_leave) # Text self.text_gi = TextGraphicsItem() self.text_gi.setAcceptHoverEvents(False) # -so that the underlying item will not be disturbed ib_str = mc.model.PhrasesM.get(mc.mc_global.active_phrase_id_it).ib self.text_gi.setHtml(mc.mc_global.get_html(ib_str)) self.text_gi.setTextWidth(200) self.text_gi.update_pos_and_origin_point(VIEW_WIDTH_INT, VIEW_HEIGHT_INT) self.text_gi.setDefaultTextColor(QtGui.QColor(mc.mc_global.MC_DARKER_GREEN_COLOR_STR)) self._graphics_scene.addItem(self.text_gi) self._peak_scale_ft = 1
Example #14
Source File: lab3.py From Computer-graphics with MIT License | 6 votes |
def __init__(self): QtWidgets.QWidget.__init__(self) uic.loadUi("window.ui", self) self.scene = QtWidgets.QGraphicsScene(0, 0, 511, 511) self.mainview.setScene(self.scene) self.image = QImage(511, 511, QImage.Format_ARGB32_Premultiplied) self.pen = QPen() self.color_line = QColor(Qt.black) self.color_bground = QColor(Qt.white) self.draw_line.clicked.connect(lambda: draw_line(self)) self.clean_all.clicked.connect(lambda : clear_all(self)) self.btn_bground.clicked.connect(lambda: get_color_bground(self)) self.btn_line.clicked.connect(lambda: get_color_line(self)) self.draw_sun.clicked.connect(lambda: draw_sun(self)) self.cda.setChecked(True)
Example #15
Source File: lab3.py From Computer-graphics with MIT License | 6 votes |
def get_color_bground(win): color = QtWidgets.QColorDialog.getColor(initial=Qt.white, title='Цвет фона', options=QtWidgets.QColorDialog.DontUseNativeDialog) if color.isValid(): win.color_bground = color win.image.fill(color) s = QtWidgets.QGraphicsScene(0, 0, 10, 10) s.setBackgroundBrush(color) win.bground_color.setScene(s) win.scene.setBackgroundBrush(color)
Example #16
Source File: lab4.py From Computer-graphics with MIT License | 6 votes |
def __init__(self): QtWidgets.QWidget.__init__(self) uic.loadUi("window.ui", self) self.scene = QtWidgets.QGraphicsScene(0, 0, 511, 511) self.mainview.setScene(self.scene) self.image = QImage(511, 511, QImage.Format_ARGB32_Premultiplied) self.pen = QPen() self.color_line = QColor(Qt.black) self.color_bground = QColor(Qt.white) self.draw_once.clicked.connect(lambda: draw_once(self)) self.clean_all.clicked.connect(lambda: clear_all(self)) self.btn_bground.clicked.connect(lambda: get_color_bground(self)) self.btn_line.clicked.connect(lambda: get_color_line(self)) self.draw_centr.clicked.connect(lambda: draw_centr(self)) layout = QtWidgets.QHBoxLayout() layout.addWidget(self.what) layout.addWidget(self.other) self.setLayout(layout) self.circle.setChecked(True) self.canon.setChecked(True) #self.circle.toggled.connect(lambda : change_text(self))
Example #17
Source File: lab3.py From Computer-graphics with MIT License | 5 votes |
def get_color_line(win): color = QtWidgets.QColorDialog.getColor(initial=Qt.black, title='Цвет линии', options=QtWidgets.QColorDialog.DontUseNativeDialog) if color.isValid(): win.color_line = color win.pen.setColor(color) s = QtWidgets.QGraphicsScene(0, 0, 10, 10) s.setBackgroundBrush(color) win.line_color.setScene(s)
Example #18
Source File: codescene.py From CodeAtlasSublime with Eclipse Public License 1.0 | 5 votes |
def __init__(self, *args): super(CodeScene, self).__init__(*args) self.itemDict = {} self.edgeDict = {} self.stopItem = {} # 不显示的符号 self.scheme = {} # 保存的call graph, # {'schemeName': {'node':[node1, node2,...], 'edge':{(node3, node5):{'customEdge':True}, ...}}, ...} self.curValidScheme = []# 选中物体有关的scheme self.curValidSchemeColor = [] self.candidateEdge = [] # candidate edge up/down/left/right will select self.isSourceCandidate = True self.edgeDataDict = {} # 存放需要保存的边用户数据 self.itemDataDict = {} # 存放需要保存的点用户数据 self.itemLruQueue = [] self.lruMaxLength = 100 self.isLayoutDirty = False self.setItemIndexMethod(QtWidgets.QGraphicsScene.NoIndex) self.lock = RecursiveLock() self.updateThread = SceneUpdateThread(self, self.lock) self.updateThread.start() self.cornerItem = [] self.autoFocus = True self.autoFocusToggle = True self.selectTimeStamp = 0 for i in range(4): item = QtWidgets.QGraphicsRectItem(0,0,5,5) item.setPen(QtGui.QPen(QtGui.QColor(0,0,0,0))) item.setBrush(QtGui.QBrush()) self.cornerItem.append(item) self.addItem(item) # self.connect(self, QtCore.SIGNAL('selectionChanged()'), self, QtCore.SLOT('onSelectItems()')) self.selectionChanged.connect(self.onSelectItems) # 添加或修改call graph
Example #19
Source File: main.py From python-examples with MIT License | 5 votes |
def __init__(self): super().__init__() self.view = QtWidgets.QGraphicsView() self.scene = QtWidgets.QGraphicsScene(self) self.view.setScene(self.scene) my_rect = MyRect() self.scene.addItem(my_rect) layout = QtWidgets.QHBoxLayout() layout.addWidget(self.view) self.setLayout(layout)
Example #20
Source File: live_spectrogram.py From urh with GNU General Public License v3.0 | 5 votes |
def go(): global graphic_view, status_label data_parent, data_child = Pipe(duplex=False) receiver = Process(target=generate_data, args=(data_child,)) receiver.daemon = True receiver.start() scene = QGraphicsScene() graphic_view.setScene(scene) scene.setSceneRect(0, 0, 1024, 1024) x_pos = 0 y_pos = 0 t = time.time() while True: speed = time.time() data = data_parent.recv() spectrogram = Spectrogram(data) pixmap = QPixmap.fromImage(spectrogram.create_spectrogram_image(transpose=True)) scene.setSceneRect(scene.sceneRect().adjusted(0, 0, 0, pixmap.height())) item = scene.addPixmap(pixmap) item.setPos(x_pos, y_pos) y_pos += pixmap.height() graphic_view.fitInView(scene.sceneRect()) status_label.setText("Height: {0:.0f} // Speed: {1:.2f} // Total Time: {2:.2f}".format(scene.sceneRect().height(), 1/(time.time()-speed), time.time()-t)) QApplication.instance().processEvents()
Example #21
Source File: SpectrumDialogController.py From urh with GNU General Public License v3.0 | 5 votes |
def __init__(self, project_manager, parent=None, testing_mode=False): super().__init__(project_manager, is_tx=False, parent=parent, testing_mode=testing_mode) self.graphics_view = self.ui.graphicsViewFFT self.update_interval = 1 self.ui.stackedWidget.setCurrentWidget(self.ui.page_spectrum) self.hide_receive_ui_items() self.hide_send_ui_items() self.setWindowTitle("Spectrum Analyzer") self.setWindowIcon(QIcon(":/icons/icons/spectrum.svg")) self.ui.btnStart.setToolTip(self.tr("Start")) self.ui.btnStop.setToolTip(self.tr("Stop")) self.scene_manager = FFTSceneManager(parent=self, graphic_view=self.graphics_view) self.graphics_view.setScene(self.scene_manager.scene) self.graphics_view.scene_manager = self.scene_manager self.ui.graphicsViewSpectrogram.setScene(QGraphicsScene()) self.__clear_spectrogram() self.gain_timer = QTimer(self) self.gain_timer.setSingleShot(True) self.if_gain_timer = QTimer(self) self.if_gain_timer.setSingleShot(True) self.bb_gain_timer = QTimer(self) self.bb_gain_timer.setSingleShot(True) self.create_connects() self.device_settings_widget.update_for_new_device(overwrite_settings=False)
Example #22
Source File: common.py From detection with GNU General Public License v2.0 | 5 votes |
def blurPixmap(pixmap, radius): effect = QGraphicsBlurEffect() effect.setBlurRadius(radius) buffer = QPixmap(pixmap) item = QGraphicsPixmapItem(buffer) item.setGraphicsEffect(effect) output = QPixmap(pixmap.width(), pixmap.height()) painter = QtGui.QPainter(output) scene = QtWidgets.QGraphicsScene() view = QtWidgets.QGraphicsView(scene) scene.addItem(item) scene.render(painter) return output
Example #23
Source File: aman.py From bluesky with GNU General Public License v3.0 | 5 votes |
def __init__(self): super(AMANDisplay, self).__init__() self.setGeometry(0, 0, 500, 600) self.setStyleSheet('background-color:#233370') self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.scene = QGraphicsScene(0, 0, 500, 600) # Timeline boundaries pen = QPen(QColor('white')) brush = QBrush(QColor('#233370')) self.scene.addLine(220, 0, 220, 600, pen) self.scene.addLine(280, 0, 280, 600, pen) self.scene.addLine(0, 30, 500, 30, pen) timelinebox = self.scene.addRect(220, 30, 60, 540, pen, brush) timelinebox.setFlag(timelinebox.ItemClipsChildrenToShape, True) # Timeline scale self.timeline = QGraphicsItemGroup() self.timeline.setParentItem(timelinebox) self.timeticks = [] for i in range(40): y = 15 * i w = 6 if i % 5 == 0: w = 10 self.timeticks.append(self.scene.addText('%02d' % (40 - i), QFont('Courier', 10))) self.timeticks[-1].setPos(240, y - 10) self.timeticks[-1].setDefaultTextColor(QColor('white')) self.timeline.addToGroup(self.timeticks[-1]) self.timeline.addToGroup(self.scene.addLine(220, y, 220 + w, y, pen)) self.timeline.addToGroup(self.scene.addLine(280 - w, y, 280, y, pen)) self.lrwy = self.scene.addText('18R', QFont('Arial', 20, 50)) self.lrwy.setPos(1, 1) self.lrwy.setDefaultTextColor(QColor('white')) # Finalize self.setScene(self.scene) self.show()
Example #24
Source File: HDF5VideoPlayer.py From tierpsy-tracker with MIT License | 5 votes |
def __init__(self, view): self._view = view self._scene = QtWidgets.QGraphicsScene(self._view) self._view.setScene(self._scene) self._canvas = QtWidgets.QGraphicsPixmapItem() self._scene.addItem(self._canvas) self._zoom = 0 self._view.wheelEvent = self.zoomWheelEvent # zoom wheel
Example #25
Source File: test_drawing_pyqt5_backend.py From ezdxf with MIT License | 5 votes |
def backend(): global _app _app = qw.QApplication([]) scene = qw.QGraphicsScene() return PyQtBackend(scene)
Example #26
Source File: cad_viewer.py From ezdxf with MIT License | 5 votes |
def mouseMoveEvent(self, event: qg.QMouseEvent) -> None: pos = self.mapToScene(event.pos()) self._current_item = self.scene().itemAt(pos, qg.QTransform()) self.element_selected.emit(self._current_item, pos) self.scene().invalidate(self.sceneRect(), qw.QGraphicsScene.ForegroundLayer) super().mouseMoveEvent(event)
Example #27
Source File: image_dialog.py From CvStudio with MIT License | 5 votes |
def __init__(self, parent=None): super(ImageDialogViewer, self).__init__(parent) self.setRenderHints(QPainter.Antialiasing | QPainter.SmoothPixmapTransform) # self.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignTop) self.setTransformationAnchor(QGraphicsView.AnchorUnderMouse) self.setDragMode(QGraphicsView.ScrollHandDrag) self.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff) self.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff) self._scene = QGraphicsScene(self) self.setScene(self._scene) self._pixmap = None
Example #28
Source File: lab10.py From Computer-graphics with MIT License | 5 votes |
def __init__(self): QtWidgets.QWidget.__init__(self) uic.loadUi("window.ui", self) self.scene = QGraphicsScene(0, 0, 711, 601) self.scene.win = self self.view.setScene(self.scene) self.image = QImage(710, 600, QImage.Format_Alpha8) self.image.fill(black) self.pen = QPen(black) self.draw.clicked.connect(lambda: draw(self)) self.dial_x.valueChanged.connect(lambda: draw(self)) self.dial_y.valueChanged.connect(lambda: draw(self)) self.dial_z.valueChanged.connect(lambda: draw(self)) self.funcs.addItem("cos(x) * sin(z)") self.funcs.addItem("2 * cos(x * z)") self.funcs.addItem("exp(sin(sqrt(x^2 + z^2)))") self.funcs.addItem("x^2 / 20 + z^2 / 20") self.funcs.addItem("|sin(x) * sin(z)|")
Example #29
Source File: breathing_history_wt.py From mindfulness-at-the-computer with GNU General Public License v3.0 | 5 votes |
def __init__(self): super().__init__() self.show() self.setMinimumHeight(300) self.ib_qtimer = None self.ob_qtimer = None self.updating_gui_bool = False self.new_cycle_bool = True self.in_breath_graphics_qgri_list = [] self.out_breath_graphics_qgri_list = [] vbox_l2 = QtWidgets.QVBoxLayout() self.setLayout(vbox_l2) # vbox_l2.addWidget(QtWidgets.QLabel("Breathing History")) self.breathing_graphicsview = QtWidgets.QGraphicsView() # QGraphicsScene vbox_l2.addWidget(self.breathing_graphicsview) self.breathing_graphicsscene = QtWidgets.QGraphicsScene() self.breathing_graphicsview.setScene(self.breathing_graphicsscene) # self.breathing_graphicsview.centerOn(QtCore.Qt.AlignRight) # alignment can be set with "setAlignment" self.breathing_graphicsview.setDragMode(QtWidgets.QGraphicsView.ScrollHandDrag)
Example #30
Source File: QtImageViewer.py From PyQtImageViewer with MIT License | 5 votes |
def __init__(self): QGraphicsView.__init__(self) # Image is displayed as a QPixmap in a QGraphicsScene attached to this QGraphicsView. self.scene = QGraphicsScene() self.setScene(self.scene) # Store a local handle to the scene's current image pixmap. self._pixmapHandle = None # Image aspect ratio mode. # !!! ONLY applies to full image. Aspect ratio is always ignored when zooming. # Qt.IgnoreAspectRatio: Scale image to fit viewport. # Qt.KeepAspectRatio: Scale image to fit inside viewport, preserving aspect ratio. # Qt.KeepAspectRatioByExpanding: Scale image to fill the viewport, preserving aspect ratio. self.aspectRatioMode = Qt.KeepAspectRatio # Scroll bar behaviour. # Qt.ScrollBarAlwaysOff: Never shows a scroll bar. # Qt.ScrollBarAlwaysOn: Always shows a scroll bar. # Qt.ScrollBarAsNeeded: Shows a scroll bar only when zoomed. self.setHorizontalScrollBarPolicy(Qt.ScrollBarAsNeeded) self.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded) # Stack of QRectF zoom boxes in scene coordinates. self.zoomStack = [] # Flags for enabling/disabling mouse interaction. self.canZoom = True self.canPan = True