2n2u

Untitled

Apr 11th, 2016
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.12 KB | None | 0 0
  1.  
  2. class MainToolBar(Toolbar):
  3.     dots_menu = ObjectProperty()
  4.     tabs_layout = ObjectProperty()
  5.     tab1 = ObjectProperty()
  6.     tab2 = ObjectProperty()
  7.     sm = ObjectProperty()
  8.     x = NumericProperty(0)
  9.     y = NumericProperty(0)
  10.     temp_size = ReferenceListProperty(x,y)
  11.     temp_pos = ReferenceListProperty()
  12.  
  13.     def __init__(self, **kwargs):
  14.         super(MainToolBar, self).__init__(**kwargs)
  15.         Clock.schedule_once(self.my_init, -1)
  16.  
  17.     def my_init(self, dt):
  18.         self.dots_menu = DotsMenu()
  19.         self.id = 'toolbar'
  20.         self.title = 'Futsal World'
  21.         self.left_action_items = [['menu', lambda x: app.nav_drawer.toggle()]]
  22.         self.right_action_items = [['more-vert', lambda x: self.dots_menu.open(self.ids.right_actions)]]
  23.         self.size_hint_y = .2
  24.         self.tab1.text = 'News'
  25.         self.tab1.text_color = (1, 1, 1, 1)  # white color
  26.         self.tab1.bind(on_release=self.change_screen)
  27.         self.tab2.text = 'Livescores'
  28.         self.tab2.text_color = (1, 1, 1, 1)  # white color
  29.         self.tab2.bind(on_release=self.change_screen)
  30.         self.tabs_layout.canvas.after.get_group('rectangle')[0].size = (self.tab1.width, dp(4))
  31.         self.x = self.tab1.width
  32.         self.y = dp(4)
  33.         self.temp_size = (self.x, self.y)
  34.         self.bind(temp_size=self.tabs_layout.canvas.after.get_group('rectangle')[0].setter('size'))
  35.  
  36.     def change_screen(self, instance):
  37.         self.move_rect(instance)
  38.         if instance.name == 'tab1':
  39.             app.root.ids['sm'].change_screen('News')
  40.         if instance.name == 'tab2':
  41.             if not app.root.ids['sm'].has_screen('Livescores'):
  42.                 app.root.ids['sm'].add_widget(LiveScoresScreen())
  43.                 app.root.ids['sm'].change_screen('Livescores')
  44.             else:
  45.                 app.root.ids['sm'].change_screen('Livescores')
  46.  
  47.     def move_rect(self, instance):
  48.  
  49.         animation = Animation(size=(instance.width, dp(4)), duration=.4)
  50.         animation &= Animation(pos=(instance.x, instance.y), duration=.4)
  51.         animation.start(self.tabs_layout.canvas.after.get_group('rectangle')[0])
Advertisement
Add Comment
Please, Sign In to add comment