Skip to content

Instantly share code, notes, and snippets.

@dandrake
Created April 20, 2026 17:44
Show Gist options
  • Select an option

  • Save dandrake/ecad24ec6ce9e91ff2409ff6f1269746 to your computer and use it in GitHub Desktop.

Select an option

Save dandrake/ecad24ec6ce9e91ff2409ff6f1269746 to your computer and use it in GitHub Desktop.
simplest way to display an image in a Python tkinter program
import tkinter as tk
def main():
win = tk.Tk()
win.geometry("400x200")
label = tk.Label(win, text="Here is an image.")
label.grid(row=0, column=0)
my_tk_photoimage = tk.PhotoImage(file="your_image_here.png")
img_widget = tk.Label(win, image=my_tk_photoimage)
img_widget.grid(row=1, column=0)
win.mainloop()
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment