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


Python console.set_color方法代码示例

本文整理汇总了Python中console.set_color方法的典型用法代码示例。如果您正苦于以下问题:Python console.set_color方法的具体用法?Python console.set_color怎么用?Python console.set_color使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在console的用法示例。


在下文中一共展示了console.set_color方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: catch_exceptions

# 需要导入模块: import console [as 别名]
# 或者: from console import set_color [as 别名]
def catch_exceptions(func):
    """Decorator catching all exceptions and printing info to the console.

    Use this decorator for functions handling keyboard shortcuts,
    keyboard events, ... to avoid Pythonista crash.

    Args:
        func: Function to decorate

    Returns:
        Return value of decorated function.
    """
    @functools.wraps(func)
    def new_func(*args, **kwargs):
        try:
            return func(*args, **kwargs)
        except Exception:
            if console:
                console.set_color(1, 0, 0)
            print(traceback.format_exc())
            print('Please, file an issue at {}'.format('https://github.com/zrzka/blackmamba/issues'))
            if console:
                console.set_color()

    return new_func 
开发者ID:zrzka,项目名称:blackmamba,代码行数:27,代码来源:system.py

示例2: print_methods

# 需要导入模块: import console [as 别名]
# 或者: from console import set_color [as 别名]
def print_methods(clsname,print_private=False):
   cls=ObjCClass(clsname)
   console.set_color(1,0,0)
   print clsname
   print 'Class Methods______'
   console.set_color(0,0,0)
   m=get_class_methods(cls)
   print '\n'.join([(k[1]+' ' +k[0]+'( '+', '.join(k[2])+' )') for k in m if not k[0].startswith('_')])
   if print_private:
         print '\n'.join([(k[1]+' ' +k[0]+'( '+', '.join(k[2])+' )') for k in m if k[0].startswith('_')])
   console.set_color(1,0,0)
   print '_______Instance Methods______'
   console.set_color(0,0,0)
   m=get_methods(cls)
   print '\n'.join([(k[1]+'\t' +k[0]+'( '+', '.join(k[2])+' )') for k in m if not k[0].startswith('_')])
   if print_private:
         print '\n'.join([(k[1]+'\t' +k[0]+'( '+', '.join(k[2])+' )') for k in m if k[0].startswith('_')]) 
开发者ID:khilnani,项目名称:pythonista-scripts,代码行数:19,代码来源:print_objc.py

示例3: green

# 需要导入模块: import console [as 别名]
# 或者: from console import set_color [as 别名]
def green():
	console.set_color(0.3,0.7,0) 
开发者ID:RussianOtter,项目名称:networking,代码行数:4,代码来源:krack.py

示例4: yellow

# 需要导入模块: import console [as 别名]
# 或者: from console import set_color [as 别名]
def yellow():
	console.set_color(0.7,0.6,0) 
开发者ID:RussianOtter,项目名称:networking,代码行数:4,代码来源:krack.py

示例5: noc

# 需要导入模块: import console [as 别名]
# 或者: from console import set_color [as 别名]
def noc():
	console.set_color() 
开发者ID:RussianOtter,项目名称:networking,代码行数:4,代码来源:krack.py

示例6: set_color

# 需要导入模块: import console [as 别名]
# 或者: from console import set_color [as 别名]
def set_color(r=False,g=False,b=False,c=False):
			if b:
				sys.stdout.write("\xb1[34m")
			else:
				sys.stdout.write("\xb1[0m") 
开发者ID:RussianOtter,项目名称:elpscrk,代码行数:7,代码来源:elpscrk.py

示例7: terminal

# 需要导入模块: import console [as 别名]
# 或者: from console import set_color [as 别名]
def terminal(text=False,inp=False):
	console.set_color(0.0,0.3,0.8)
	sys.stdout.write("root@elliot:$ ")
	console.set_color()
	if text == False:
		return raw_input()
	else:
		if inp:
			return raw_input(text)
		else:
			print text 
开发者ID:RussianOtter,项目名称:elpscrk,代码行数:13,代码来源:elpscrk.py

示例8: diff

# 需要导入模块: import console [as 别名]
# 或者: from console import set_color [as 别名]
def diff(lhs,rhs):
    if not os.path.isfile(lhs):
        sys.stderr.write('%s not a file\n'%lhs)
        sys.exit(1)
    if os.path.isdir(rhs):
        rhs = '%s/%s'%(rhs,os.path.basename(lhs))
    if not os.path.isfile(rhs):
        sys.stderr.write('%s not a file\n'%rhs)
        sys.exit(1)
        
    flhs = open(lhs).readlines()
    frhs = open(rhs).readlines()
    
    diffs = unified_diff(
        flhs,
        frhs,
        fromfile=lhs,
        tofile=rhs,
        fromfiledate=modified(lhs),
        tofiledate=modified(rhs)
    )
    for line in diffs:
        if line.startswith('+'):
            console.set_color(0,1,0)
        if line.startswith('-'):
            console.set_color(0,0,1)
            sys.stdout.write(line)
        console.set_color(1,1,1)
    return

#_____________________________________________________ 
开发者ID:ywangd,项目名称:stash,代码行数:33,代码来源:diff.py

示例9: _log

# 需要导入模块: import console [as 别名]
# 或者: from console import set_color [as 别名]
def _log(level, *args, **kwargs):
    if _level > level:
        return

    color = _COLORS.get(level, None)
    if console and color:
        console.set_color(*color)

    print(*args, **kwargs)

    if console and color:
        console.set_color() 
开发者ID:zrzka,项目名称:blackmamba,代码行数:14,代码来源:log.py

示例10: spectre

# 需要导入模块: import console [as 别名]
# 或者: from console import set_color [as 别名]
def spectre():
	time.sleep(1)
	console.set_font("Menlo",10)
	console.set_color(0.9,0,0)
	print "\n"
	print logo
	print
	time.sleep(2.5)
	console.set_color()
	console.set_font("Menlo",7)
	pr = pointer(47839215)
	lc = False
	for _ in range(500*2):
		if lc:
			console.set_color()
			lc = False
		if not random.randint(0,35):
			console.set_color(1,0,0)
			lc = True
		o1 = pr.next()+"  "+seg1()+" "+seg2()
		o2 = pr.next()+" "*25+seg2()
		o3 = pr.next()
		print random.choice([o1,o1,o1,o2,o2,o3])
		if lc:
			time.sleep(0.02)
		time.sleep(0.01)
	
	console.set_font("Menlo",8.62)
	console.set_color(0.9,0,0)
	print "\n"
	for _ in melt.split("\n"):
		print _
		time.sleep(0.01)
	time.sleep(2.5)
	console.set_color()
	console.set_font("Menlo",14)
	typeit("Leaking Memory "+"."*18+" [  OK  ]")
	pr = pointer(47839215)
	print
	for _ in range(5000):
		sys.stdout.write("\rMemory Address "+"."*12+" [ "+pr.next()+" ]")
		time.sleep(0.01) 
开发者ID:RussianOtter,项目名称:networking,代码行数:44,代码来源:AestheticAssembly.py

示例11: print_danmu

# 需要导入模块: import console [as 别名]
# 或者: from console import set_color [as 别名]
def print_danmu(self, danmu_msg: dict):
        if not self.danmu_control:
            return
        danmu_msg_info = danmu_msg['info']

        list_msg = []
        list_color = []
        if danmu_msg_info[7] == 3:
            # print('舰', end=' ')
            list_msg.append('⚓️ ')
            list_color.append([])
        else:
            if danmu_msg_info[2][3] == 1:
                if danmu_msg_info[2][4] == 0:
                    list_msg.append('爷 ')
                    list_color.append(self.dic_color['others']['vip'])
                else:
                    list_msg.append('爷 ')
                    list_color.append(self.dic_color['others']['svip'])
            if danmu_msg_info[2][2] == 1:
                list_msg.append('房管 ')
                list_color.append(self.dic_color['others']['admin'])

            # 勋章
            if danmu_msg_info[3]:
                list_color.append(self.dic_color['fans-level'][f'fl{danmu_msg_info[3][0]}'])
                list_msg.append(f'{danmu_msg_info[3][1]}|{danmu_msg_info[3][0]} ')
            # 等级
            if not danmu_msg_info[5]:
                list_color.append(self.dic_color['user-level'][f'ul{danmu_msg_info[4][0]}'])
                list_msg.append(f'UL{danmu_msg_info[4][0]} ')

        list_msg.append(danmu_msg_info[2][1] + ':')
        try:
            if danmu_msg_info[2][7]:
                list_color.append(self.hex_to_rgb_percent(danmu_msg_info[2][7]))
            else:
                list_color.append(self.dic_color['others']['default_name'])
        except IndexError:
            print("# 小电视降临本直播间")
            list_color.append(self.dic_color['others']['default_name'])
            
        list_msg.append(danmu_msg_info[1])
        list_color.append([])
        for i, j in zip(list_msg, list_color):
            console.set_color(*j)
            print(i, end='')
        print()
        console.set_color() 
开发者ID:yjqiang,项目名称:bili2.0,代码行数:51,代码来源:printer.py


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