From f27e5f1fb80d81c54f2e28994133f120841bfca2 Mon Sep 17 00:00:00 2001 From: Justin Nesselrotte Date: Wed, 7 Jan 2015 10:00:28 -0600 Subject: [PATCH] Possible fix for #75 using appleScript --- Cura/gui/aboutWindow.py | 4 ++-- Cura/gui/app.py | 15 +++++++-------- Cura/gui/mainWindow.py | 4 ++-- Cura/gui/preferencesDialog.py | 4 ++-- 4 files changed, 13 insertions(+), 14 deletions(-) diff --git a/Cura/gui/aboutWindow.py b/Cura/gui/aboutWindow.py index a930d879..0db7352e 100644 --- a/Cura/gui/aboutWindow.py +++ b/Cura/gui/aboutWindow.py @@ -4,8 +4,8 @@ import wx import platform class aboutWindow(wx.Frame): - def __init__(self): - super(aboutWindow, self).__init__(None, title="About", style = wx.DEFAULT_DIALOG_STYLE) + def __init__(self, parent): + super(aboutWindow, self).__init__(parent, title="About", style = wx.DEFAULT_DIALOG_STYLE) wx.EVT_CLOSE(self, self.OnClose) diff --git a/Cura/gui/app.py b/Cura/gui/app.py index a0bfd57a..43f6bae5 100644 --- a/Cura/gui/app.py +++ b/Cura/gui/app.py @@ -5,6 +5,7 @@ import os import platform import shutil import glob +import subprocess import warnings try: @@ -162,14 +163,12 @@ class CuraApp(wx.App): wx.CallAfter(self.StupidMacOSWorkaround) def StupidMacOSWorkaround(self): - """ - On MacOS for some magical reason opening new frames does not work until you opened a new modal dialog and closed it. - If we do this from software, then, as if by magic, the bug which prevents opening extra frames is gone. - """ - dlg = wx.Dialog(None) - wx.PostEvent(dlg, wx.CommandEvent(wx.EVT_CLOSE.typeId)) - dlg.ShowModal() - dlg.Destroy() + subprocess.Popen(['osascript', '-e', '''\ + tell application "System Events" + set procName to name of first process whose unix id is %s + end tell + tell application procName to activate + ''' % os.getpid()]) if platform.system() == "Darwin": #Mac magic. Dragons live here. THis sets full screen options. try: diff --git a/Cura/gui/mainWindow.py b/Cura/gui/mainWindow.py index c81edbf7..be24fe7d 100644 --- a/Cura/gui/mainWindow.py +++ b/Cura/gui/mainWindow.py @@ -353,7 +353,6 @@ class mainWindow(wx.Frame): prefDialog.Centre() prefDialog.Show() prefDialog.Raise() - wx.CallAfter(prefDialog.Show) def OnMachineSettings(self, e): prefDialog = preferencesDialog.machineSettingsDialog(self) @@ -572,9 +571,10 @@ class mainWindow(wx.Frame): wx.MessageBox(_("You are running the latest version of Cura!"), _("Awesome!"), wx.ICON_INFORMATION) def OnAbout(self, e): - aboutBox = aboutWindow.aboutWindow() + aboutBox = aboutWindow.aboutWindow(self) aboutBox.Centre() aboutBox.Show() + aboutBox.Raise() def OnClose(self, e): profile.saveProfile(profile.getDefaultProfilePath(), True) diff --git a/Cura/gui/preferencesDialog.py b/Cura/gui/preferencesDialog.py index fd4b209e..6148b3b6 100644 --- a/Cura/gui/preferencesDialog.py +++ b/Cura/gui/preferencesDialog.py @@ -11,7 +11,7 @@ from Cura.util import resources class preferencesDialog(wx.Dialog): def __init__(self, parent): - super(preferencesDialog, self).__init__(None, title="Preferences") + super(preferencesDialog, self).__init__(parent, title="Preferences") wx.EVT_CLOSE(self, self.OnClose) @@ -65,7 +65,7 @@ class preferencesDialog(wx.Dialog): class machineSettingsDialog(wx.Dialog): def __init__(self, parent): - super(machineSettingsDialog, self).__init__(None, title="Machine settings") + super(machineSettingsDialog, self).__init__(parent, title="Machine settings") wx.EVT_CLOSE(self, self.OnClose) -- 2.30.2