本文整理汇总了Python中urwid.set_encoding函数的典型用法代码示例。如果您正苦于以下问题:Python set_encoding函数的具体用法?Python set_encoding怎么用?Python set_encoding使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了set_encoding函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run
def run(self, initial_scene):
logger.info('Director starting up.')
self.push(initial_scene)
self._set_scene()
screen = self.screen = urwid.raw_display.Screen()
screen.set_terminal_properties(colors=256)
urwid.set_encoding("UTF-8")
def unhandled(key):
# logger.debug('Received key sequence: %s', key)
signals.keyboard.send(key=key)
# FIXME: This shouldn't be hard-coded here. Rely on scene popping.
if key in 'qQxX' or key == 'esc':
logger.info('Director quitting.')
raise urwid.ExitMainLoop()
self.loop = urwid.MainLoop(
self.scene.main_frame, list(palette.entries), screen,
unhandled_input=unhandled)
self.iterator = iter(self)
self.loop.set_alarm_in(0, self.schedule_agent)
self.loop.run()
示例2: run
def run(self):
size = self.ui.get_cols_rows()
urwid.set_encoding("utf-8")
self.body.set_focus(1)
while 1:
self.body.set_focus(1)
canvas = self.body.render(size, focus=True)
self.ui.draw_screen( size, canvas )
keys = None
while not keys:
keys = self.ui.get_input()
for k in keys:
if k == 'window resize':
size = self.ui.get_cols_rows()
canvas = self.body.render(size, focus=True)
self.ui.draw_screen( size, canvas )
elif k == 'esc':
self.do_quit()
elif k == 'enter':
self.commitText()
elif ("up" in k) or ("down" in k):
self.body.set_focus(0)
else:
self.body.set_focus(1)
#self.text_edit_area.keypress((1,), k)
self.updatePrompt()
self.body.keypress(size, k)
self.body.set_focus(1)
d_keys = self._cheap_queue.keys() #not smart to iterate a dict and delete elements on the process
for cheap_thread_key in d_keys:
if not self._cheap_queue[cheap_thread_key].isAlive():
self._cheap_queue[cheap_thread_key].join()
del(self._cheap_queue[cheap_thread_key])
示例3: __init__
def __init__(self, path, application, with_menu=True):
super(UrwidWindow, self).__init__(path, application)
urwid.set_encoding("utf8")
self._builder = UrwidUIBuilder(self.application)
self.with_menu = with_menu
self.logger.debug("Creating urwid tui for '%s'" % application)
self.logger.debug("Detected encoding: %s" % urwid.get_encoding_mode())
示例4: sbgtest
def sbgtest(self, desc, data, top, exp ):
urwid.set_encoding('utf-8')
g = urwid.BarGraph( ['black','red','blue'],
None, {(1,0):'red/black', (2,1):'blue/red'})
g.set_data( data, top )
rval = g.calculate_display((5,3))
assert rval == exp, "%s expected %r, got %r"%(desc,exp,rval)
示例5: test_utf8_input
def test_utf8_input(self):
urwid.set_encoding("utf-8")
self.t1.set_edit_text('')
self.t1.keypress((12,), u'û')
self.assertEqual(self.t1.edit_text, u'û'.encode('utf-8'))
self.t4.keypress((12,), u'û')
self.assertEqual(self.t4.edit_text, u'û')
示例6: render
def render(self):
urwid.set_encoding("UTF-8")
self.registerSignals()
workspace_menu = ui.WorkspaceMenu(self.myWorkspaces())
urwid.connect_signal(workspace_menu, 'click', self.showProjectList)
self.frame = urwid.Pile([
('pack', urwid.AttrMap(workspace_menu, 'workspace')),
None
])
if self.state['view'] == 'workspace':
self.showProjectList(self.state['id'])
elif self.state['view'] == 'project':
self.showProject(self.state['id'])
elif self.state['view'] == 'atm':
self.showMyTasks(self.state['id'])
elif self.state['view'] == 'details':
self.showDetails(self.state['id'])
else:
raise KeyError
self.loop = urwid.MainLoop(self.frame,
unhandled_input=self.handleInput,
palette=ui.palette
)
self.loop.run()
示例7: main
def main():
"""
Launch ``turses``.
"""
set_title(__name__)
set_encoding('utf8')
args = parse_arguments()
# check if stdout has to be restored after program exit
if any([args.debug,
args.offline,
getattr(args, 'help', False),
getattr(args, 'version', False)]):
# we are going to print information to stdout
save_and_restore_stdout = False
else:
save_and_restore_stdout = True
if save_and_restore_stdout:
save_stdout()
# load configuration
configuration = Configuration(args)
configuration.load()
# start logger
logging.basicConfig(filename=LOG_FILE,
level=configuration.logging_level)
# create view
curses_interface = CursesInterface(configuration)
# select API backend
if args.offline:
api_backend = MockApi
else:
api_backend = TweepyApi
# create controller
turses = Turses(configuration=configuration,
ui=curses_interface,
api_backend=api_backend)
try:
turses.start()
except KeyboardInterrupt:
pass
except:
# open the debugger
if args.debug or args.offline:
import pdb
pdb.post_mortem()
finally:
if save_and_restore_stdout:
restore_stdout()
restore_title()
exit(0)
示例8: __init__
def __init__(self):
super(GUIScreen, self).__init__()
urwid.set_encoding('utf8')
self.root = None
self.size = (180, 60)
self.title = "Taurus Status"
self.text = None
self.font = None
示例9: main
def main(self):
urwid.set_encoding("UTF-8")
self.StartMenu = urwid.Padding(self.firstMenu(self.firstMenuChoices), left=5, right=5)
top = urwid.Overlay(self.StartMenu, urwid.SolidFill(u'\N{MEDIUM SHADE}'),
align='center', width=('relative', 60),
valign='middle', height=('relative', 60),
min_width=20, min_height=9)
urwid.MainLoop(top, self.palette).run()
示例10: main
def main():
"""
Launch ``turses``.
"""
set_title(__name__)
set_encoding('utf8')
args = read_arguments()
# check if stdout has to be restored after program exit
if any([args.debug,
args.offline,
getattr(args, 'help', False),
getattr(args, 'version', False)]):
# we are going to print information to stdout
save_and_restore_stdout = False
else:
save_and_restore_stdout = True
if save_and_restore_stdout:
save_stdout()
# parse arguments and load configuration
configuration.parse_args(args)
configuration.load()
# start logger
logging.basicConfig(filename=LOG_FILE,
level=configuration.logging_level)
# create view
curses_interface = CursesInterface()
# create model
timeline_list = TimelineList()
# create API
api = create_async_api(MockApi if args.offline else TweepyApi)
# create controller
turses = Turses(ui=curses_interface,
api=api,
timelines=timeline_list,)
try:
turses.start()
except:
# A unexpected exception occurred, open the debugger in debug mode
if args.debug or args.offline:
import pdb
pdb.post_mortem()
finally:
if save_and_restore_stdout:
restore_stdout()
restore_title()
exit(0)
示例11: test
def test(self):
urwid.set_encoding("euc-jp")
self.assertRaises(text_layout.CanNotDisplayText,
text_layout.default_layout.calculate_text_segments,
B('\xA1\xA1'), 1, 'space' )
urwid.set_encoding("utf-8")
self.assertRaises(text_layout.CanNotDisplayText,
text_layout.default_layout.calculate_text_segments,
B('\xe9\xa2\x96'), 1, 'space' )
示例12: run
def run(self):
self.make_screen()
urwid.set_encoding("utf-8")
self.set_keys()
try:
self.loop.run()
except KeyboardInterrupt:
print "Keyboard interrupt received, quitting gracefully"
raise urwid.ExitMainLoop
示例13: run
def run(self):
self.make_screen()
urwid.set_encoding('utf-8')
urwid.connect_signal(self.walker, 'modified', self.update_footer)
self.set_keys()
try:
self.loop.run()
except KeyboardInterrupt:
print "Keyboard interrupt received, quitting gracefully"
raise urwid.ExitMainLoop
示例14: main
def main():
"""
Launch ``turses``.
"""
set_title(__name__)
set_encoding('utf8')
args = parse_arguments()
# stdout
if any([args.debug,
args.offline,
getattr(args, 'help', False),
getattr(args, 'version', False)]):
# we are going to print information to stdout
save_and_restore_stdout = False
else:
save_and_restore_stdout = True
if save_and_restore_stdout:
save_stdout()
# configuration
configuration = Configuration(args)
configuration.load()
# view
curses_interface = CursesInterface(configuration)
# API
if args.offline:
api_backend = MockApi
else:
api_backend = TweepyApi
# controller
turses = Turses(configuration=configuration,
ui=curses_interface,
api_backend=api_backend)
try:
turses.start()
except KeyboardInterrupt:
pass
except:
if args.debug or args.offline:
import pdb
pdb.post_mortem()
finally:
if save_and_restore_stdout:
restore_stdout()
restore_title()
exit(0)
示例15: test3
def test3(self):
urwid.set_encoding("euc-jp")
self.cotest("db0","\xA1\xA1\xA1\xA1\xA1\xA1",[],"HI",[],2,2,
[[(None,None,B("\xA1\xA1")),(None,None,B("HI")),
(None,None,B("\xA1\xA1"))]])
self.cotest("db1","\xA1\xA1\xA1\xA1\xA1\xA1",[],"OHI",[],1,2,
[[(None,None,B(" ")),(None,None,B("OHI")),
(None,None,B("\xA1\xA1"))]])
self.cotest("db2","\xA1\xA1\xA1\xA1\xA1\xA1",[],"OHI",[],2,1,
[[(None,None,B("\xA1\xA1")),(None,None,B("OHI")),
(None,None,B(" "))]])
self.cotest("db3","\xA1\xA1\xA1\xA1\xA1\xA1",[],"OHIO",[],1,1,
[[(None,None,B(" ")),(None,None,B("OHIO")),(None,None,B(" "))]])