python pyinstaller 加载ui路径方法

yipeiwu_com6年前Python基础

如下所示:

class Login(QMainWindow):
  """登录窗口"""
  global status_s
  global connect_signal
  def __init__(self, *args):
    super(Login, self).__init__(*args)
    
    if getattr(sys,'frozen',False):
      bundle_dir = sys._MEIPASS
    else:
      bundle_dir = os.path.dirname(os.path.abspath(__file__))
    loadUi(bundle_dir+'\set_controller.ui', self) 

使用pyinstaller进行封装时,使用语句:

不带命令行界面 pyinstaller -w -F --add-data="set_controller.ui;." .\jiaben.py 

带命令行界面    pyinstaller -c -F --add-data="set_controller.ui;." .\jiaben.py 

添加icon图标时,在spec文件中添加,然后运行pyinstaller **.spec

以上这篇python pyinstaller 加载ui路径方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持【听图阁-专注于Python设计】。

相关文章

python类中super()和__init__()的区别

单继承时super()和__init__()实现的功能是类似的 class Base(object): def __init__(self): print 'Base create'...

PyQt5的安装配置过程,将ui文件转为py文件后显示窗口的实例

PyQt5安装 在cmd下输入pip install PyQt5 完成PyQt5安装, 安装完成后,在python安装目录下可以看到 配置PyCharm 配置PyCharm是为了在P...

Python中Iterator迭代器的使用杂谈

迭代器是一种支持next()操作的对象。它包含一组元素,当执行next()操作时,返回其中一个元素;当所有元素都被返回后,生成一个StopIteration异常。 >>&...

python pands实现execl转csv 并修改csv指定列的方法

如下所示: # -*- coding: utf-8 -*- import os import pandas as pd import numpy as np #from os im...

python类继承用法实例分析

本文实例讲述了python类继承用法。分享给大家供大家参考。具体方法如下: #!/usr/bin/python # Filename: inherit.py class Schoo...