vendredi 28 octobre 2016

Taking data from a data.txt file in JSON format and displaying it randomly on the GUI

I have to import the data.txt file currently having 3 dictionaries (can have more as well) and to randomly select the name of an item and print it on the GUI. The code above is designed to do the required but it doesn't do anything. Can you please help me with this.

with open('data.txt') as data_file:
        data = json.load(data_file)
        data_file.close()
self.firstPrompt = tkinter.Label(self.top, width=7, \
                       text=random.sample(data['name'], 1), fg='blue', font=("Helvetica", 16))




Aucun commentaire:

Enregistrer un commentaire