6 Star 11 Fork 3

jakey.chen/PyinstallerTool

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
main.py 2.68 KB
一键复制 编辑 原始数据 按行查看 历史
jakey.chen 提交于 2015-02-15 13:15 +08:00 . 初版上传
#! /usr/bin/env python
# -*- coding: utf-8 -*-
import Tkinter as tk
import os
import sys
import threading
from UI import pyinstallerUI
class MainPyinstaller(pyinstallerUI.PyinstallerUI):
def __init__(self, master=None):
super(MainPyinstaller, self).__init__()
self.start_flag = False
def Generate(self):
'''
生成可执行文件
'''
if not self.start_flag:
thread_generate = threading.Thread(target=self.ThreadGenerate)
thread_generate.setDaemon(True)
thread_generate.start()
else:
self.frm_status_label["text"] = "Being Packing, please re-run later!"
def ThreadGenerate(self):
'''
线程执行生成动作
'''
if len(self.entry_value_list[0].get()) == 0:
self.frm_status_label["text"] = "Please select the source file!"
return
try:
self.start_flag = True
command = self.assembly_command_string()
self.frm_status_label["text"] = "Being Packing, please wait a moment!"
os.system(command)
self.start_flag = False
self.frm_status_label["text"] = "Complete package!"
except Exception as e:
self.frm_status_label["text"] = e.message
self.start_flag = False
def assembly_command_string(self):
'''
组装终端执行命令行
'''
self.command_string = ""
self.command_list = list()
self.command_list.append("pyinstaller")
if len(self.entry_value_list[1].get()) > 0:
self.command_list.append("--workpath=" + self.entry_value_list[1].get())
if len(self.entry_value_list[2].get()) > 0:
self.command_list.append("--distpath=" + self.entry_value_list[2].get())
if len(self.entry_value_list[3].get()) > 0:
self.command_list.append("--icon=" + self.entry_value_list[3].get())
if self.onefile.get() == 1:
self.command_list.append("--onefile")
if self.noconsole.get() == 1:
self.command_list.append("--noconsole")
if self.rename_exe.get() == 1:
if len(self.rename_strvar.get()) > 0:
self.command_list.append("--name=" + self.rename_strvar.get())
if len(self.entry_value_list[0].get()) > 0:
self.command_list.append(self.entry_value_list[0].get())
self.command_string = " ".join(self.command_list)
return self.command_string
if __name__ == '__main__':
'''
main loop
'''
root = tk.Tk()
root.title("Pyinstaller Tool")
MainPyinstaller(master=root)
root.resizable(False, False)
root.mainloop()
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/jakey.chen/PyinstallerTool.git
git@gitee.com:jakey.chen/PyinstallerTool.git
jakey.chen
PyinstallerTool
PyinstallerTool
master

搜索帮助