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: - 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()
Thank you
PS: I'm french so sorry if you don't understand some variables :)
1 1298 bvdet 2,851
Expert Mod 2GB
At the time of assignment to getWord.motFinal, there is no text in motTexte. You can add motTexte as an argument in the button callback and call get() in draw(). - def getWord():
-
rootMot = Toplevel(root)
-
motTexte = Entry(rootMot)
-
motTexte.get()
-
motTexte.pack()
-
boutonMot = Button(rootMot, text="Submit", width=10,
-
command=lambda: draw(rootMot, motTexte))
-
boutonMot.pack()
-
-
def draw(top, widget):
-
print(widget.get())
-
top.destroy()
-
gameDraw = Canvas(root, width=200, height=100)
-
gameDraw.pack()
You should consider encompassing your dialogs in a class object where individual elements are created as instance objects and can be accessed by attribute reference (as in self.motTexte).
Sign in to post your reply or Sign up for a free account.
Similar topics
by: weiwei |
last post by:
HI
I am having a problem with print friendly function with asp, I have
download some code regard with print friendly,
it works fine with static html information, however, I have the
dynamic pages...
|
by: MARK |
last post by:
Hi, Can anyone help me with some vb code as i have little or no know
of this programming language.
I have a SQL server containing my datatbase and using an Access front
end.
I have two table:...
|
by: Jamie Pittman via AccessMonster.com |
last post by:
I am currently using a form to track employee time to customer and warehouse. I want to be able to take information from one record and post this to tne next record(finish time on the first record...
|
by: Shannan Casteel via AccessMonster.com |
last post by:
I have a table called tblParttest. It has fields PartNo, PartNo2, PartNo3, ..
.., PartNo25 and Quantity, Quantity2, Quantity3, ...Quantity25.
If I enter "1234" into the PartNo field and "4" into...
|
by: Alan Ho |
last post by:
Thanks...
|
by: Steven Woody |
last post by:
Hi,
i am using gcc. in the following code
void ( * on_data_receive_of_ph ) ( const short line, const uint8_t c );
....
printf( "addr of function = %x\n", (void*)on_data_receive_of_ph )
---...
|
by: 50gumbys |
last post by:
I have a field that uses a drop-list. When I select one of the options from the list, I'd like to make another field (it's a Yes/No field) on the form disabled, to ensure the user doesn't try to use...
|
by: Simon Gare |
last post by:
Hi,
have form on asp page with an email address field, when the user enters
their email address I want it to populate another field automatically on the
same page, some kind of OnBlur event....
|
by: somenath |
last post by:
Hi ALL ,
I need to print the name of the function as my debug message. I have
tried the following way
#include<stdio.h>
#include<stdlib.h>
#define __STR(x) _VAL(x)
#define _VAL(x) #x
int...
|
by: tolokoban |
last post by:
I read in the following thread that the "cmp" method is not needed for sorting and that "key" is egnough :
http://bytes.com/topic/python/answers/844614-python-3-sorting-comparison-function
but if...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |