From 0763f01c7ce7680df0ef0f22d00e0173d0eae43d Mon Sep 17 00:00:00 2001 From: stevenhua0320 Date: Thu, 26 Mar 2026 22:06:03 -0400 Subject: [PATCH] fix:pdfgui functionality fix after skpkg --- news/fix-gui-functionality.rst | 23 ++++++++++++ pyproject.toml | 2 +- src/diffpy/pdfgui/gui/aboutdialog.py | 5 ++- src/diffpy/pdfgui/gui/pdfguiglobals.py | 49 ++++++++++++-------------- 4 files changed, 51 insertions(+), 28 deletions(-) create mode 100644 news/fix-gui-functionality.rst diff --git a/news/fix-gui-functionality.rst b/news/fix-gui-functionality.rst new file mode 100644 index 00000000..943481e6 --- /dev/null +++ b/news/fix-gui-functionality.rst @@ -0,0 +1,23 @@ +**Added:** + +* No News Added: hot-fix on gui-functionality + +**Changed:** + +* + +**Deprecated:** + +* + +**Removed:** + +* + +**Fixed:** + +* + +**Security:** + +* diff --git a/pyproject.toml b/pyproject.toml index 01cc3a5c..b366a894 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -49,7 +49,7 @@ exclude = [] # exclude packages matching these glob patterns (empty by default) namespaces = false # to disable scanning PEP 420 namespaces (true by default) [project.scripts] -diffpy-pdfgui = "diffpy.pdfgui.app:main" +pdfgui = "diffpy.pdfgui.applications.pdfgui:main" [tool.setuptools.dynamic] dependencies = {file = ["requirements/pip.txt"]} diff --git a/src/diffpy/pdfgui/gui/aboutdialog.py b/src/diffpy/pdfgui/gui/aboutdialog.py index 821bddd0..eb06f195 100644 --- a/src/diffpy/pdfgui/gui/aboutdialog.py +++ b/src/diffpy/pdfgui/gui/aboutdialog.py @@ -16,12 +16,15 @@ ############################################################################## import random +from datetime import datetime, timezone import wx import wx.lib.agw.hyperlink from diffpy.pdfgui.gui.pdfguiglobals import iconpath -from diffpy.pdfgui.version import __date__, __version__ +from diffpy.pdfgui.version import __version__ + +__date__ = datetime.now(timezone.utc).date().isoformat() _acknowledgement = """\ This software was developed by the Billinge-group as part of the Distributed diff --git a/src/diffpy/pdfgui/gui/pdfguiglobals.py b/src/diffpy/pdfgui/gui/pdfguiglobals.py index 5580dca5..5dc74ca6 100644 --- a/src/diffpy/pdfgui/gui/pdfguiglobals.py +++ b/src/diffpy/pdfgui/gui/pdfguiglobals.py @@ -14,8 +14,8 @@ ############################################################################## """This module contains global parameters needed by PDFgui.""" -import os.path from importlib.resources import files +from pathlib import Path from diffpy.pdfgui.gui import debugoptions @@ -24,34 +24,24 @@ # Maximum number of files to be remembered MAXMRU = 5 # The location of the configuration file -configfilename = os.path.expanduser("~/.pdfgui_py3.cfg") +configfilename = Path.home() / ".pdfgui_py3.cfg" # Project modification flag isAltered = False -# Resolve APPDATADIR base path to application data files. -try: - _mydir = os.path.abspath(str(files(__name__))) -except TypeError: # For Python < 3.12 - _mydir = os.path.abspath(os.path.dirname(__file__)) +_mydir = Path(str(files(__name__))).resolve() -_upbasedir = os.path.normpath(_mydir + "/../../..") -_development_mode = os.path.basename(_upbasedir) == "src" and os.path.isfile( - os.path.join(_upbasedir, "../pyproject.toml") -) +_upbasedir = _mydir.parents[2] +_development_mode = _upbasedir.name == "src" and (_upbasedir.parent / "pyproject.toml").is_file() # Requirement must have egg-info. Do not use in _development_mode. _req = "diffpy.pdfgui" -# pavol -# APPDATADIR = (os.path.dirname(_upbasedir) if _development_mode -# else str(files(_req))) -# long if _development_mode: - APPDATADIR = os.path.dirname(_mydir) + APPDATADIR = _mydir.parent else: - APPDATADIR = str(files(_req)) + APPDATADIR = Path(str(files(_req))).resolve() -APPDATADIR = os.path.abspath(APPDATADIR) +APPDATADIR = APPDATADIR.resolve() # Location of the HTML manual docMainFile = "https://diffpy.github.io/diffpy.pdfgui/manual.html" @@ -62,16 +52,24 @@ def iconpath(iconfilename): - """Full path to the icon file in pdfgui installation. This function - should be used whenever GUI needs access to custom icons. + """Full path to the icon file in pdfgui installation. - iconfilename -- icon file name without any path + This function should be used whenever GUI needs access to custom + icons. - Return string. + Parameters + ---------- + iconfilename : str + The icon file name without any path. + + Returns + ------- + str + The full path to the icon file. """ - rv = os.path.join(APPDATADIR, "icons", iconfilename) - assert os.path.isfile(rv), "icon file does not exist" - return rv + rv = APPDATADIR / "icons" / iconfilename + assert rv.is_file(), "icon file does not exist" + return str(rv) # options and arguments passed on command line @@ -79,7 +77,6 @@ def iconpath(iconfilename): cmdargs = [] # debugging options: - dbopts = debugoptions.DebugOptions() # End of file