From 8bd2563acff5f03f4c42e9333f0f2978facf1d71 Mon Sep 17 00:00:00 2001 From: Aarni Koskela Date: Tue, 13 Aug 2024 23:40:22 +0300 Subject: [PATCH] Use standard `types.SimpleNamespace` instead of custom `struct` --- labelme/app.py | 5 +++-- labelme/utils/__init__.py | 1 - labelme/utils/qt.py | 5 ----- 3 files changed, 3 insertions(+), 8 deletions(-) diff --git a/labelme/app.py b/labelme/app.py index 7bbce4936..964c2938c 100644 --- a/labelme/app.py +++ b/labelme/app.py @@ -6,6 +6,7 @@ import os import os.path as osp import re +import types import webbrowser import imgviz @@ -622,7 +623,7 @@ def __init__( self.labelList.customContextMenuRequested.connect(self.popLabelListMenu) # Store actions for further handling. - self.actions = utils.struct( + self.actions = types.SimpleNamespace( saveAuto=saveAuto, saveWithImageData=saveWithImageData, changeOutputDir=changeOutputDir, @@ -715,7 +716,7 @@ def __init__( self.canvas.vertexSelected.connect(self.actions.removePoint.setEnabled) - self.menus = utils.struct( + self.menus = types.SimpleNamespace( file=self.menu(self.tr("&File")), edit=self.menu(self.tr("&Edit")), view=self.menu(self.tr("&View")), diff --git a/labelme/utils/__init__.py b/labelme/utils/__init__.py index 7fa2154fe..499d52811 100644 --- a/labelme/utils/__init__.py +++ b/labelme/utils/__init__.py @@ -23,7 +23,6 @@ from .qt import newAction from .qt import addActions from .qt import labelValidator -from .qt import struct from .qt import distance from .qt import distancetoline from .qt import fmtShortcut diff --git a/labelme/utils/qt.py b/labelme/utils/qt.py index 7fed3ad18..f6b3798c4 100644 --- a/labelme/utils/qt.py +++ b/labelme/utils/qt.py @@ -70,11 +70,6 @@ def labelValidator(): return QtGui.QRegExpValidator(QtCore.QRegExp(r"^[^ \t].+"), None) -class struct(object): - def __init__(self, **kwargs): - self.__dict__.update(kwargs) - - def distance(p): return sqrt(p.x() * p.x() + p.y() * p.y())