解决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 ...
随机推荐
- 在 Laravel 5 中集成七牛云存储实现云存储功能(非上传)
本扩展包基于https://github.com/qiniu/php-sdk开发,是七牛云储存 Laravel 5 Storage版,通过本扩展包可以在Laravel 5中集成七牛云存储功能. 1.安 ...
- 基于Windows 配置 nginx 集群 & 反向代理
1.下载 nginx 下载页面 : http://nginx.org/en/download.html 具体文件: http://nginx.org/download/nginx-1.7.0.zip ...
- #用openfiledialog文件和savefileDialog打开和保存文件
一.打开文件 Stream myStream = null; OpenFileDialog openFileDialog1 = new OpenFileDialog(); ...
- 使用打印方法时,要先引用命名空间: Using System.Drawing.Pringing
使用打印方法时,要先引用命名空间: Using System.Drawing.Pringing PrintDocument类的重要属性和方法:属性:DocumentName 设置打印文档时要显示的文 ...
- 可视化库-Matplotlib-条形图(第四天)
1.画两个条形图,bar和barh, 同时axes[0].axhline画一条横线,axes[1].axvline画一条竖线 import numpy as np import matplotlib. ...
- tar使用
[tar使用] 1..tar.gz文件 压缩:tar -czvf dstFileName.tar.gz a.txt b.txt …… 解压:tar -xzvf fileName.tar.gz 2..t ...
- 外层div高度不随内层div高度改变的解决办法
当b1和b2都是float=left时候,a1层的高度不会被b1和b2的高度撑开. <div id=“div1″> <div id=”div2″ style="float: ...
- win8上部署.net4.0程序到iis
在win8.1上默认的iis版本为8.5版,不做任何配置回报3个错误, 一下是错误提示内容及解决方案 1>HTTP 错误 404.3 – Not Found由于扩展配置问题而无法提供您请求的页面 ...
- 静态HTML服务器
主要代码 #pragma once#include "pre.h"#include <thread> NAMESPACE(DEF) class Socket {publ ...
- Android内核的编译与测试
1.下载Android内核 source.android.com/source->Downloading and Building Building Kernels 大概要花2个小时,其源码在培 ...