Hi, I'm trying to print the string of: Entry "motTexte" who is located in getWord(), in draw(). But everytime in write something in the entry, it prints an empty line in the Python IDLE.
The code:
Thank you
PS: I'm french so sorry if you don't understand some variables :)
The code:
Code:
from time import *
from math import *
from re import *
from tkinter import *
def getWord():
rootMot = Toplevel(root)
motTexte = Entry(rootMot)
motTexte.get()
motTexte.pack()
getWord.motFinal = motTexte.get()
boutonMot = Button(rootMot, text="Submit", width=10,
command=lambda: draw(rootMot))
boutonMot.pack()
def draw(widget):
print(getWord.motFinal)
widget.destroy()
gameDraw = Canvas(root, width=200, height=100)
gameDraw.pack()
#Create the menu
root = Tk()
menu = Menu(root)
root.config(menu=menu)
gameOptions = Menu(menu)
menu.add_cascade(label="Game", menu=gameOptions)
gameOptions.add_command(label="New Game", command=getWord)
gameOptions.add_command(label="Options...", command=getWord)
gameOptions.add_separator()
gameOptions.add_command(label="Exit", command=getWord)
helpOptions = Menu(menu)
menu.add_cascade(label="Help", menu=helpOptions)
helpOptions.add_command(label="How to play...", command=getWord)
helpOptions.add_command(label="About...", command=getWord)
mainloop()
PS: I'm french so sorry if you don't understand some variables :)
Comment