From 403d299fc71ce3604e662fb59fa198652671b6c1 Mon Sep 17 00:00:00 2001 From: Matic Kukovec Date: Thu, 19 Aug 2021 22:24:09 +0200 Subject: [PATCH] Windows XP compatibility upgrade --- functions.py | 2 +- gui/baseeditor.py | 11 ++++++---- gui/mainwindow.py | 49 +++++++++++++++++++++++++++++--------------- gui/menu.py | 31 ++++++++++++++++++---------- gui/replbox.py | 17 +++++++++------ gui/repllineedit.py | 17 +++++++++------ gui/stylesheets.py | 41 ++++++++++++++++++++++++------------- gui/tabwidget.py | 50 ++++++++++++++++++++++++++++++--------------- 8 files changed, 142 insertions(+), 76 deletions(-) diff --git a/functions.py b/functions.py index a7dbfa5..489cd89 100644 --- a/functions.py +++ b/functions.py @@ -55,7 +55,7 @@ def create_icon(icon_name): def get_resource_file(relative_path): path = unixify_path_join(data.resources_directory, relative_path) if not os.path.isfile(path): - raise Exception(f"[Resources] File does not exist: {path}") + raise Exception("[Resources] File does not exist: {}".format(path)) return path pixmap_cache = {} diff --git a/gui/baseeditor.py b/gui/baseeditor.py index b8a841d..67cdddf 100644 --- a/gui/baseeditor.py +++ b/gui/baseeditor.py @@ -66,13 +66,16 @@ def set_theme(self, theme): self.setCaretLineBackgroundColor( theme.Cursor_Line_Background ) - self.setStyleSheet(f""" + self.setStyleSheet(""" BaseEditor {{ border: 0px; - background-color: {data.theme.Indication.PassiveBackGround}; + background-color: {}; padding: 0px; spacing: 0px; margin: 0px; }} - {StyleSheetScrollbar.full()} - """) \ No newline at end of file + {} + """.format( + data.theme.Indication.PassiveBackGround, + StyleSheetScrollbar.full(), + )) \ No newline at end of file diff --git a/gui/mainwindow.py b/gui/mainwindow.py index 2518900..de00347 100644 --- a/gui/mainwindow.py +++ b/gui/mainwindow.py @@ -3525,9 +3525,9 @@ def hide_settings_gui_manipulator(self): self._parent.settings.gui_manipulator.hide() def init_style_sheet(self): - style_sheet = (f""" + style_sheet = (""" #Form {{ - background-color: {data.theme.Form}; + background-color: {}; border: 0px; }} #Main_Groupbox {{ @@ -3539,10 +3539,14 @@ def init_style_sheet(self): width: 4px; }} QSplitter::handle {{ - background: {data.theme.Form}; + background: {}; }} - {StyleSheetScrollbar.full()} - """) + {} + """.format( + data.theme.Form, + data.theme.Form, + StyleSheetScrollbar.full() + )) return style_sheet def reset_window_colors(self, in_sheet): @@ -3561,35 +3565,46 @@ def reset_entire_style_sheet(self): self.indication_check() def generate_window_colors(self): - style_sheet = f""" + style_sheet = """ TabWidget::pane {{ - border: 2px solid {data.theme.Indication.PassiveBorder}; - background-color: {data.theme.Indication.PassiveBackGround}; + border: 2px solid {}; + background-color: {}; margin: 0px; spacing: 0px; padding: 0px; }} TabWidget[indicated=false]::pane {{ - border: 2px solid {data.theme.Indication.PassiveBorder}; - background-color: {data.theme.Indication.PassiveBackGround}; + border: 2px solid {}; + background-color: {}; }} TabWidget[indicated=true]::pane {{ - border: 2px solid {data.theme.Indication.ActiveBorder}; - background-color: {data.theme.Indication.ActiveBackGround}; + border: 2px solid {}; + background-color: {}; }} TabWidget QToolButton {{ - background: {data.theme.Indication.PassiveBackGround}; - border: 1px solid {data.theme.Indication.PassiveBorder}; + background: {}; + border: 1px solid {}; margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 1px; }} TabWidget QToolButton:hover {{ - background: {data.theme.Indication.ActiveBackGround}; - border: 1px solid {data.theme.Indication.ActiveBorder}; + background: {}; + border: 1px solid {}; }} - """ + """.format( + data.theme.Indication.PassiveBorder, + data.theme.Indication.PassiveBackGround, + data.theme.Indication.PassiveBorder, + data.theme.Indication.PassiveBackGround, + data.theme.Indication.ActiveBorder, + data.theme.Indication.ActiveBackGround, + data.theme.Indication.PassiveBackGround, + data.theme.Indication.PassiveBorder, + data.theme.Indication.ActiveBackGround, + data.theme.Indication.ActiveBorder, + ) return style_sheet def generate_treedisplay_colors(self, type): diff --git a/gui/menu.py b/gui/menu.py index 58e8ca3..6a03675 100644 --- a/gui/menu.py +++ b/gui/menu.py @@ -56,19 +56,24 @@ def __init__(self, *args, **kwargs): self.setFont(data.get_current_font()) def update_style(self): - self.setStyleSheet(f""" + self.setStyleSheet(""" QMenu {{ - background-color: {data.theme.Indication.PassiveBackGround}; - border: 1px solid {data.theme.Indication.PassiveBorder}; - color: {data.theme.Font.DefaultHtml} + background-color: {}; + border: 1px solid {}; + color: {} }} QMenu::item {{ background-color: transparent; }} QMenu::item:selected {{ - background-color: {data.theme.Indication.Hover}; + background-color: {}; }} - """) + """.format( + data.theme.Indication.PassiveBackGround, + data.theme.Indication.PassiveBorder, + data.theme.Font.DefaultHtml, + data.theme.Indication.Hover, + )) class MenuBar(data.QMenuBar): @@ -80,18 +85,22 @@ def __init__(self, *args, **kwargs): self.update_style() def update_style(self): - self.setStyleSheet(f""" + self.setStyleSheet(""" QMenuBar {{ - background-color: {data.theme.Indication.PassiveBackGround}; - color: {data.theme.Font.DefaultHtml}; + background-color: {}; + color: {}; }} QMenuBar::item {{ background-color: transparent; }} QMenuBar::item:selected {{ - background-color: {data.theme.Indication.Hover}; + background-color: {}; }} - """) + """.format( + data.theme.Indication.PassiveBackGround, + data.theme.Font.DefaultHtml, + data.theme.Indication.Hover, + )) diff --git a/gui/replbox.py b/gui/replbox.py index 600574d..17e5d49 100644 --- a/gui/replbox.py +++ b/gui/replbox.py @@ -87,13 +87,13 @@ def set_style(self, indicated): else: background = data.theme.Indication.PassiveBackGround border = data.theme.Indication.PassiveBorder - self.setStyleSheet(f""" + self.setStyleSheet(""" #REPL_Box {{ font-size: 8pt; font-weight: bold; - color: {border}; - background-color: {data.theme.Indication.PassiveBackGround}; - border: 2px solid {border}; + color: {}; + background-color: {}; + border: 2px solid {}; border-radius: 0px; margin-top: 6px; margin-bottom: 0px; @@ -105,12 +105,17 @@ def set_style(self, indicated): padding-right: 0px; }} #REPL_Box::title {{ - color: {data.theme.Indication.ActiveBorder}; + color: {}; subcontrol-position: top left; padding: 0px; left: 8px; top: -6px; }} - """) + """.format( + border, + data.theme.Indication.PassiveBackGround, + border, + data.theme.Indication.ActiveBorder, + )) \ No newline at end of file diff --git a/gui/repllineedit.py b/gui/repllineedit.py index 046f5a8..e3cb1f4 100644 --- a/gui/repllineedit.py +++ b/gui/repllineedit.py @@ -84,16 +84,21 @@ def __init__(self, parent, main_form, interpreter_references=None): def update_style(self): # REPL and REPL helper have to be set directly - self.setStyleSheet(f""" + self.setStyleSheet(""" QLineEdit[indicated=false] {{ - color: {data.theme.Font.DefaultHtml}; - background-color: {data.theme.Indication.PassiveBackGround}; + color: {}; + background-color: {}; }} QLineEdit[indicated=true] {{ - color: {data.theme.Font.DefaultHtml}; - background-color: {data.theme.Indication.ActiveBackGround}; + color: {}; + background-color: {}; }} - """) + """.format( + data.theme.Font.DefaultHtml, + data.theme.Indication.PassiveBackGround, + data.theme.Font.DefaultHtml, + data.theme.Indication.ActiveBackGround, + )) def indication_set(self): self.setProperty("indicated", True) diff --git a/gui/stylesheets.py b/gui/stylesheets.py index f60dc19..c50b7c5 100644 --- a/gui/stylesheets.py +++ b/gui/stylesheets.py @@ -23,22 +23,22 @@ def horizontal(): color_background = data.theme.ScrollBar.background color_handle = data.theme.ScrollBar.handle color_handle_hover = data.theme.ScrollBar.handle_hover - style_sheet = f""" + style_sheet = """ QScrollBar:horizontal {{ border: none; - background: {color_background}; - height: {height}px; + background: {}; + height: {}px; margin: 0px 0px 0px 0px; }} QScrollBar::handle:horizontal {{ - background: {color_handle}; + background: {}; min-width: 20px; }} QScrollBar::handle:hover {{ - background: {color_handle_hover}; + background: {}; }} QScrollBar::handle:horizontal:pressed {{ - background: {color_handle_hover}; + background: {}; }} QScrollBar::sub-line:horizontal, QScrollBar::add-line:horizontal, @@ -48,7 +48,13 @@ def horizontal(): width: 0px; height: 0px; }} - """ + """.format( + color_background, + height, + color_handle, + color_handle_hover, + color_handle_hover, + ) return style_sheet @staticmethod @@ -58,22 +64,22 @@ def vertical(): color_background = data.theme.ScrollBar.background color_handle = data.theme.ScrollBar.handle color_handle_hover = data.theme.ScrollBar.handle_hover - style_sheet = f""" + style_sheet = """ QScrollBar:vertical {{ border: none; - background: {color_background}; - width: {width}px; + background: {}; + width: {}px; margin: 0px 0px 0px 0px; }} QScrollBar::handle:vertical {{ - background: {color_handle}; + background: {}; min-height: 20px; }} QScrollBar::handle:hover {{ - background: {color_handle_hover}; + background: {}; }} QScrollBar::handle:vertical:pressed {{ - background: {color_handle_hover}; + background: {}; }} QScrollBar::sub-line:vertical, QScrollBar::add-line:vertical, @@ -83,7 +89,14 @@ def vertical(): width: 0px; height: 0px; }} - """ + """.format( + color_background, + width, + color_handle, + color_handle_hover, + color_handle_hover, + + ) return style_sheet @staticmethod diff --git a/gui/tabwidget.py b/gui/tabwidget.py index f5206a1..05fdeca 100644 --- a/gui/tabwidget.py +++ b/gui/tabwidget.py @@ -72,12 +72,12 @@ def set_style(self): right_arrow_hover_image = functions.get_resource_file("feather/air-blue/chevron-right.svg") left_arrow_image = functions.get_resource_file("feather/air-grey/chevron-left.svg") left_arrow_hover_image = functions.get_resource_file("feather/air-blue/chevron-left.svg") - style = f""" + style = """ QTabBar::close-button {{ - image: url({close_image}) + image: url({}) }} QTabBar::close-button:hover {{ - image: url({close_hover_image}) + image: url({}) }} QTabBar QToolButton {{ @@ -86,39 +86,55 @@ def set_style(self): }} QTabBar QToolButton::right-arrow {{ - image: url({right_arrow_image}); + image: url({}); }} QTabBar QToolButton::right-arrow:hover {{ - image: url({right_arrow_hover_image}); + image: url({}); }} QTabBar QToolButton::left-arrow {{ - image: url({left_arrow_image}); + image: url({}); }} QTabBar QToolButton::left-arrow:hover {{ - image: url({left_arrow_hover_image}); + image: url({}); }} QTabBar::tab {{ - background: {data.theme.Indication.PassiveBackGround}; - border: 1px solid {data.theme.Indication.PassiveBorder}; - border-bottom-color: {data.theme.Indication.PassiveBackGround}; + background: {}; + border: 1px solid {}; + border-bottom-color: {}; padding-top: 2px; padding-bottom: 2px; padding-left: 4px; padding-right: 4px; - color: {data.theme.Font.DefaultHtml}; + color: {}; }} QTabBar::tab:hover {{ - background: {data.theme.Indication.Hover}; - border-bottom-color: {data.theme.Indication.Hover}; + background: {}; + border-bottom-color: {}; }} QTabBar::tab:selected {{ - background: {data.theme.Indication.ActiveBackGround}; - border: 1px solid {data.theme.Indication.ActiveBorder}; - border-bottom-color: {data.theme.Indication.PassiveBackGround}; + background: {}; + border: 1px solid {}; + border-bottom-color: {}; }} - """ + """.format( + close_image, + close_hover_image, + right_arrow_image, + right_arrow_hover_image, + left_arrow_image, + left_arrow_hover_image, + data.theme.Indication.PassiveBackGround, + data.theme.Indication.PassiveBorder, + data.theme.Indication.PassiveBackGround, + data.theme.Font.DefaultHtml, + data.theme.Indication.Hover, + data.theme.Indication.Hover, + data.theme.Indication.ActiveBackGround, + data.theme.Indication.ActiveBorder, + data.theme.Indication.PassiveBackGround, + ) self.setStyleSheet(style) def mousePressEvent(self, event):