挫败试图为python脚本创建GUI [英] Frustration trying to create GUI for python script

查看:54
本文介绍了挫败试图为python脚本创建GUI的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一般对编码都非常陌生,因此决定从Python开始. 我已经掌握了一些基础知识,但是我总是觉得我通过做事就能学到更好的东西.

I'm extremely new to coding in general, and decided to start with Python. I've got some of the basics down, but I always feel like I learn better by just doing things.

我正在使用GUI2EXE来帮助我将简单的脚本(询问您的姓名和年龄,然后以天,小时,分钟和秒为单位告诉您年龄)转换为EXE.当我编译为EXE(使用py2exe)时,出现此错误:

I'm using GUI2EXE to help me turn my simple script (asks your name and age, then tells you how old you are in days, hours, minutes, and seconds) into an EXE. When I compile into an EXE (using py2exe), I get this error:

Traceback (most recent call last):
  File "Age.py", line 2, in <module>
EOFError: EOF when reading a line

从以前的研究中,我将setup.py更改为使用控制台"而不是窗口",但是遇到了同样的问题.

From previous research, I changed the setup.py to use "console" instead of "window", but ran into the same issue.

这是我的代码:

print("Let's see how long you have lived in days, minutes, and seconds!")
name = input("name: ")

print("Now enter your age!")
age = int(input("age: "))

days = age * 365
minutes = age * 525948
seconds = age * 31556926

print(name, "has been alive for", days, "days", minutes, "minutes and", seconds, "seconds! Wow!")

任何建议将不胜感激!

P.S.我同时拥有python的2.7和3.3版本,但是我将重点放在2.7上,以进行大多数学习.

P.S. I have both versions 2.7 and 3.3 of Python, but I am focusing on 2.7 for this and most learning.

推荐答案

    http://www.pyinstaller.org/(zip版本)
  1. 下载pyinstaller
  2. >
  3. 将其提取到C:\,您现在应该具有C:\pyinstaller-2.1\<bunchafiles>
  4. 之类的路径.
  5. 转到您通常运行程序的源文件夹
  6. 按住 SHIFT + RIGHTCLICK 选择在此处打开命令窗口"
  7. 您现在应该在命令提示符下C:\path\to\code> _
  8. 类型:python C:\pyinstaller-2.1\pyinstaller.py --onefile --console Age.py
  9. 运行已发芽的exe ...
  1. download pyinstaller from http://www.pyinstaller.org/ (the zip version)
  2. extract it to C:\ , you should now have a path like C:\pyinstaller-2.1\<bunchafiles>
  3. go to your source folder where you normally run your program
  4. hold SHIFT + RIGHTCLICK select "open command window here"
  5. you should now be at a command prompt C:\path\to\code> _
  6. type: python C:\pyinstaller-2.1\pyinstaller.py --onefile --console Age.py
  7. run exe that is gernerated ...

我认为它只能使用2倍...

it will only work with 2x I think ...

这篇关于挫败试图为python脚本创建GUI的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆