datetime:2019/5/21 17:51
author:nzb
工具框
import sys
from PyQt5.QtWidgets import QWidget, QApplication, QLabel, QGroupBox, \
QHBoxLayout, QPushButton, QVBoxLayout, QSpinBox, QLCDNumber
from PyQt5.QtWidgets import QDial, QToolBox
from PyQt5 import QtGui, QtCore
from PyQt5.QtCore import Qt, QThread, pyqtSignal
class UI_demo(QWidget):
"""用户界面"""
def __init__(self):
super().__init__()
self.title = 'PyQt5 Toolbox'
self.left = 600
self.top = 200
self.width = 440
self.height = 400
self.iconName = '../img/home.ico'
self.initWindow()
def initWindow(self):
self.setWindowIcon(QtGui.QIcon(self.iconName))
self.setGeometry(self.left, self.top, self.width, self.height)
self.setWindowTitle(self.title)
self.setStyleSheet('background-color:yellow')
self.initUI()
self.show()
def initUI(self):
"""工具盒子"""
vbox = QVBoxLayout()
toolbox = QToolBox()
toolbox.setStyleSheet('background-color:green')
vbox.addWidget(toolbox)
label = QLabel()
toolbox.addItem(label, "Python")
label = QLabel()
toolbox.addItem(label, "Java")
label = QLabel()
toolbox.addItem(label, "PHP")
self.setLayout(vbox)
if __name__ == "__main__":
app = QApplication(sys.argv)
ex = UI_demo()
sys.exit(app.exec_())