From 2dfa2bb038073e18efb91ba8109e7fc4da31215c Mon Sep 17 00:00:00 2001 From: Avasam Date: Thu, 14 Mar 2024 10:41:47 -0400 Subject: [PATCH] remove legacy code in pywin.framework.app (#2144) --- Pythonwin/pywin/Demos/app/basictimerapp.py | 2 +- Pythonwin/pywin/Demos/app/customprint.py | 1 - Pythonwin/pywin/Demos/app/dlgappdemo.py | 4 ++-- Pythonwin/pywin/Demos/app/dojobapp.py | 5 ++-- Pythonwin/pywin/framework/app.py | 28 ---------------------- Pythonwin/pywin/framework/intpyapp.py | 4 ---- Pythonwin/pywin/framework/startup.py | 14 ----------- 7 files changed, 5 insertions(+), 53 deletions(-) diff --git a/Pythonwin/pywin/Demos/app/basictimerapp.py b/Pythonwin/pywin/Demos/app/basictimerapp.py index af2f95490b..a932ae0604 100644 --- a/Pythonwin/pywin/Demos/app/basictimerapp.py +++ b/Pythonwin/pywin/Demos/app/basictimerapp.py @@ -8,7 +8,7 @@ import win32api import win32con import win32ui -from pywin.framework import cmdline, dlgappcore +from pywin.framework import dlgappcore class TimerAppDialog(dlgappcore.AppDialog): diff --git a/Pythonwin/pywin/Demos/app/customprint.py b/Pythonwin/pywin/Demos/app/customprint.py index 356073e5fb..442737b5bd 100644 --- a/Pythonwin/pywin/Demos/app/customprint.py +++ b/Pythonwin/pywin/Demos/app/customprint.py @@ -5,7 +5,6 @@ # This sample was contributed by Roger Burnham. -import win32api import win32con import win32ui from pywin.framework import app diff --git a/Pythonwin/pywin/Demos/app/dlgappdemo.py b/Pythonwin/pywin/Demos/app/dlgappdemo.py index 38659a62fc..efb50a627e 100644 --- a/Pythonwin/pywin/Demos/app/dlgappdemo.py +++ b/Pythonwin/pywin/Demos/app/dlgappdemo.py @@ -9,7 +9,7 @@ import sys import win32ui -from pywin.framework import app, dlgappcore +from pywin.framework import dlgappcore class TestDialogApp(dlgappcore.DialogApp): @@ -43,7 +43,7 @@ def write(self, str): win32ui.OutputDebug("dlgapp - no edit control! >>\n%s\n<<\n" % str) -app.AppBuilder = TestDialogApp +app = TestDialogApp() if __name__ == "__main__": import demoutils diff --git a/Pythonwin/pywin/Demos/app/dojobapp.py b/Pythonwin/pywin/Demos/app/dojobapp.py index d97ce5e2a8..77197f4c25 100644 --- a/Pythonwin/pywin/Demos/app/dojobapp.py +++ b/Pythonwin/pywin/Demos/app/dojobapp.py @@ -6,10 +6,9 @@ # pythonwin /app demos\dojobapp.py -import win32api import win32con import win32ui -from pywin.framework import app, dlgappcore +from pywin.framework import dlgappcore class DoJobAppDialog(dlgappcore.AppDialog): @@ -57,7 +56,7 @@ def __init__(self): DoJobDialogApp.__init__(self) -app.AppBuilder = DoJobDialogApp +app = DoJobDialogApp() def t(): diff --git a/Pythonwin/pywin/framework/app.py b/Pythonwin/pywin/framework/app.py index 9793aa1307..96cf45368b 100644 --- a/Pythonwin/pywin/framework/app.py +++ b/Pythonwin/pywin/framework/app.py @@ -1,4 +1,3 @@ -# App.py # Application stuff. # The application is responsible for managing the main frame window. # @@ -17,29 +16,6 @@ from . import scriptutils -## NOTE: App and AppBuild should NOT be used - instead, you should contruct your -## APP class manually whenever you like (just ensure you leave these 2 params None!) -## Whoever wants the generic "Application" should get it via win32iu.GetApp() - -# These are "legacy" -AppBuilder = None -App = None # default - if used, must end up a CApp derived class. - - -# Helpers that should one day be removed! -def AddIdleHandler(handler): - print( - "app.AddIdleHandler is deprecated - please use win32ui.GetApp().AddIdleHandler() instead." - ) - return win32ui.GetApp().AddIdleHandler(handler) - - -def DeleteIdleHandler(handler): - print( - "app.DeleteIdleHandler is deprecated - please use win32ui.GetApp().DeleteIdleHandler() instead." - ) - return win32ui.GetApp().DeleteIdleHandler(handler) - # Helper for writing a Window position by name, and later loading it. def SaveWindowSize(section, rect, state=""): @@ -169,10 +145,6 @@ def ExitInstance(self): if self._obj_: self._obj_.AttachObject(None) self._obj_ = None - global App - global AppBuilder - App = None - AppBuilder = None return 0 def HaveIdleHandler(self, handler): diff --git a/Pythonwin/pywin/framework/intpyapp.py b/Pythonwin/pywin/framework/intpyapp.py index e70e7c09f0..71690a9abe 100644 --- a/Pythonwin/pywin/framework/intpyapp.py +++ b/Pythonwin/pywin/framework/intpyapp.py @@ -551,8 +551,4 @@ def OnHelpIndex(self, id, code): help.SelectAndRunHelpFile() -# As per the comments in app.py, this use is depreciated. -# app.AppBuilder = InteractivePythonApp - -# Now all we do is create the application thisApp = InteractivePythonApp() diff --git a/Pythonwin/pywin/framework/startup.py b/Pythonwin/pywin/framework/startup.py index 4a7323225d..5496063e38 100644 --- a/Pythonwin/pywin/framework/startup.py +++ b/Pythonwin/pywin/framework/startup.py @@ -64,17 +64,3 @@ # Import the application module. __import__(moduleName) - -try: - win32ui.GetApp()._obj_ - # This worked - an app already exists - do nothing more -except (AttributeError, win32ui.error): - # This means either no app object exists at all, or the one - # that does exist does not have a Python class (ie, was created - # by the host .EXE). In this case, we do the "old style" init... - from . import app - - if app.AppBuilder is None: - raise TypeError("No application object has been registered") - - app.App = app.AppBuilder()