Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from kivy.app import App
- from kivy.lang import Builder
- from kivy.uix.screenmanager import ScreenManager, Screen
- import sqlite3
- import datetime
- import shutil
- KV = """
- <ScreenManagement>:
- EntryInterface:
- name: 'test'
- <EntryInterface>:
- BoxLayout:
- TextInput:
- id: textInput
- Button:
- text:'Save'
- on_press: root.save()
- """
- class ScreenManagement(ScreenManager):
- pass
- class EntryInterface (Screen):
- def save(self):
- self.now = str(datetime.datetime.now())
- self.time = self.now[11:22]
- #formatting the text
- self.time = self.time.replace(':','_')
- self.time = self.time.replace('.','_')
- if(self.ids.textInput.text ==''):
- self.stuff = 'Blank'
- else: self.stuff = self.ids.textInput.text
- conn = sqlite3.connect("test.db")
- cur = conn.cursor()
- cur.execute("INSERT INTO test_table VALUES (:stuff)", {'stuff': self.stuff})
- conn.commit()
- conn.close()
- self.ids.textInput.text = ''
- shutil.copy('test.db','BACKUP_'+self.time+'.db')
- class TestApp(App):
- title = "Login Screen"
- def build(self):
- Builder.load_string(KV)
- return ScreenManagement()
- if __name__ == "__main__":
- TestApp().run()
Advertisement
Add Comment
Please, Sign In to add comment