python - 将Python代码转换为Linux可执行文件

标签 python python-2.7 tkinter

这是我的代码

#!/usr/bin/ python
from Tkinter import *
root = Tk(className="My first GUI") # creates root window
# all components of thw window will come here
root.mainloop() # To keep GUI window running


它只是生成一个窗口。
我想将其转换为基于Linux的机器的可执行文件,即(当单击可执行文件时,它应直接显示窗口)。
我不希望用户从终端运行它。

最佳答案

只需将其放在脚本的第一行即可:

#!/usr/bin/env python


使文件可执行

`chmod +x GuiFile.`py


执行

./GuiFile.py


对于Windows,可以使用py2exepyinstaller

关于python - 将Python代码转换为Linux可执行文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43584413/

相关文章:

python - 如何为实例更改 dict() 的行为

python-2.7 - 没有名为 'matplotlib.pyplot' 的模块; 'matplotlib' 不是包

python tensorflow - relu 未在自动编码器任务中学习

python - 如何将参数传递给 Tkinter 按钮的回调命令?

python - 动态 tkinter 输入框

python - Django 表单不工作

python - 您如何管理自定义模块?

python - 如何将元组字典转换为列表字典(Python)?

python - 控制 Tkinter 中滚动条的位置

python - 带有滚动条的 tkinter 表格显示