Python Forum
[Tkinter] Can i draw more elements in a canvas?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Tkinter] Can i draw more elements in a canvas?
#1
Hi, i am new to tkinter. I want to know if there is a way to draw more elements into a canvas in tkinter. My goal is to display in a canvas a trajectory made with plotnine and two circles as the boundaries like in the attached image [Image: 0K696.png]

First of all i've created the plots then i saved it in a image and i've assigned a canvas for each image like this:
vis=ggplot()+geom_point(aes(x='xR', y='yR', color='factor(repetitionID)'), traiettoria_utente)+ facet_grid("hand~repetitionID")+ coord_fixed()
            vis=vis+theme(legend_position=None, axis_text_x=element_blank(),axis_text_y=element_blank(),axis_title_x=element_blank(),axis_title_y=element_blank(),axis_ticks=element_blank(),panel_background=element_blank(), legend_key_size=8)
            vis=vis+labs(color='Ripetizione', title=f"{first_user_id}")+coord_fixed()

            vis.save(f'{dest_folder}plot_{i}.png', dpi=500)

        img = Image.open(f'{dest_folder}plot_{i}.png')
        resized_image = img.resize((dim_width, dim_height), Image.LANCZOS) 
        image_container.plot_image.append(ImageTk.PhotoImage(resized_image))

       
        vis_canvas = Canvas(plot_frame, width=dim_width, height=dim_height)
        vis_canvas.grid(row=i // num_columns, column=i % num_columns, padx=2, pady=2)


        vis_canvas.create_image(0, 0, anchor=NW, image=image_container.plot_image[-1])
now that i have created the trajectory i don't know how to integrate the two circles.
With the code above i can display only the trajectory: [Image: imYNS.png]
if you have further question please let me know.
Larz60+ write Dec-14-2023, 10:37 AM:
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Tags have been added for you this time. Please use BBCode tags on future posts.
Reply


Messages In This Thread
Can i draw more elements in a canvas? - by Yeti - Dec-13-2023, 12:03 PM
RE: Can i draw more elements in a canvas? - by Yeti - Dec-14-2023, 11:24 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  [Tkinter] Draw a grid of Tkinter Canvas Rectangles MrTim 5 8,253 May-09-2021, 01:48 PM
Last Post: joe_momma
  [Tkinter] Resizing image inside Canvas (with Canvas' resize) Gupi 2 25,244 Jun-04-2019, 05:05 AM
Last Post: Gupi

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020