当前位置:网站首页>Metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its bases
Metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its bases
2022-08-05 12:28:00 【Lan.W】
Python: 虚拟类用到弹窗UI界面做继承实现时,报以下错误 :
class Ui_Dialog(QDialog, RunTimeCallBack):
# RunTimeCallBack.class
def notify(self, msgType, postname):
# 更新SN, SOC
print(f"哈哈,PopDialog收到别人的通知了{postname=}")
# RunTimeCallBack.class
def timeUpdate(self, device_index, run_state, startime):
# 更新测试时间
mLogger.debug(f"收到计时器更新 ,{device_index=},{run_state=} ,={startime}")
pass
#。。。。
#。。。。
class RunTimeCallBack(Subscriber):
# def notify(self):
# pass
@abstractmethod
def timeUpdate(self,device_index,run_state,startime): # 用于更新Dialog显示测试时间
pass
class Subscriber(metaclass=ABCMeta):
def __init__(self):
pass
@abstractmethod
def notify(self):
passTraceback (most recent call last):
File "/Users/gdlocal/Documents/Lani_work/T03/T03/t03Gui/mainT03HSUi.py", line 5, in <module>
from DeviceItem import T03DeviceWindow
File "/Users/gdlocal/Documents/Lani_work/T03/T03/t03Gui/DeviceItem.py", line 8, in <module>
from PopDialog import Ui_Dialog
File "/Users/gdlocal/Documents/Lani_work/T03/T03/t03Gui/PopDialog.py", line 84, in <module>
class Ui_Dialog(QDialog, RunTimeCallBack):
TypeError: metaclass conflict: the metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its bases
原因:
说是元类冲突,
目前暂时的解决方法是:
原来父类,类声明:class Subscriber(metaclass=ABCMeta):
现在修改一下,直接继承object:
class Subscriber(object):
__metaclass__ = ABCMeta #虚拟类的声明在代码块声明,
#class Subscriber(metaclass=ABCMeta):
class Subscriber(object):
__metaclass__ = ABCMeta
def __init__(self):
pass
@abstractmethod
def notify(self):
pass
但是
************************************************************************
Python3.0到Python3.3,必须在class语句中使用metaclass=ABCMeta;
在python2中使用时。这个报错,说明定义正确,生效了。
Python2中使用__metaclass__=ABCMeta
***************************************************************
说明上面的__metaclass__ = ABCMeta,没有实现作用。
边栏推荐
- STM32H743IIT6 study notes 03 - using third-party components FreeRTOS
- solaris-oralce rac 安装
- 素士科技IPO被终止:年营收18.7亿 顺为小米景林昆仲是股东
- Shang Silicon Valley-JVM-Performance Monitoring and Tuning (P302~P381)
- 对话庄表伟:开源第一课
- RK3588+FPGA high-speed image processing communication processor solution
- Common methods of Go language strings library
- [转载]卡尔曼滤波(kalman filter)和均值滤波有什么关系?
- sentinel介绍和使用
- Dialogue with Zhuang Biaowei: The first lesson of open source
猜你喜欢
随机推荐
leetcode 240. Search a 2D Matrix II 搜索二维矩阵 II(中等)
MySQL之InnoDB存储结构
一致性协议-ChainPaxos详解
【无标题】
素士科技IPO被终止:年营收18.7亿 顺为小米景林昆仲是股东
The difference between MySQL's InnoDB and MyISAM
C进阶-自定义类型:结构体,枚举,联合
ansible-playbook configure ssh mutual trust
The memory problem is difficult to locate, that's because you don't use ASAN
食品饮料行业B2B商城系统:加速行业数字化转型,提升B2B平台交易效率
华为分析&联运活动,助您提升游戏总体付费
express logging module Morgan
Query optimization (TTFB is too long) left join index does not take effect
【IC5000教程】-02-使用daqIDEA图形化显示“Array数组”和“struct结构体”类型变量的值变化
For high performance, large scale model training, this combination "career"
今日开幕:LiveVideoStackCon 2022 音视频技术大会 上海站
796. Sum of Submatrices
The Open-Closed Principle (OCP) of the Seven Principles of Software Design
MySQL check constraint
Two: OpenCV image overlay logical operation






![[供应链·案例篇]疫情影响下的全球十大零售商都做了些什么](/img/44/9ef9f86f8afb85f49aac1cce55723d.jpg)

