def listBuild(self): l = self.gui.rl.ids.bl_triList self.wItems = [] for ni, i in enumerate(self.triaItems): st = "" if i.status == 'DONE': st = "lat: {} lon: {}".format(i.trianPoint.lat, i.trianPoint.lon) ii = ThreeLineListItem(text="name:{} points:{} status:{}".format( i.name, len(i.points), i.status), secondary_text=st) self.wItems.append(ii) ii.on_release = partial(self.on_releaseItemTouch, ii, ni, i.name) l.add_widget(ii)
def updateDebts(self): self.ids.container.clear_widgets(children=None) idTable = [] nameTable = [] accountTable = [] currencyTable = [] typeTable = [] amountTable = [] dateTable = [] commentTable = [] conn = sqlite3.connect("moneyAppDatabase.db") cursor = conn.cursor() conn.execute("PRAGMA foreign_keys = 1") for row in cursor.execute("SELECT name, account, currency, type, amount, date, comment, id FROM Debts"): nameTable.append(row[0]) accountTable.append(row[1]) currencyTable.append(row[2]) typeTable.append(row[3]) amountTable.append(row[4]) dateTable.append(row[5][:-9]) commentTable.append(row[6]) idTable.append(row[7]) conn.commit() conn.close() for i in range(len(nameTable)): self.ids.container.add_widget(ThreeLineListItem(font_style = 'Subtitle2', secondary_font_style = 'Overline', tertiary_font_style = 'Overline', text = str(idTable[i]) + ". " + nameTable[i] + ': ' + str(amountTable[i]) + ' ' + currencyTable[i], secondary_text = str(dateTable[i]) + ', ' + accountTable[i], tertiary_text = commentTable[i], on_press = self.itemPressed))
def Update_Timeline(self, new_data): global DB_conn #try: if new_data != None: timeEnd = datetime.datetime.now() timeEnd = timeEnd.strftime("%H:%M") print(str(self.displayData) + " | new data :" + str(new_data)) addingData = {"name" : new_data["name"], "type": new_data["type"],"project": new_data["project"], "date":new_data["date"], "timeStart":new_data["timeStart"], "timeEnd":timeEnd, "timeSpent":new_data["timeSpent"]} print(str(addingData) + " || added too"+str(self.displayData)) self.displayData.append([addingData["name"],addingData["timeSpent"], addingData["type"],addingData["date"], addingData["timeStart"],addingData["project"]]) sql = ("INSERT INTO timetable(task_name, task_type,project_name, date, timeStart, timeEnd, timeSpent) VALUES (") for i in addingData.keys(): sql = sql +"'"+ str(addingData[i]) + "'" if i != list(addingData.keys())[-1]: sql = sql + ", " sql = sql + ")" print(sql) DB_conn.cursor().execute(sql) DB_conn.commit() else: print("no new data") #if self.parent.parent.ids.get("past_items") == True: listedItems = self.ids.past_items listedItems.clear_widgets() for i in self.displayData: listedItems.add_widget(ThreeLineListItem(text=(str(i[0]) + " | timespent: " + str(i[1])), secondary_text=("type: "+ i[2]+" | date: "+ str(i[3]) + "| start time: " + i[4] ), tertiary_text=("Project: " + i[5]))) print(i)
def get_message_from_server(self, response): # получает сообщение и записывает в Ui, выполняет в онлайн режиме пользователя for data in response: self.db.set_message(text_message=data[0], time=data[1], chat_id=data[3], author=data[2]) if self.object_chats.parent.current == 'Chat' and self._id_button[0] == data[3]: item_mes = ThreeLineListItem(text=data[0], secondary_text=data[2], tertiary_text=data[1]) self.object_chats.parent.ids.chat.ids.messages.add_widget(item_mes)
def build(self): screen = Screen() scroll = ScrollView() list_view = MDList() scroll.add_widget(list_view) for i in range(20): item = OneLineListItem(text="Item " + str(i)) list_view.add_widget(item) item2 = TwoLineListItem(text="Two Line item1", secondary_text="Hello world") item3 = ThreeLineListItem(text="Three Line item1", secondary_text="Hello world", tertiary_text="Sample text") icon = IconLeftWidget(icon="android") itemicon = ThreeLineIconListItem(text="Three Line item1", secondary_text="Hello world", tertiary_text="Sample text") itemicon.add_widget(icon) list_view.add_widget(item2) list_view.add_widget(item3) list_view.add_widget(itemicon) screen.add_widget(scroll) return screen
def searchResults(self): def chng(*args): if args[0] == datetime.datetime.now().date(): self.root.ids['search_test'].ids[ 'giveTest_sm'].current = 'Test' else: self.showToast("You only give this test on DATE:- " + args[0]) try: for root_dir, folders, files in walk("exam"): if files != []: for file in files: if file.endswith('.mock'): self.test_fileName = path.splitext(file)[0] test_date, test_name, test_id = self.test_fileName.split( ' ') self.root.ids['search_test'].ids[ 'search_options'].add_widget( ThreeLineListItem( text=test_name, secondary_text="ID:- " + test_id, tertiary_text="Date:- " + test_date, on_release=partial(chng, test_date))) except Exception as e: self.showToast(e)
def create_list(self): protest_name = self.app.ids.name.text protests = ThreeLineListItem(text="Name:" + protest_name, secondary_text="Location:" + self.app.ids.location.text, tertiary_text="Date:" + str(self.date)) self.app.ids.prolist.add_widget(protests) self.app.ids.screen_manager.current = "screen5"
def nieobecnosciList(self): nieobecnosc = self.nieobecnosci(self.lib.nieObecnosci()) for i in nieobecnosc: self.root.ids.nieobecnosci_1.add_widget( ThreeLineListItem(text=' '.join(i[:2]), secondary_text=i[2], tertiary_text=' '.join(i[3:]))) nieobecnosc2 = self.nieobecnosciW( self.lib.nieObecnosci(True))[:-(len(nieobecnosc))] + nieobecnosc for i in nieobecnosc2[::-1]: self.root.ids.nieobecnosci_2.add_widget( ThreeLineListItem(text=' '.join(i[:2]), secondary_text=i[2], tertiary_text=' '.join(i[3:])))
def load(self): for x in range(len(self.lis)): items = ThreeLineListItem( text=f'No {x + 1}', secondary_text=f"REGNO: {self.lis[x]['REGNO']}", tertiary_text=f"Issue: {self.lis[x]['REMARK']}", on_release=self.target) self.ids.lister.add_widget(items)
def __init__(self, content, **kwargs): super(ProvinceContent, self).__init__(**kwargs) self.cols = 1 self.adaptive_height = True for i in content: numbers = i[2] + ' ' + i[3] self.add_widget( ThreeLineListItem(text=i[0], secondary_text=i[1], tertiary_text=numbers))
def on_enter(self, *args): for i in range(129): if df_cleaned['diet'].iloc[i] != '-1': item = ThreeLineListItem( text=df_cleaned['name'].iloc[i], secondary_text=df_cleaned['diet'].iloc[i], tertiary_text=str(df_cleaned['price'].iloc[i]) + '$') rec_list.append(item.text) self.ids.container2.add_widget(item)
def get_message_from_server(self, response): self.db.set_message(text_message=response['text_message'], time=response['time'], chat_id=response['chat_id'], author=response['author']) if self._id_button[0] == response['chat_id']: item_mes = ThreeLineListItem(text=response['text_message'], secondary_text=response['author'], tertiary_text=response['time']) self.object_chats.root.ids.coc.add_widget(item_mes)
def on_start(self): hc_data = get_hospitals(params) for hosp in hc_data: self.root.ids.container.add_widget( ThreeLineListItem(text=hosp['hospital_name'], secondary_text=hosp['address'], tertiary_text= '{}, {} {}'.format(\ hosp['city'], hosp['state'], hosp['zip_code']) ) )
def get_message_from_server(self, response): for data in response: self.db.set_message(text_message=data[0], time=data[1], chat_id=data[3], author=data[2]) if self._id_button == data[3]: item_mes = ThreeLineListItem(text=data[0], secondary_text=data[2], tertiary_text=data[1]) self.object_chats.root.ids.coc.add_widget(item_mes)
def on_pre_enter(self, *args): self.parent.ids.chat.ids.toolbar_name.title = db.get_chat_name( _id_button[0]) ws.set_id_button(_id_button) Window.bind(on_key_down=self.key_action) messages = db.get_messages(_id_button[0]) for message in messages: item_mes = ThreeLineListItem(text=message[0], secondary_text=message[2], tertiary_text=message[1]) self.parent.ids.chat.ids.messages.add_widget(item_mes) ws.synch_messages()
def analysis(self, number_of_days, scroll_list): dt = datetime.today() days = dt.date() - timedelta(days=number_of_days) print(days) mycursor = sqliteConnection.cursor() mycursor.execute( f"SELECT a.task_name, a.scheduled_time, AVG(b.execution_time), COUNT(b.id_task), count(b.done_date) " f"FROM task_type a " f"JOIN work_plan b " f"ON a.id_type = b.id_type " f"WHERE b.scheduled_date <= DATE('now') AND scheduled_date > ?" f"GROUP BY b.id_type ", (days, )) rows = mycursor.fetchall() task_name = [] task_time = [] avg_time = [] number_of_task = [] done_tasks = [] for i in range(len(rows)): task_name.append(rows[i][0]) task_time.append(rows[i][1]) avg_time.append(rows[i][2]) number_of_task.append(rows[i][3]) done_tasks.append(rows[i][4]) for i in range(len(task_name)): if avg_time[i] == None: time_precent = "0" else: time_precent = str(int(avg_time[i] / task_time[i] * 100)) + "%" if done_tasks[i] == None: task_precent = "0" else: task_precent = str(int( done_tasks[i] / number_of_task[i] * 100)) + "%" if avg_time[i] == None: avg_time[i] = str(avg_time[i]) else: avg_time[i] = int(avg_time[i]) scroll_list.add_widget( ThreeLineListItem(text=str(task_name[i]), secondary_text=str(done_tasks[i]) + "/" + str(number_of_task[i]) + "/" + task_precent, tertiary_text=str(task_time[i]) + "/" + str(avg_time[i]) + "/" + time_precent))
def get_message_from_server( self, response ): # инициируется в момент получения сообщения, отображает новое сообщение в диалоге self.db.set_message(text_message=response['text_message'], time=response['time'], chat_id=response['chat_id'], author=response['author']) if self.object_chats.parent.current == 'Chat' and self._id_button[ 0] == response['chat_id']: item_mes = ThreeLineListItem(text=response['text_message'], secondary_text=response['author'], tertiary_text=response['time']) self.object_chats.parent.ids.chat.ids.messages.add_widget(item_mes)
def createContent(self): dpdl = self.dwparser.create_distro_page_data_list(self.distro) if len(dpdl) > 0: self.createPaginationImage(dpdl[0]) self.exist = True for i in list(dpdl[1]): text_1 = i.split(':')[0] + ':' text_2 = i.split(':')[1] self.ids.distro_info.add_widget( ThreeLineListItem(text=text_1, secondary_text=text_2)) else: self.exist = False
def get_message(self, chat_name): for key, value in self.chats.items(): if chat_name == value: self.chat_id = key ws.set_id_button([key]) break self.root.ids.coc.clear_widgets() messages = db.get_messages(self.chat_id) for name in messages: self.root.ids.coc.add_widget( ThreeLineListItem(text=name[0], secondary_text=name[2], tertiary_text=name[1])) ws.set_id_button(self.chat_id) ws.synch_messages()
def build(self): screen = Screen() scroll = ScrollView() list_view = MDList() scroll.add_widget(list_view) for i in range(20): items = ThreeLineListItem(text='Item ' + str(i + 1), secondary_text='Hello world', tertiary_text='third text') list_view.add_widget(items) screen.add_widget(scroll) return screen
def insert_local_db(self, response, text_input, username, date_sent, chat_id): if response['status'] == 'ok': self.db.set_message(text_message=text_input, time=date_sent, chat_id=chat_id, author=username) item_mes = ThreeLineListItem(text=text_input, secondary_text=username, tertiary_text=date_sent) self.object_chats.root.ids.coc.add_widget(item_mes) elif response['status'] == 'fail': item_mes = OneLineListItem( text='Error! The message was not delivered!') self.object_chats.root.ids.coc.add_widget(item_mes)
def display_results(self, nodes): anim = Animation(pos_hint={"center_x": 0.5}, duration=0.5) anim.start(self.ids["res_card"]) for itm in nodes: start = itm[0].rfind("/") end = itm[0].find(".pdf") name = itm[0][start + 1:end] print(itm[0]) self.ids.res_lst.add_widget( ThreeLineListItem( text=itm[0], secondary_text= f'Hard Keys match: {int(itm[1])}% Soft Keys match: {int(itm[2])}%', tertiary_text= f'Distance to Ideal Candidate: {int(itm[3])} lu', on_release=self.opn_file))
def insert_local_db(self, response, text_input, username, date_sent, chat_id, object_dialog): # записывает сообдения в локальное бд if response['status'] == 'ok': self.db.set_message(text_message=text_input, time=date_sent, chat_id=chat_id, author=username) item_mes = ThreeLineListItem(text=text_input, secondary_text=username, tertiary_text=date_sent) object_dialog.parent.ids.chat.ids.messages.add_widget(item_mes) elif response['status'] == 'fail': item_mes = OneLineListItem( text='Error! The message was not delivered!') object_dialog.parent.ids.chat.ids.messages.add_widget(item_mes)
def answerCheck(self): score = 0 for i in range(int(self.noOfQues)): test = self.testQuestion[i].split(',') self.root.ids['search_test'].ids['review_test'].add_widget( ThreeLineListItem( text=test[0], secondary_text="Your Answer:- " + self.userAnswer[i], tertiary_text="Correct Answer:- " + test[1], )) if self.userAnswer[i] == test[1]: score = score + 1 dialog = MDDialog(title="Result", size_hint=(.5, .3), text=str(score) + " marks out of " + self.noOfQues, auto_dismiss=False) dialog.open()
def change_name(self, *args, text): print(text) self.change_screen('editscreen') self.dialog.dismiss() self.deskripsi['history'].reverse() self.ids.editscreen.ids.container.clear_widgets() for i in self.deskripsi['history']: isi = ThreeLineListItem(text=i["position"], secondary_text=i["time"], tertiary_text=i["desc"], on_press=lambda x, item=i: self. copy_details(f'{i["position"]}\n' f'{i["time"]}\n' f'{i["desc"]}')) self.ids.editscreen.ids.container.add_widget(isi)
def build(self): screen = MDScreen() list_view = MDList() scroll = ScrollView() # item1=OneLineListItem(text='Item 1') # item2 =OneLineListItem(text='Item 2') # list_view.add_widget(item1) # list_view.add_widget(item2) for i in range(20): # items=OneLineListItem(text='Item '+ str(i)) # items = TwoLineListItem(text='Item ' + str(i), secondary_text='Hello World') items = ThreeLineListItem(text='Item ' + str(i), secondary_text='Hello World', tertiary_text='third text') list_view.add_widget(items) scroll.add_widget(list_view) screen.add_widget(scroll) return screen
def results(self): from kivymd.uix.label import MDLabel for root_dir, folders, files in walk("results"): if files == []: self.root.ids['result'].ids['results'].add_widget( MDLabel(text='You not give any mock test yet', halign='center')) else: for file in files: if file.endswith('.mock'): self.fileName = path.splitext(file)[0] date, name, id = self.fileName.split(' ') self.root.ids['result'].ids['results'].add_widget( ThreeLineListItem(text=name, secondary_text="ID:- " + id, tertiary_text="Date:- " + date, on_release=partial( self.resultsCarousel, self.fileName)))
def write_messages(self, data): if not data: self.object_chats.root.ids.box.clear_widgets() return correct_format_db = list() for i in range(len(data)): data[i].pop(4) data[i].pop(3) for tpl in self.db.get_messages(self._id_button[0]): correct_format_db.append(list(tpl)) if correct_format_db != data: self.db.delete_messages(self._id_button[0]) self.object_chats.root.ids.coc.clear_widgets() for message in data: self.db.set_message(message[0], message[1], self._id_button[0], message[2]) item_mes = ThreeLineListItem(text=message[0], secondary_text=message[2], tertiary_text=message[1]) self.object_chats.root.ids.coc.add_widget(item_mes)
def add_hosp_list(self): if global_text == None: # add popup text to say "PLEASE SELECT A MEASURE" self.manager.current = 'search_screen' self.dialog = MDDialog(text='Please Select a Measure') self.dialog.set_normal_height() self.dialog.open() else: # get hospital compare data HCData.send_hc_request() hc_data = HCData.get_hc_data() self.ids.hosp_contain.clear_widgets() # refreshes list for hosp in hc_data: self.ids.hosp_contain.add_widget(ThreeLineListItem(text=hosp['hospital_name'], secondary_text=hosp['address'], tertiary_text='{}, {} {}'.format(\ hosp['city'], hosp['state'], hosp['zip_code']), on_release=self.switch_screen))
def time(self): mycursor = main.sqliteConnection.cursor() mycursor.execute( "select a.task_name, a.scheduled_time, b.execution_time, avg(b.execution_time) " "from task_type a " "join work_plan b " "on a.id_type = b.id_type " "where b.scheduled_date = date('now') " "group by b.id_type ") rows = mycursor.fetchall() task_name = [] task_time = [] real_time = [] avg_time = [] for i in range(len(rows)): task_name.append(rows[i][0]) task_time.append(rows[i][1]) real_time.append(rows[i][2]) avg_time.append(rows[i][3]) print(avg_time) for i in range(len(task_name)): if real_time[i] == None: precent = "You need to measure the time first" else: precent = str(int(real_time[i] / task_time[i] * 100)) + "%" if avg_time[i] == None: avg_time[i] = str(avg_time[i]) else: avg_time[i] = int(avg_time[i]) self.ids.progress.add_widget( ThreeLineListItem(text=str(task_name[i]), secondary_text=str(real_time[i]) + "/" + str(task_time[i]) + "/" + str(avg_time[i]), tertiary_text=precent))