daily pastebin goal
12%
SHARE
TWEET

py files

a guest May 11th, 2016 17 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. main.py:
  2.  
  3. from classes import *
  4. from screens import *
  5.  
  6. from kivy.app import App
  7. from kivy.uix.widget import Widget
  8. from kivy.config import Config
  9.  
  10. from kivy.uix.screenmanager import ScreenManager, Screen, FadeTransition
  11. from kivy.lang import Builder
  12.  
  13. Config.set('graphics','height',500)
  14. Config.set('graphics','width',350)
  15.  
  16. layout = Builder.load_file("main.kv")
  17. class MainApp(App):
  18.     def build(self):
  19.         return layout
  20.        
  21. if __name__ == '__main__':
  22.     MainApp().run()
  23.  
  24.  
  25.  
  26. classes.py:
  27.  
  28. class Object:
  29.     def __init__(self,name,category,img):
  30.         self.name=name
  31.         self.category=category
  32.         self.img=img
  33.     def GetName(self):
  34.         return self.name
  35.     def GetCategory(self):
  36.         return self.category
  37.     def GetImg(self):
  38.         return self.img
  39.  
  40.  
  41.  
  42. screens.py:
  43.  
  44. from kivy.uix.screenmanager import ScreenManager, Screen, FadeTransition
  45. from kivy.properties import StringProperty
  46.  
  47. from classes import *
  48. #======================================#
  49. #=========  SCREENS ===================#
  50. #======================================#
  51.  
  52. class ScreenManagement(ScreenManager):
  53.     pass
  54.  
  55. class MainScreen(Screen):
  56.     pass
  57.    
  58. class CategorySelectScreen(Screen):
  59.     selected = "All"
  60.    
  61. class DictScreen(Screen):
  62.    
  63.     def NextItem(self,obj,i):
  64.         if i==len(obj)-1:
  65.             i=0
  66.         else:
  67.             i=i+1
  68.         print "\nNEXT ITEM\nAktualny indeks:"+str(i)
  69.         return i
  70.        
  71.     def PrevItem(self,obj,i):
  72.         if i==0:
  73.             i=len(obj)-1
  74.         else:
  75.             i=i-1
  76.         print "\nPREVIOUS ITEM\nAktualny indeks:"+str(i)
  77.         return i
  78.        
  79.     def ChangeLabel(self,obj,i):
  80.         name_text=obj[i].GetName()
  81.         print "Aktualna nazwa:"+name_text
  82.         print obj[i].name
  83.         return name_text
  84.        
  85.     def ChangeImage(self,obj,i):   
  86.         imagepath = "data/img/"+str(obj[i].GetImg())
  87.         print "Aktualny obrazek:"+imagepath
  88.         return imagepath
  89.        
  90.     def ChangeCategory(self,obj,i):
  91.         categoryname_text=obj[i].GetCategory()
  92.         print "Aktualna kategoria:"+categoryname_text
  93.         return categoryname_text
  94.        
  95.     def CategorySelect(self,obj,cat):
  96.         current=[]
  97.         if cat=="All":
  98.             return obj
  99.         else:
  100.             for item in obj:
  101.                 if item.category==cat:
  102.                     current.append(item)
  103.             return current
  104.        
  105.        
  106.     index=0    
  107.     objects=[]
  108.     current_category = "All"
  109.     selected_objects=[]
  110.    
  111. # test objects #
  112.  
  113.     obj1 = Object("Bike","Sport","bike.jpg")
  114.     obj2 = Object("Ball","Sport","ball.jpg")
  115.     obj3 = Object("Volleyball","Sport","volleyball.jpg")
  116.     obj4 = Object("Basketball","Sport","basketball.jpg")
  117.    
  118.     obj5 = Object("Apple","Food","apple.jpg")
  119.     obj6 = Object("Bread","Food","bread.jpg")
  120.     obj7 = Object("Chicken","Food","chicken.jpg")
  121.     obj8 = Object("Potato","Food","potato.jpg")
  122.    
  123.     objects.append(obj1)
  124.     objects.append(obj2)
  125.     objects.append(obj3)
  126.     objects.append(obj4)
  127.     objects.append(obj5)
  128.     objects.append(obj6)
  129.     objects.append(obj7)
  130.     objects.append(obj8)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top