0

Is it possible to display ImageDraw images in Tkinter Tabs? I'm working on something where I would like to generate some squares or arcs or other things with ImageDraw then display them statically in a GUI created with Tkinter.

It is important to note that I use the tab function (tkk) in Tkinter.

Canvas stuff:

canvas_arcs= Canvas(tab_arcs, width= screen_height*0.3, height= screen_height*0.3,background='#161616')
canvas_arcs.pack(anchor=tk.NE)

def create_arc(x,y,the_arcs_radius,arc_start,arc_end,arc_width,fill_color):
    new_image = Image.new('RGB',(int(tab_arcs_width_input.get()), int(tab_arcs_height_input.get())))
    draw = ImageDraw.Draw(new_image)

    leftUpPoint = (x-the_arcs_radius, y-the_arcs_radius)
    rightDownPoint = (x+the_arcs_radius, y+the_arcs_radius)
    twoPointList = [leftUpPoint, rightDownPoint]
    draw.arc((twoPointList),start=arc_start,end=arc_end,width=arc_width,fill=fill_color)
    new_image.save("HERE_COMES_MY_PATH/1.png","png",quality=100)
    tkimage= ImageTk.PhotoImage(new_image)
    canvas_arcs_picture=Label(tab_arcs,image=tkimage)
    canvas_arcs_picture.pack(anchor=tk.NE)
    tab_arcs.update_idletasks()
    tab_arcs.update()

Basically I defined a function called "create_arc". In this I create some arcs and a new_image with Pillow.

After that I would like to display it on the canvas tab in the upper right corner. Unfortunately, it doesn't work.

Is this even possible?

derpaherpa
  • 81
  • 7
  • 2
    Does this answer your question? [Why does Tkinter image not show up if created in a function?](https://stackoverflow.com/questions/16424091/why-does-tkinter-image-not-show-up-if-created-in-a-function). Also you almost never need `update_idletasks()` or `update()` manually. – Delrius Euphoria Jan 21 '22 at 08:45

0 Answers0