Skip to content

Commit

Permalink
refactor: ending support for WX3 (#259)
Browse files Browse the repository at this point in the history
* refactor: ending support for WX3

* refine news

* pcmt
  • Loading branch information
Tieqiong authored Jan 18, 2025
1 parent c446969 commit b7c5c65
Show file tree
Hide file tree
Showing 10 changed files with 88 additions and 178 deletions.
8 changes: 0 additions & 8 deletions doc/source/api/diffpy.pdfgui.gui.wxextensions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,6 @@ diffpy.pdfgui.gui.wxextensions package
Submodules
----------

diffpy.pdfgui.gui.wxextensions.wx12 module
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

.. automodule:: diffpy.pdfgui.gui.wxextensions.wx12
:members:
:undoc-members:
:show-inheritance:

diffpy.pdfgui.gui.wxextensions.listctrls module
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Expand Down
23 changes: 23 additions & 0 deletions news/wx3.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
**Added:**

* <news item>

**Changed:**

* <news item>

**Deprecated:**

* <news item>

**Removed:**

* Removed wx3 support that was previously deprecated.

**Fixed:**

* <news item>

**Security:**

* <news item>
4 changes: 1 addition & 3 deletions src/diffpy/pdfgui/gui/extendedplotframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,10 @@
from matplotlib.font_manager import FontProperties

from diffpy.pdfgui.gui.pdfguiglobals import iconpath
from diffpy.pdfgui.gui.wxextensions import wx12

matplotlib.use("WXAgg")

DATA_SAVE_ID = wx12.NewIdRef()
DATA_SAVE_ID = wx.NewIdRef()


class ExtendedToolbar(NavToolbar):
Expand All @@ -40,7 +39,6 @@ class ExtendedToolbar(NavToolbar):

def __init__(self, canvas):
NavToolbar.__init__(self, canvas)
wx12.patchToolBarMethods(self)
# Load customized icon image
save_icon_fp = iconpath("exportplotdata.png")
save_icon = wx.Bitmap(save_icon_fp)
Expand Down
3 changes: 1 addition & 2 deletions src/diffpy/pdfgui/gui/fittree.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,10 @@
from diffpy.pdfgui.control.controlerrors import ControlError
from diffpy.pdfgui.control.fitting import Fitting
from diffpy.pdfgui.gui.pdfguiglobals import iconpath
from diffpy.pdfgui.gui.wxextensions import wx12
from diffpy.pdfgui.utils import safeCPickleDumps


class FitTree(wx12.TreeCtrl):
class FitTree(wx.TreeCtrl):
"""TreeCtrl designed to organize pdffit fits.
The root of the tree is hidden. Below that there are several levels
Expand Down
90 changes: 44 additions & 46 deletions src/diffpy/pdfgui/gui/mainframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
from diffpy.pdfgui.gui.rseriespanel import RSeriesPanel
from diffpy.pdfgui.gui.temperatureseriespanel import TemperatureSeriesPanel
from diffpy.pdfgui.gui.welcomepanel import WelcomePanel
from diffpy.pdfgui.gui.wxextensions import wx12

(PDFCustomEvent, EVT_PDFCUSTOM) = wx.lib.newevent.NewEvent()

Expand Down Expand Up @@ -234,14 +233,14 @@ def __defineLocalIds(self):
"""
# Functions that modify the tree.
# These are used in the fitting right-click menu and the main menu.
self.newFitId = wx12.NewIdRef() # New Fit
self.newCalcId = wx12.NewIdRef() # New Calculation
self.newPhaseId = wx12.NewIdRef() # New Phase
self.newDataId = wx12.NewIdRef() # New Data Set
self.newFitId = wx.NewIdRef() # New Fit
self.newCalcId = wx.NewIdRef() # New Calculation
self.newPhaseId = wx.NewIdRef() # New Phase
self.newDataId = wx.NewIdRef() # New Data Set
self.deleteId = wx.ID_DELETE # Delete tree item
self.copyId = wx.ID_COPY # Copy a tree item
self.pasteId = wx.ID_PASTE # Paste a tree item into tree
self.pasteLinkId = wx12.NewIdRef() # Paste and link a fit node
self.pasteLinkId = wx.NewIdRef() # Paste and link a fit node

# Misc. functions, these are exclusive to the main menu.
self.newId = wx.ID_NEW # Start a new Project
Expand All @@ -250,19 +249,19 @@ def __defineLocalIds(self):
self.saveId = wx.ID_SAVE # Save the project
self.saveAsId = wx.ID_SAVEAS # Save the project as...
self.quitId = wx.ID_CLOSE # Quit the program
self.runFitId = wx12.NewIdRef() # Run a fit
self.stopFitId = wx12.NewIdRef() # Stop a fit
self.quickPlotId = wx12.NewIdRef() # Quick plot a fit
self.exportFitPDFId = wx12.NewIdRef() # Save a fit PDF
self.exportFitStruId = wx12.NewIdRef() # Save a fit structure
self.exportNewStruId = wx12.NewIdRef() # Export a 'new' structure
self.plotIStructId = wx12.NewIdRef() # Plot initial structure
self.plotFStructId = wx12.NewIdRef() # Plot final structure
self.printBLId = wx12.NewIdRef() # Print the bond lengths of a structure
self.printBAId = wx12.NewIdRef() # Print the bond angles of a structure
self.exportResId = wx12.NewIdRef() # Save the results file
self.runCalcId = wx12.NewIdRef() # Run a calculation
self.exportCalcPDFId = wx12.NewIdRef() # Save a calculated PDF
self.runFitId = wx.NewIdRef() # Run a fit
self.stopFitId = wx.NewIdRef() # Stop a fit
self.quickPlotId = wx.NewIdRef() # Quick plot a fit
self.exportFitPDFId = wx.NewIdRef() # Save a fit PDF
self.exportFitStruId = wx.NewIdRef() # Save a fit structure
self.exportNewStruId = wx.NewIdRef() # Export a 'new' structure
self.plotIStructId = wx.NewIdRef() # Plot initial structure
self.plotFStructId = wx.NewIdRef() # Plot final structure
self.printBLId = wx.NewIdRef() # Print the bond lengths of a structure
self.printBAId = wx.NewIdRef() # Print the bond angles of a structure
self.exportResId = wx.NewIdRef() # Save the results file
self.runCalcId = wx.NewIdRef() # Run a calculation
self.exportCalcPDFId = wx.NewIdRef() # Save a calculated PDF
return

def __customProperties(self):
Expand Down Expand Up @@ -438,12 +437,12 @@ def __setupMainMenu(self):
self.SetMenuBar(self.menuBar)

# File Menu
self.fileMenu = wx12.Menu()
self.fileMenu = wx.Menu()
self.newItem = wx.MenuItem(self.fileMenu, self.newId, "&New Project\tCtrl+n", "", wx.ITEM_NORMAL)
self.fileMenu.Append(self.newItem)
self.openItem = wx.MenuItem(self.fileMenu, self.openId, "&Open Project\tCtrl+o", "", wx.ITEM_NORMAL)
self.fileMenu.Append(self.openItem)
self.recentMenu = wx12.Menu()
self.recentMenu = wx.Menu()
msub = self.fileMenu.AppendSubMenu(self.recentMenu, "&Recent Files")
self.recentId = msub.Id
self.fileMenu.AppendSeparator()
Expand All @@ -464,7 +463,7 @@ def __setupMainMenu(self):
# End File Menu

# Edit Menu
self.editMenu = wx12.Menu()
self.editMenu = wx.Menu()
self.delItem = wx.MenuItem(self.editMenu, self.deleteId, "&Delete Item(s)\tCtrl+X", "", wx.ITEM_NORMAL)
self.editMenu.Append(self.delItem)
self.copyItem = wx.MenuItem(self.editMenu, self.copyId, "&Copy Item\tCtrl+C", "", wx.ITEM_NORMAL)
Expand All @@ -474,33 +473,33 @@ def __setupMainMenu(self):
self.pasteLinkItem = wx.MenuItem(self.editMenu, self.pasteLinkId, "Paste &Linked Fit", "", wx.ITEM_NORMAL)
self.editMenu.Append(self.pasteLinkItem)
self.editMenu.AppendSeparator()
self.prefItem = wx.MenuItem(self.editMenu, wx12.NewIdRef(), "&Preferences", "", wx.ITEM_NORMAL)
self.prefItem = wx.MenuItem(self.editMenu, wx.NewIdRef(), "&Preferences", "", wx.ITEM_NORMAL)
self.editMenu.Append(self.prefItem)
self.menuBar.Append(self.editMenu, "&Edit")
# End Edit Menu

# View Menu
self.viewMenu = wx12.Menu()
self.viewMenu = wx.Menu()
self.defaultLayoutItem = wx.MenuItem(
self.editMenu, wx12.NewIdRef(), "Default Window Layout", "", wx.ITEM_NORMAL
self.editMenu, wx.NewIdRef(), "Default Window Layout", "", wx.ITEM_NORMAL
)
self.viewMenu.Append(self.defaultLayoutItem)
self.viewMenu.AppendSeparator()
# These items are context sensitive.
self.showFitItem = wx.MenuItem(self.viewMenu, wx12.NewIdRef(), "Show Fit Tree", "", wx.ITEM_NORMAL)
self.showFitItem = wx.MenuItem(self.viewMenu, wx.NewIdRef(), "Show Fit Tree", "", wx.ITEM_NORMAL)
self.viewMenu.Append(self.showFitItem)
self.showPlotItem = wx.MenuItem(self.viewMenu, wx12.NewIdRef(), "Show Plot Control", "", wx.ITEM_NORMAL)
self.showPlotItem = wx.MenuItem(self.viewMenu, wx.NewIdRef(), "Show Plot Control", "", wx.ITEM_NORMAL)
self.viewMenu.Append(self.showPlotItem)
self.showOutputItem = wx.MenuItem(self.viewMenu, wx12.NewIdRef(), "Show Output", "", wx.ITEM_NORMAL)
self.showOutputItem = wx.MenuItem(self.viewMenu, wx.NewIdRef(), "Show Output", "", wx.ITEM_NORMAL)
self.viewMenu.Append(self.showOutputItem)
self.showJournalItem = wx.MenuItem(
self.viewMenu, wx12.NewIdRef(), "Show Journal\tCtrl+j", "", wx.ITEM_NORMAL
self.viewMenu, wx.NewIdRef(), "Show Journal\tCtrl+j", "", wx.ITEM_NORMAL
)
self.viewMenu.Append(self.showJournalItem)
self.menuBar.Append(self.viewMenu, "&View")

# Fits Menu
self.fitsMenu = wx12.Menu()
self.fitsMenu = wx.Menu()
self.newFitItem = wx.MenuItem(self.fitsMenu, self.newFitId, "&New Fit\tCtrl+t", "", wx.ITEM_NORMAL)
self.fitsMenu.Append(self.newFitItem)
self.fitsMenu.AppendSeparator()
Expand All @@ -513,19 +512,19 @@ def __setupMainMenu(self):
self.fitsMenu.Append(self.expResItem)
self.fitsMenu.AppendSeparator()
# Macros sub-menu
self.macrosMenu = wx12.Menu()
self.rseriesItem = wx.MenuItem(self.macrosMenu, wx12.NewIdRef(), "r-Series", "", wx.ITEM_NORMAL)
self.macrosMenu = wx.Menu()
self.rseriesItem = wx.MenuItem(self.macrosMenu, wx.NewIdRef(), "r-Series", "", wx.ITEM_NORMAL)
self.macrosMenu.Append(self.rseriesItem)
self.tseriesItem = wx.MenuItem(self.macrosMenu, wx12.NewIdRef(), "Temperature Series", "", wx.ITEM_NORMAL)
self.tseriesItem = wx.MenuItem(self.macrosMenu, wx.NewIdRef(), "Temperature Series", "", wx.ITEM_NORMAL)
self.macrosMenu.Append(self.tseriesItem)
self.dseriesItem = wx.MenuItem(self.macrosMenu, wx12.NewIdRef(), "Doping Series", "", wx.ITEM_NORMAL)
self.dseriesItem = wx.MenuItem(self.macrosMenu, wx.NewIdRef(), "Doping Series", "", wx.ITEM_NORMAL)
self.macrosMenu.Append(self.dseriesItem)
self.fitsMenu.AppendSubMenu(self.macrosMenu, "Macros")
self.menuBar.Append(self.fitsMenu, "Fi&ts")
# End Fits Menu

# Phases Menu
self.phasesMenu = wx12.Menu()
self.phasesMenu = wx.Menu()
self.newPhaseItem = wx.MenuItem(self.phasesMenu, self.newPhaseId, "&New Phase\tCtrl+p", "", wx.ITEM_NORMAL)
self.phasesMenu.Append(self.newPhaseItem)
self.phasesMenu.AppendSeparator()
Expand Down Expand Up @@ -580,7 +579,7 @@ def __setupMainMenu(self):
# End Phases Menu

# Data Menu
self.dataMenu = wx12.Menu()
self.dataMenu = wx.Menu()
self.newDataItem = wx.MenuItem(self.dataMenu, self.newDataId, "&New Data Set\tCtrl+d", "", wx.ITEM_NORMAL)
self.dataMenu.Append(self.newDataItem)
self.dataMenu.AppendSeparator()
Expand All @@ -590,7 +589,7 @@ def __setupMainMenu(self):
# End Data Menu

# Calculations Menu
self.calcMenu = wx12.Menu()
self.calcMenu = wx.Menu()
self.newCalcItem = wx.MenuItem(
self.calcMenu,
self.newCalcId,
Expand Down Expand Up @@ -621,20 +620,20 @@ def __setupMainMenu(self):
# End Calculations Menu

# Help Menu
self.helpMenu = wx12.Menu()
self.docItem = wx.MenuItem(self.helpMenu, wx12.NewIdRef(), "&Documentation\tF1", "", wx.ITEM_NORMAL)
self.helpMenu = wx.Menu()
self.docItem = wx.MenuItem(self.helpMenu, wx.NewIdRef(), "&Documentation\tF1", "", wx.ITEM_NORMAL)
self.helpMenu.Append(self.docItem)
self.requestItem = wx.MenuItem(
self.helpMenu,
wx12.NewIdRef(),
wx.NewIdRef(),
"Request a Feature / Report a Bug",
"",
wx.ITEM_NORMAL,
)
self.helpMenu.Append(self.requestItem)
self.communityItem = wx.MenuItem(self.helpMenu, wx12.NewIdRef(), "PDFgui Community", "", wx.ITEM_NORMAL)
self.communityItem = wx.MenuItem(self.helpMenu, wx.NewIdRef(), "PDFgui Community", "", wx.ITEM_NORMAL)
self.helpMenu.Append(self.communityItem)
self.aboutItem = wx.MenuItem(self.helpMenu, wx12.NewIdRef(), "&About", "", wx.ITEM_NORMAL)
self.aboutItem = wx.MenuItem(self.helpMenu, wx.NewIdRef(), "&About", "", wx.ITEM_NORMAL)
self.helpMenu.Append(self.aboutItem)
self.menuBar.Append(self.helpMenu, "&Help")
# End Help Menu
Expand All @@ -648,7 +647,6 @@ def __setupMainMenu(self):
def __setupToolBar(self):
"""This sets up the tool bar in the parent window."""
self.toolBar = self.CreateToolBar()
wx12.patchToolBarMethods(self.toolBar)
size = (16, 16)
bitmap = wx.ArtProvider.GetBitmap(wx.ART_NEW, wx.ART_TOOLBAR, size)
self.toolBar.AddTool(
Expand Down Expand Up @@ -1312,7 +1310,7 @@ def onRightClick(self, event): # wxGlade: MainPanel.<event_handler>
if self.mode == "fitting":

# The menu Ids are defined in __defineLocalIds.
menu = wx12.Menu()
menu = wx.Menu()
menu.Append(self.newFitId, "New Fit")
menu.AppendSeparator()
menu.Append(self.copyId, "Copy")
Expand Down Expand Up @@ -2546,11 +2544,11 @@ def showMessage(self, info, title="PDF Control Error"):

# control items
def lock(self):
if not wx12.IsMainThread():
if not wx.IsMainThread():
wx.MutexGuiEnter()

def unlock(self):
if not wx12.IsMainThread():
if not wx.IsMainThread():
wx.MutexGuiLeave()

def postEvent(self, type, info):
Expand Down
7 changes: 3 additions & 4 deletions src/diffpy/pdfgui/gui/parameterspanel.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import wx.grid

from diffpy.pdfgui.gui.pdfpanel import PDFPanel
from diffpy.pdfgui.gui.wxextensions import wx12
from diffpy.pdfgui.gui.wxextensions.autowidthlabelsgrid import AutoWidthLabelsGrid
from diffpy.utils.wx import gridutils

Expand Down Expand Up @@ -274,9 +273,9 @@ def popupMenu(self, window, x, y):
# only do this part the first time so the events are only bound once
if not hasattr(self, "did_popupIDs"):
self.did_popupIDs = True
self.popupID1 = wx12.NewIdRef()
self.popupID2 = wx12.NewIdRef()
self.popupID3 = wx12.NewIdRef()
self.popupID1 = wx.NewIdRef()
self.popupID2 = wx.NewIdRef()
self.popupID3 = wx.NewIdRef()

self.Bind(wx.EVT_MENU, self.onPopupFixFree, id=self.popupID1)
self.Bind(wx.EVT_MENU, self.onPopupCopyRefinedToInitial, id=self.popupID2)
Expand Down
15 changes: 7 additions & 8 deletions src/diffpy/pdfgui/gui/phaseconfigurepanel.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
from diffpy.pdfgui.gui import phasepanelutils, tooltips
from diffpy.pdfgui.gui.insertrowsdialog import InsertRowsDialog
from diffpy.pdfgui.gui.pdfpanel import PDFPanel
from diffpy.pdfgui.gui.wxextensions import wx12
from diffpy.pdfgui.gui.wxextensions.autowidthlabelsgrid import AutoWidthLabelsGrid
from diffpy.pdfgui.gui.wxextensions.textctrlutils import textCtrlAsGridCell
from diffpy.pdfgui.gui.wxextensions.validators import FLOAT_ONLY, TextValidator
Expand Down Expand Up @@ -642,13 +641,13 @@ def popupMenu(self, window, x, y):
"""
# only do this part the first time so the events are only bound once
if not hasattr(self, "insertID"):
self.insertID = wx12.NewIdRef()
self.deleteID = wx12.NewIdRef()
self.selectID = wx12.NewIdRef()
self.copyID = wx12.NewIdRef()
self.pasteID = wx12.NewIdRef()
self.supercellID = wx12.NewIdRef()
self.spaceGroupID = wx12.NewIdRef()
self.insertID = wx.NewIdRef()
self.deleteID = wx.NewIdRef()
self.selectID = wx.NewIdRef()
self.copyID = wx.NewIdRef()
self.pasteID = wx.NewIdRef()
self.supercellID = wx.NewIdRef()
self.spaceGroupID = wx.NewIdRef()

self.Bind(wx.EVT_MENU, self.onPopupInsert, id=self.insertID)
self.Bind(wx.EVT_MENU, self.onPopupDelete, id=self.deleteID)
Expand Down
9 changes: 4 additions & 5 deletions src/diffpy/pdfgui/gui/phaseconstraintspanel.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
from diffpy.pdfgui.gui import phasepanelutils, tooltips
from diffpy.pdfgui.gui.pdfpanel import PDFPanel
from diffpy.pdfgui.gui.sgconstraindialog import SGConstrainDialog
from diffpy.pdfgui.gui.wxextensions import wx12
from diffpy.pdfgui.gui.wxextensions.autowidthlabelsgrid import AutoWidthLabelsGrid
from diffpy.pdfgui.gui.wxextensions.textctrlutils import textCtrlAsGridCell
from diffpy.utils.wx import gridutils
Expand Down Expand Up @@ -582,10 +581,10 @@ def popupMenu(self, window, x, y):
"""
# only do this part the first time so the events are only bound once
if not hasattr(self, "spaceGroupID"):
self.spaceGroupID = wx12.NewIdRef()
self.selectID = wx12.NewIdRef()
self.copyID = wx12.NewIdRef()
self.pasteID = wx12.NewIdRef()
self.spaceGroupID = wx.NewIdRef()
self.selectID = wx.NewIdRef()
self.copyID = wx.NewIdRef()
self.pasteID = wx.NewIdRef()

self.Bind(wx.EVT_MENU, self.onPopupSpaceGroup, id=self.spaceGroupID)
self.Bind(wx.EVT_MENU, self.onPopupSelect, id=self.selectID)
Expand Down
12 changes: 5 additions & 7 deletions src/diffpy/pdfgui/gui/wxextensions/listctrls.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,12 @@
import wx
import wx.lib.mixins.listctrl as listmix

from diffpy.pdfgui.gui.wxextensions import wx12


class AutoWidthListCtrl(wx12.ListCtrl, listmix.ListCtrlAutoWidthMixin):
class AutoWidthListCtrl(wx.ListCtrl, listmix.ListCtrlAutoWidthMixin):
"""WxListCtrl subclass that automatically adjusts its column width."""

def __init__(self, parent, ID, pos=wx.DefaultPosition, size=wx.DefaultSize, style=0, *args, **kwargs):
wx12.ListCtrl.__init__(self, parent, ID, pos, size, style, *args, **kwargs)
wx.ListCtrl.__init__(self, parent, ID, pos, size, style, *args, **kwargs)
listmix.ListCtrlAutoWidthMixin.__init__(self)

def clearSelections(self):
Expand Down Expand Up @@ -185,6 +183,6 @@ def OnKeyDown(self, evt):
# End of class KeyEventsListCtrl

# verify inheritance of all ListCtrl classes
assert issubclass(AutoWidthListCtrl, wx12.ListCtrl)
assert issubclass(ColumnSortListCtrl, wx12.ListCtrl)
assert issubclass(KeyEventsListCtrl, wx12.ListCtrl)
assert issubclass(AutoWidthListCtrl, wx.ListCtrl)
assert issubclass(ColumnSortListCtrl, wx.ListCtrl)
assert issubclass(KeyEventsListCtrl, wx.ListCtrl)
Loading

0 comments on commit b7c5c65

Please sign in to comment.