def reset(btn): if btn['text'] == "Start": global n new_data = random.randint(low, high, n) chosen_algorithms = [] for algorithm_showing in algorithms_showing: chosen_algorithms.append(algorithm_showing.algorithm) algorithm_showing.pack_forget() algorithms_showing.clear() for i in range(len(chosen_algorithms)): if i < 3: barchart = BarChart(chosen_algorithms[i], new_data.copy(), top_frame) else: barchart = BarChart(chosen_algorithms[i], new_data.copy(), middle_frame) barchart.pack() algorithms_showing.append(barchart)
def create(listbox, add_window, e1): global n n = int(e1.get()) data = random.randint(low, high, n) chosen_algorithms = [listbox.get(i) for i in listbox.curselection()] for algorithm_showing in algorithms_showing: algorithm_showing.pack_forget() algorithms_showing.clear() for i in range(len(chosen_algorithms)): alg = next(a for a in Algorithms if a.value == chosen_algorithms[i]) if i < 3: barchart = BarChart(alg, data.copy(), top_frame) else: barchart = BarChart(alg, data.copy(), middle_frame) barchart.pack() algorithms_showing.append(barchart) if len(algorithms_showing) > 0: btn["state"] = "active" reset_btn["state"] = "active" else: btn["state"] = "disabled" reset_btn["state"] = "disabled" add_window.destroy()