| 1 |
from PySide6.QtWidgets import QApplication, QMainWindow |
| 2 |
from PySide6.QtUiTools import QUiLoader |
| 3 |
from PySide6.QtGui import QFontDatabase |
| 4 |
from qt_material import QtStyleTools |
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
class RuntimeStylesheets(QMainWindow, QtStyleTools): |
| 9 |
|
| 10 |
def __init__(self): |
| 11 |
"""""" |
| 12 |
super().__init__() |
| 13 |
self.main = QUiLoader().load('main_window.ui', self) |
| 14 |
|
| 15 |
self.main.pushButton.clicked.connect(lambda: self.apply_stylesheet(self.main, 'dark_teal.xml')) |
| 16 |
self.main.pushButton_2.clicked.connect(lambda: self.apply_stylesheet(self.main, 'light_red.xml', extra={'font_family': 'mono', })) |
| 17 |
self.main.pushButton_3.clicked.connect(lambda: self.apply_stylesheet(self.main, 'light_blue.xml', extra={'font_family': 'Raleway', })) |
| 18 |
|
| 19 |
|
| 20 |
if __name__ == "__main__": |
| 21 |
app = QApplication() |
| 22 |
|
| 23 |
|
| 24 |
QFontDatabase.addApplicationFont('Raleway-Regular.ttf') |
| 25 |
|
| 26 |
frame = RuntimeStylesheets() |
| 27 |
frame.main.show() |
| 28 |
|
| 29 |
app.exec_() |
| 30 |
|