本文整理汇总了Python中ugfx.set_default_font函数的典型用法代码示例。如果您正苦于以下问题:Python set_default_font函数的具体用法?Python set_default_font怎么用?Python set_default_font使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了set_default_font函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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)
示例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
示例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
示例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()
示例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)
示例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)
示例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
示例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()
示例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
示例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)
示例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)
示例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
示例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()
示例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()
示例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