Package: pyside6-drawer
PySide6-DrawerPySide6 drawer - based on pyqt-drawerYou can set the widget to drawer.Opening, closing drawer involved animations of size change and drawer/parent window's opacity.Requirementssee requirements.txtSetuppython -m pip install PySide6-DrawerFeatureDrawer(parent, widget: QWidget, alignment)Constructor.parentis parent windowwidgetis the widget you want to set in the drawer.alignmentPlacement of drawer. Currently support Qt.AlignTop, Qt.AlignLeft, Qt.AlignRight, Qt.AlignBottomBeing able to set size/opacity duration withdrawer.setDuration(msc)Being able to set end size value withdrawer.setEndValue(size)Call .toggleDrawer to toggle the drawer's visibility. In the example below, the QPushButton clicked signal will call this;
up to the user to handle the button stateExampleCode ExamplefromPySide6.QtCoreimportQtfromPySide6.QtWidgetsimportQMainWindow,QApplication,QWidget,QGridLayout,QPushButton,QSizePolicyfrompyside6_drawer.drawerimportDrawerclassMainWindow(QMainWindow):def__init__(self):super().__init__()self.__initUi()def__initUi(self):mainWidget=QWidget()mainWidget.setLayout(QGridLayout())# Content behind widgetpb=QPushButton("Content",mainWidget)pb.setSizePolicy(QSizePolicy.Policy.Expanding,QSizePolicy.Policy.Expanding)mainWidget.layout().addWidget(pb)pb.clicked.connect(lambda:print("Content Clicked!"))# Left side drawer and buttonleftWidget=QPushButton("Left Drawer")leftWidget.setSizePolicy(QSizePolicy.Policy.Expanding,QSizePolicy.Policy.Expanding)drawerLeft=Drawer(self,leftWidget,alignment=Qt.AlignmentFlag.AlignLeft)mainWidget.layout().addWidget(drawerLeft,0,0,1,1)pb=QPushButton("Open Drawer",mainWidget)mainWidget.layout().addWidget(pb,0,0,0,0,Qt.AlignLeft)pb.clicked.connect(drawerLeft.toggleDrawer)# Top side drawer and buttontopWidget=QPushButton("Top Drawer")topWidget.setSizePolicy(QSizePolicy.Policy.Expanding,QSizePolicy.Policy.Expanding)drawerTop=Drawer(mainWidget,topWidget,alignment=Qt.AlignmentFlag.AlignTop)mainWidget.layout().addWidget(drawerTop,0,0,1,1)pb=QPushButton("Open Drawer",mainWidget)mainWidget.layout().addWidget(pb,0,0,0,0,Qt.AlignTop|Qt.AlignCenter)pb.clicked.connect(drawerTop.toggleDrawer)# Right side drawer and buttonrightWidget=QPushButton("Right Drawer")rightWidget.setSizePolicy(QSizePolicy.Policy.Expanding,QSizePolicy.Policy.Expanding)drawerRight=Drawer(self,rightWidget,alignment=Qt.AlignmentFlag.AlignRight)mainWidget.layout().addWidget(drawerRight,0,0,1,1)pb=QPushButton("Open Drawer",mainWidget)mainWidget.layout().addWidget(pb,0,0,0,0,Qt.AlignRight)pb.clicked.connect(drawerRight.toggleDrawer)# Bottom side drawer and buttonbottomWidget=QPushButton("Bottom Drawer")bottomWidget.setSizePolicy(QSizePolicy.Policy.Expanding,QSizePolicy.Policy.Expanding)drawerBottom=Drawer(mainWidget,bottomWidget,alignment=Qt.AlignmentFlag.AlignBottom)mainWidget.layout().addWidget(drawerBottom,0,0,1,1)pb=QPushButton("Open Drawer",mainWidget)mainWidget.layout().addWidget(pb,0,0,0,0,Qt.AlignBottom|Qt.AlignCenter)pb.clicked.connect(drawerBottom.toggleDrawer)mainWidget.layout().setContentsMargins(0,0,0,0)self.setCentralWidget(mainWidget)if__name__=="__main__":importsysapp=QApplication(sys.argv)mainWindow=MainWindow()mainWindow.setWindowTitle("PySide6 Drawer")mainWindow.show()mainWindow.setMinimumSize(600,600)app.exec()