解决AttributeError: 'Ui_MainWindow' object has no attribute 'show'报错
1、首先使用pyqt designer来设计ui界面,将其保存为"***.ui"文件,
然后进入到pyqt所在的文件目录中,执行cmd中命令,即在当前目录中可以生成相应的**.py文件。

2、生成之后的Python代码,我们需要对其继承的object类进行修改为QtGui.QMainWindow。添加一个__init__方法,在__init__里,先调用了父类QMainWindow的构造方法,然后调用了自动生成的两个方法。(注意,传的参数是self,因为他已经是QMainWindow了。)
class Ui_MainWindow(QtGui.QMainWindow):
def __init__(self):
super(Ui_MainWindow,self).__init__()
self.setupUi(self)
self.retranslateUi(self)
如果直接对生成的test.py编译运行,则会报错:
AttributeError: 'Ui_MainWindow' object has no attribute 'show'。
解决AttributeError: 'Ui_MainWindow' object has no attribute 'show'报错的更多相关文章
- AttributeError: 'NoneType' object has no attribute 'split' 报错处理
报错场景 social_django 组件对原生 django 的支持较好, 但是因为 在此DRF进行的验证为 JWT 方式 和 django 的验证存在区别, 因此需要进行更改自行支持 JWT 方式 ...
- appium 与 selenium python解决python 'WebElement' object does not support indexing 报错问题问题
再用selenium编写测试脚本时,发现出现python 'WebElement' object does not support indexing 报错问题问题,再找一些解决方法时,发现Appium ...
- 解决 AttributeError: 'ForeignKey' object has no attribute 're'
解决办法 # print('rel...',filter_field_obj.re.to.objects.all()) print("rel...", filter_field_o ...
- 解决AttributeError: 'module' object has no attribute 'main' 安装第三方包报错
1.找到pycharm 目录下的 \helper\packaging_tool.py 文件 2.用新版pycharm 的packaging_tool.py 替换 旧版 同名文件 文件代码如下: imp ...
- 'CSRFCheck' object has no attribute 'process_request' 报错
环境:Python3.5 way 1: way 2: 在项目的setting.py中设置
- zc.buildout构建项目时报错‘AttributeError: '_NamespacePath' object has no attribute 'sort'’
在使用zc.buildout构建项目时如果碰到‘AttributeError: '_NamespacePath' object has no attribute 'sort'’报错: An inter ...
- python3.x运行的坑:AttributeError: 'str' object has no attribute 'decode'
1.Python3.x和Python2.X版本有一些区别,我遇到了两个问题如下: a.第一个报:mysqlclient 1.3版本不对: 解决办法:注释掉这行即可: b.第二个报:字符集的问题: 报错 ...
- attributeError:'module' object has no attribute ** 解决办法
写了一个小脚本,执行的时候报错: Traceback (most recent call last): File "F:/test/qrcode.py", line 109, in ...
- 对于AttributeError: 'Flask' object has no attribute 'cli'的解决办法
版权声明:本文为博主原创文章,未经博主允许不得转载. 环境flask-script2.0.5.flask0.10.1 运行官方文档sample 出现问题 c:\kk\flask\examples\fl ...
随机推荐
- mysql 8.0 初识
1 下载并安装mysql 8.0官网下载比较慢,这里选择163的镜像http://mirrors.163.com/mysql/Downloads/MySQL-8.0/下载版本mysql-8.0.14- ...
- 记录在Python2.7 x64 bit 下 PyQt5.8的编译过程
由于工作需要使用python下面的Qt库.PyQt现在只提供针对Python3.X系列的PyQt,所有需要自己手动编译.防止忘记,特意写下随笔记录备忘. 工 作 环境:Python版本:Python ...
- urllib2 Handler处理器和自定义opener(六)
Handler处理器 和 自定义Opener opener是 urllib2.OpenerDirector 的实例,我们之前一直都在使用的urlopen,它是一个特殊的opener(也就是模块帮我们构 ...
- 温故而知新-面向对象的PHP
1 类的多态 不同的类对同一操作可以有不同的行为. 比如自行车和汽车都有移动这个成员函数行为, 那么自行车类可以移动,行为和汽车的移动行为肯定不同. 2 析构函数不能有参数 3 __set和__get ...
- escape(), encodeURL(), encodeURIComponent()
escape() 方法: 采用ISO Latin字符集对指定的字符串进行编码.所有的空格符.标点符号.特殊字符以及其他非ASCII字符都将被转化成%xx格式的字符编码(xx等于该字符在字符集表里面的编 ...
- 实战zabbix3.0.2 使用percona mysql插件监控mysql5.7
1.系统环境 [root@shard0 templates]# cat /etc/redhat-release Red Hat Enterprise Linux Server release 7.2 ...
- zookeeper简绍
先一句话概括下zookeeper:zookeeper可谓是目前使用最广泛的分布式组件了.其功能和职责单一,但却非常重要. zookeeper到底是什么?(技术文) 1)zookeeper实际上是yah ...
- k8s gpu 资源设置
将所有相同型号显卡的node打上 相同的label kubectl label node ogs-gpu02 gpu_type=k20m 启动device plugin 和app 时: nodeSel ...
- CentOS 7 调整 home分区 扩大 root分区
总体过程: 把/home内容备份,然后将/home文件系统所在的逻辑卷删除,扩大/root文件系统,新建/home ,恢复/home内容 1.查看分区 df -h 2.备份home分区文件 tar c ...
- c# class struct区别
一句话,前者引用类型,后者值类型,适合高性能的情况,但不可存储大数据.