Is it possible to just click printed text, I know buttons are usable but it would be nice if I could use text or buttons that don't open a new window, I don't need to open links, just to make it call a function. I searched the internet but I'm not finding anything relevant, if you do please post the link.
-
1What UI framework are you using. TKinter?Nick Bailey– Nick Bailey2022-03-13 16:10:28 +00:00Commented Mar 13, 2022 at 16:10
-
If you're using Tkinter, then create a button and set parameter (command=YourFucntion)Vishwa Mittar– Vishwa Mittar2022-03-13 16:19:41 +00:00Commented Mar 13, 2022 at 16:19
Add a comment
|
2 Answers
To clarify, I assume you are asking for a way to click on the displayed text in the GUI to call a function.
- If so, you can simply store this displayed text and not display it, but rather create a button with a transparent background with the stored text as its label.
Maybe something like this:
from tkinter import *
#Tab setup
win = Tk()
win.geometry("800x500")
#The text and button setup
displayText = "Hello World"
textButton=Button(win,text=displayText,width=20,height=2,command=FUNCTION_NAME_HERE).pack()
#Run tab
win.mainloop()
1 Comment
danny
Hey, I don't want a button that opens in a new window, just a printed text in a console that I can click for input, but I'm not sure it's possible. Thanks anyway for your answer.
Use span
<span onclick="doSomething()">Your Text</span>
function doSomething() {
// do something
}
1 Comment
danny
Sorry, I didn't clarify but I'd like something in python, not HTML.