From 14b1c93baff6a6b93588ca36f9754a3292e12658 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Baptiste=20MAR=C3=89CHAL?= Date: Fri, 24 Sep 2021 12:33:30 +0200 Subject: [PATCH] Updated code to run with wxPython 4.1.1. --- config.py | 5 +++++ gui.py | 13 ++++++++++--- highlightdialog.py | 5 ++++- ignoredialog.py | 5 ++++- 4 files changed, 23 insertions(+), 5 deletions(-) diff --git a/config.py b/config.py index 316b0fd..e348f0e 100644 --- a/config.py +++ b/config.py @@ -14,6 +14,8 @@ import requests import wx # required for colour codes in DARK_MODE +import re # for wxPython version dentification + import optstore # cSpell Checker - Correct Words**************************************** # // cSpell:words MEIPASS, datefmt, russsian, pyinstaller, posix, pyspy @@ -34,6 +36,9 @@ def resource_path(relative_path): return os.path.join(base_path, relative_path) +# Identify wxPython version (not wxWidgets version). +wx_major, wx_minor, wx_rev = \ + map(int, re.match(r"([0-9]+)\.([0-9]+)(?:\.([0-9]+))", wx.__version__).groups()) # If application is frozen executable if getattr(sys, 'frozen', False): diff --git a/gui.py b/gui.py index 3ea3134..ec3a1ef 100644 --- a/gui.py +++ b/gui.py @@ -356,8 +356,12 @@ def __do_layout(self): sizer_bottom.Add(self.status_label, 1, wx.ALIGN_CENTER_VERTICAL, 0) static_line = wx.StaticLine(self, wx.ID_ANY, style=wx.LI_VERTICAL) sizer_bottom.Add(static_line, 0, wx.EXPAND, 0) - sizer_bottom.Add(self.alpha_slider, 0, wx.ALIGN_RIGHT, 0) - sizer_main.Add(sizer_bottom, 0, wx.ALIGN_BOTTOM | wx.ALL | wx.EXPAND, 1) + if config.wx_minor < 1: + sizer_bottom.Add(self.alpha_slider, 0, wx.ALIGN_RIGHT, 0) + sizer_main.Add(sizer_bottom, 0, wx.ALIGN_BOTTOM | wx.ALL | wx.EXPAND, 1) + else: + sizer_bottom.Add(self.alpha_slider) + sizer_main.Add(sizer_bottom, 0, wx.ALL | wx.EXPAND, 1) self.SetSizer(sizer_main) self.Layout() self._restoreColWidth() @@ -640,7 +644,10 @@ def updateList(self, outlist, duration=None): for value in out: color = False self.grid.SetCellValue(rowidx, colidx, str(value)) - self.grid.SetCellAlignment(self.columns[colidx][2], rowidx, colidx) + if config.wx_minor < 1: + self.grid.SetCellAlignment(self.columns[colidx][2], rowidx, colidx) + else: + self.grid.SetCellAlignment(rowidx, colidx, self.columns[colidx][2], wx.ALIGN_CENTER) if hl_blops and r[9] is not None and r[11] > 0: # Highlight BLOPS chars self.grid.SetCellTextColour(rowidx, colidx, self.hl1_colour) color = True diff --git a/highlightdialog.py b/highlightdialog.py index 3527d69..fe0b8a1 100644 --- a/highlightdialog.py +++ b/highlightdialog.py @@ -100,7 +100,10 @@ def __do_layout(self): buttonSizer.Add(self.appBtn, 1, wx.RIGHT, 5) buttonSizer.Add(self.cnclBtn, 1, wx.LEFT, 5) self.buttonPanel.SetSizer(buttonSizer) - main.Add(self.buttonPanel, 0, wx.ALIGN_BOTTOM | wx.BOTTOM | wx.EXPAND | wx.LEFT | wx.RIGHT, 10) + if config.wx_minor < 1: + main.Add(self.buttonPanel, 0, wx.ALIGN_BOTTOM | wx.BOTTOM | wx.EXPAND | wx.LEFT | wx.RIGHT, 10) + else: + main.Add(self.buttonPanel, 0, wx.BOTTOM | wx.EXPAND | wx.LEFT | wx.RIGHT, 10) self.SetSizer(main) self.Layout() self.Centre() diff --git a/ignoredialog.py b/ignoredialog.py index 11d1747..ae5d278 100644 --- a/ignoredialog.py +++ b/ignoredialog.py @@ -100,7 +100,10 @@ def __do_layout(self): buttonSizer.Add(self.appBtn, 1, wx.RIGHT, 5) buttonSizer.Add(self.cnclBtn, 1, wx.LEFT, 5) self.buttonPanel.SetSizer(buttonSizer) - main.Add(self.buttonPanel, 0, wx.ALIGN_BOTTOM | wx.BOTTOM | wx.EXPAND | wx.LEFT | wx.RIGHT, 10) + if config.wx_minor < 1: + main.Add(self.buttonPanel, 0, wx.ALIGN_BOTTOM | wx.BOTTOM | wx.EXPAND | wx.LEFT | wx.RIGHT, 10) + else: + main.Add(self.buttonPanel, 0, wx.BOTTOM | wx.EXPAND | wx.LEFT | wx.RIGHT, 10) self.SetSizer(main) self.Layout() self.Centre()