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?
#2
i want to make a GUI where i can display some trajectories made with the hands by some users placed by column. To create the plots i've used plotnine and for each i placed them in a separate canvas. Now the canvas appears like this:[Image: imYNS.png] but it is not complete because i have to create two circles below so it looks like the trajectory made with the hands stays inside the trail like this:[Image: 0K696.png] but i don't know how to draw those two circles.
here's the code i've used to create the plots and display them in a canvas.
for i, userID_to_select in enumerate(users['userID'].head(num_plots)):
            utenteConsiderato = dom_hand[dom_hand['userID'] == userID_to_select]

            traiettoria=pd.merge(utenteConsiderato, input, how="left", on=["sessionID", "repetitionID"])
vis=ggplot()+geom_point(aes(x='xR', y='yR', color='factor(repetitionID)'), traiettoria)
            vis=vis+theme(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(), panel_grid_major=element_blank(), panel_grid_minor=element_blank(), legend_position='none') #per tenere la legenda togliere legend_position='none' e se si vuole modificare la grande legend_key_size=10
            vis=vis+coord_fixed()
vis.save(f'{dest_folder}plot_{i}.png', dpi=200)
img = Image.open(f'{dest_folder}plot_{i}.png')
            resized_image = img.resize((dim_width, math.floor(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=0, pady=0)

vis_canvas.create_image(0, 0, anchor=NW, image=image_container.plot_image[-1])
total_inner_height += vis_canvas.winfo_reqheight()
canvas.configure(scrollregion=(0, 0, dim_width * num_columns, total_inner_height))
class ImageContainer:
    def __init__(self):
        self.plot_image = []

image_container = ImageContainer()
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,264 May-09-2021, 01:48 PM
Last Post: joe_momma
  [Tkinter] Resizing image inside Canvas (with Canvas' resize) Gupi 2 25,257 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