python-curses


Print to shell Python in curses


I found a question whose title is "Print to standard console in curses". Here describes a solution with an object that replaces the sys.stdout to print to standard console after close the curse screen. I tested this solution and works correctly but I would like to know how could i print something to a python shell?.
the programming code is the following
class stdoutwrapper:
text=""
def write(self,txt):
self.text +=txt
self.text='\n'.join(self.text.split('\n')[-30:])
def get_text(self,beg,end):
return '\n'.join(self.text.split('\n')[beg:end])
if __name__=="__main__":
mystdout=stdoutwrapper()
sys.stdout=mystdout
sys.stderr=mystdout
print "bienvenido"
...........
..........
..........
...........
# Main program
processmenu(menu_data)
curses.endwin() #VITAL! This closes out the menu system and returns you to the bash prompt.
os.system('clear')
sys.stdout=sys.__stdout__
sys.stderr=sys.__stderr__
sys.stdout.write(mystdout.get_text(0,30))
After exit from curse screen, the out in standard console is:
bienvenido
c:\users\casalino>
Not sure that I completely understand your question.
If you want to print text in curses program - you should use something like that:
screen = curses.initscr()
screen.noecho()
screen.addstr(y=5, x=5, "My_string")
self.screen.refresh()
For example here is my curses dummy "screensaver".
Python curses tutorial.
If you want to print some debug values then it's better to use logger module and log to file.
Good luck!

Related Links

Passing values between forms with npyscreen
Print to shell Python in curses

Categories

HOME
rust
openshift
cucumber
yahoo-weather-api
compilation
loopbackjs
odata
openflow
flurry
linker
bittorrent
locationmanager
watch-os-3
vimeo
cname
powermock
global-variables
supervisord
uima
android-contacts
spam
infrared
cmake-gui
rxjs5
pubxml
window-managers
hdmi
miniprofiler
bobo-browse.net
fusion
fotorama
plantuml
osx-lion
express-session
assertions
bluemixtools
djcelery
installanywhere
elastica
gitolite
spring-restcontroller
microkernel
right-click
kitura
liteide
cyanogenmod
sharpdx
node-apn
webvtt
http-basic-authentication
glimpse
email-forwarding
dex
finder
xcode6.4
s-function
clp
ftp-client
spring-mongo
jemdoc
teensy
helm
asp.net-web-api-helppages
wlanapi
postal-code
fantom
algebraixlib
relational-model
explain
componentart
adwords-apiv201402
squeezebox
network-printers
assetic
notifyjs
objective-c-runtime
sunstudio
jquery-lazyload
jquery-cycle
ntlmv2
instance-variables
word-frequency
zend-server-ce
servercontrol
vows
play2-mini
tablet-pc
ios-4.2
ninject-interception
icicles
android-input-method
rational-unified-process
powergui
motif
activex-exe
jvm-bytecode

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App