|
1 | | -#!/usr/bin/env python |
2 | | -# -*- coding: utf-8 -*- |
3 | | - |
4 | | -""" |
5 | | -Created on 2019年1月18日 |
6 | | -@author: Irony |
7 | | -@site: https://pyqt5.com https://github.com/892768447 |
8 | | -@email: 892768447@qq.com |
9 | | -@file: Test.TestMainwindowStyle |
10 | | -@description: |
11 | | -""" |
12 | | -from PyQt5.QtCore import Qt |
13 | | -from PyQt5.QtWidgets import QWidget, QListWidget |
14 | | - |
15 | | -from UiFiles.Ui_MainWindow import Ui_FormMainWindow |
16 | | -from Utils.ThemeManager import ThemeManager |
17 | | - |
18 | | - |
19 | | -__Author__ = "Irony" |
20 | | -__Copyright__ = "Copyright (c) 2019" |
21 | | - |
22 | | - |
23 | | -class Window(QWidget, Ui_FormMainWindow): |
24 | | - |
25 | | - def __init__(self, *args, **kwargs): |
26 | | - super(Window, self).__init__(*args, **kwargs) |
27 | | - self.setAttribute(Qt.WA_TranslucentBackground, True) |
28 | | - self.setWindowFlags(self.windowFlags() | Qt.FramelessWindowHint) |
29 | | - self.setupUi(self) |
30 | | - ThemeManager.loadTheme() |
31 | | - ThemeManager.loadCursor(self) |
32 | | - ThemeManager.loadCursor(self.buttonHead, ThemeManager.CursorPointer) |
33 | | - |
34 | | - |
35 | | -if __name__ == '__main__': |
36 | | - import sys |
37 | | - import os |
38 | | - os.chdir('../') |
39 | | - from PyQt5.QtWidgets import QApplication |
40 | | - app = QApplication(sys.argv) |
41 | | - w = Window() |
42 | | - w.resize(800, 770) |
43 | | - w.show() |
44 | | - w.grab().save('Resources/Themes/Default/preview.png') |
45 | | - |
46 | | - lw = QListWidget() |
47 | | - lw.show() |
48 | | - lw.addItems(os.listdir('Resources/Themes')) |
49 | | - |
50 | | - def setStyle(item): |
51 | | - path = os.path.join('Resources/Themes', item.text(), 'style.qss') |
52 | | - if os.path.isfile(path): |
53 | | - ThemeManager.loadUserTheme(item.text()) |
54 | | - w.grab().save('Resources/Themes/{}/preview.png'.format(item.text())) |
55 | | - lw.itemClicked.connect(setStyle) |
56 | | - |
57 | | - sys.exit(app.exec_()) |
| 1 | +#!/usr/bin/env python |
| 2 | +# -*- coding: utf-8 -*- |
| 3 | + |
| 4 | +""" |
| 5 | +Created on 2019年1月18日 |
| 6 | +@author: Irony |
| 7 | +@site: https://pyqt5.com https://github.com/892768447 |
| 8 | +@email: 892768447@qq.com |
| 9 | +@file: Test.TestMainwindowStyle |
| 10 | +@description: |
| 11 | +""" |
| 12 | +from time import time |
| 13 | + |
| 14 | +from PyQt5.QtCore import Qt |
| 15 | +from PyQt5.QtWidgets import QWidget, QListWidget |
| 16 | + |
| 17 | +from UiFiles.Ui_MainWindow import Ui_FormMainWindow |
| 18 | +from Utils.ThemeManager import ThemeManager |
| 19 | + |
| 20 | + |
| 21 | +__Author__ = "Irony" |
| 22 | +__Copyright__ = "Copyright (c) 2019" |
| 23 | + |
| 24 | + |
| 25 | +class Window(QWidget, Ui_FormMainWindow): |
| 26 | + |
| 27 | + def __init__(self, *args, **kwargs): |
| 28 | + super(Window, self).__init__(*args, **kwargs) |
| 29 | + self.setAttribute(Qt.WA_TranslucentBackground, True) |
| 30 | + self.setWindowFlags(self.windowFlags() | Qt.FramelessWindowHint) |
| 31 | + self.setupUi(self) |
| 32 | + t = time() |
| 33 | + ThemeManager.loadTheme() |
| 34 | + print(time() - t) |
| 35 | + ThemeManager.loadCursor(self) |
| 36 | + ThemeManager.loadCursor(self.buttonHead, ThemeManager.CursorPointer) |
| 37 | + |
| 38 | + |
| 39 | +if __name__ == '__main__': |
| 40 | + import sys |
| 41 | + import os |
| 42 | + os.chdir('../') |
| 43 | + from PyQt5.QtWidgets import QApplication |
| 44 | + app = QApplication(sys.argv) |
| 45 | + w = Window() |
| 46 | + w.resize(800, 770) |
| 47 | + w.show() |
| 48 | + w.grab().save('Resources/Themes/Default/preview.png') |
| 49 | + |
| 50 | + lw = QListWidget() |
| 51 | + lw.show() |
| 52 | + lw.addItems(os.listdir('Resources/Themes')) |
| 53 | + |
| 54 | + def setStyle(item): |
| 55 | + path = os.path.join('Resources/Themes', item.text(), 'style.qss') |
| 56 | + if os.path.isfile(path): |
| 57 | + t = time() |
| 58 | + ThemeManager.loadUserTheme(item.text()) |
| 59 | + print(time()-t) |
| 60 | + w.grab().save('Resources/Themes/{}/preview.png'.format(item.text())) |
| 61 | + lw.itemClicked.connect(setStyle) |
| 62 | + |
| 63 | + sys.exit(app.exec_()) |
0 commit comments