Python Forum
[Tkinter] Silly sentence generator (how to print the sentence in the app)
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Tkinter] Silly sentence generator (how to print the sentence in the app)
#1
Dear python Community, I am having a hard time trying to figure out how to print the result in the app for my silly sentence generator. I was able to write the app and have the generate the silly sentences without using tkinter. However, I cannot seem to figure out how to get it to work with the GUI. I've done a lot of research and I have looked through the Forum, but I've had no luck figuring it out. Here is the code. I have a lot to learn with tkinter yet. As of right now, I get no error. Nothing pops up at all on the app.

import random
import names
from tkinter import *

window = Tk()
window.title('Silly Sentence Generator')
window.geometry('500x500')

#names.get_full_name()
#names.get_full_name(gender='male')
#names.get_first_name()
#names.get_first_name(gender='female')
#names.get_last_name()

first = (names.get_first_name())
second = ("likes", "wants", "prefers" )
third = ("a hamburger", "a roast beef sandwich", "chicken tenders")

def sentencegen():
    firrst = (first)
    seccond = random.choice(second)
    thirrd = random.choice(third)

def phrase():
    phrase = ((firrst) + " " + (seccond) + " " + (thirrd) + ".")


ssg = Button(text='Generate', command=sentencegen)
ssg.pack()
result=phrase


window.mainloop()
Reply


Messages In This Thread
Silly sentence generator (how to print the sentence in the app) - by pav1983 - May-18-2020, 03:37 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020