Python PyQt5 add CSS-like properties easy! 🎨

preview_player
Показать описание
#pythontutorial #python #pythonprogramming

00:00:00 intro
00:00:21 imports
00:00:47 buttons setup
00:01:35 layout manager
00:03:10 apply CSS to a class
00:06:12 apply CSS to an id
00:08:17 advanced colors
00:09:56 pseudo-classes

# PyQt5 setStyleSheet()
import sys
from PyQt5.QtWidgets import QApplication, QMainWindow, QPushButton, QWidget, QHBoxLayout

class MainWindow(QMainWindow):
def __init__(self):
super().__init__()

def initUI(self):
central_widget = QWidget()

hbox = QHBoxLayout()

QPushButton{
font-size: 40px;
font-family: Arial;
padding: 15px 75px;
margin: 25px;
border: 3px solid;
border-radius: 15px;
}
QPushButton#button1{
background-color: hsl(0, 100%, 64%);
}
QPushButton#button2{
background-color: hsl(122, 100%, 64%);
}
QPushButton#button3{
background-color: hsl(204, 100%, 64%);
}
QPushButton#button1:hover{
background-color: hsl(0, 100%, 84%);
}
QPushButton#button2:hover{
background-color: hsl(122, 100%, 84%);
}
QPushButton#button3:hover{
background-color: hsl(204, 100%, 84%);
}
""")

if ___name___ == '__main__':
window = MainWindow()
Рекомендации по теме
Комментарии
Автор

# PyQt5 setStyleSheet()
import sys
from PyQt5.QtWidgets import QApplication, QMainWindow, QPushButton, QWidget, QHBoxLayout

class MainWindow(QMainWindow):
def __init__(self):
super().__init__()
self.button1 = QPushButton("#1")
self.button2 = QPushButton("#2")
self.button3 = QPushButton("#3")
self.initUI()

def initUI(self):
central_widget = QWidget()


hbox = QHBoxLayout()

hbox.addWidget(self.button1)
hbox.addWidget(self.button2)
hbox.addWidget(self.button3)







self.setStyleSheet("""
QPushButton{
font-size: 40px;
font-family: Arial;
padding: 15px 75px;
margin: 25px;
border: 3px solid;
border-radius: 15px;
}
QPushButton#button1{
background-color: hsl(0, 100%, 64%);
}
QPushButton#button2{
background-color: hsl(122, 100%, 64%);
}
QPushButton#button3{
background-color: hsl(204, 100%, 64%);
}
QPushButton#button1:hover{
background-color: hsl(0, 100%, 84%);
}
QPushButton#button2:hover{
background-color: hsl(122, 100%, 84%);
}
QPushButton#button3:hover{
background-color: hsl(204, 100%, 84%);
}
""")

if ___name___ == '__main__':
app = QApplication(sys.argv)
window = MainWindow()
window.show()
sys.exit(app.exec_())

BroCodez
Автор

Pleass talk more about this. Thank you for your work.

tarindell
Автор

Bro please make in data structure algorithm in c++

SunitaSharma-mjhx
Автор

bro continue the react full tut video pls

devlver
Автор

Bro. Whats wrong with you channel new videos notifications. Bell checked but still a lot of subscribers aren't notified.

hurricanos
visit shbcf.ru