font_name 在 MMDialog 中
font_name in MDDialog
我想更改 kivymd 库中的 mddialog 字体。当我添加 font_name 时,此代码不起作用。
如果您能帮助我,我将不胜感激。
from kivy.lang import Builder
from kivy.animation import Animation
from kivymd.app import MDApp
from kivymd.uix.button import MDFlatButton
from kivymd.uix.dialog import MDDialog
KV = '''
FloatLayout:
MDFlatButton:
text: "ALERT DIALOG"
pos_hint: {'center_x': .5, 'center_y': .5}
on_release: app.show_alert_dialog()
'''
class Example(MDApp):
dialog = None
def build(self):
return Builder.load_string(KV)
def show_alert_dialog(self):
if not self.dialog:
self.dialog = MDDialog(
text="Hello",font_name='calibrib.ttf',
buttons=[
MDFlatButton(
text="CANCEL"
),
MDFlatButton(
text="DISCARD"
),
],
)
self.dialog.open()
Example().run()
self.dialog = MDDialog(text="[font=calibrib.ttf]Hello[/font]")
我想更改 kivymd 库中的 mddialog 字体。当我添加 font_name 时,此代码不起作用。 如果您能帮助我,我将不胜感激。
from kivy.lang import Builder
from kivy.animation import Animation
from kivymd.app import MDApp
from kivymd.uix.button import MDFlatButton
from kivymd.uix.dialog import MDDialog
KV = '''
FloatLayout:
MDFlatButton:
text: "ALERT DIALOG"
pos_hint: {'center_x': .5, 'center_y': .5}
on_release: app.show_alert_dialog()
'''
class Example(MDApp):
dialog = None
def build(self):
return Builder.load_string(KV)
def show_alert_dialog(self):
if not self.dialog:
self.dialog = MDDialog(
text="Hello",font_name='calibrib.ttf',
buttons=[
MDFlatButton(
text="CANCEL"
),
MDFlatButton(
text="DISCARD"
),
],
)
self.dialog.open()
Example().run()
self.dialog = MDDialog(text="[font=calibrib.ttf]Hello[/font]")