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'报错的更多相关文章

  1. AttributeError: 'NoneType' object has no attribute 'split' 报错处理

    报错场景 social_django 组件对原生 django 的支持较好, 但是因为 在此DRF进行的验证为 JWT 方式 和 django 的验证存在区别, 因此需要进行更改自行支持 JWT 方式 ...

  2. appium 与 selenium python解决python 'WebElement' object does not support indexing 报错问题问题

    再用selenium编写测试脚本时,发现出现python 'WebElement' object does not support indexing 报错问题问题,再找一些解决方法时,发现Appium ...

  3. 解决 AttributeError: 'ForeignKey' object has no attribute 're'

    解决办法 # print('rel...',filter_field_obj.re.to.objects.all()) print("rel...", filter_field_o ...

  4. 解决AttributeError: 'module' object has no attribute 'main' 安装第三方包报错

    1.找到pycharm 目录下的 \helper\packaging_tool.py 文件 2.用新版pycharm 的packaging_tool.py 替换 旧版 同名文件 文件代码如下: imp ...

  5. 'CSRFCheck' object has no attribute 'process_request' 报错

    环境:Python3.5 way 1: way 2: 在项目的setting.py中设置

  6. zc.buildout构建项目时报错‘AttributeError: '_NamespacePath' object has no attribute 'sort'’

    在使用zc.buildout构建项目时如果碰到‘AttributeError: '_NamespacePath' object has no attribute 'sort'’报错: An inter ...

  7. python3.x运行的坑:AttributeError: 'str' object has no attribute 'decode'

    1.Python3.x和Python2.X版本有一些区别,我遇到了两个问题如下: a.第一个报:mysqlclient 1.3版本不对: 解决办法:注释掉这行即可: b.第二个报:字符集的问题: 报错 ...

  8. attributeError:'module' object has no attribute ** 解决办法

    写了一个小脚本,执行的时候报错: Traceback (most recent call last): File "F:/test/qrcode.py", line 109, in ...

  9. 对于AttributeError: 'Flask' object has no attribute 'cli'的解决办法

    版权声明:本文为博主原创文章,未经博主允许不得转载. 环境flask-script2.0.5.flask0.10.1 运行官方文档sample 出现问题 c:\kk\flask\examples\fl ...

随机推荐

  1. mysql-6正则表达式

    mysql正则表达式 匹配的两种方式: 1.模糊匹配:like 2.正则表达式 正则表达式语法: 语法 说明 ^ 起始位置.如果设置了RegExp对象的Multiline属性,^也匹配'\n'或'\r ...

  2. Controlling DNS prefetching

    Controlling DNS prefetching IN THIS ARTICLE Background Configuring prefetching in the browser Contro ...

  3. jquery文件的引入

    上节课说到,一般情况下,是库的文件,该库中都会抛出来构造函数或者对象 ,如果是构造函数,那么创建对象,如果是对象直接调用属性和方法 使用jquery第一步,先引入jquery,然后再写相应的jquer ...

  4. p3新式类__new__使用和实例化

    嗯,new方法返回的是一个全新的对象是真正在内存中分配的内存地址 示例1·class Foo(object): # __metaclass__ = MyType def __init__(self, ...

  5. 《Linux内核精髓:精通Linux内核必会的75个绝技》一HACK #3 如何编写内核模块

    HACK #3 如何编写内核模块 本节将介绍向Linux内核中动态添加功能的结构—内核模块的编写方法.内核模块Linux内核是单内核(monolithic kernel),也就是所有的内核功能都集成在 ...

  6. js 取元素相对页面的高度和宽度

    function pos(elem) {    var x = elem.offsetLeft,  y = elem.offsetTop;    while (elem = elem.offsetPa ...

  7. sqlplus rlwrap readline

  8. Windows环境下为PHP5.6安装redis扩展和memcached扩展

    一.php安装redis扩展   1.使用phpinfo()函数查看PHP的版本信息,这会决定扩展文件版本       2.根据PHP版本号,编译器版本号和CPU架构, 选择php_redis-2.2 ...

  9. could not be installed at this time

    无法下载应用 此时无法安装 Unable to Download App ''App" could not be installed at this time 编译程序的时候,Target ...

  10. java.io.CharConversionException: Not an ISO 8859-1 character:

    java.io.CharConversionException: Not an ISO 8859-1 character: XXX 这个问题可能是因为outputstream输出中文字造成的影响. r ...