473,584 Members | 2,883 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Clearing the screen

Hi i use IDLE to code Python in my machine. What i haven't been able
to do is call an in-built function called clear()/cls()/clr() because
it mightn't exist. so what i did is coded my own function called cls()
as such
def cls():

for i in range(1,40):
print " ";

now that does the job very nicely and i get cleared screen but what i
really want to achieve it everytime i start IDLE, without importing
any module, i want to be able to do just cls() and be able to clear
the screen. Is that achievable? Does that have mean i have to tinker a
bit with in-builts??

Thank you.

--
cheers,
Ishwor Gurung
Jul 18 '05 #1
4 4253
Hi Iswor,

If I understand you correctly then your program is writing output to a
console/terminal window and you want to clear that window.
I don't know of any library methods for that, but you might just do:

os.system("cls" ) #for windows
or
os.system("clea r") #for unix
Not the most advanced solution though.
---
Happy holidays!
~Lars

Jul 18 '05 #2
On 24 Dec 2004 15:33:26 -0800, Lars <la******@lycos .com> wrote:
Hi Iswor,

If I understand you correctly then your program is writing output to a
console/terminal window and you want to clear that window.
I don't know of any library methods for that, but you might just do:
well i am not doing any console i/o. Just simple one. i am trying to
clear the IDLE (one of python IDE distributed with the original
distribution) screen which is pretty easy but having to do
import cls
cls() everytime is boring (2 lines of boredom!!) so what i want is to be
able to do justcls()

and nothing more or even less!! ;-)

os.system("cls" ) #for windows
or
os.system("clea r") #for unix yeah i have used the 'os' module's system() method but that wasn't what i meant.
Not the most advanced solution though.

;-) Thanx anyway mate.

[snip]
--
cheers,
Ishwor Gurung
Jul 18 '05 #3
On Sat, 2004-12-25 at 07:43, Ishwor wrote:
On 24 Dec 2004 15:33:26 -0800, Lars <la******@lycos .com> wrote:
Hi Iswor,

If I understand you correctly then your program is writing output to a
console/terminal window and you want to clear that window.
I don't know of any library methods for that, but you might just do:
well i am not doing any console i/o. Just simple one. i am trying to
clear the IDLE (one of python IDE distributed with the original
distribution) screen which is pretty easy but having to do

import cls
cls() everytime is boring (2 lines of boredom!!) so what i want is to be
able to do just cls()

and nothing more or even less!! ;-)


Assuming cls.cls() does the job for you, just add 'from cls import cls'
to your pythonrc ( ${HOME}/.pythonrc on UNIX , NFI on windows ).

On a side note, it'd be easier to read your post if you'd use the shift
key more often :-P

--
Craig Ringer

Jul 18 '05 #4
In the darkest hour on Sat, 25 Dec 2004 09:41:54 +1030,
Ishwor <is***********@ gmail.com> screamed:
def cls():

for i in range(1,40):
print " ";


Slightly ot, but perhaps this'll work for you:

def cls():
print "\033[2J"
--
[ Artur M. Piwko : Pipen : AMP29-RIPE : RLU:100918 : From == Trap! : SIG:217B ]
[ 22:06:17 user up 10478 days, 10:01, 1 user, load average: 0.06, 0.06, 0.06 ]

Even God cannot change the past.
Jul 18 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
9663
by: Miki Tebeka | last post by:
Hello All, I'd like to bind <CTRL+L> so that it will clear IDLE's screen (in the interactive prompt). Any pointers/suggetions? Thanks. Miki
2
2879
by: Robin | last post by:
Ok, I have a form that on clicking of the Update button first updates the specific record in the db, then Inserts if the vMemo field is not empty. The problem that I'm having is that After updating if you hit the key (refresh) it inserts another record ... I have tried: 1. Clearing the vMemo field after the insert is done (vMemo = "") 2. ...
0
1899
by: Gary | last post by:
I have a problem with the datagrid not clearing when the datasource changes, a few fields remain on the screen and even when new data would fill those grid squares the old data remains. I wind up with 101 Another field
1
2006
by: raghavendra | last post by:
Hi, i am facing problem clearing screen in console application. As, in C++ we have clrscr(); Is? their any similar type of function is avaliable.. Raghavendra...
1
1329
by: asdf | last post by:
I just started my first project where i draw lines and strings on the screen. I sucessfully drew what i needed on the screen, then realized that when it updated it just drew over the same area w/o clearing the first instance of text and lines. How can i clear it? Below is my code, basically it is a thermometer and my program is drawing a...
2
1980
by: Slack | last post by:
I wish to write a console text editor. Can anyone tell me how to capture the screen like Vi or Pico does? Also, I wish to draw "tabs" on the screen, is there a standard way to draw so that my code is crossplatform and will compile on most platforms? Thanks, -Jason
10
564
by: mwt | last post by:
I'm doing some python programming for a linux terminal (just learning). When I want to completely redraw the screen, I've been using os.system("clear") This command works when using python in terminal mode, and in IDLE. However, when running a little .py file containing that command, the screen doesn't clear. What to do?
65
8568
by: Leslie Kis-Adam | last post by:
Hi everyone! Does anyone know, if it is possible to clear the screen in ANSI C? If it is,then how? Any help would be appreciated. Laszlo Kis-Adam <dfighter_AT-NOSPAM_freemail.hu
0
7897
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7829
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
1
7940
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8198
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6587
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5379
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
1
2336
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1438
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1162
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.