Advertisement
furas

Python - Kivy - example

May 17th, 2017
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.18 KB | None | 0 0
  1. # --- main.py ---
  2.  
  3. from kivy.app import App
  4. from kivy.uix.boxlayout import BoxLayout
  5.  
  6. class ChoseFile(BoxLayout):
  7.    
  8.     def select(self, *args):
  9.         try:
  10.             self.ids.label.text = args[1][0]
  11.         except Exception as ex:
  12.             print(ex)
  13.         else:
  14.             print(self.ids.label.text)
  15.  
  16.  
  17. class ChoseFileApp(App):
  18.    
  19.     def build(self):
  20.         return ChoseFile()
  21.    
  22.    
  23. if __name__ == '__main__':
  24.     ChoseFileApp().run()
  25.  
  26.  
  27. # --- chosefile.kv ---
  28.  
  29. <ChoseFile>:
  30.     FileChooserListView:
  31.         canvas.before:
  32.             Color:
  33.                 rgb: .4,.5,.5
  34.             Rectangle:
  35.                 pos: self.pos
  36.                 size: self.size
  37.         on_selection: root.select(*args)
  38.     FileChooserIconView:
  39.         canvas.before:
  40.             Color:
  41.                 rgb: .5,.4,.5
  42.             Rectangle:
  43.                 pos: self.pos
  44.                 size: self.size
  45.         on_selection: root.select(*args)
  46.     Label:
  47.         id: label
  48.         size_hint_y: .1
  49.         canvas.before:
  50.             Color:
  51.                 rgb: .5,.5,.4
  52.             Rectangle:
  53.                 pos: self.pos
  54.                 size: self.size
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement