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实现zencart产品数据导入到magento(python导入数据)

python版本要求在3.3.x,需要mysql connector for python第三方库支持不适用所有的zencart导入到magento 复制代码 代码如下:#encodin...

python显示生日是星期几的方法

本文实例讲述了python显示生日是星期几的方法。分享给大家供大家参考。具体实现方法如下: # find the day of the week of a given date #...

pyQT5 实现窗体之间传值的示例

pyQT5 实现窗体之间传值的示例

准备 一个MainWindow和一个WidgetForm,总代码如下 # -*- coding: utf-8 -*- from PyQt5 import QtWidgets fr...

python 判断一个进程是否存在

源代码如下:复制代码 代码如下:#-*- coding:utf-8 -*- def check_exsit(process_name): import win32com.client W...

Python标准库shutil用法实例详解

本文实例讲述了Python标准库shutil用法。分享给大家供大家参考,具体如下: shutil模块提供了许多关于文件和文件集合的高级操作,特别提供了支持文件复制和删除的功能。 文件夹与...