This commit is contained in:
恍兮惚兮 2024-12-29 01:43:17 +08:00
parent 3d422a4dd4
commit 14cdd4d4f7

View File

@ -225,15 +225,17 @@ class TagWidget(QWidget):
self.__addTag((tag, _type, refdata)) self.__addTag((tag, _type, refdata))
self.__calltagschanged(signal) self.__calltagschanged(signal)
@tryprint
def __removeTag(self, key): def __removeTag(self, key):
_w = self.tag2widget[key] _w = self.tag2widget[key]
self.layout().removeWidget(_w) self.layout().removeWidget(_w)
self.tag2widget.pop(key) self.tag2widget.pop(key)
def removeTag(self, key, signal=True): def removeTag(self, key, signal=True):
try:
self.__removeTag(key) self.__removeTag(key)
self.__calltagschanged(signal) self.__calltagschanged(signal)
except:
pass
def __calltagschanged(self, signal): def __calltagschanged(self, signal):
if signal: if signal:
@ -241,7 +243,10 @@ class TagWidget(QWidget):
def clearTag(self, signal=True): def clearTag(self, signal=True):
for key in self.tag2widget.copy(): for key in self.tag2widget.copy():
try:
self.__removeTag(key) self.__removeTag(key)
except:
pass
self.__calltagschanged(signal) self.__calltagschanged(signal)