def profile_menu(login): print('logged as: ' + login) menu_commands = [ 'Show my gallery', 'Generate new art', 'Rate paintings', 'Save your changes & logout' ] index_ = 0 i = 0 logged_in = True while logged_in: print_magic_menu(menu_commands, index_, 'logged as: ' + login) index_, choice = get_input(index_, menu_commands) if index_ == 0 and choice == 1: if os.path.isfile("profiles/" + login + '.json'): picture = data_manager.import_from_file(login) pictures.display_gallery(picture) input("Press Enter to continue...") else: print('Your gallery is empty') input("Press Enter to continue...") if index_ == 1 and choice == 1: picture = pictures.generate_picture() pictures.display_picture(picture) choose_picture(login, picture) if index_ == 2 and choice == 1: picture = rating_pictures() gallery_ = grade_picture(picture) data_manager.export_to_file(login, gallery_) if index_ == 3 and choice == 1: logged_in = False
def change_colors(option, color, colors_list_for_user): color_proportions = data_manager.import_from_file("proportions") color_list = get_colors_data() color_to_change = color_list[color] if option == 1: color_proportions = list( filter(lambda a: a != color_to_change, color_proportions)) colors_list_for_user.remove(colors_list_for_user[color]) elif option == 2: color_proportions.append(color_to_change) elif option == 3: X = len(color_list) Y = len(color_proportions) index = random.randint(X, Y) for i in range(index): color_proportions.insert(Y, color_to_change) elif option == 4: for color_to_change in color_proportions: index = random.randint(0, 1) if index == 1: color_proportions.remove(color_to_change) data_manager.export_to_file("proportions", color_proportions, "w") return colors_list_for_user
def get_colors_list(percent_of_change): colors_list = data_manager.import_from_file("proportions") colors_list = random.sample(colors_list, len(colors_list)) x = int(percent_of_change * len(colors_list)) if x < 1: x = 1 for i in range(x): j = random.randint(0, len(colors_list) - 1) if colors_list[i] != colors_list[j]: colors_list[i] = colors_list[j] return colors_list
def make_gallery(picture, login, grade=5, price=100, number_of_grades=1): name = input("Enter picture name: ") file_ = "profiles/" + login + '.json' if os.path.isfile(file_): gallery = data_manager.import_from_file(login) else: gallery = {} gallery[name] = { "Author": login, "Picture": picture, "Grade": grade, "Price": price, "Number of grades": number_of_grades } return gallery
def rating_pictures(): artists = [] accounts_ = accounts.load_accounts_and_pass('accounts') for key, value in accounts_.items(): artists.append(key) for artist in artists: print(artist) choice = input('Choose artist to display his/her work: ') if choice in artists: if os.path.isfile('profiles/' + choice + '.json'): picture = data_manager.import_from_file(choice) return picture else: print('Artist has no paintings') else: print('No such artist!')