當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。