Skip to content

Instantly share code, notes, and snippets.

@wasimafser
Created July 7, 2019 14:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wasimafser/233e8ecfd715c2f632b17e19925422d9 to your computer and use it in GitHub Desktop.
Save wasimafser/233e8ecfd715c2f632b17e19925422d9 to your computer and use it in GitHub Desktop.
from kivy.app import App
from kivy.lang import Builder
from kivy.uix.button import Button
from kivy.uix.floatlayout import FloatLayout
from kivy.uix.gridlayout import GridLayout
from kivy.uix.recycleview import RecycleView
from kivy.uix.modalview import ModalView
from kivy.uix.textinput import TextInput
from kivy.properties import ObjectProperty, StringProperty, NumericProperty
import db
Builder.load_string("""
<ItemsGrid>:
cols: 4
Label:
text: root.title
Label:
text: root.current
Label:
text: root.lowest
Button:
size_hint_x: 0.25
text: 'x'
<AllItemsTable>:
viewclass: 'ItemsGrid'
RecycleBoxLayout:
default_size: None, dp(56)
default_size_hint: 1, None
size_hint_y: None
height: self.minimum_height
orientation: 'vertical'
<AppContainer>
Label:
text: "Price Checker"
size_hint_y: 0.05
pos_hint: {'top': 1}
AllItemsTable:
pos_hint: {'top': 0.9}
Button:
text: '+'
size_hint: (0.1, 0.1)
pos_hint: {'right': 1}
on_press: root.add_url_modal.open()
<AddUrlModal>
size_hint: (0.25, 0.10)
BoxLayout:
orientation: 'vertical'
TextInput:
id: url
size_hint_y: 0.50
hint_text: "URL"
BoxLayout:
size_hint_y: 0.50
orientation: 'horizontal'
Button:
text: "Add"
on_release: root.add_url(url.text)
Button:
text: "Cancel"
on_release: root.dismiss()
""")
class ItemsGrid(GridLayout):
title = StringProperty('Item')
current = StringProperty('Current')
lowest = StringProperty('Lowest')
pass
class AllItemsTable(RecycleView):
def __init__(self, **kwargs):
self.data = [{'title': str(x), 'current': str(x+1), 'lowest': str(x+10)} for x in range(5)]
class AddUrlModal(ModalView):
def add_url(self, url):
print(url)
db.add_url(url)
class AppContainer(FloatLayout):
add_url_modal = ObjectProperty(None)
def __init__(self, **kwargs):
super(AppContainer, self).__init__(**kwargs)
self.add_url_modal = AddUrlModal()
def print_info(self):
print("Hello")
class PriceApp(App):
def build(self):
return AppContainer()
if __name__ == '__main__':
PriceApp().run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment