def tray_start(): restore_settings() while True: # The event loop menu_item = tray.Read() if menu_item == 'Exit': break elif menu_item == 'Save as...': apath = sg.PopupGetFile('hi',save_as=True, file_types=(('PNG files', '*.png' ),('JPEG files', '*.jpg'))) walld.save_image(apath) elif menu_item == '__ACTIVATED__': walld.spin_dice() elif 'cat_' in menu_item: make_flip(menu_item) tray.Update(menu=menu_def) #ТУТ НУЖЕН ЦИКЛ FOR ДЛЯ ПРОШЕРСТЕНИЯ ВСЕХ ЛИСТОВ elif 'res_' in menu_item: make_flip(menu_item) tray.Update(menu=menu_def) elif menu_item == 'spin_dice': walld.spin_dice() elif menu_item == 'Save': walld.save_image()
def load_raw_data(output_folder, stopwords_path, label_words_val): output_folder = os.path.abspath(output_folder) filename = sg.PopupGetFile('raw data filename', no_window=True, file_types=(("CSV Files", "*.csv"), )) print(filename) if filename is not None and filename != '': fn = path_leaf(filename) window.Element('output').Update('loading file: ' + str(fn)) window.Refresh() # raw_data = read_raw_data(filename) out_queue = queue.Queue() # https://realpython.com/intro-to-python-threading/ x = threading.Thread(target=read_raw_data, args=(filename, out_queue)) x.start() update_status(x, 'read data') raw_data = out_queue.get() window.Element('output').Update('file loaded.') window.Refresh() # data preprocess window.Element('output').Update('data preprocessing...') window.Refresh() out_queue = queue.Queue() x = threading.Thread(target=data_preprocess, args=(raw_data, stopwords_path, out_queue)) x.start() update_status(x, 'process data') newcorpus = out_queue.get() window.Element('output').Update('Data preprocess complete.') window.Refresh() # build the label dictionary window.Element('output').Update('build the label dictionary') window.Refresh() x = threading.Thread(target=generate_labels, args=(output_folder, newcorpus, label_words_val)) x.start() update_status(x, 'generate labels') window.Element('output').Update( 'Label dictionary written to labels.csv. Create labels file then load. ' ) window.Refresh() return raw_data, raw_data['overview'] else: return None, None
def get_label_file(): filename = sg.PopupGetFile('label data filename', no_window=True, file_types=(("CSV Files", "*.csv"), )) if filename is not None: fn = path_leaf(filename) window.Element('output').Update('loading label file: ' + str(fn)) window.Refresh() out_queue = queue.Queue() x = threading.Thread(target=read_raw_data, args=(filename, out_queue)) x.start() update_status(x, 'read data') label_data = out_queue.get() window.Element('output').Update('file loaded.') window.Refresh() return label_data