简体   繁体   English

从IDLE运行时,同一个程序运行良好,但直接运行时,同一个程序运行不正常

[英]Same Program Runs Fine when ran from IDLE but not when ran directly

I wrote a small Tkinter based GUI app on python. 我在python上编写了一个基于Tkinter的小型GUI应用程序。 It worked fine when run with IDLE, but displays moduleError on running it directly. 与IDLE一起运行时,它工作正常,但在直接运行它时显示moduleError。 I am on windows. 我在窗户上。 Running it directly means double-clicking the .py file. 直接运行它意味着双击.py文件。 Here's the link to the code. 这是代码的链接。 I have the path to python appended in the PATH environment variable 我在PATH环境变量中附加了python的路径

http://codepad.org/ezxcpi7Y http://codepad.org/ezxcpi7Y

And the error image: 和错误图片:

错误

Why i am getting that error? 为什么我收到该错误? Please help 请帮忙

You need to import tkinter.messagebox 您需要import tkinter.messagebox

IDLE(writen in tk) imports this module in tkinter (python not imports modules twice). IDLE(用tk编写)在tkinter中导入此模块(python不会两次导入模块)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 从运行导入程序的按钮运行程序时弹出空白“tk”window | 适用于 Tkinter - Blank 'tk' window popping up when program is ran from a button which runs an imported program | For Tkinter if 语句在运行但不空闲时给出错误 - if statement giving errors when ran but not in idle 程序在运行时立即关闭 - Program immediately closes when ran 当程序直接运行时,更改 python 程序中的墙纸有效。 但在从服务运行时不起作用 - changing the wallpaper in python program works when the program is ran directly. but doesn't work when it's run from a service 程序在Pycharm和IDLE下运行,直接打开就崩溃 - Program runs in Pycharm and IDLE, but crashes when opened directly 从另一个模块运行时,Python BackgroundScheduler程序崩溃 - Python BackgroundScheduler program crashing when ran from another module 从终端运行并从Python运行时,脚本的工作方式不同 - Script works differently when ran from the terminal and ran from Python 运行时 Python 中的程序错误(Python 2.7) - Program Error in Python When Ran (Python 2.7) 运行程序时无法在 chrome 上显示网站 - Unable to display website on chrome when ran the program 区分何时“直接”运行脚本或使用Python可执行文件 - Distinguishing between when a script is ran 'directly', or with Python executable
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM