def save(): new_asset = {"Currency": currency_spinbox.get(), "Amount": amount_entry.get(), "Note": note.get("1.0", "end-1c"), } if manage_db.check_for_real_numbers(new_asset["Amount"]): manage_db.add_asset(new_asset) manage_db.delete_row_from_table( "assets", "timestamp", asset[0]) top_window.destroy() Assets.populate_canvas(parent)
def delete(parent, to_delete, choice_window): """deletes unwanted share""" if messagebox.askyesno("Delete", "Are you sure you want to delete this?"): if to_delete[6] == "": manage_db.delete_row_from_table("gpw_shares", "timestamp", to_delete[0]) shares_page.Shares.curent_canvas(parent) else: manage_db.delete_row_from_table("gpw_shares_closed", "timestamp", to_delete[0]) shares_page.Shares.historical_canvas(parent) choice_window.destroy()
def save(): """save settings""" settings_dict = { "sms": str(sms_var.get()), "mail": str(email_var.get()), "screen": str(screen_var.get()), "id": id_entry.get(), "api": api_entry.get(), "p_number": number_entry.get(), "email": email_entry.get(), "from": from_time.get(), "to": to_time.get(), "break": break_time.get() } if email_pass.get().rstrip("*"): settings_dict["email_pass"] = email_pass.get() else: settings_dict["email_pass"] = current_settings[7] manage_db.delete_row_from_table('settings', 'sms', current_settings[0]) manage_db.add_settings(settings_dict) Settings.populate_frame(parent)
def delete_asset(): manage_db.delete_row_from_table( "assets", "timestamp", asset[0]) choice_window.destroy() Assets.populate_canvas(parent)
def save(): share = { "Name": name.get(), "Quantity": quantity.get(), "BuyingPrice": entry_price.get(), "BuyingDate": entry_date.get(), "SellingPrice": exit_price.get(), "SellingDate": exit_date.get(), "Cost": '' } # cost depends on changing current share price but if a # share was sold, you need to consider fixed selling price. # Therefore sold cost can be calculated and added to dictionary # without the need of calculating it all over again: if exit_price.get() != "": total_buying_price = int(share["Quantity"]) * float( share["BuyingPrice"]) total_selling_price = int(share["Quantity"]) * float( share["SellingPrice"]) share["Cost"] = str( calculate.total_costs(total_buying_price, total_selling_price)) # Collect and save in order all user input from dividend # and dividend_date entries. # If no previous inputs: if old_share[8] == "": list_of_entries = (div_2, div_3, div_4, div_5) list_of_dates = (div_date_2, div_date_3, div_date_4, div_date_5) share["Dividends"] = "" if div_1.get(): share["Dividends"] = (div_1.get() + "-" + div_date_1.get()) for counter, entrie in enumerate(list_of_entries): if entrie.get(): share["Dividends"] = (share["Dividends"] + "|" + entrie.get() + "-" + list_of_dates[counter].get()) # If previous entries exist, replace the ones displayed # (up to 4 latest) with the new ones (in case edits were made) else: list_of_entries = (div_1, div_2, div_3, div_4, div_5) list_of_dates = (div_date_1, div_date_2, div_date_3, div_date_4, div_date_5) number_of_entries_to_clear = 4 all_dividents = old_share[8].split("|") for __ in range(0, number_of_entries_to_clear): if all_dividents: # if len(all_dividents) > 0: all_dividents.remove(all_dividents[len(all_dividents) - 1]) for counter, entrie in enumerate(list_of_entries): if entrie.get(): all_dividents.append(entrie.get() + "-" + list_of_dates[counter].get()) share["Dividends"] = '|'.join(all_dividents) # check if all input correct if (manage_db.check_if_valid_name(name.get()) and manage_db.check_for_real_numbers(entry_price.get()) and manage_db.check_for_real_numbers(exit_price.get()) or exit_price.get() == '' and manage_db.check_date_format(entry_date.get()) and manage_db.check_date_format(exit_date.get()) or exit_date.get() == ''): top_window.destroy() if old_share[6] == "": manage_db.delete_row_from_table("gpw_shares", "timestamp", old_share[0]) else: manage_db.delete_row_from_table("gpw_shares_closed", "timestamp", old_share[0]) if share["SellingDate"] == "": manage_db.add_share("gpw_shares", share) manage_db.add_current_price( share["Name"], scrap_web.pull_current_price(share["Name"])) shares_page.Shares.curent_canvas(parent) else: manage_db.add_share("gpw_shares_closed", share) shares_page.Shares.historical_canvas(parent)
def delete_asset(to_delete): manage_db.delete_row_from_table("reports", "profile", to_delete[0][0]) choice_window.destroy() Watched.populate_canvas(parent)