当前位置: 首页>>代码示例>>Python>>正文


Python urwid.set_encoding函数代码示例

本文整理汇总了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()
开发者ID:eykd,项目名称:orphan,代码行数:25,代码来源:controllers.py

示例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])
开发者ID:aseba,项目名称:TNT,代码行数:34,代码来源:tnt_urwid.py

示例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())
开发者ID:Zealsathish,项目名称:ovirt-node,代码行数:7,代码来源:urwid_builder.py

示例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)
开发者ID:Janteby1,项目名称:bloggy,代码行数:7,代码来源:test_graphics.py

示例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'û')
开发者ID:andy-z,项目名称:urwid,代码行数:7,代码来源:test_widget.py

示例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()
开发者ID:aarongut,项目名称:cmdasana,代码行数:27,代码来源:cmdasana.py

示例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)
开发者ID:1reza,项目名称:turses,代码行数:59,代码来源:cli.py

示例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
开发者ID:Yingmin-Li,项目名称:taurus,代码行数:8,代码来源:screen.py

示例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()
开发者ID:smilart,项目名称:smilart.os.distribution,代码行数:8,代码来源:smilartos-install.py

示例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)
开发者ID:Erik-k,项目名称:turses,代码行数:58,代码来源:cli.py

示例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' )
开发者ID:0x15,项目名称:urwid,代码行数:9,代码来源:test_text_layout.py

示例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
开发者ID:gefei,项目名称:bbcli,代码行数:9,代码来源:core.py

示例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
开发者ID:danclaudiupop,项目名称:pyhackernews,代码行数:10,代码来源:core.py

示例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)
开发者ID:tazjel,项目名称:turses,代码行数:54,代码来源:cli.py

示例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(" "))]])
开发者ID:0x15,项目名称:urwid,代码行数:13,代码来源:test_canvas.py


注:本文中的urwid.set_encoding函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。