Giter Club home page Giter Club logo

Comments (2)

yjg30737 avatar yjg30737 commented on July 22, 2024

Sorry for the belated answer. I've seen the issue you had brought up, but i've been busy lately.

Well, first things first

  1. 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

image

There's a lot more things to go.

  1. Make the QGraphicsView to move the shape
  2. Drag the shape out of the window and drop it into the QGraphicsView
  3. Different section of the sidebar menus
  4. 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.

yjg30737 avatar yjg30737 commented on July 22, 2024

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 photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.