我最近发布了关于向屏幕添加进度条小部件的信息,但由于我的 MDBottomNavigation 包含在一个屏幕中,每次我切换到底部导航中的不同项目时,进度条都会保持存在。所以,我想要做的是将进度条添加到MDBottomNavigation 项目中的一个而不是其他 2 个。这是我的代码:
.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 Goals(Screen):
pass
class Workout(MDApp):
dialog = None
PB = ObjectProperty(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(
value = 50,
max = 100
)
self.root.ids.GoalsBN.add_widget(progressbar)
self.dialog.dismiss()
是需要进行编辑的地方。我知道这条线不对,我只是不确定如何调用我给定 id: 'GoalsBN'的 MDBottomNavigationItem 。帮助将不胜感激!
慕森卡
相关分类