How to bind mouse action over multiple entry widgets Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!How to add placeholder to an Entry in tkinter?Passing Entry widget input to binding/event handler functionHow to return multiple values from a function?Accessing Entry widget information: tkinter pythonPython Tkinter - Overwriting/Deleting “Default” Widget BindingsHow to iterate over rows in a DataFrame in Pandas?grid_remove on an Entry widgetVisible textvariable in tkinter Entry widgetPython - function arguments not workingPython tkinter Canvas root.after() maximum recursion depth exceededHow to trigger tkinter's “<Enter>” event with mouse down?
What do you call the main part of a joke?
Amount of permutations on an NxNxN Rubik's Cube
Central Vacuuming: Is it worth it, and how does it compare to normal vacuuming?
Does the Mueller report show a conspiracy between Russia and the Trump Campaign?
Intuitive explanation of the rank-nullity theorem
Draw 4 of the same figure in the same tikzpicture
Did any compiler fully use 80-bit floating point?
1-probability to calculate two events in a row
What order were files/directories output in dir?
Girl Hackers - Logic Puzzle
What would you call this weird metallic apparatus that allows you to lift people?
Can the Flaming Sphere spell be rammed into multiple Tiny creatures that are in the same 5-foot square?
Dyck paths with extra diagonals from valleys (Laser construction)
What does 丫 mean? 丫是什么意思?
How do living politicians protect their readily obtainable signatures from misuse?
How many time has Arya actually used Needle?
How would a mousetrap for use in space work?
Is it possible for SQL statements to execute concurrently within a single session in SQL Server?
What is the difference between a "ranged attack" and a "ranged weapon attack"?
Did Mueller's report provide an evidentiary basis for the claim of Russian govt election interference via social media?
How were pictures turned from film to a big picture in a picture frame before digital scanning?
How many morphisms from 1 to 1+1 can there be?
What initially awakened the Balrog?
Strange behavior of Object.defineProperty() in JavaScript
How to bind mouse action over multiple entry widgets
Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern)
Data science time! April 2019 and salary with experience
The Ask Question Wizard is Live!How to add placeholder to an Entry in tkinter?Passing Entry widget input to binding/event handler functionHow to return multiple values from a function?Accessing Entry widget information: tkinter pythonPython Tkinter - Overwriting/Deleting “Default” Widget BindingsHow to iterate over rows in a DataFrame in Pandas?grid_remove on an Entry widgetVisible textvariable in tkinter Entry widgetPython - function arguments not workingPython tkinter Canvas root.after() maximum recursion depth exceededHow to trigger tkinter's “<Enter>” event with mouse down?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I'm able to bind a mouse action on a single entry widget, meaning, by default a value will be present in the entry box, if i click then the default will be removed. How would i do the same when loop is used over individual boxes. If i click on any entry box, the default value must be removed
from tkinter import *
root = Tk()
def hello(event):
ent.delete(0, END)
for x in range(4):
ent=Entry(root,fg="grey")
ent.insert(0, "dd/mm/yy")
ent.pack()
ent.bind('<Button-1>',hello)
root.minsize(400, 400)
root.mainloop()
python tkinter
add a comment |
I'm able to bind a mouse action on a single entry widget, meaning, by default a value will be present in the entry box, if i click then the default will be removed. How would i do the same when loop is used over individual boxes. If i click on any entry box, the default value must be removed
from tkinter import *
root = Tk()
def hello(event):
ent.delete(0, END)
for x in range(4):
ent=Entry(root,fg="grey")
ent.insert(0, "dd/mm/yy")
ent.pack()
ent.bind('<Button-1>',hello)
root.minsize(400, 400)
root.mainloop()
python tkinter
So are you asking how to call the same callback on all entries when one of them is clicked upon? or are you asking how to bind the same command to multiple different entries
– Joshua Nixon
Mar 22 at 11:08
same command to different entries over the loop
– Nalini V
Mar 22 at 11:14
Check out this solution and also this one.
– fhdrsdg
Mar 22 at 11:14
i edited the code where am seeing the change only in the last box irrespective of where i click
– Nalini V
Mar 22 at 11:30
That's because at the end of the loop,ent
is the last entry widget. You could replaceent.delete(0, END)
withevent.widget.delete(0, END)
, but I'd recommend you take a look at the two answers I linked, they make a class inherited from Entry with this functionality added, which makes this a lot easier.
– fhdrsdg
Mar 22 at 11:35
add a comment |
I'm able to bind a mouse action on a single entry widget, meaning, by default a value will be present in the entry box, if i click then the default will be removed. How would i do the same when loop is used over individual boxes. If i click on any entry box, the default value must be removed
from tkinter import *
root = Tk()
def hello(event):
ent.delete(0, END)
for x in range(4):
ent=Entry(root,fg="grey")
ent.insert(0, "dd/mm/yy")
ent.pack()
ent.bind('<Button-1>',hello)
root.minsize(400, 400)
root.mainloop()
python tkinter
I'm able to bind a mouse action on a single entry widget, meaning, by default a value will be present in the entry box, if i click then the default will be removed. How would i do the same when loop is used over individual boxes. If i click on any entry box, the default value must be removed
from tkinter import *
root = Tk()
def hello(event):
ent.delete(0, END)
for x in range(4):
ent=Entry(root,fg="grey")
ent.insert(0, "dd/mm/yy")
ent.pack()
ent.bind('<Button-1>',hello)
root.minsize(400, 400)
root.mainloop()
python tkinter
python tkinter
edited Mar 22 at 11:29
Nalini V
asked Mar 22 at 11:02
Nalini VNalini V
83
83
So are you asking how to call the same callback on all entries when one of them is clicked upon? or are you asking how to bind the same command to multiple different entries
– Joshua Nixon
Mar 22 at 11:08
same command to different entries over the loop
– Nalini V
Mar 22 at 11:14
Check out this solution and also this one.
– fhdrsdg
Mar 22 at 11:14
i edited the code where am seeing the change only in the last box irrespective of where i click
– Nalini V
Mar 22 at 11:30
That's because at the end of the loop,ent
is the last entry widget. You could replaceent.delete(0, END)
withevent.widget.delete(0, END)
, but I'd recommend you take a look at the two answers I linked, they make a class inherited from Entry with this functionality added, which makes this a lot easier.
– fhdrsdg
Mar 22 at 11:35
add a comment |
So are you asking how to call the same callback on all entries when one of them is clicked upon? or are you asking how to bind the same command to multiple different entries
– Joshua Nixon
Mar 22 at 11:08
same command to different entries over the loop
– Nalini V
Mar 22 at 11:14
Check out this solution and also this one.
– fhdrsdg
Mar 22 at 11:14
i edited the code where am seeing the change only in the last box irrespective of where i click
– Nalini V
Mar 22 at 11:30
That's because at the end of the loop,ent
is the last entry widget. You could replaceent.delete(0, END)
withevent.widget.delete(0, END)
, but I'd recommend you take a look at the two answers I linked, they make a class inherited from Entry with this functionality added, which makes this a lot easier.
– fhdrsdg
Mar 22 at 11:35
So are you asking how to call the same callback on all entries when one of them is clicked upon? or are you asking how to bind the same command to multiple different entries
– Joshua Nixon
Mar 22 at 11:08
So are you asking how to call the same callback on all entries when one of them is clicked upon? or are you asking how to bind the same command to multiple different entries
– Joshua Nixon
Mar 22 at 11:08
same command to different entries over the loop
– Nalini V
Mar 22 at 11:14
same command to different entries over the loop
– Nalini V
Mar 22 at 11:14
Check out this solution and also this one.
– fhdrsdg
Mar 22 at 11:14
Check out this solution and also this one.
– fhdrsdg
Mar 22 at 11:14
i edited the code where am seeing the change only in the last box irrespective of where i click
– Nalini V
Mar 22 at 11:30
i edited the code where am seeing the change only in the last box irrespective of where i click
– Nalini V
Mar 22 at 11:30
That's because at the end of the loop,
ent
is the last entry widget. You could replace ent.delete(0, END)
with event.widget.delete(0, END)
, but I'd recommend you take a look at the two answers I linked, they make a class inherited from Entry with this functionality added, which makes this a lot easier.– fhdrsdg
Mar 22 at 11:35
That's because at the end of the loop,
ent
is the last entry widget. You could replace ent.delete(0, END)
with event.widget.delete(0, END)
, but I'd recommend you take a look at the two answers I linked, they make a class inherited from Entry with this functionality added, which makes this a lot easier.– fhdrsdg
Mar 22 at 11:35
add a comment |
1 Answer
1
active
oldest
votes
Your problem is that you're hardcoding ent
in your callback. The event
object tells you which widget received the event, so use that instead.
def hello(event):
event.widget.delete(0, END)
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55298219%2fhow-to-bind-mouse-action-over-multiple-entry-widgets%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Your problem is that you're hardcoding ent
in your callback. The event
object tells you which widget received the event, so use that instead.
def hello(event):
event.widget.delete(0, END)
add a comment |
Your problem is that you're hardcoding ent
in your callback. The event
object tells you which widget received the event, so use that instead.
def hello(event):
event.widget.delete(0, END)
add a comment |
Your problem is that you're hardcoding ent
in your callback. The event
object tells you which widget received the event, so use that instead.
def hello(event):
event.widget.delete(0, END)
Your problem is that you're hardcoding ent
in your callback. The event
object tells you which widget received the event, so use that instead.
def hello(event):
event.widget.delete(0, END)
answered Mar 22 at 12:32
Bryan OakleyBryan Oakley
223k22279440
223k22279440
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55298219%2fhow-to-bind-mouse-action-over-multiple-entry-widgets%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
So are you asking how to call the same callback on all entries when one of them is clicked upon? or are you asking how to bind the same command to multiple different entries
– Joshua Nixon
Mar 22 at 11:08
same command to different entries over the loop
– Nalini V
Mar 22 at 11:14
Check out this solution and also this one.
– fhdrsdg
Mar 22 at 11:14
i edited the code where am seeing the change only in the last box irrespective of where i click
– Nalini V
Mar 22 at 11:30
That's because at the end of the loop,
ent
is the last entry widget. You could replaceent.delete(0, END)
withevent.widget.delete(0, END)
, but I'd recommend you take a look at the two answers I linked, they make a class inherited from Entry with this functionality added, which makes this a lot easier.– fhdrsdg
Mar 22 at 11:35