From bd4bc95258143375026f33c3464f7c1dce57fba7 Mon Sep 17 00:00:00 2001 From: karxi Date: Mon, 9 Jan 2017 16:52:25 -0500 Subject: [PATCH] Made the console respect theme changes. --- console.py | 22 ++++++++++++++++------ pesterchum.py | 5 +++++ 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/console.py b/console.py index 77b21f2..e3dbd4a 100644 --- a/console.py +++ b/console.py @@ -23,6 +23,7 @@ class ConsoleWindow(QtGui.QDialog): #~class ConsoleWindow(styler.PesterBaseWindow): # A simple console class, cobbled together from the corpse of another. + stylesheet_path = "main/defaultwindow/style" # This is a holder for our text inputs. text = AttrDict() # I should probably put up constants for 'direction' if this is going to @@ -40,14 +41,10 @@ class ConsoleWindow(QtGui.QDialog): except: self.mainwindow = parent theme = self.mainwindow.theme + # This won't initialize the sub-objects, because they don't exist yet. + self.initTheme(theme) self.text = AttrDict() - - # Set up our style/window specifics - self.setStyleSheet(theme["main/defaultwindow/style"]) - self.setWindowTitle("==> Console") - self.resize(350,300) - self.text.area = ConsoleText(theme, self) self.text.input = ConsoleInput(theme, self) self.text.input.setFocus() @@ -116,6 +113,19 @@ class ConsoleWindow(QtGui.QDialog): parent = self.parent() parent.console.is_open = False + def initTheme(self, theme): + # Set up our style/window specifics + self.changeTheme(theme) + self.resize(350,300) + + def changeTheme(self, theme): + self.setStyleSheet(theme[self.stylesheet_path]) + self.setWindowTitle("==> Console") + if "area" in self.text and "input" in self.text: + self.text.area.changeTheme(theme) + self.text.input.changeTheme(theme) + + # Actual console stuff. def execInConsole(self, scriptstr, env=None): # Since that's what imports *us*, this should be okay diff --git a/pesterchum.py b/pesterchum.py index 0b50aee..dcf6832 100644 --- a/pesterchum.py +++ b/pesterchum.py @@ -1776,6 +1776,11 @@ class PesterWindow(MovingWindow): else: self.mychumcolor.setText("") + if _CONSOLE: + if self.console.window: + # A bit of an ugly hack.... + self.console.window.changeTheme(theme) + # sounds self._setup_sounds() self.setVolume(self.config.volume())