def setup(self): window_layout = [[ sg.Text(f'GitHub Notifications: {notif_num}', key='notifications_num'), sg.Button('info', size=(5, 1)) ], [sg.T('') ], [sg.Multiline(notifications, size=(500, 200), key='output')], [sg.Text('')], [ sg.Ok(size=(10, 1)), sg.Button('To GitHub', size=(10, 1), key='open_url'), sg.Button('Mark all as read', size=(20, 1), key='read_all'), ]] self.window = sg.Window(f'GitHub Notifier ver.{version}', window_layout, icon=icon1) self.window.Finalize()
def main(): # List to sort num_bars = DATA_SIZE[0] // (BAR_WIDTH + 1) arr = [DATA_SIZE[1] // num_bars * i for i in range(1, num_bars)] # Window layout graph = sg.Graph(GRAPH_SIZE, (0, 0), DATA_SIZE, background_color='#F5F6F4') layout = [[ sg.Text('Visualization', size=(30, 1), font=("Helvetica", 25), background_color='#8F90A0', text_color='#FFFFFF') ], [graph], [ sg.Button('Select sorting method', button_color=['#FFFFFF', '#35343B'], font=("Helvetica", 12)), sg.Button('Generate new array', button_color=['#FFFFFF', '#35343B'], font=("Helvetica", 12)) ]] window = sg.Window('Algorithm Visualizer', layout) window.Finalize() draw_bars(graph, arr) while True: event, values = window.read() if event in (None, 'Exit'): break if event == 'Generate new array': graph.Erase() random.shuffle(arr) draw_bars(graph, arr) if event == 'Select sorting method': l2 = [[ sg.T('Choose sorting method', font=("Helvetica", 12), background_color='#8F90A0', text_color='#FFFFFF') ], [ sg.Listbox(['Bubble', 'Insertion', 'Selection'], size=(16, 3)) ], [sg.Ok()]] w2 = sg.Window('Choose sorting method', l2) button, values = w2() w2.close() try: if values[0][0] == 'Bubble': sort = bubblesort.bubbleSort(arr) sortmethod = 'Bubble' elif values[0][0] == 'Insertion': sort = insertionsort.insertionSort(arr) sortmethod = 'Insertion' else: sort = selectionsort.selectionSort(arr) sortmethod = 'Selection' except: sg.Popup('None selected.', font=("Helvetica", 12), background_color='#8F90A0', text_color='#FFFFFF') continue timeout = 10 for partially_sorted_list in sort: event, values = window.read(timeout=timeout) if event is None: break graph.Erase() draw_bars(graph, partially_sorted_list) timeout = int(10) sg.Popup(f'{sortmethod} sort done.', font=("Helvetica", 12), background_color='#8F90A0', text_color='#FFFFFF')