Nov-26-2019, 03:09 PM
Hello, I have a coding question please.
This here code makes a simple (and ugly) tkinter bot GUI, but design isn't my question. I'm trying to figure out how to regenerate a new set varibles and print here:
This is just a random keyword generator using random words from the text files.
This here code makes a simple (and ugly) tkinter bot GUI, but design isn't my question. I'm trying to figure out how to regenerate a new set varibles and print here:
myLabel = Label(root, text=(a, b, e, c, d, f))When I run the bot, it works but I need to figure out how to make a loop with each click to generate a new set of variables in the lable with each press of the Click me button.
This is just a random keyword generator using random words from the text files.
from tkinter import * root = Tk() import random def wwwwwh(fname): lines = open(fname).read().splitlines() return random.choice(lines) def common_conjugated(fname): lines = open(fname).read().splitlines() return random.choice(lines) def noun(fname): lines = open(fname).read().splitlines() return random.choice(lines) def verb(fname): lines = open(fname).read().splitlines() return random.choice(lines) def adjective(fname): lines = open(fname).read().splitlines() return random.choice(lines) def adverb(fname): lines = open(fname).read().splitlines() return random.choice(lines) def myClick(): myLabel = Label(root, text=(a, b, e, c, d, f)) myLabel.pack() a = (wwwwwh('WWWWWH.txt')) b = (common_conjugated('common_conjugated_nouns.txt')) c = (noun('91K_nouns.txt')) d = (verb('31K_verbs.txt')) e = (adjective('28K_adjectives.txt')) f = (adverb('6K_adverbs.txt')) myButton = Button(root, text="Click Me!", height=1, width=35, command=myClick) myButton.pack() button_quit = Button(root, text="Exit", command=root.quit) button_quit.pack() root.mainloop()Thank you for any help.