def status_bar_refresh(self, s_dict=search_dict): """Updates status bar text with chosen period""" from parsers import date_transform p = '' c = '' if s_dict['P_DATE']: l = list(s_dict['P_DATE'][1:]) for i in range(0, len(l)): l[i] = date_transform(l[i], '.', 0) if len(l) == 2: p = 'период покупок c ' + l[0] + ' по ' + l[1] else: p = 'период покупок: ' + l[0] if s_dict['C_DATE']: l = list(s_dict['C_DATE'][1:]) for i in range(0, len(l)): l[i] = date_transform(l[i], '.', 0) if len(l) == 2: c = 'период замены c ' + l[0] + ' по ' + l[1] else: c = 'период замены: ' + l[0] if p and c: self.setStatusTip('Выбран ' + p + ' и ' + c + '.') elif p: self.setStatusTip('Выбран ' + p + '.') elif c: self.setStatusTip('Выбран ' + c + '.') else: self.setStatusTip('Период не выбран')
def fill_in_table(self, data_rows): """takes a list as an arg and fills the table with its rows and columns""" from parsers import date_transform self.ui.the_table.setRowCount(len(data_rows)) # setting row number by number of strings list_of_ids = [] # the list is for table's vertical header # query_strings = '''SELECT NAME, PHONE, P_DATE, C_DATE, COMMENT, INFORMED, AGREED, CONTRACT, B_B, B_A, ID # FROM NOTIFY NATURAL JOIN NAMES WHERE ''' + ' AND '.join(str(s) for s in query_strings) for row in range(0, len(data_rows)): # from first to last row: list_of_ids.append(str(data_rows[row][-1])) # add new purchase-id from current row data_rows[row] = [f for f in data_rows[row]] # changing the row from tuple to list TODO: use list()? data_rows[row][2] = date_transform(data_rows[row][2], '.', 0) # transforming dates from SQLite format data_rows[row][3] = date_transform(data_rows[row][3], '.', 0) # to human-readable format (dd-mm-yyyy) for column in range(0, 10): # filling table loop item = QtGui.QTableWidgetItem(str(data_rows[row][column])) # creating new item with text from db if (column < 4) or (column > 6): # setting columns 0-3 and 6-9 item.setFlags(QtCore.Qt.ItemIsEnabled) # user read-only self.ui.the_table.setItem(row, column, item) # inserting a new item in a cell self.ui.the_table.setVerticalHeaderLabels(list_of_ids) # filling vertical headers labels
def change_button_text(self, date=''): """changes text on date buttons depending on what period or date is set""" from parsers import date_transform if date: l = list(search_dict[date][1:]) for i in range(0, len(l)): l[i] = date_transform(l[i], '.', 0) caption = '\n'.join(l) if date == 'P_DATE': self.ui.p_dateButton.setText(caption) elif date == 'C_DATE': self.ui.c_dateButton.setText(caption) else: self.ui.p_dateButton.setText('Дата\nпокупки') self.ui.c_dateButton.setText('Дата\nзамены')