Created
January 11, 2021 23:29
-
-
Save anddam/c671d3592c10131c0ebeb8bafef0f7f7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class QSelfLoadingWidgetMixin: | |
"""Load UI and CSS files into current instance | |
Expects a dict containing "ui" mandatory and "css" optional keys. | |
""" | |
def __init__(self, resource_files=None, parent=None): | |
super().__init__(parent) | |
if resource_files: | |
ui_file = resource_files.get("ui") | |
css_file = resource_files.get("css") | |
else: | |
ui_file, css_file = None, None | |
if ui_file: | |
loadUi(ui_file, self) | |
if css_file: | |
with open(css_file) as css_file: | |
self.setStyleSheet(css_file.read()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment