try wxPython before tkinter, recent macOS otherwise fails

This commit is contained in:
Philip Eisenlohr 2020-06-29 21:50:33 -04:00
parent 2d0c680daf
commit 97ca1b1a9b
1 changed files with 14 additions and 8 deletions

View File

@ -1,19 +1,25 @@
import os import os
from pathlib import Path from pathlib import Path
import tkinter
class Environment: class Environment:
def __init__(self): def __init__(self):
"""Read and provide values of DAMASK configuration.""" """Read and provide values of DAMASK configuration."""
self.screen_width = 1024
self.screen_height = 768
try: try:
tk = tkinter.Tk() import wx
self.screen_width = tk.winfo_screenwidth() app = wx.App(False)
self.screen_height = tk.winfo_screenheight() self.screenwidth, self.screenheight = wx.GetDisplaySize()
tk.destroy() except ImportError:
except tkinter.TclError: try:
self.screen_width = 1024 import tkinter
self.screen_height = 768 tk = tkinter.Tk()
self.screen_width = tk.winfo_screenwidth()
self.screen_height = tk.winfo_screenheight()
tk.destroy()
except:
pass
@property @property
def options(self): def options(self):