.py 文件
class WindowManager(ScreenManager):
pass
class HomeScreen(Screen):
pass
class MyWorkouts(Screen):
pass
class RecommendedWorkouts(Screen):
pass
class AddWorkouts(Screen):
pass
class CreateNewWorkout(Screen):
pass
class AddNewGoal(Screen):
pass
class Workout(MDApp):
dialog = None
def build(self):
return
def AddNewGoal_Dialog(self):
if not self.dialog:
self.dialog = MDDialog(
size_hint_x = 0.8,
size_hint_y = 1,
pos_hint = {'center_x': .5, 'center_y': .5},
radius = [10, 10, 10, 10],
title = 'Add New Goal',
auto_dismiss = False,
type = 'custom',
content_cls = AddNewGoal(),
buttons = [
MDFlatButton(
text = 'CANCEL', text_color = self.theme_cls.primary_color,
on_release = self.closeDialog),
MDRaisedButton(
text = 'CREATE', text_color = self.theme_cls.primary_color,
on_release = self.addNewGoal)
],
)
self.dialog.open()
def addNewGoal(self, inst):
progressbar = ProgressBar()
HomeScreen().add_widget(progressbar)
.kv 文件
MDToolbar:
title: 'App Attack'
type: 'top'
right_action_items: [['plus', lambda x: app.AddNewGoal_Dialog()]]
elevation: 10
因此,当我按下工具栏上的正确操作项时,它会创建对话框。然后,我想要它,所以当我按下对话框上的 CREATE Raised Button 时,它将向主屏幕添加一个小部件(进度条)。我没有收到错误代码。相反,当按钮被释放时,什么也没有发生。任何人都可以帮忙吗?