Advertisement
Guest User

Untitled

a guest
Aug 21st, 2018
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.20 KB | None | 0 0
  1. from kivy.app import App
  2. from kivy.uix.screenmanager import ScreenManager, Screen
  3. from kivy.properties import ObjectProperty
  4. from kivy.uix.boxlayout import BoxLayout
  5. from kivy.lang import Builder
  6. from kivy.clock import mainthread
  7. from kivy.uix.button import Button
  8. from kivy.uix.popup import Popup
  9. from kivy.uix.label import Label
  10. from kivy.uix.button import Button
  11. from kivy.properties import BooleanProperty, StringProperty
  12. from kivy.uix.image import AsyncImage
  13. from kivy.uix.behaviors import ButtonBehavior
  14. from kivy.uix.image import Image
  15.  
  16. Builder.load_file('main.kv')
  17.  
  18. login_plz = Popup(title='Please login',
  19. content=Label(text='You need to login first'),
  20. size_hint=(None, None), size=(400, 400),
  21. auto_dismiss=True)
  22.  
  23.  
  24. class Menu(BoxLayout):
  25.  
  26. access_denied = BooleanProperty(True)
  27.  
  28.  
  29. class ScreenLogIn(Screen):
  30.  
  31.  
  32. @mainthread
  33. def verify_credentials(self):
  34. popup = Popup(title='Try again',
  35. content=Label(text='Wrong Email/Password'),
  36. size_hint=(None, None), size=(400, 400),
  37. auto_dismiss=True)
  38.  
  39. try:
  40.  
  41. if len(self.ids.login.text) > 20 or len(self.ids.passw.text) > 32:
  42. popup.open()
  43.  
  44.  
  45.  
  46. elif self.ids.login.text == "a" and self.ids.passw.text == "a":
  47. App.get_running_app().root.access_denied = False
  48. self.manager.current = "match"
  49.  
  50.  
  51. else:
  52. App.get_running_app().root.access_denied = True
  53.  
  54. popup.open()
  55. except Exception as e:
  56. pass
  57.  
  58.  
  59. class ScreenNearUsers(Screen):
  60.  
  61. @mainthread
  62. def on_enter(self):
  63. if App.get_running_app().root.access_denied is True:
  64. self.manager.current = 'login'
  65. login_plz.open()
  66. else:
  67. for i in xrange(31):
  68. button = Button(text="B_" + str(i))
  69. self.ids.grid.add_widget(button)
  70.  
  71.  
  72. class ScreenMatch(Screen):
  73.  
  74.  
  75.  
  76. def on_enter(self, *args):
  77. if App.get_running_app().root.access_denied is True:
  78. self.manager.current = 'login'
  79. login_plz.open()
  80. else:
  81. for i in range(10):
  82. src = "http://placehold.it/480x270.png&text=slide-%d&.png" % i
  83. image = AsyncImage(source=src, allow_stretch=True, keep_ratio=False, opacity=1, size_hint=(1, 1.3),
  84. pos_hint={'center_x': 0.5, 'center_y': 0.75}, border=True)
  85. self.ids.carousel.add_widget(image)
  86.  
  87. class ImageButton(ButtonBehavior, Image):
  88. def __init__(self, **kwargs):
  89. super(ImageButton, self).__init__(**kwargs)
  90.  
  91.  
  92.  
  93. class ScreenChats(Screen):
  94.  
  95.  
  96. def on_enter(self, *args):
  97. if App.get_running_app().root.access_denied is True:
  98. self.manager.current = 'login'
  99. login_plz.open()
  100. else:
  101. # This is the button with the image below
  102. for i in range(4):
  103. button = ImageButton(source=('Trifecta.png'), size=(200,200), size_hint=(None,None), text='some text')
  104. self.ids.chat_layout.add_widget(button)
  105.  
  106.  
  107.  
  108. class ScreenUserProfile(Screen):
  109. def on_enter(self, *args):
  110. if App.get_running_app().root.access_denied is True:
  111. self.manager.current = 'login'
  112. login_plz.open()
  113. else:
  114. pass
  115.  
  116.  
  117. class Manager(ScreenManager):
  118. screen_log_in = ObjectProperty(None)
  119. screen_near_user = ObjectProperty(None)
  120. screen_match = ObjectProperty(None)
  121. screen_chats = ObjectProperty(None)
  122. screen_user_profile = ObjectProperty(None)
  123.  
  124.  
  125. class MenuApp(App):
  126.  
  127.  
  128.  
  129.  
  130.  
  131.  
  132. def build(self):
  133. return Menu()
  134.  
  135. def on_start(self):
  136. self.current_screen = 'login'
  137.  
  138.  
  139.  
  140.  
  141.  
  142. if __name__ == '__main__':
  143. MenuApp().run()
  144.  
  145. <Menu>:
  146. manager: screen_manager
  147. orientation: "vertical"
  148. id: action
  149.  
  150. ActionBar:
  151. size_hint_y: 0.1
  152. background_color: 0, 0, 1000, 10
  153. background_normal: ""
  154. ActionView:
  155. ActionPrevious:
  156. app_icon:""
  157. with_previous: False
  158. markup:True
  159. font_size:"16dp"
  160. ActionButton:
  161. id: near_users
  162. size_hint: 1, 1
  163. height: self.texture_size[ 1 ]
  164. width: self.texture_size[ 0 ] + 40
  165. minimum_width: self.texture_size[ 0 ] + 60
  166.  
  167. halign: "center"
  168. icon: 'icons/internet.png'
  169. disabled: True if root.access_denied else False
  170. on_press: root.manager.current = 'near_users'
  171. ActionButton:
  172. id: matching_bar
  173. size_hint: 1, 1
  174.  
  175. height: self.texture_size[ 1 ]
  176. width: self.texture_size[ 0 ] + 40
  177. minimum_width: -self.texture_size[ 0 ] + 60
  178. halign: "center"
  179. text: "Matching"
  180. disabled: True if root.access_denied else False
  181. on_press: root.manager.current= 'match'
  182. ActionButton:
  183. id: chat
  184. size_hint: 1, 1
  185.  
  186. height: self.texture_size[ 1 ]
  187. width: self.texture_size[ 0 ] + 40
  188. minimum_width: self.texture_size[ 0 ] + 60
  189.  
  190. halign: "center"
  191. text: "chat"
  192. disabled: True if root.access_denied else False
  193. on_press: root.manager.current = 'chats'
  194. ActionButton:
  195. id: profile
  196. size_hint: 1, 1
  197.  
  198. height: self.texture_size[ 1 ]
  199. width: self.texture_size[ 0 ] + 40
  200. minimum_width: self.texture_size[ 0 ] + 60
  201.  
  202. halign: "center"
  203. text: "Profile"
  204. disabled: True if root.access_denied else False
  205. on_press: root.manager.current = 'profile'
  206. Manager:
  207. id: screen_manager
  208.  
  209. <ScreenLogIn>:
  210. id: login_screen
  211. BoxLayout:
  212. orientation: "vertical"
  213. padding: 20, 20
  214. spacing: 50
  215. TextInput:
  216. id: login
  217. size_hint_y: None
  218.  
  219. multiline: False
  220. TextInput:
  221. id: passw
  222. size_hint_y: None
  223. multiline: False
  224. password: True # hide password
  225. Button:
  226. text: "Log In"
  227. on_release: root.verify_credentials()
  228.  
  229. <ScreenNearUsers>:
  230. ScrollView:
  231. GridLayout:
  232. id: grid
  233. size_hint_y: None
  234. height: self.minimum_height
  235. cols: 2
  236. row_default_height: '20dp'
  237. row_force_default: True
  238. spacing: 0, 0
  239. padding: 0, 0
  240.  
  241.  
  242.  
  243. <ScreenMatch>:
  244. name: 'Carousel'
  245. fullscreen: True
  246.  
  247.  
  248.  
  249. BoxLayout:
  250. size_hint_y: None
  251. height: '48dp'
  252.  
  253. Button:
  254.  
  255. text: 'last user'
  256. id: last_user
  257.  
  258. Button:
  259.  
  260. text: 'like'
  261.  
  262. Button:
  263. text: 'super like'
  264. on_release: carousel.load_previous()
  265.  
  266. Button:
  267. text: 'Dislike'
  268. on_release: carousel.load_next()
  269.  
  270.  
  271. AnchorLayout:
  272. anchor_x: 'center'
  273. anchor_y: 'center'
  274.  
  275.  
  276.  
  277.  
  278. Carousel:
  279.  
  280. id: carousel
  281. loop: last_user.state == 'down'
  282.  
  283.  
  284.  
  285. <ScreenChats>:
  286.  
  287.  
  288. ScrollView:
  289.  
  290. GridLayout:
  291. id: chat_layout
  292. size_hint_y: None
  293. height: self.minimum_height
  294. cols: 1
  295. row_default_height: '125dp'
  296. row_force_default: True
  297. spacing: 0, 0
  298. padding: 0, 0
  299.  
  300.  
  301.  
  302. <ScreenUserProfile>:
  303.  
  304. Button:
  305. text: "stuff4"
  306.  
  307. <Manager>:
  308. id: screen_manager
  309. screen_log_in: screen_log_in
  310. screen_near_users: screen_near_users
  311. screen_match: screen_match
  312. screen_chats: screen_chats
  313. screen_user_profile: screen_user_profile
  314.  
  315. ScreenLogIn:
  316. id: screen_log_in
  317. name: 'login'
  318. manager: screen_manager
  319. ScreenNearUsers:
  320. id: screen_near_users
  321. name: 'near_users'
  322. manager: screen_manager
  323. ScreenMatch:
  324. id: screen_match
  325. name: 'match'
  326. manager: screen_manager
  327. ScreenChats:
  328. id: screen_chats
  329. name: 'chats'
  330. manager: screen_manager
  331. ScreenUserProfile:
  332. id: screen_user_profile
  333. name: 'profile'
  334. manger: screen_manager
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement