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

Python ugfx.set_default_font函数代码示例

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

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



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

示例1: drawui

def drawui():
    ugfx.init()
    buttons.init()
    ugfx.clear(ugfx.html_color(0x87F717))

    ugfx.set_default_font(ugfx.FONT_MEDIUM)

    ugfx.fill_circle(50,50, 20, ugfx.WHITE)
    ugfx.fill_circle(50, 100, 20, ugfx.WHITE)

    ugfx.text(45, 45, "A", ugfx.RED)
    ugfx.text(45, 95, "B", ugfx.RED)

    ugfx.text(95, 45, "Flash the lights", ugfx.WHITE)
    ugfx.text(95, 95, "Disco Inferno", ugfx.WHITE)

    ugfx.fill_polygon(270,50, [ [0,0], [40,0], [40, 175], [0, 175] ], ugfx.RED)#  , [230, 100], [230, 60]
    ugfx.fill_polygon(270,50, [ [0,0], [-20,10], [-20, 50], [0, 40] ], ugfx.RED)#  , [230, 100], [230, 60]

    ugfx.area(283, 61, 14, 10, ugfx.WHITE)
    ugfx.area(283, 79, 14, 10, ugfx.WHITE)
    ugfx.area(283, 97, 14, 10, ugfx.WHITE)
    ugfx.area(283, 115, 14, 10, ugfx.WHITE)
    ugfx.area(283, 133, 14, 10, ugfx.WHITE)
    ugfx.area(283, 151, 14, 10, ugfx.WHITE)
    ugfx.area(283, 169, 14, 10, ugfx.WHITE)
    ugfx.area(283, 187, 14, 10, ugfx.WHITE)
开发者ID:davidcarboni,项目名称:emf2016-sign-badge,代码行数:27,代码来源:main.py


示例2: game_over

def game_over(reason):
	ugfx.clear(ugfx.BLACK)
	ugfx.set_default_font(ugfx.FONT_TITLE)
	
	ugfx.text(80,40,"Game Over!",ugfx.WHITE)
	ugfx.text(20,100,reason,ugfx.RED)
	playing=0
开发者ID:liedra,项目名称:adventure-emf,代码行数:7,代码来源:main.py


示例3: viewmsg

def viewmsg():
	msgid = db.get('msgseq')
	msg = inbox.get(msgid)
	if msg == None:
		ugfx.set_default_font(ugfx.FONT_SMALL)	
		ugfx.area(0,0,ugfx.width(),ugfx.height(),0x0000)
		ugfx.text(40,100,"NO MESSAGES",ugfx.BLUE)
		pyb.delay(1000)
		return
	else:
		data = json.loads(msg)
		printmsg(data['sender'], data['payload'], data['ts'])
	while True:
		if buttons.is_triggered("JOY_UP"):
			print(msgid)
			msgid -= 1
			msg = inbox.get(msgid)
			if msg != None:
				data = json.loads(msg)
				printmsg(data['sender'], data['payload'], data['ts'])
			else:
				msgid += 1
		if buttons.is_triggered("JOY_DOWN"):
			print(msgid)
			msgid += 1
			msg = inbox.get(msgid)
			if msg != None:
				data = json.loads(msg)
				printmsg(data['sender'], data['payload'], data['ts'])
			else:
				msgid -= 1
		if buttons.is_triggered("BTN_B"):
			display()
			return
开发者ID:Kimbsy,项目名称:EMF_20016,代码行数:34,代码来源:main.py


示例4: run_app

def run_app(path):
	import buttons
	buttons.init()
	if not buttons.has_interrupt("BTN_MENU"):
		buttons.enable_menu_reset()
	try:
		mod = __import__(path)
		if "main" in dir(mod):
			mod.main()
	except Exception as e:
		import sys
		import uio
		import ugfx
		s = uio.StringIO()
		sys.print_exception(e, s)
		ugfx.clear()
		ugfx.set_default_font(ugfx.FONT_SMALL)
		w=ugfx.Container(0,0,ugfx.width(),ugfx.height())
		ugfx.Label(0,0,ugfx.width(),ugfx.height(),s.getvalue(),parent=w)
		w.show()
		raise(e)
	import stm
	stm.mem8[0x40002850] = 0x9C
	import pyb
	pyb.hard_reset()
开发者ID:Jonty,项目名称:Mk3-Firmware,代码行数:25,代码来源:run_app.py


示例5: draw_fps

def draw_fps():
    ugfx.set_default_font(ugfx.FONT_SMALL)
    #redraw_bg_range(300, 10, 320, 35)
    try:
        fps = int((len(frame_times) / (frame_times[-1] - frame_times[0])) * 1000)
    except ZeroDivisionError:
        fps = 0
    ugfx.text(300, 10, "%d" % fps, ugfx.WHITE)
开发者ID:MatthewWilkes,项目名称:tildamk3-dronehunt,代码行数:8,代码来源:main.py


示例6: display

def display():
	logo = 'apps/nexmo~messages/nexmo_logo.gif'
	ugfx.area(0,0,ugfx.width(),ugfx.height(),0xFFFF)
	ugfx.set_default_font(ugfx.FONT_MEDIUM_BOLD)	
	ugfx.text(20,20,"My Number is...",ugfx.BLACK)
	ugfx.text(20,130,"Powered By, ",ugfx.GREY)
	ugfx.display_image(15,150,logo)
	ugfx.set_default_font(ugfx.FONT_TITLE)
	ugfx.text(40,75,mynumber+" ",ugfx.BLUE)
开发者ID:Kimbsy,项目名称:EMF_20016,代码行数:9,代码来源:main.py


示例7: tick

def tick(icon):
	global i
	i += 1
	icon.show()
	ugfx.set_default_font("c*")
	icon.area(0, 0, icon.width(), icon.height(), 0xFFFF)
	icon.text(0, 0, str(i), 0)

	return "Test: %d"% i
开发者ID:Giannie,项目名称:Mk3-Firmware,代码行数:9,代码来源:external.py


示例8: prompt_option

def prompt_option(options, index=0, text = "Please select one of the following:", title=None, select_text="OK", none_text=None):
	"""Shows a dialog prompting for one of multiple options

	If none_text is specified the user can use the B or Menu button to skip the selection
	if title is specified a blue title will be displayed about the text
	"""
	ugfx.set_default_font(ugfx.FONT_SMALL)
	window = ugfx.Container(5, 5, ugfx.width() - 10, ugfx.height() - 10)
	window.show()

	list_y = 30
	if title:
		window.text(5, 10, title, TILDA_COLOR)
		window.line(0, 25, ugfx.width() - 10, 25, ugfx.BLACK)
		window.text(5, 30, text, ugfx.BLACK)
		list_y = 50
	else:
		window.text(5, 10, text, ugfx.BLACK)

	options_list = ugfx.List(5, list_y, ugfx.width() - 25, 180 - list_y, parent = window)

	for option in options:
		if isinstance(option, dict) and option["title"]:
			options_list.add_item(option["title"])
		else:
			options_list.add_item(str(option))
	options_list.selected_index(index)

	select_text = "A: " + select_text
	if none_text:
		none_text = "B: " + none_text

	button_select = ugfx.Button(5, ugfx.height() - 50, 140 if none_text else ugfx.width() - 25, 30 , select_text, parent=window)
	button_none = ugfx.Button(ugfx.width() - 160, ugfx.height() - 50, 140, 30 , none_text, parent=window) if none_text else None

	try:
		buttons.init()

		while True:
			pyb.wfi()
			ugfx.poll()
			if buttons.is_triggered("BTN_A"): return options[options_list.selected_index()]
			if button_none and buttons.is_triggered("BTN_B"): return None
			if button_none and buttons.is_triggered("BTN_MENU"): return None

	finally:
		window.hide()
		window.destroy()
		options_list.destroy()
		button_select.destroy()
		if button_none: button_none.destroy()
		ugfx.poll()
开发者ID:emfcamp,项目名称:Mk3-Firmware,代码行数:52,代码来源:dialogs.py


示例9: printmsg

def printmsg(sender, text, ts):
	ugfx.set_default_font(ugfx.FONT_SMALL)	
	ugfx.area(0,0,ugfx.width(),ugfx.height(),0x0000)
	ugfx.text(10,10,"From: "+sender,ugfx.BLUE)
	timestamp = timestring(ts)
	linelen = 40
	lines = int(math.ceil(len(text)/linelen))
	for l in range(0, lines):
		pixels = l*25+35
		start = l*linelen
		end = l*linelen+linelen
		if end>len(text):
			end = len(text)
		linetext = text[start:end]
		ugfx.text(10,pixels,linetext,0xFFFF)
	ugfx.text(10,200,timestamp,ugfx.GREEN)
	return
开发者ID:Kimbsy,项目名称:EMF_20016,代码行数:17,代码来源:main.py


示例10: setup_right_menu

def setup_right_menu():
	ugfx.set_default_font(ugfx.FONT_SMALL)

	if room==1:
		if (haskey1==0):
			ugfx.text(190, 30, "The gate is locked.", ugfx.RED)
			ugfx.text(190, 50, "Maybe you should ", ugfx.RED)
			ugfx.text(190, 70, "find a key.", ugfx.RED)
		elif (haskey1==1):
			ugfx.text(190, 30, "The key fits the lock!", ugfx.RED)
			ugfx.text(190, 50, "A: Escape the Castle", ugfx.RED)
			
	if room==2:
		if orc1:
			ugfx.text(190, 30, "An orc is here.", ugfx.RED)
			ugfx.text(190, 50, "A: Kick", ugfx.RED)
			ugfx.text(190, 70, "B: Punch", ugfx.RED)
			
	if room==5:
		if orc2:
			ugfx.text(190, 30, "A slightly bigger", ugfx.RED) 
			ugfx.text(190, 50, "orc is here.", ugfx.RED)
			ugfx.text(190, 70, "A: Kick", ugfx.RED)
			ugfx.text(190, 90, "B: Tell it a joke", ugfx.RED)
	if room==6:
		ugfx.text(190, 30, "A fountain", ugfx.RED) 
		ugfx.text(190, 50, "is here.", ugfx.RED)
		ugfx.text(190, 70, "A: Drink", ugfx.RED)
		ugfx.text(190, 90, "B: Look in", ugfx.RED)
		
	if room==8:
		if orc3:
			ugfx.text(190, 30, "A humongous", ugfx.RED) 
			ugfx.text(190, 50, "orc is here.", ugfx.RED)
			ugfx.text(190, 70, "A: Kick", ugfx.RED)
			ugfx.text(190, 90, "B: Sneak past", ugfx.RED)
			
			
	if room==9:
		ugfx.text(190, 30, "A key is here.", ugfx.RED)
		ugfx.text(190, 50, "A: Take", ugfx.RED)
		ugfx.text(190, 70, "B: Eat", ugfx.RED)
		
	ugfx.text(30, 200, "HP: "+str(hp), ugfx.BLUE)
开发者ID:liedra,项目名称:adventure-emf,代码行数:44,代码来源:main.py


示例11: draw_battery

def draw_battery(back_colour,percent, win_bv):
	percent = max(0,percent)
	ugfx.set_default_font("c*")
	main_c = ugfx.WHITE #back_colour^0xFFFF
	x=3
	y=3
	win_bv.area(x+35,y,40,24,back_colour)
	if percent <= 120:
		win_bv.text(x+35,y,str(int(min(percent,100))),main_c)
	y += 2
	win_bv.area(x,y,30,11,main_c)
	win_bv.area(x+30,y+3,3,5,main_c)

	if percent > 120:
		win_bv.area(x+2,y+2,26,7,ugfx.YELLOW)
	elif percent > 2:
		win_bv.area(x+2,y+2,26,7,back_colour)
		win_bv.area(x+2,y+2,int(min(percent,100)*26/100),7,main_c)
	else:
		win_bv.area(x+2,y+2,26,7,ugfx.RED)
开发者ID:farragar,项目名称:Mk3-Firmware,代码行数:20,代码来源:main.py


示例12: showevent

def showevent(stage, event):
	start = event['start_date']
	end = event['end_date']
	speaker = event['speaker']
	text = event['title']
	ugfx.set_default_font(ugfx.FONT_MEDIUM)	
	ugfx.area(0,0,ugfx.width(),ugfx.height(),0x0000)
	ugfx.text(10,10,stage,ugfx.GREY)
	ugfx.text(10,35,"Start: "+start,ugfx.GREEN)
	ugfx.text(10,60,"End: "+end,ugfx.RED)
	ugfx.text(10,85,"Speaker: "+speaker,ugfx.BLUE)
	linelen = 25
	lines = int(math.ceil(len(text)/linelen))
	for l in range(0, lines):
		pixels = l*25+110
		start = l*linelen
		end = l*linelen+linelen
		if end>len(text):
			end = len(text)
		linetext = text[start:end]
		ugfx.text(10,pixels,linetext,0xFFFF)
	return
开发者ID:sammachin,项目名称:EMFBadge-NowNext,代码行数:22,代码来源:main.py


示例13: draw

def draw(x,y,window):
	global obj
	global sty
	if len(obj) == 0:
	
		sty = ugfx.Style()
		sty.set_enabled([ugfx.RED, ugfx.BLACK, ugfx.GREY, ugfx.GREY])
		
		
		#ugfx.Imagebox(0,0,window.width(),window.height(),"apps/home/back.bmp",0, win2)
		ugfx.set_default_font(ugfx.FONT_NAME)
		l=ugfx.Label(5,20,310,window.height()-20,database_get("display-name", "<not actually set yet>"),parent=window)
		obj.append(l)
		ugfx.set_default_font(ugfx.FONT_MEDIUM_BOLD)
		obj.append(ugfx.Label(5,0,310,20,"My name is...",parent=window,style=sty))
		#ugfx.text(40,80,database_get("display-name", "<not set yet>"),ugfx.BLUE)
		#ugfx.circle(140,150,40,ugfx.GREEN)
		#ugfx.circle(160,150,40,ugfx.GREEN)
		#ugfx.circle(180,150,40,ugfx.GREEN)
		window.show()
	else:
		window.hide()
		window.show()
开发者ID:Kimbsy,项目名称:EMF_20016,代码行数:23,代码来源:draw_name.py


示例14: prompt_boolean

def prompt_boolean(text, title="TiLDA", true_text="Yes", false_text="No", width = 260, height = 180, font=ugfx.FONT_SMALL, style=None):
	"""A simple one and two-options dialog

	if 'false_text' is set to None only one button is displayed.
	If both 'true_text' and 'false_text' are given a boolean is returned
	"""
	global default_style_dialog
	if style == None:
		style = default_style_dialog
	ugfx.set_default_font(ugfx.FONT_MEDIUM_BOLD)
	window = ugfx.Container((ugfx.width() - width) // 2, (ugfx.height() - height) // 2,  width, height, style=style)
	window.show()
	ugfx.set_default_font(font)
	window.text(5, 10, title, TILDA_COLOR)
	window.line(0, 30, width, 30, ugfx.BLACK)

	if false_text:
		true_text = "A: " + true_text
		false_text = "B: " + false_text

	ugfx.set_default_font(font)
	label = ugfx.Label(5, 30, width - 10, height - 80, text = text, parent=window)
	ugfx.set_default_font(ugfx.FONT_MEDIUM_BOLD)
	button_yes = ugfx.Button(5, height - 40, width // 2 - 15 if false_text else width - 15, 30 , true_text, parent=window)
	button_no = ugfx.Button(width // 2 + 5, height - 40, width // 2 - 15, 30 , false_text, parent=window) if false_text else None

	try:
		buttons.init()

		button_yes.attach_input(ugfx.BTN_A,0)
		if button_no: button_no.attach_input(ugfx.BTN_B,0)

		window.show()

		while True:
			pyb.wfi()
			if buttons.is_triggered("BTN_A"): return True
			if buttons.is_triggered("BTN_B"): return False

	finally:
		window.hide()
		window.destroy()
		button_yes.destroy()
		if button_no: button_no.destroy()
		label.destroy()
开发者ID:emfcamp,项目名称:Mk3-Firmware,代码行数:45,代码来源:dialogs.py


示例15: prompt_text

def prompt_text(description, init_text = "", true_text="OK", false_text="Back", width = 300, height = 200, font=ugfx.FONT_MEDIUM_BOLD, style=default_style_badge):
	"""Shows a dialog and keyboard that allows the user to input/change a string

	Returns None if user aborts with button B
	"""

	window = ugfx.Container(int((ugfx.width()-width)/2), int((ugfx.height()-height)/2), width, height, style=style)

	if false_text:
		true_text = "M: " + true_text
		false_text = "B: " + false_text

	if buttons.has_interrupt("BTN_MENU"):
		buttons.disable_interrupt("BTN_MENU")

	ugfx.set_default_font(ugfx.FONT_MEDIUM)
	kb = ugfx.Keyboard(0, int(height/2), width, int(height/2), parent=window)
	edit = ugfx.Textbox(5, int(height/2)-30, int(width*4/5)-10, 25, text = init_text, parent=window)
	ugfx.set_default_font(ugfx.FONT_SMALL)
	button_yes = ugfx.Button(int(width*4/5), int(height/2)-30, int(width*1/5)-3, 25 , true_text, parent=window)
	button_no = ugfx.Button(int(width*4/5), int(height/2)-30-30, int(width/5)-3, 25 , false_text, parent=window) if false_text else None
	ugfx.set_default_font(font)
	label = ugfx.Label(int(width/10), int(height/10), int(width*4/5), int(height*2/5)-60, description, parent=window)

	try:
		buttons.init()

		button_yes.attach_input(ugfx.BTN_MENU,0)
		if button_no: button_no.attach_input(ugfx.BTN_B,0)

		window.show()
		edit.set_focus()
		while True:
			pyb.wfi()
			ugfx.poll()
			#if buttons.is_triggered("BTN_A"): return edit.text()
			if buttons.is_triggered("BTN_B"): return None
			if buttons.is_triggered("BTN_MENU"): return edit.text()

	finally:
		window.hide()
		window.destroy()
		button_yes.destroy()
		if button_no: button_no.destroy()
		label.destroy()
		kb.destroy()
		edit.destroy();
	return
开发者ID:emfcamp,项目名称:Mk3-Firmware,代码行数:48,代码来源:dialogs.py


示例16: scale

ugfx.set_default_style(s)

win_header = ugfx.Container(0,0,wi,33,style=s)
win_legend = ugfx.Container(0,hi-30,wi,30,style=s)


toplot = ['vbat','vunreg','light','rssi']
# scale  to fit on the y scale (range 0->150)
scale_m = [75,   75,   0.4,  1]
scale_c = [-255, -255, 0,    100]
colour =  [ugfx.RED, ugfx.ORANGE, ugfx.YELLOW, ugfx.BLUE]

buttons.disable_menu_reset()

ugfx.set_default_font(ugfx.FONT_TITLE)
title = ugfx.Label(3,3,wi-10,45,"Log Viewer",parent=win_header)
ugfx.set_default_font(ugfx.FONT_SMALL)
chk_upload = ugfx.Checkbox(190,3,130,20,"M: Enable uplink",parent=win_header)
chk_upload.attach_input(ugfx.BTN_MENU,0)
if database_get("stats_upload"):
	chk_upload.checked(1)

win_header.show()
win_legend.show()

ugfx.set_default_font(ugfx.FONT_MEDIUM)
ugfx.set_default_style(s)

graph = ugfx.Graph(0,33,wi,hi-33-33,3,3)
graph.appearance(ugfx.Graph.STYLE_POINT, ugfx.Graph.POINT_NONE, 0, 0)
开发者ID:Giannie,项目名称:Mk3-Firmware,代码行数:30,代码来源:main.py


示例17:

	arrow = [[0,0],[20,7],[0,14],[4,7]]
	win.fill_polygon(4, cursor_loc*25+18, arrow , backcolour)
	cursor_loc += x
	if cursor_loc < 0:
		cursor_loc = 0
	if cursor_loc > 2:
		cursor_loc = 2
	win.fill_polygon(4, cursor_loc*25+18, arrow ,ugfx.RED)


# Create visual elements
win_header = ugfx.Container(0,0,width,33)
win_main = ugfx.Container(0,35,width,height-35)

components = [win_header, win_main]
ugfx.set_default_font(ugfx.FONT_TITLE)
components.append(ugfx.Label(3,3,width-10,29,"Wifi Settings",parent=win_header))
ugfx.set_default_font(ugfx.FONT_MEDIUM_BOLD)
components.append(ugfx.Label(40,10,85,25,"Name:",parent=win_main))
components.append(ugfx.Label(40,35,85,25,"Password:",parent=win_main))
ugfx.set_default_font(ugfx.FONT_MEDIUM)
lname = ugfx.Label(125,10,100,25,"BadgeNet",parent=win_main)
lpwd = ugfx.Label(125,35,100,25,"letmein",parent=win_main)
components.append(lname)
components.append(lpwd)
ckdefault = ugfx.Checkbox(40,65,250,25,"EMF camp default",parent=win_main)
components.append(ckdefault)

win_main.show()
win_header.show()
开发者ID:Giannie,项目名称:Mk3-Firmware,代码行数:30,代码来源:main.py


示例18: display_name

def display_name():
	ugfx.area(0,0,ugfx.width(),ugfx.height(),0xFFFF)
	ugfx.set_default_font("D*")
	ugfx.text(40,120,"MATT",ugfx.YELLOW)
	ugfx.circle(160,200,40,ugfx.GREEN)
开发者ID:Jonty,项目名称:Mk3-Firmware,代码行数:5,代码来源:name.py


示例19: home_main

def home_main():
	global orientation, next_tick, tick

	ugfx.area(0,0,320,240,sty_tb.background())

	ugfx.set_default_font(ugfx.FONT_MEDIUM)
	win_bv = ugfx.Container(0,0,80,25, style=sty_tb)
	win_wifi = ugfx.Container(82,0,60,25, style=sty_tb)
	win_name = ugfx.Container(0,25,320,240-25-60, style=dialogs.default_style_badge)
	win_text = ugfx.Container(0,240-60,320,60, style=sty_tb)

	windows = [win_bv, win_wifi, win_text]

	obj_name = apps.home.draw_name.draw(0,25,win_name)

	buttons.init()

	gc.collect()
	ugfx.set_default_font(ugfx.FONT_MEDIUM_BOLD)
	hook_feeback = ugfx.List(0, 0, win_text.width(), win_text.height(), parent=win_text)

	win_bv.show()
	win_text.show()
	win_wifi.show()

	min_ctr = 28

	# Create external hooks so other apps can run code in the context of
	# the home screen.
	# To do so an app needs to have an external.py with a tick() function.
	# The tick period will default to 60 sec, unless you define something
	# else via a "period" variable in the module context (use milliseconds)
	# If you set a variable "needs_wifi" in the module context tick() will
	# only be called if wifi is available
	# If you set a variable "needs_icon" in the module context tick() will
	# be called with a reference to a 25x25 pixel ugfx container that you
	# can modify
	external_hooks = []
	icon_x = 150
	for path in get_external_hook_paths():
		try:
			module = __import__(path)
			if not hasattr(module, "tick"):
				raise Exception("%s must have a tick function" % path)

			hook = {
				"name": path[5:-9],
				"tick": module.tick,
				"needs_wifi": hasattr(module, "needs_wifi"),
				"period": module.period if hasattr(module, "period") else 60 * 1000,
				"next_tick_at": 0
			}

			if hasattr(module, "needs_icon"):
				hook["icon"] = ugfx.Container(icon_x, 0, 25, 25)
				icon_x += 27

			external_hooks.append(hook)
		except Exception as e: # Since we dont know what exception we're looking for, we cant do much
			print ("%s while parsing background task %s.  This task will not run! " % (type(e).__name__, path[5:-9]))
			sys.print_exception(e)
			continue # If the module fails to load or dies during the setup, skip it

	backlight_adjust()

	inactivity = 0
	last_rssi = 0

	## start connecting to wifi in the background
	wifi_timeout = 30 #seconds
	wifi_reconnect_timeout = 0
	try:
		wifi.connect(wait = False)
	except OSError:
		print("Creating default wifi settings file")
		wifi.create_default_config()

	while True:
		pyb.wfi()
		ugfx.poll()

		if (next_tick <= pyb.millis()):
			tick = True
			next_tick = pyb.millis() + 1000

		#if wifi still needs poking
		if (wifi_timeout > 0):
			if wifi.nic().is_connected():
				wifi_timeout = -1
				#wifi is connected, but if becomes disconnected, reconnect after 5 sec
				wifi_reconnect_timeout = 5
			else:
				wifi.nic().update()


		if tick:
			tick = False

			ledg.on()

#.........这里部分代码省略.........
开发者ID:farragar,项目名称:Mk3-Firmware,代码行数:101,代码来源:main.py


示例20: file_loader

def file_loader():
	width = ugfx.width()
	height = ugfx.height()
	buttons.disable_menu_reset()

	# Create visual elements
	win_header = ugfx.Container(0,0,width,30)
	win_files = ugfx.Container(0,33,int(width/2),height-33)
	win_preview = ugfx.Container(int(width/2)+2,33,int(width/2)-2,height-33)
	components = [win_header, win_files, win_preview]
	ugfx.set_default_font(ugfx.FONT_TITLE)
	components.append(ugfx.Label(3,3,width-10,29,"Choose App",parent=win_header))
	ugfx.set_default_font(ugfx.FONT_MEDIUM)
	options = ugfx.List(0,30,win_files.width(),win_files.height()-30,parent=win_files)
	btnl = ugfx.Button(5,3,20,20,"<",parent=win_files)
	btnr = ugfx.Button(win_files.width()-7-20,3,20,20,">",parent=win_files)
	btnr.attach_input(ugfx.JOY_RIGHT,0)
	btnl.attach_input(ugfx.JOY_LEFT,0)
	components.append(options)
	components.append(btnr)
	components.append(btnl)
	ugfx.set_default_font(ugfx.FONT_MEDIUM_BOLD)
	l_cat = ugfx.Label(30,3,100,20,"Built-in",parent=win_files)
	components.append(l_cat)
	components.append(ugfx.Button(10,win_preview.height()-25,20,20,"A",parent=win_preview))
	components.append(ugfx.Label(35,win_preview.height()-25,50,20,"Run",parent=win_preview))
	components.append(ugfx.Button(80,win_preview.height()-25,20,20,"B",parent=win_preview))
	components.append(ugfx.Label(105,win_preview.height()-25,100,20,"Back",parent=win_preview))
	components.append(ugfx.Button(10,win_preview.height()-50,20,20,"M",parent=win_preview))
	components.append(ugfx.Label(35,win_preview.height()-50,100,20,"Pin/Unpin",parent=win_preview))
	ugfx.set_default_font(ugfx.FONT_SMALL)
	author = ugfx.Label(1,win_preview.height()-78,win_preview.width()-3,20,"by: ",parent=win_preview)
	desc = ugfx.Label(3,1,win_preview.width()-10,win_preview.height()-83,"",parent=win_preview,justification=ugfx.Label.LEFTTOP)
	components.append(author)
	components.append(desc)

	app_to_load = None

	pinned = database_get("pinned_apps", [])
	catergories = get_local_app_categories()
	c_ptr = 0

	try:
		win_header.show()
		win_files.show()
		win_preview.show()

		pinned = database_get("pinned_apps", [])
	#	apps = []
		apps_path = []

		if is_dir("apps"):
			for app in os.listdir("apps"):
				path = "apps/" + app
				if is_dir(path) and is_file(path + "/main.py"):
					apps_path.append(path + "/main.py")
		if is_dir("examples"):
			for app in os.listdir("examples"):
				path = "examples/" + app
				if is_file(path) and path.endswith(".py"):
					apps_path.append(path)

		displayed_apps = update_options(options, catergories[c_ptr], pinned)

		index_prev = -1;

		while True:
			pyb.wfi()
			ugfx.poll()

			if index_prev != options.selected_index():
				if options.selected_index() < len(displayed_apps):
					author.text("by: %s" % displayed_apps[options.selected_index()].user)
					desc.text(displayed_apps[options.selected_index()].description)
				index_prev = options.selected_index()

			if buttons.is_triggered("JOY_LEFT"):
				if c_ptr > 0:
					c_ptr -= 1
					btnl.set_focus()
					l_cat.text(catergories[c_ptr])
					displayed_apps = update_options(options, catergories[c_ptr], pinned)
					index_prev = -1

			if buttons.is_triggered("JOY_RIGHT"):
				if c_ptr < len(catergories)-1:
					c_ptr += 1
					btnr.set_focus()
					l_cat.text(catergories[c_ptr])
					displayed_apps = update_options(options, catergories[c_ptr], pinned)
					index_prev = -1

			if buttons.is_triggered("BTN_MENU"):
				app = displayed_apps[options.selected_index()]
				if app.folder_name in pinned:
					pinned.remove(app.folder_name)
				else:
					pinned.append(app.folder_name)
				update_options(options, catergories[c_ptr], pinned)
				database_set("pinned_apps", pinned)
#.........这里部分代码省略.........
开发者ID:Giannie,项目名称:Mk3-Firmware,代码行数:101,代码来源:file_loader.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python uhd_interface.uhd_receiver函数代码示例发布时间:2022-05-27
下一篇:
Python ugfx.init函数代码示例发布时间: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