Hello,
My first post so if I miss something in proper edict let me know as well. I am just starting out in using Pythonista.
I am trying to make an attendance app. I want a Ui to pop up and it will have a date field, meeting description field, last name, first name, and two buttons that will say Here and Not here.
I am pulling from a SQLite database. I have two tables, one a members table that stores the names and an attendance table that will store the meeting date and who attended. I am able to pull a list from the table and get the first name displayed in my Ui.
What is suppose to happen is when I press Here or Not Here, the names displayed on the UI should go to the next name on the imported list. But It doesn’t seem to display the next one. I am at a loss where to fix. I have been trying all different ways but have failed.
UPDATE:
I figured out the loop and where to have it run within the button function. Below is the entire script. I hope it will help others.
Here is my code so far:
import ui
import sqlite3
attendanceView = ui.View('attendance_UI.pyui')
conn = sqlite3.connect('fire_department.db')
cur = conn.cursor()
cur.execute('SELECT id,last_name,first_name FROM members ORDER BY last_name ASC')
members_list = cur.fetchall()
list_config = 0
s_listConfig = str(list_config)
#member = members_list[list_config]
#member_id = member[0]
#lastName = member[1]
#firstName = member[2]
#@ui.in_background
def button_here(sender):
lastName = sender.superview['lastnameEntry']
firstName = sender.superview['firstnameEntry']
count = sender.superview['listCount']
buttonLabel = sender.superview['hereButton']
member = members_list[int(count.text)]
lastName.text = member[1]
firstName.text = member[2]
new_count = int(count.text) + 1
count.text = str(new_count)
buttonLabel.title = 'Here'
def button_notHere(sender):
lastName = sender.superview['lastnameEntry']
firstName = sender.superview['firstnameEntry']
count = sender.superview['listCount']
buttonLabel = sender.superview['hereButton']
member = members_list[int(count.text)]
lastName.text = member[1]
firstName.text = member[2]
new_count = int(count.text) + 1
count.text = str(new_count)
v = ui.load_view('attendance_UI')
v['listCount'].text = s_listConfig
#v['lastnameEntry'].text = lastName
#v['firstnameEntry'].text = firstName
v.present('sheet')
Any help in tweaking this to make it cycle through would be greatly appreciated.