2n2u

Untitled

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