python-idle

idle-python3.2 not starting: complains of NameError: name 'Tk' is not defined

喜夏-厌秋 提交于 2019-12-20 05:40:28
问题 running linux mint 13 idle-python3.2 did work from the terminal before, now it does not. Calling idle-python3.2 from the terminal throws the error below BUT I can run Idle by double clicking on the script! Here's the very simple script that broke it all(?) http://pastebin.com/pP9An3UU FWIW, the script does not appear to work either (nothing happens when I run it). Here's the error in the terminal when trying to run Idle3.2 from the terminal: File "tkinter.py", line 2, in <module> tk = Tk()

What does “== RESTART <path> ==” in the IDLE Shell mean?

家住魔仙堡 提交于 2019-12-20 05:29:07
问题 I have a simple script I wrote, and when trying to run it (F5) , I get this msg: ================== RESTART: C:\Users\***\Desktop\tst.py ================== I restarted the shell, reopened the script, but still, the same msg appears. I use python 3.5.1 and I tried to simplify the script as much as possible, but I still get this result. Now my script is only one line with a simple print(1) command and I still get this msg. Was there something wrong with the shell installation? 回答1: I have a

Imports working with raw file, but not in IDLE

ε祈祈猫儿з 提交于 2019-12-20 05:21:44
问题 UPDATE 10 Secs later Fixed properly now, and thanks to JF and Gauden. UPDATE I have found a temporary fix by saving the IDLE file in the directory the other working file is in. (I would still like to know how to fix it entirely if I can.) That's not a permanant fix, so if you want to try and help make it work wherever the file is saved, feel free. This is the start of a python file: #!/usr/bin/python # -*- coding: utf-8 -*- import wikipedia import pagegenerators import sys import re import

How to remove lines from stdout in Python - in SciTe, Idle, Eclipse or other editor with console

删除回忆录丶 提交于 2019-12-20 04:38:42
问题 For a standard Python Console window, you can remove the last line with for example sys.stdout.write('\r'+' '*len(line)) as I explained here. But for editors like SciTe, Idle or Eclipse (with PyDev), the stdout is a file-type object, probably flushing its content to the console window leaving its buffer empty and thus not allowing modify the content once it has appeared on in the window. What trick can be applied to, for example, erase the last line of such console? Is there a one-size-fits

Python IDLE becomes slow on very large program input

空扰寡人 提交于 2019-12-20 03:26:10
问题 Why does python idle become so slow when handling very large inputs, when the python command line does not? For example, if I run "aman"*10000000 in python IDLE, it becomes unresponsive, but on python cmd line, it is quick. 回答1: I had to research a bit. When I invoked idle on my machine, I saw another python process which uses idlelib ~$ ps -eaf | grep -in idle 234:1000 13122 1 5 16:44 ? 00:00:01 /usr/bin/python2.7 /usr/bin/idle-python2.7 235:1000 13124 13122 3 16:44 ? 00:00:01 /usr/bin

Run a module in IDLE (Python 3.4) without Restart

旧时模样 提交于 2019-12-19 12:23:51
问题 It appears that, in the past, IDLE did not restart (clean the environment) when you ran a script (module). Today, however, this is the case. But for prototyping I would like the environment (assigned variables, imported modules, functions, ...) to survive running different modules (files). Example: I am working on a function, let's call it f7(), that requires a certain environment. The environment is built in another script (file), say, env1.py. After env1.py has been run, I can built on all

Why does returning in Interactive Python print to sys.stdout?

百般思念 提交于 2019-12-19 10:46:00
问题 I ran into something different today. Consider this simple function: def hi(): return 'hi' If I call it in a Python shell, >>> hi() 'hi' >>> print hi() hi It prints out the 'returned' value, even if it's just the repr . This felt odd to me, how could returning be printing to stdout? So I changed it to a script to be run: def hi(): return 'hi' hi() I ran this from terminal: Last login: Mon Jun 1 23:21:25 on ttys000 imac:~ zinedine$ cd documents imac:documents zinedine$ python hello.py imac

Programming in Python: Getting “name 'Tk' is not defined” only at Command Prompt, works in IDLE

*爱你&永不变心* 提交于 2019-12-19 08:52:46
问题 A question from a beginner just starting with Tkinter. I downloaded it and wrote the tutorial Hello World program, and it ran fine in IDLE. However, when I saved the program and ran it using command prompt, they all returned NameError: name 'tk' is not defined. I also tried going to the main Python command program and manually entering the code, and it worked fine. It only fails to recognize Tk() when run through command prompt or through double clicking. I have no idea what could be going on

starting Python IDLE from command line to edit scripts

让人想犯罪 __ 提交于 2019-12-19 06:15:11
问题 I've tried many variations of this command: idle.py -e filepath , but it simply starts IDLE like normal, not opening any extra windows for editing, and not throwing any errors. So how can I do the equivalent of opening IDLE, file>open>filepath via the command line (or perhaps even a Python module)? 回答1: Make a new text file, and put something like this in it: C:\Python26\Lib\idlelib\idle.pyw "C:\file1.py" "C:\file2.py" In your actual script, you'll replace "C:\file1.py" and "C:\file2.py" with

Python IDLE won´t start

会有一股神秘感。 提交于 2019-12-19 04:12:18
问题 I´m a noob in python and about a week ago IDLE stop working, I have readed some other people questions about this, but none of them had the same error that I´m getting, which is: Traceback (most recent call last): File "c:\python26\Lib\idlelib\idle.py", line 21, in <module> idlelib.Pyshell.main() File "C:\python26\Lib\idlelib\PyShll.py", line 1386, in main root = Tk(className="Idle") File "C:\python26\Lib\lib-tk\Tkinter.py", line 1643, in __init__ self.tk = _tkinter.creat(screenName, baseName