Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How do you set functions for a button, on Tkinter?

my function wont carry out for the button assigned. Im using visual studio code. For the
def myClick():
myLabel =Label(window, text …, command…

it wont occur. on visual studio code, the ‘myLabel’ greys out and has the error ‘is not accessedPylance’

# add response to input


def myClick():
    myLabel = Label(window, text="Hello" + e.get() + "...      ")
myLabel.pack

# create button
myButton = Button(window, text="next", command=myClick, fg="black")
myButton.pack()

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

I think its just that you are not calling pack(). When I fix that I see the label appear:

def myClick():
    myLabel = Label(window, text="Hello" + e.get() + "...      ")
    myLabel.pack()
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading