#this is '_uiPPP_' file #rembere to rename the other file '_printJsonName_' to make it work import json import os import re from ipywidgets import widgets from IPython.display import display #from tkinter import * import tkinter as tk #get the nested dictionary with models info import _printJsonName_ grab_the_json = {} grab_the_json = _printJsonName_.returnJsonNames() tmp_grab_the_json = grab_the_json printThemasterModelsNames_ = 0 printThemasterModelsDic_ = 0 xxx = """ {'Applejack_38k steps': 'sub_folder_dir': 'models/Applejack_38k steps', 'speaker_json_name': 'Applejack', 'json_full_dir': 'models/Applejack_38k stepsconfig_aj.json', 'g_model__full_dir': 'models/Applejack_38k steps/G_38000.pth'} """ #options = ['option1', 'option2', 'option3'] #use names from the 'key' valable from the main dictionary #than use it as the loop to grab them into index list and #pass it along as a dropdown list options = [key for key in tmp_grab_the_json] print(tmp_grab_the_json) def runDicList(): theOptions = [key for key in tmp_grab_the_json] return theOptions #options = runDicList() def on_select(v): print('______') print("Model's Folder:" + v) #print(grab_the_json) #print(grab_the_json[Applejack_38k_steps]) print('spk_list: ' + tmp_grab_the_json[v]['speaker_json_name']) ###print(tmp_grab_the_json[v]['sub_folder_dir']) print('model_path: ' + tmp_grab_the_json[v]['g_model__full_dir']) print('config_path: ' + tmp_grab_the_json[v]['json_full_dir']) def offlineMode(): root = tk.Tk() root.geometry('400x200') #entry1 = tk.Entry(root, width = 30) #entry1.pack() #def button_command(): # text = entry1.get() # print(text) # #print("test") # return None #tk.Button(root, text="Button", command=button_command).pack() #drop down var = tk.StringVar(value='option1') #options = ['option1', 'option2', 'option3'] dropdown = tk.OptionMenu(root, var, *options, command=on_select) dropdown.pack() ###elements go above root.mainloop() def onlineMode(): zxcv = 'yes' # check if the COLAB_ENV variable is present # this variable is set by default in Colab if 'COLAB_ENV' in os.environ: print('This code is running in Colab') onlineMode() else: print('This code is running in offline Python') offlineMode() #########Testing out grabing function has worked########################## ####call out loop by the first layer names inside of the nested dictionary def printThemasterModelsNames(): for masterModelsNames in grab_the_json.keys(): print(masterModelsNames) ####print everything inside the masterModelsDictionary def printThemasterModelsDic(): print(grab_the_json) if (printThemasterModelsNames_): printThemasterModelsNames() if (printThemasterModelsDic_): printThemasterModelsDic() #print(grab_the_json)