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设计】。

相关文章

使用APScheduler3.0.1 实现定时任务的方法

需求是在某一指定的时刻执行操作 网上的建议多为通过调用Scheduler的add_date_job实现 不过APScheduler 3.0.1与之前差异较大, 无法通过上述方法实现 参考...

python如何去除字符串中不想要的字符

问题:     过滤用户输入中前后多余的空白字符       ‘    ++++abc123---    ‘     过滤某w...

用Python编写web API的教程

自从Roy Fielding博士在2000年他的博士论文中提出REST(Representational State Transfer)风格的软件架构模式后,REST就基本上迅速取代了复...

教你安装python Django(图文)

教你安装python Django(图文)

安装环境:python版本2.7.5 ,win7系统安装Djangohttps://www.djangoproject.com/download/ 官方下载Django-1.5.5.ta...

Python模块WSGI使用详解

WSGI(Web Server Gateway Interface):Web服务网关接口,是Python中定义的服务器程序和应用程序之间的接口。 Web程序开发中,一般分为服务器程序和...