本文整理汇总了Python中kivy.core.text.LabelBase.register方法的典型用法代码示例。如果您正苦于以下问题:Python LabelBase.register方法的具体用法?Python LabelBase.register怎么用?Python LabelBase.register使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kivy.core.text.LabelBase
的用法示例。
在下文中一共展示了LabelBase.register方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from kivy.core.text import LabelBase [as 别名]
# 或者: from kivy.core.text.LabelBase import register [as 别名]
def __init__(self, **kwargs):
super(ThemeManager, self).__init__(**kwargs)
self._win_size = Window.size
Window.bind(on_resize=lambda *x: setattr(self, '_win_size', Window.size),
on_rotate=lambda *x: setattr(self, '_win_size', Window.size))
for font in FONTS:
LabelBase.register(**font)
示例2: build
# 需要导入模块: from kivy.core.text import LabelBase [as 别名]
# 或者: from kivy.core.text.LabelBase import register [as 别名]
def build(self):
"""
Build and return the root widget.
"""
self.settings_cls = SettingsWithSpinner
Window.size = (1920, 1080)
Window.minimum_width = 1280
Window.minimum_height = 800
#Window.clearcolor = (1, 0, 0, 1)
#Window.fullscreen = True
print(Window.dpi)
print(Window.size)
with open("classes.json") as f:
self.class_data = json.load(f)
class_picker = self.root.ids["class_spinner"]
class_picker.values = self.class_data.keys()
class_picker.bind(text=self.on_class_change)
class_picker.text = self.class_data.keys()[0]
#Register custom fonts
for font in common.FONTS:
LabelBase.register(**font)
return self.root
示例3: build
# 需要导入模块: from kivy.core.text import LabelBase [as 别名]
# 或者: from kivy.core.text.LabelBase import register [as 别名]
def build(self):
# register fonts
for font in settings.KIVY_FONTS:
LabelBase.register(**font)
self.bsm = BackgroundScreenManager()
return self.bsm
示例4: start
# 需要导入模块: from kivy.core.text import LabelBase [as 别名]
# 或者: from kivy.core.text.LabelBase import register [as 别名]
def start():
for font in G.kivy_fonts:
LabelBase.register(**font)
Window.size = (900, 600)
Builder.load_string(kv_text)
G.app = ScrollApp()
G.app.run()
示例5: set_regular
# 需要导入模块: from kivy.core.text import LabelBase [as 别名]
# 或者: from kivy.core.text.LabelBase import register [as 别名]
def set_regular(family, *filenames):
for f in filenames:
try:
LabelBase.register(family, f)
break
except IOError:
continue
else:
raise IOError, 'No appropriate fonts for Kivy UI'
示例6: main
# 需要导入模块: from kivy.core.text import LabelBase [as 别名]
# 或者: from kivy.core.text.LabelBase import register [as 别名]
def main():
from kivy.core.window import Window
Window.clearcolor = get_color_from_hex('#101216')
LabelBase.register(
name='Roboto',
fn_regular='fonts/Roboto-Thin.ttf',
fn_bold='fonts/Roboto-Medium.ttf'
)
ClockApp().run()
示例7: pymterm_main
# 需要导入模块: from kivy.core.text import LabelBase [as 别名]
# 或者: from kivy.core.text.LabelBase import register [as 别名]
def pymterm_main():
args = args_parser().parse_args()
try:
sys.argv = sys.argv[:1]
cfg = session_config.SessionConfig(args)
except:
logging.exception('load configuration failed')
args_parser().print_help()
sys.exit(1)
if cfg.render and cfg.render == 'console':
from term.terminal_console import TerminalConsoleApp
TerminalConsoleApp(cfg).start()
elif cfg.render and cfg.render == 'kivy':
from kivy.config import Config
Config.set('kivy', 'exit_on_escape', 0)
Config.set('graphics', 'height', '660')
os.environ['KIVY_NO_FILELOG'] = ''
os.environ['KIVY_NO_CONSOLELOG'] = ''
from kivy.core.text import LabelBase
FONTS = {'WenQuanYi':'wqy-microhei-mono.ttf',
'YaHei Consolas':'YaHei Consolas Hybrid 1.12.ttf',
'NotoSans':'NotoSansMonoCJKsc-Regular.otf'}
for f_name in FONTS:
font_path = os.path.join(os.path.dirname(__file__), '..', 'data', 'fonts', FONTS[f_name])
logging.getLogger('term_kivy_app').debug(font_path)
LabelBase.register(f_name, font_path)
from term_kivy.term_kivy import TerminalKivyApp
#from kivy.logger import Logger
#Logger.setLevel(logging.ERROR)
TerminalKivyApp(cfg).start()
elif cfg.render and cfg.render in session_config.PYGLET_RENDERS:
from term_pyglet.term_pyglet import TerminalPygletApp
TerminalPygletApp(cfg).start()
else:
from term_pygui.term_pygui import TerminalPyGUIApp
TerminalPyGUIApp(cfg).start()
示例8: passEnter
# 需要导入模块: from kivy.core.text import LabelBase [as 别名]
# 或者: from kivy.core.text.LabelBase import register [as 别名]
def passEnter(self):
psw =str(self.root.ids["parola"].text)
if len(psw)>0:
self.psw=psw
else:
self.psw=None
self.showError()
def showError(self):
m=MModalView()
m.open()
#self.root.ids["kullanici"].focus=True
def exitOnClick(self,instance=None,val=None):
uyariModal = KModalView(labeltext=" Uygulamadan çıkmak\nistediğinizden emin misiniz?")
uyariModal.open()
def build(self):
Window.bind(on_keyboard=self.hook_kb)
def hook_kb(self, win, key, *largs):
if key == 27:
self.exitOnClick()
return True
elif key in (282, 319):
print "setting panel goster"
return True
return False
def tester(self):
print "working"
if __name__ == '__main__':
Window.clearcolor=(0.3,1,0.3,1)
LabelBase.register(name="ky",fn_regular="esantial.ttf")
LoginApp().run()
示例9: EndGameScreen
# 需要导入模块: from kivy.core.text import LabelBase [as 别名]
# 或者: from kivy.core.text.LabelBase import register [as 别名]
class EndGameScreen(Screen):
pass
class ScoreMenu(Screen):
scroll=ObjectProperty(None)
list=None
def on_pre_enter(self, *args):
super(ScoreMenu,self).on_pre_enter(*args)
if self.scroll.children.__len__()>0:
self.scroll.clear_widgets()
self.scroll.add_widget(MiLabel(text="Math6 Game Top 20",font_size="60px",color=Clr("#ead9ed")))
cnt=self.list.__len__()
if cnt>20:
cnt=20
for i in range(cnt):
lbl=MiLabel(text=str(i+1)+"."+self.list[i]["ad"]+" "+self.list[i]["puan"])
self.scroll.add_widget(lbl)
self.scroll.bind(minimum_height=self.scroll.setter("height"))
sm=ScreenManager()
if __name__ == '__main__':
Builder.load_file("kymath.kv")
LabelBase.register(name="rt",fn_regular="Roboto-Light.ttf")
LabelBase.register(name="myfont",fn_regular="byom.ttf")
sm.add_widget(MenuScreen())
sm.add_widget(GameScreen())
sm.add_widget(EndGameScreen())
sm.add_widget(ScoreMenu())
KyMathApp().run()
示例10: reset
# 需要导入模块: from kivy.core.text import LabelBase [as 别名]
# 或者: from kivy.core.text.LabelBase import register [as 别名]
self.game_end = 1
if self.game_end:
#self.root.ids.b13.color = [0, 0, 0, 1]
self.game_buttons[12].background_color = [0.5, 0, 0, 1]
self.root.ids.info_label.text = font_s + 'BINGO!' + font_e
self.game_end = 0
def reset(self):
for btn in self.game_buttons:
btn.background_color = C('#2ecc71')
btn.color = [1, 1, 1, 1]
self.index = [0]*game_pole
self.root.ids.info_label.text = ''
def drop_select(self, value):
self.root.ids.open_butt.text = text_choise + value
self.game_select = self.game_data[self.games_index[value]][1:]
self.reset()
self.update_button()
if __name__ in ('__main__', '__android__'):
Config.set('graphics', 'width', '540')
Config.set('graphics', 'height', '960') # 9:16
Config.set('graphics', 'resizable', '1')
Config.set('input', 'mouse', 'mouse,disable_multitouch')
LabelBase.register(name='PT Sans Narrow',
fn_regular='PTN57F.ttf')
MainApp().run()
示例11: strftime
# 需要导入模块: from kivy.core.text import LabelBase [as 别名]
# 或者: from kivy.core.text.LabelBase import register [as 别名]
self.root.time_prop.text = strftime('[b]%H[/b]:%M:%S')
self.root.ids.stopwatch.text = (
'%02d:%02d.[size=40]%02d[/size]' %
(int(minutes), int(seconds),
int(seconds * 100 % 100))
)
def on_start(self):
Clock.schedule_interval(self.update_time, 0)
def start_stop(self):
self.root.ids.start_stop.text = ('Start' if self.sw_started else 'Stop')
self.sw_started = not self.sw_started
def reset(self):
if self.sw_started:
self.root.ids.start_stop.text = 'Start'
self.sw_started = False
self.sw_seconds = 0
if __name__ == "__main__":
from kivy.core.window import Window
from kivy.utils import get_color_from_hex
Window.clearcolor = get_color_from_hex('#101216')
LabelBase.register(name="Roboto",
fn_regular="Roboto-Thin.ttf",
fn_bold='Roboto-Medium.ttf')
ClockApp().run()
示例12: resource_path
# 需要导入模块: from kivy.core.text import LabelBase [as 别名]
# 或者: from kivy.core.text.LabelBase import register [as 别名]
from kivy.core.text import LabelBase
import sys
import os
# from kivy.core.tex
#You added this, remove it if it doesn't work
def resource_path(relative):
if hasattr(sys, "_MEIPASS"):
return os.path.join(sys._MEIPASS, relative)
return os.path.join(relative)
LabelBase.register(name="courier new",
fn_regular=resource_path(os.path.join('', 'Courier New.ttf')))
LabelBase.DEFAULT = "courier new"
# C:/Users/Jonathan/PycharmProjects/EloTab/
示例13: update_time
# 需要导入模块: from kivy.core.text import LabelBase [as 别名]
# 或者: from kivy.core.text.LabelBase import register [as 别名]
Clock.schedule_interval(self.update_time, 0)
def update_time(self, nap):
self.root.ids.time.text = strftime('[b]%H[/b]:%M:%S')
if self.sw_started:
self.sw_seconds += nap
minutes, seconds = divmod(self.sw_seconds, 60)
self.root.ids.stopwatch.text = (
'%02d:%02d.[size=40]%02d[/size]' %
(int(minutes), int(seconds), int(seconds * 100 % 100)))
def start_stop(self):
self.root.ids.start_stop.text = 'Start' if self.sw_started else 'Stop'
self.sw_started = not self.sw_started
def reset(self):
if self.sw_started:
self.root.ids.start_stop.text = 'Start'
self.sw_started = False
self.sw_seconds = 0
if __name__ == '__main__':
Window.clearcolor = get_color_from_hex('#101216')
LabelBase.register(name='Roboto',
fn_regular='fonts/Roboto-Thin.ttf',
fn_bold='fonts/Roboto-Medium.ttf')
ClockApp().run()
示例14: MainApp
# 需要导入模块: from kivy.core.text import LabelBase [as 别名]
# 或者: from kivy.core.text.LabelBase import register [as 别名]
from kivy.uix.image import Image
from kivy.uix.button import Button
from kivy.core.window import Window
from kivy.uix.floatlayout import FloatLayout
from kivy.adapters.listadapter import ListAdapter
from kivy.uix.listview import ListView, ListItemButton
from kivy.core.text import LabelBase
Window.clearcolor = (1, 1, 1, 1)
KIVY_FONTS = [{
"name": "Soft Elegance",
"fn_regular": "fonts/Soft Elegance.ttf",
}]
for font in KIVY_FONTS:
LabelBase.register(**font)
class MainApp(App):
def build(self):
''''Initialisation de l'app (text et bouton)'''
self.fenetre = FloatLayout()
self.date = 'Aujourd\'hui'
self.label_ville_depart = 'Ville de départ' #pour les test : 'Ville de départ !' en temp normal
self.ville_depart = None #pour les test : None en temp normal
self.arret_depart = None #pour les test : None en temp normal
self.status_ville_depart = None #permet de gerer si c'est pour le bouton de depart ou d'arriver
self.label_ville_arriver = 'Ville d\'arriver' #pour les test : 'Ville d\'arriver !' en temp normal
self.ville_arriver = None #pour les test : None en temp normal
self.arret_arriver = None #pour les test : None en temp normal
self.init_list_adapter_alphabet()
self.init_list_adapter_ville([])
示例15: Board
# 需要导入模块: from kivy.core.text import LabelBase [as 别名]
# 或者: from kivy.core.text.LabelBase import register [as 别名]
from kivy.app import App
from kivy.lang import Builder
from kivy.config import Config
from kivy.uix.screenmanager import ScreenManager
from kivy.core.text import LabelBase
from model import Board, Problem
from view import SudokuScreen
from view.widget import *
Config.set('graphics', 'width', '320')
Config.set('graphics', 'height', '480')
Builder.load_file('kv/sudoku.kv')
LabelBase.register(
'SeoulNamsan',
fn_regular='static/font/SeoulNamsanM.ttf',
fn_bold='static/font/SeoulNamsanB.ttf')
problem = Problem.loads(
"800523910162489075350170420425008009690000"
"057700600234037062041540317692016954003",
"87452391616248937535917642842573816969324185"
"7781695234937862541548317692216954783",
9)
board = Board(problem)
sm = ScreenManager()
sm.switch_to(SudokuScreen(board_model=board))