Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class MainToolBar(Toolbar):
- dots_menu = ObjectProperty()
- tabs_layout = ObjectProperty()
- tab1 = ObjectProperty()
- tab2 = ObjectProperty()
- sm = ObjectProperty()
- x = NumericProperty(0)
- y = NumericProperty(0)
- temp_size = ReferenceListProperty(x,y)
- temp_pos = ReferenceListProperty()
- def __init__(self, **kwargs):
- super(MainToolBar, self).__init__(**kwargs)
- Clock.schedule_once(self.my_init, -1)
- def my_init(self, dt):
- self.dots_menu = DotsMenu()
- self.id = 'toolbar'
- self.title = 'Futsal World'
- self.left_action_items = [['menu', lambda x: app.nav_drawer.toggle()]]
- self.right_action_items = [['more-vert', lambda x: self.dots_menu.open(self.ids.right_actions)]]
- self.size_hint_y = .2
- self.tab1.text = 'News'
- self.tab1.text_color = (1, 1, 1, 1) # white color
- self.tab1.bind(on_release=self.change_screen)
- self.tab2.text = 'Livescores'
- self.tab2.text_color = (1, 1, 1, 1) # white color
- self.tab2.bind(on_release=self.change_screen)
- self.tabs_layout.canvas.after.get_group('rectangle')[0].size = (self.tab1.width, dp(4))
- self.x = self.tab1.width
- self.y = dp(4)
- self.temp_size = (self.x, self.y)
- self.bind(temp_size=self.tabs_layout.canvas.after.get_group('rectangle')[0].setter('size'))
- def change_screen(self, instance):
- self.move_rect(instance)
- if instance.name == 'tab1':
- app.root.ids['sm'].change_screen('News')
- if instance.name == 'tab2':
- if not app.root.ids['sm'].has_screen('Livescores'):
- app.root.ids['sm'].add_widget(LiveScoresScreen())
- app.root.ids['sm'].change_screen('Livescores')
- else:
- app.root.ids['sm'].change_screen('Livescores')
- def move_rect(self, instance):
- animation = Animation(size=(instance.width, dp(4)), duration=.4)
- animation &= Animation(pos=(instance.x, instance.y), duration=.4)
- animation.start(self.tabs_layout.canvas.after.get_group('rectangle')[0])
Advertisement
Add Comment
Please, Sign In to add comment