代码拉取完成,页面将自动刷新
同步操作将从 PyQt5/CustomWidgets 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Created on 2019年7月24日
@author: Irony
@site: https://pyqt5.com https://github.com/892768447
@email: 892768447@qq.com
@file: TestCDrawer
@description:
"""
from PyQt5.QtCore import Qt
from PyQt5.QtWidgets import QWidget, QGridLayout, QPushButton, QVBoxLayout,\
QLineEdit
from CustomWidgets.CDrawer import CDrawer
__Author__ = 'Irony'
__Copyright__ = 'Copyright (c) 2019'
class DrawerWidget(QWidget):
def __init__(self, *args, **kwargs):
super(DrawerWidget, self).__init__(*args, **kwargs)
self.setAttribute(Qt.WA_StyledBackground, True)
self.setStyleSheet('DrawerWidget{background:white;}')
layout = QVBoxLayout(self)
layout.addWidget(QLineEdit(self))
layout.addWidget(QPushButton('button', self))
class Window(QWidget):
def __init__(self, *args, **kwargs):
super(Window, self).__init__(*args, **kwargs)
self.resize(400, 300)
layout = QGridLayout(self)
layout.addWidget(QPushButton('上', self, clicked=self.doOpenTop), 0, 1)
layout.addWidget(QPushButton('左', self, clicked=self.doOpenLeft), 1, 0)
layout.addWidget(QPushButton(
'右', self, clicked=self.doOpenRight), 1, 2)
layout.addWidget(QPushButton(
'下', self, clicked=self.doOpenBottom), 2, 1)
def doOpenTop(self):
if not hasattr(self, 'topDrawer'):
self.topDrawer = CDrawer(self, stretch=0.5, direction=CDrawer.TOP)
self.topDrawer.setWidget(DrawerWidget(self.topDrawer))
self.topDrawer.show()
def doOpenLeft(self):
if not hasattr(self, 'leftDrawer'):
self.leftDrawer = CDrawer(self, direction=CDrawer.LEFT)
self.leftDrawer.setWidget(DrawerWidget(self.leftDrawer))
self.leftDrawer.show()
def doOpenRight(self):
if not hasattr(self, 'rightDrawer'):
self.rightDrawer = CDrawer(self, widget=DrawerWidget())
self.rightDrawer.setDirection(CDrawer.RIGHT)
self.rightDrawer.show()
def doOpenBottom(self):
if not hasattr(self, 'bottomDrawer'):
self.bottomDrawer = CDrawer(
self, direction=CDrawer.BOTTOM, widget=DrawerWidget())
self.bottomDrawer.setStretch(0.5)
self.bottomDrawer.show()
if __name__ == '__main__':
import sys
import cgitb
sys.excepthook = cgitb.enable(1, None, 5, '')
from PyQt5.QtWidgets import QApplication
app = QApplication(sys.argv)
w = Window()
w.show()
sys.exit(app.exec_())
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。