• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python urwid.set_encoding函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中urwid.set_encoding函数的典型用法代码示例。如果您正苦于以下问题:Python set_encoding函数的具体用法?Python set_encoding怎么用?Python set_encoding使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了set_encoding函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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


示例16: main

def main():
    try:
        set_encoding('utf8')

        args = parse_arguments()
        configuration = Configuration(args)
        configuration.load()
        ui = CursesInterface(configuration)

        # start `turses`
        CursesController(configuration=configuration, 
                         ui=ui,
                         api_backend=TweepyApi)
    except KeyboardInterrupt:
        exit(0)
开发者ID:codelurker,项目名称:turses,代码行数:15,代码来源:cli.py


示例17: _check_encoding

def _check_encoding():
    """Set the Urwid global byte encoding to utf-8.

    Exit the application if, for some reasons, the change does not have effect.
    """
    urwid.set_encoding('utf-8')
    if not urwid.supports_unicode():
        # Note: the following message must only include ASCII characters.
        msg = (
            'Error: your terminal does not seem to support UTF-8 encoding.\n'
            'Please check your locale settings.\n'
            'On Ubuntu, running the following might fix the problem:\n'
            '  sudo locale-gen en_US.UTF-8\n'
            '  sudo dpkg-reconfigure locales'
        )
        sys.exit(msg.encode('ascii'))
开发者ID:pmondal08,项目名称:openstack-installer,代码行数:16,代码来源:gui.py


示例18: main

def main():
    """ Main function. """
    global ui, dlogger
    # We are not python.
    misc.RenameProcess("wicd-curses")

    ui = urwid.raw_display.Screen()

    # if options.debug:
    #    dlogger = logging.getLogger("Debug")
    #    dlogger.setLevel(logging.DEBUG)
    #    dlogger.debug("wicd-curses debug logging started")

    # Default Color scheme.
    # Other potential color schemes can be found at:
    # http://excess.org/urwid/wiki/RecommendedPalette

    # Thanks to nanotube on #wicd for helping with this
    ui.register_palette(
        [
            ("body", "default", "default"),
            ("focus", "black", "light gray"),
            ("header", "light blue", "default"),
            ("important", "light red", "default"),
            ("connected", "dark green", "default"),
            ("connected focus", "black", "dark green"),
            ("editcp", "default", "default", "standout"),
            ("editbx", "light gray", "dark blue"),
            ("editfc", "white", "dark blue", "bold"),
            ("editnfc", "brown", "default", "bold"),
            ("tab active", "dark green", "light gray"),
            ("infobar", "light gray", "dark blue"),
            ("listbar", "light blue", "default"),
            # Simple colors around text
            ("green", "dark green", "default"),
            ("blue", "light blue", "default"),
            ("red", "dark red", "default"),
            ("bold", "white", "black", "bold"),
        ]
    )
    # Handle SIGQUIT correctly (otherwise urwid leaves the terminal in a bad state)
    signal.signal(signal.SIGQUIT, handle_sigquit)
    # This is a wrapper around a function that calls another a function that
    # is a wrapper around a infinite loop.  Fun.
    urwid.set_encoding("utf8")
    ui.run_wrapper(run)
开发者ID:M157q,项目名称:wicd,代码行数:46,代码来源:wicd-curses.py


示例19: main

    def main(self):
        urwid.set_encoding('UTF-8')

        self.listbox = ViListBox(self.key_bindings, urwid.SimpleListWalker([]))
        self.refresh()
        self.header = self.create_header()
        self.footer = self.create_footer()

        self.frame = urwid.Frame(urwid.AttrMap(self.listbox, 'plain'), header=self.header, footer=self.footer)

        self.view = ViColumns(self.key_bindings, [
            ('weight', 2, self.frame)
        ])

        self.loop = urwid.MainLoop(self.view, self.palette, unhandled_input=self.keystroke)
        self.loop.screen.set_terminal_properties(colors=256)
        self.loop.run()
开发者ID:kespindler,项目名称:todotxt-machine,代码行数:17,代码来源:main.py


示例20: buildUI

	def buildUI(self):
		urwid.set_encoding("UTF-8")

		palette = [('title', 'white,bold', 'black'),('stats', 'white', 'white')]
		palette.extend((name, 'white', style) for name, style in TUI.COLORS)

		header = urwid.AttrMap(urwid.Text('Swap', align='center'), 'title')

		leftGrid = urwid.Text('')
		leftCont = urwid.LineBox(urwid.Filler(leftGrid, 'top'))

		rightGrid = urwid.Text('')
		rightCont = urwid.LineBox(urwid.Filler(rightGrid, 'top'))

		scoreTitle = urwid.AttrMap(urwid.Text('Score', align='center'), 'title')
		scoreCont = urwid.Filler(scoreTitle, 'top', top=2)
		scoreLabel = urwid.Text('_%s | %s_' % (self.game.players[0].score, self.game.players[1].score), align='center')

		multiplierTitle = urwid.AttrMap(urwid.Text('Multiplier', align='center'), 'title')
		multiplierCont = urwid.Filler(multiplierTitle, 'top', top=2)
		multiplierLabel = urwid.Text('%s | %s' % (self.game.players[0].scoreMultiplier, self.game.players[1].scoreMultiplier), align='center')

		stateTitle = urwid.AttrMap(urwid.Text('State', align='center'), 'title')
		stateCont = urwid.Filler(stateTitle, 'top', top=2)
		stateLabel = urwid.Text('%s\n%s' % (self.game.players[0].stateMachine.vcrepr(), self.game.players[1].stateMachine.vcrepr()), align='left')

		statsPile = urwid.Pile([scoreCont,
			urwid.Filler(urwid.AttrMap(scoreLabel, 'stats'), 'top', top=1),
			multiplierCont,
			urwid.Filler(urwid.AttrMap(multiplierLabel, 'stats'), 'top', top=1),
			stateCont,
			urwid.Filler(urwid.AttrMap(stateLabel, 'stats'), 'top', top=1)
			])

		columns = urwid.Columns([(12*2+2, leftCont), statsPile, (12*2+2, rightCont)])

		frame = urwid.Frame(header=header, body=columns)

		self.leftGrid, self.rightGrid = leftGrid, rightGrid
		self.scoreLabel = scoreLabel
		self.multiplierLabel = multiplierLabel
		self.stateLabel = stateLabel
		self.palette = palette
		self.frame = frame
		self.mainLoop = urwid.MainLoop(frame, palette, unhandled_input=self.handleInput)
开发者ID:ztenma,项目名称:Swap,代码行数:45,代码来源:tui.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python urwid.Edit类代码示例发布时间:2022-05-27
下一篇:
Python urwid.emit_signal函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap