Answer the question
In order to leave comments, you need to log in
How to write a design for several buttons in PyQt5 Python in one setStyleSheet block?
Hello everyone, I'm trying to write an interface in PyQt without QT Designer. I need to set the design for several buttons in one StyleSheet block. (in this case b1 and b2).
groubBox.setStyleSheet doesn't work(
from PyQt5 import QtWidgets,QtGui,QtCore
from PyQt5.QtWidgets import QGroupBox,QHBoxLayout,QVBoxLayout,QPushButton
class Main(object):
def setupUi(self,window):
window.setObjectName("window")
window.setMinimumSize(500,500)
window.setWindowTitle("My Window")
self.central = QtWidgets.QWidget(window)
self.central.setObjectName("central")
window.setCentralWidget(self.central)
buttonsBox = QGroupBox("select") #группа кнопок
hbox = QHBoxLayout()
hbox.addWidget(buttonsBox)
vbox = QVBoxLayout()
self.b1 = QPushButton("ok",self.central).setGeometry(100,100,100,30) #первая кнопка
vbox.addWidget(self.b1)
self.b2 = QPushButton("cancel",self.central).setGeometry(0,100,100,30) #вторая кнопка
if __name__=="__main__":
import sys
app = QtWidgets.QApplication(sys.argv)
MainWindow = QtWidgets.QMainWindow()
ui = Main()
ui.setupUi(MainWindow)
MainWindow.show()
sys.exit(app.exec_())
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question