Comments (2)
Sorry for the belated answer. I've seen the issue you had brought up, but i've been busy lately.
Well, first things first
- Menu of shapes
import sys
from PyQt5.QtWidgets import QApplication, QMainWindow, QGraphicsRectItem, \
QGraphicsScene, QGraphicsView, QWidget, QGridLayout, QGraphicsEllipseItem, \
QGraphicsPolygonItem, QGraphicsItem
from PyQt5.QtGui import QPolygonF
from PyQt5.QtCore import Qt, QPointF
class ShapeIcon(QGraphicsView):
def __init__(self, graphics_item: QGraphicsItem):
super().__init__()
self.setScene(QGraphicsScene(self))
self.setAlignment(Qt.AlignCenter)
self.scene().addItem(graphics_item)
self.setStyleSheet('QGraphicsView { border: 0 }')
class ShapeMenu(QWidget):
def __init__(self):
super().__init__()
self.__initVal()
self.__initUi()
def __initVal(self):
self.__rect = QGraphicsRectItem(0, 0, 40, 30)
self.__ellipse = QGraphicsEllipseItem(0, 0, 40, 30)
points = [
QPointF(20, 0),
QPointF(0, 20),
QPointF(20, 40),
QPointF(40, 20),
]
self.__rhombus = QGraphicsPolygonItem(QPolygonF(points))
points = [
QPointF(0, 0),
QPointF(-10, 30),
QPointF(30, 30),
QPointF(40, 0),
]
self.__parallelogram = QGraphicsPolygonItem(QPolygonF(points))
def __initUi(self):
lay = QGridLayout()
lay.setSpacing(0)
shape_lst = [self.__rect,
self.__ellipse,
self.__rhombus,
self.__parallelogram]
for i in range(len(shape_lst)):
curShape = shape_lst[i]
cellWidget = ShapeIcon(curShape)
lay.addWidget(cellWidget, i // 3, i % 3)
self.setLayout(lay)
class Window(QMainWindow):
def __init__(self):
super().__init__()
self.__initUi()
def __initUi(self):
mainWidget = ShapeMenu()
mainWidget.setFixedSize(mainWidget.sizeHint())
self.setCentralWidget(mainWidget)
if __name__ == "__main__":
app = QApplication(sys.argv)
window = Window()
window.show()
sys.exit(app.exec_())
Result
There's a lot more things to go.
- Make the QGraphicsView to move the shape
- Drag the shape out of the window and drop it into the QGraphicsView
- Different section of the sidebar menus
- Foldable menu
Correct me if i'm wrong
I think that the issues you brought up at my other repositories talk about the same thing. So let's just talk about it in here.
This is kinda challenging so i need to do this, step by step :) Hope you don't mind
from pyqt-hidable-menubar.
This is the repo i've just made by this request
https://github.com/yjg30737/pyqt-grid-item-manager
You can keep track of that as well
from pyqt-hidable-menubar.
Related Issues (1)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pyqt-hidable-menubar.