1

Already I have seen Tkinter library, but I am unable to find a shortcut or at least a way to click on the image button in any window application. This image button is used for uploading a folder.

To click on a specific button, we need the specific property of that button. After trying the below code (with one of a similar threads in StackOverflow regarding buttons in python)

from Tkinter import Button
b = Button()
for k in b.configure().keys():
    print (k, ':', b.cget(k), b.winfo_class())

Output:

('highlightthickness', ':', <pixel object at 0283A930>, 'Button')

But with the output I have got:

  1. I am not sure which property of that image button to use, and
  2. how to code to click that image button.

There is no text seen for this image button in the window application. It is a simple square image button, which only changes a bit in size when hovered over by the cursor.

Please ask if you need any more details regarding the same.

2
  • I do not understand what you are trying to achieve. A button click in Tkinter is too simple and available on any random tutorial you pick. Commented Jun 13, 2016 at 8:34
  • if you want to click on a button and have it call a function, use the command attribute. This is described in pretty much every single tkinter tutorial. Commented Jun 13, 2016 at 13:58

1 Answer 1

1

If you really just want a widget, display a button on it and then be able to click it. You will need a function to call and an image:

root = Tk() # This is your window, if you want one to click on

#you need to define your image
image = your_image_here

def whatever_you_want_to_do():
    # and here you just put your code, this could be getting information about your button
    pass

b1 = Button(root, img=your_iamge, command=whatever_you_want_to_do) # This sets up your button

b1.pack()

root.mainloop() #your loop to run tkinter
Sign up to request clarification or add additional context in comments.

Comments

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.