0

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.

2
  • 1
    What UI framework are you using. TKinter? Commented Mar 13, 2022 at 16:10
  • If you're using Tkinter, then create a button and set parameter (command=YourFucntion) Commented Mar 13, 2022 at 16:19

2 Answers 2

1

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()
Sign up to request clarification or add additional context in comments.

1 Comment

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.
0

Use span

<span onclick="doSomething()">Your Text</span>

function doSomething() {
   // do something
}

1 Comment

Sorry, I didn't clarify but I'd like something in python, not HTML.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.