first circle

This commit is contained in:
2024-09-04 21:26:42 +02:00
parent 787d4e776a
commit 054384ca85
4 changed files with 109 additions and 45 deletions

View File

@@ -1,48 +1,30 @@
import sys
from PySide6.QtCore import Qt
from PySide6.QtGui import QBrush, QPainter, QPen
from PySide6.QtGui import QPainter
from PySide6.QtWidgets import (
QApplication,
QGraphicsEllipseItem,
QGraphicsRectItem,
QGraphicsScene,
QGraphicsView,
QHBoxLayout,
QVBoxLayout,
QWidget,
QWidget
)
from grid.ui.pattern import Pattern
class Window(QWidget):
def __init__(self):
super().__init__()
self.setWindowTitle("sphere grid")
self.setGeometry(0, 0, 600, 600)
# Defining a scene rect of 400x200, with it's origin at 0,0.
# If we don't set this on creation, we can set it later with .setSceneRect
self.scene = QGraphicsScene(0, 0, 600, 400)
for i in range(5):
# Draw a rectangle item, setting the dimensions.
rect = QGraphicsRectItem(0, 0, 200, 50)
rect.setPos(50+i*10, 20+ i*20)
brush = QBrush(Qt.GlobalColor.red)
rect.setBrush(brush)
# Define the pen (line)
pen = QPen(Qt.GlobalColor.cyan)
pen.setWidth(10)
rect.setPen(pen)
self.scene.addItem(rect)
pp = Pattern(0, 0)
#for wid in pp.content:
# self.scene.addItem(wid)
ellipse = QGraphicsEllipseItem(0, 0, 100, 100)
ellipse.setPos(75, 30)
brush = QBrush(Qt.GlobalColor.blue)
ellipse.setBrush(brush)
pen = QPen(Qt.GlobalColor.green)
pen.setWidth(5)
ellipse.setPen(pen)
# Add the items to the scene. Items are stacked in the order they are added.
self.scene.addItem(ellipse)
self.scene.addItem(pp)
# Define our layout.
hbox = QHBoxLayout()
@@ -55,10 +37,8 @@ class Window(QWidget):
vbox.addWidget(view)
self.setLayout(vbox)
self.show()
app = QApplication(sys.argv)
w = Window()
w.show()
app.exec()