Wow! This concept is great! This definitely seems like a way better solution then what I was doing. I am going to mess around with this and I will update it with what I got to see how far I have gotten.
Thanks for this!!
Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
Wow! This concept is great! This definitely seems like a way better solution then what I was doing. I am going to mess around with this and I will update it with what I got to see how far I have gotten.
Thanks for this!!
I am. It’s the same name as this one. I am just starting my journey as a developer. I only have one 1 public repository right now. I am trying to grow and make more.
Please send me a demo. That would work for the EMS call and the Fire call type. When a Fire/EMS call should happen it would be easier to select the names of the people who showed up to the call. It might even prove a better way then what I am trying to do.
The way I have it setup, I was envisioning it as when the secretary is doing roll call in the meeting, the secretary can just press the here or not here button as this person is reading out the names.
@JonB How would I use dialogs?
I am still new at all of this. But I will start researching that suggestion.
The people in the roll call will always be the same.
My end goal is to try make it easy to take attendance and have it upload to the database. The first script that I updated does it where I manually write it in to a text field.
Now I am trying to improve it where it’s even easier. If I can just select the meeting type it would make filling out the form even quicker. There are more than 3 types of situations but if I can get it with 3 then I can do it with the rest.
I’m working on a table view right now but I can’t pull the text value from row 1. I can’t find any examples and the documentation is super vague.
I created a table that is to break up the meeting type. It lists:
Dept Meeting
Fire Call
Ems call
I want to select one of these and it will take the text value and write it to SQL. But I can’t figure out the attribute structure or the correct command to get it.
Here is what I have:
import ui
import sqlite3
attendanceView = ui.View('attendance_UI.pyui')
list_config = 0
s_listConfig = str(list_config)
def button_here(sender):
lastName = sender.superview['lastnameEntry']
firstName = sender.superview['firstnameEntry']
count = sender.superview['listCount']
buttonLabel = sender.superview['hereButton']
meeting_date = sender.superview['datefield']
meeting_type = sender.superview['meetingtypeEntry']
if count == 0:
new_count = int(count.text) + 1
count.text = str(new_count)
else:
conn = sqlite3.connect('fire_department.db')
cur = conn.cursor()
cur.execute('SELECT id,last_name,first_name,status FROM members ORDER BY status,last_name;')
members_list = cur.fetchall()
member = members_list[int(count.text)]
cur.execute("INSERT INTO attendance(attendance_type,present,date,members_id) Values ('{}','{}','{}','{}')".format(meeting_type.text,'Here',meeting_date.text,str(member[0])));
conn.commit()
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']
meeting_date = sender.superview['datefield']
meeting_type = sender.superview['meetingtypeEntry']
meeting_select = sender.superview['attendanceTable']
# This is where i am trying to pull from the table view of the meeting type
meeting_select = ui.TableView()
meeting_select = meeting_select.selected_row
if count == 0:
new_count = int(count.text) + 1
count.text = str(new_count)
else:
conn = sqlite3.connect('fire_department.db')
cur = conn.cursor()
cur.execute('SELECT id,last_name,first_name,status FROM members ORDER BY status,last_name;')
members_list = cur.fetchall()
member = members_list[int(count.text)]
cur.execute("INSERT INTO attendance(attendance_type,present,date,members_id) Values ('{}','{}','{}','{}')".format(meeting_select.text,'Not Here',meeting_date.text,str(member[0])));
conn.commit()
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.present('sheet')
The def button_notHere is where I am trying to pull the table data. Once I get the not here button to work then I would put it into the here as well. The name i tide to the table in the Ui editor is attendanceTable.
Thank you! That is definitely much cleaner
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.