I am trying code a single button that will fire two commands, that is, it will open two image files with one button selection.

I have researched this and have not found much directly related to this question; what I found was to use a def within a def, thus binding both to this one button. I do not quite understand this. I tried a quick idea originally of adding a second command with a comma (,) following the first command:

btn1 = Button(root, text="Play", command=show_image2, command=show_image3)

I thought this could work but it only gave an error when ran.

I am simply trying to bind two (2) commands to a single button so when it is selected by a user two images open together on the canvas.

**Note: I am not seeking help with the actual rendering of images to the screen (GUI), only help with the button commands.

Any push in the right direction or any suggestions will be greatly appreciated.


Recommended Answers

All 2 Replies

I'm confused. Couldn't you do this:

btn1 = Button(root, text="Play", command=show_images)

and then

def show_images():


Member Avatar

That seems like the obvious solution.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.