0

I'm trying to create a simple gui that displays an image with some text under it.

from tkinter import *
import os


def label(root,image,row,column):
    la = Label(root,image=image)
    la.grid(row=row,column=column)


def name(serie):
    wind =Tk()
    with open('series.txt','r') as tv:
        vv= [s.strip('\n') for s in tv.readlines()]
    vv.sort()
    name = serie + '.gif'
    url = [serie_url for serie_url in vv if serie in serie_url]
    de = os.path.join('C:\\Users\\Afro\\Desktop\\ben',name)
    name = serie+'.gif'
    pik = PhotoImage(file=de)
    label(wind,pik,0,0)
name('Breakit')

but when i run this code, it just displays a window with the text but the image doesn't show. But if i write the code without functions it actually works and the window displays the image. Please help.

HackAfro
  • 720
  • 1
  • 12
  • 28

1 Answers1

-1

First of all, you shouldn't use absolute paths, better using relative paths. If you want this code to work, just add :

wind.mainloop()

At the end of the name function :)

Sygmei
  • 467
  • 2
  • 10