本文整理汇总了Python中WConio.textattr方法的典型用法代码示例。如果您正苦于以下问题:Python WConio.textattr方法的具体用法?Python WConio.textattr怎么用?Python WConio.textattr使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WConio
的用法示例。
在下文中一共展示了WConio.textattr方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: display_once
# 需要导入模块: import WConio [as 别名]
# 或者: from WConio import textattr [as 别名]
def display_once(firmware_version):
"""Display static information, call once."""
WConio.textattr(0x70)
WConio.clrscr()
# Display Firmware Version or Firmware Status.
WConio.gotoxy(2, 0)
if firmware_version < 1.0:
WConio.textattr(0xc0)
WConio.cputs(' Firmware Unreliable! ')
else:
WConio.textattr(0xa0)
WConio.cputs(' Firmware Version %2.2f '%firmware_version)
# Display servo static labels.
WConio.gotoxy(0, 2)
WConio.textattr(0x70)
WConio.cputs(' S# Acc #Q Cyc Speed Pos mS\n')
for i in range(1, 17):
WConio.cputs(' %2i\n'%i)
# Display analog channel labels.
WConio.gotoxy(0, 20)
WConio.textattr(0x70)
WConio.cputs (' C# Voltage C# Voltage')
for i in range(1, 5):
WConio.cputs('\n %i %i'%
(i, i+4))
示例2: robust_write
# 需要导入模块: import WConio [as 别名]
# 或者: from WConio import textattr [as 别名]
def robust_write(self, command = ''):
"""Write to the RCS with robust exception handling."""
try:
self.write(command)
except DisconnectError:
global servo_mode
servo_mode = IDLE
# Blank screen due to device disconnect.
WConio.textattr(0xb0)
WConio.clrscr()
WConio.gotoxy(10, 10)
WConio.cputs('USB-RCS has been disconnected during write. '
'Trying to reconnect. ')
self.robust_reconnect()
usb = rcs.robust_read('U')
firmware_version = usb[2]
display_once(firmware_version)
except Exception, e:
WConio.textattr(0xc0)
WConio.clrscr()
WConio.gotoxy(0, 10)
print "Unexpected exception in robust_write: ", type(e)
print
print e
print
raw_input("Press enter to exit ->")
exit()
示例3: log_color
# 需要导入模块: import WConio [as 别名]
# 或者: from WConio import textattr [as 别名]
def log_color( fg_color, text ):
"""
Store current attribute settings
"""
old_setting = WConio.gettextinfo()[4] & 0x00FF
WConio.textattr( COLOR_ID[ fg_color ] )
print text
WConio.textattr( old_setting )
示例4: restore
# 需要导入模块: import WConio [as 别名]
# 或者: from WConio import textattr [as 别名]
def restore():
'''
Keep the terminal usable.
Always performed on exit.
'''
W.clreol()
W.textattr(defaultcolor)
W.setcursortype(1)
示例5: _write_color_nt
# 需要导入模块: import WConio [as 别名]
# 或者: from WConio import textattr [as 别名]
def _write_color_nt(fp, text, color):
"""Assumes WConio has been imported at module level."""
oldcolor = WConio.gettextinfo()[4]
oldtextcolor = oldcolor & 0x000F
if ";" in color:
color = color.split(";", 1)[1]
WConio.textcolor(WConioColor.get(color, oldtextcolor))
fp.write(text)
WConio.textattr(oldcolor)
示例6: __drawHUD
# 需要导入模块: import WConio [as 别名]
# 或者: from WConio import textattr [as 别名]
def __drawHUD(self):
WConio.textattr(self.__HUDColor)
WConio.gotoxy(self.__size[0]+4,1)
print "--------HUD--------"
WConio.gotoxy(self.__size[0]+4,3)
print " Player Health:", self.__worldInfo.player.health
WConio.gotoxy(self.__size[0]+4,4)
print " Kills:", self.__kills
WConio.gotoxy(self.__size[0]+4,5)
print " Turns:", self.__turns
示例7: display_update
# 需要导入模块: import WConio [as 别名]
# 或者: from WConio import textattr [as 别名]
def display_update():
"""Display changing information, call repeatedly."""
# Display the Disable Input Status.
WConio.gotoxy(28, 0)
if disabled:
WConio.textattr(0xc0)
WConio.cputs(' Enable Input Open -- All Servos Are Held Idle ')
else:
WConio.textattr(0xa0)
WConio.cputs('Enable Input Shorted -- Servo Positioning Permitted')
# Display the servo command mode.
WConio.gotoxy(28, 2)
WConio.textattr(0x70)
if command_mode is INIT:
WConio.cputs('Servos held initialized: AnyKey to run, Q to quit.')
elif command_mode is RUN:
WConio.cputs('Servos allowed to run: AnyKey to brake, Q to quit.')
elif command_mode is BRAKE:
WConio.cputs('Servos braking: AnyKey to idle servos, Q to quit.')
elif command_mode is IDLE:
WConio.cputs('Servos held idle: AnyKey to initialize, Q to quit.')
else:
WConio.cputs('Error: Unrecognized command mode!!! Q to quit.')
# Display servo cycle, speed, position in mS and position bar graph.
for i, each_servo in enumerate(all_servos):
WConio.gotoxy(4, 3 + i)
WConio.textattr(0x70)
# Cyc..Spd..Pos mS
if accel_dif:
accel = accel_list[i]
else:
accel = 1
WConio.cputs('%3i %2i %3i %5i %01.4f'
%(accel, each_servo[3], each_servo[2], each_servo[1],
each_servo[0]/12000.0))
color = 0x2b if i % 2 else 0x2a #2a is green, 9b is blue
display_bar(28, 3 + i, color,
float(each_servo[0] - SERVO_MIN) / SERVO_RANGE, 51)
# Display analog measurement values.
for i, each_channel in enumerate(analog_channels):
color = 0x3b if i % 2 else 0x3a #a is green, b is blue
volts = each_channel * 5.0 / ANALOG_MAX
if i < 4:
xoffset = 0
yoffset = i
else:
xoffset = 40
yoffset = i-4
WConio.gotoxy(5 + xoffset, 21 + yoffset)
WConio.textattr(0x70)
WConio.cputs('%01.4fv'%volts)
display_bar(13 + xoffset, 21 + yoffset, color, volts/5.0, 26)
示例8: display_bar
# 需要导入模块: import WConio [as 别名]
# 或者: from WConio import textattr [as 别名]
def display_bar(xcol, yrow, color, division, width):
"""Display a bar of 'color' and 'width', with two sections at 'division'."""
full_cells, cell_frac = divmod(int(width * division * 3), 3)
if division < 0:
display_string = SPACE * width
elif full_cells == width:
display_string = FULL_BAR * width
elif cell_frac == 0:
display_string = FULL_BAR * full_cells + SPACE * (width - full_cells)
elif cell_frac == 1:
display_string = FULL_BAR * full_cells + HALF_BAR + SPACE * (width - full_cells - 1)
else:
display_string = FULL_BAR * (full_cells + 1) + SPACE * (width - full_cells - 1)
WConio.gotoxy(xcol, yrow)
WConio.textattr(color)
WConio.cputs(display_string)
示例9: emit
# 需要导入模块: import WConio [as 别名]
# 或者: from WConio import textattr [as 别名]
def emit(self, record):
WConio = self.WConio
try:
msg = self.format(record)
levelname = record.levelname
out = sys.__stdout__ # in case redirected by filelogger, etc
if levelname in msg:
part1, part2 = msg.split(levelname, 1)
out.write(part1)
out.flush()
saved_color = WConio.gettextinfo()[4]
WConio.textattr( self.colormap.get(levelname,
WConio.LIGHTGREY) )
if levelname == 'CRITICAL': WConio.textbackground(WConio.RED)
WConio.cputs(levelname)
WConio.textattr(saved_color) # restore
print >> out, part2
else:
print >> out, msg
out.flush()
except:
self.handleError(record)
示例10: robust_read
# 需要导入模块: import WConio [as 别名]
# 或者: from WConio import textattr [as 别名]
def robust_read(self, command = None, count = 1):
"""Read from the RCS with robust exception handling."""
global servo_mode
while True:
try:
return self.read(command, count)
except DisconnectError:
servo_mode = IDLE
# Blank screen due to device disconnect.
WConio.textattr(0xb0)
WConio.clrscr()
WConio.gotoxy(10, 10)
WConio.cputs('USB-RCS has been disconnected during read. '
'Trying to reconnect. ')
self.robust_reconnect()
usb = rcs.robust_read('U')
firmware_version = usb[2]
display_once(firmware_version)
except ReadTimeoutError, e:
servo_mode = IDLE
# Blank screen due to device disconnect.
WConio.textattr(0xc0)
WConio.clrscr()
WConio.gotoxy(10, 10)
WConio.cputs('USB-RCS read timeout: '
'Communications is not responding as expected.')
WConio.gotoxy(10, 12)
raw_input("Unplug the USB-RCS.")
while self.status() != DISCONNECTED:
time.sleep(0.500)
WConio.gotoxy(10, 12)
WConio.cputs("Now, plug-in the USB-RCS.")
self.robust_reconnect()
usb = rcs.robust_read('U')
firmware_version = usb[2]
display_once(firmware_version)
except Exception, e:
WConio.textattr(0xc0)
WConio.clrscr()
WConio.gotoxy(0, 10)
print "Unexpected exception in robust_read: ", type(e)
print e
raw_input("Press enter to exit ->")
exit()
示例11: window_color_out
# 需要导入模块: import WConio [as 别名]
# 或者: from WConio import textattr [as 别名]
def window_color_out(self, c, txt):
WConio.textattr(c)
print txt
示例12: MonitorDispatcher
# 需要导入模块: import WConio [as 别名]
# 或者: from WConio import textattr [as 别名]
# -*- coding: utf-8 -*-
import sys, os
import string
from wm import WorkUnit
from wm_def import *
from wm_utils import *
import time
import datetime
from pinyin import Hanzi2Pinyin
import alert_thd
if os.name == 'nt':
import WConio
WConio.textattr(WConio.CYAN)
elif os.name == 'posix':
from termcolor import colored
cont_type_stock = 's'
cont_type_history = 'h'
cont_type_exit = 'x'
cont_type_show_k_daily = 'kd'
cont_type_show_k_min = 'km'
cont_type_show_verbose = 'vb'
cont_types = {cont_type_show_k_daily:'show_k_daily', cont_type_show_k_min:"show_k_minute", cont_type_stock:'stock', cont_type_history:'history', cont_type_show_verbose:'verbose', cont_type_exit:'exit'}
class MonitorDispatcher(WorkUnit):
def __init__(self):
WorkUnit.__init__(self)
示例13:
# 需要导入模块: import WConio [as 别名]
# 或者: from WConio import textattr [as 别名]
logger.addHandler(hdlr)
logger.setLevel(logging.DEBUG)
import sys
import os
if 'nt' not in os.name:
import XConio
import curses
import game
game.start = curses.wrapper(game.start)
import WConio as W
defaultcolor = W.gettextinfo()[4]
import game
try:
game.start()
except game.GameShutdown:
W.textmode()
pass
except KeyboardInterrupt:
W.textmode()
raise
except:
raise
finally:
logger.debug("Shutting down")
logging.shutdown()
W.clreol()
W.textattr(defaultcolor)
W.setcursortype(1)
示例14:
# 需要导入模块: import WConio [as 别名]
# 或者: from WConio import textattr [as 别名]
WConio.clrscr()
#Display something in low video
WConio.lowvideo()
WConio.cputs("Low video\r\n")
#Display something in high video
WConio.highvideo()
WConio.cputs("High video\r\n")
#Display something in normal video
WConio.normvideo()
WConio.cputs("Normal video\r\n")
#Display some text in color
WConio.textattr(WConio.LIGHTRED)
WConio.cputs("Light Red text\r\n")
#Display some more text in color
WConio.textattr(WConio.LIGHTBLUE)
WConio.cputs("Light BLUE text\r\n")
#leave a blank line - this shows you that print still works
print
#Set heading colour but using print
WConio.textattr(WConio.LIGHTGREEN)
print("Times table\r\n")
#Back to normal intensity for white
WConio.normvideo()
示例15: type
# 需要导入模块: import WConio [as 别名]
# 或者: from WConio import textattr [as 别名]
recon_count)
except Exception, e:
WConio.gotoxy(5, 16)
print "Unexpected exception during reconnect:", type(e)
print e
raw_input("Press enter to exit ->")
exit()
else:
return
########## Main Routine ##########
if __name__=='__main__':
try:
WConio.settitle("TestRCS -- Test the RC Servo Controller")
# Initial Page, Select and Open the Serial Port
WConio.textattr(0x07)
WConio.setcursortype(2)
rcs = get_rcs() # select a port and open the rcs
WConio.setcursortype(0)
WConio.cputs("\nCommunications port is open!\n")
time.sleep(0.5)
# disable servos, configure analog, read: USB report, servo status, analog
usb, all_servos, analog_channels = rcs.robust_read('CA0USM', 3)
firmware_version = usb[2]
disabled = (all_servos[-1][-1] == -1)
# Servo and Analog Display Page
servo_mode = IDLE # Set up variables for running servos
command_mode = INIT
accel_dif = False
accel_list = [1, 2, 3, 4, 6, 8, 12, 16, 24, 32, 48, 64, 96, 128, 192, 255]