Getting the fill color or any other property of a item drawn in a canvas in tkinter(Python) -


i want fill color or other property of item drawn in canvas in tkinter.

  def createwidgets(self):     self.canvas_1= tk.canvas(self, bg='#fafafa',selectforeground='#bbdefb');     i=self.canvas_1.create_rectangle((self.canvas_1.winfo_reqwidth()/2)+100,                                    (self.canvas_1.winfo_reqheight()/2)+50,                                    (self.canvas_1.winfo_reqwidth()/2)+150,                                    (self.canvas_1.winfo_reqheight()/2)+100,                                      fill='#ff4081',width=0)     self.canvas_1.grid();     color=               #want access fill color of item using getter functions. 

you can using itemcget method:
effbot

so use:

color = self.canvas_1.itemcget(i, "fill") 

Comments

Popular posts from this blog

searchKeyword not working in AngularJS filter -

sequelize.js - Sequelize: sort by enum cases -

user interface - how to replace an ongoing process of image capture from another process call over the same ImageLabel in python's GUI TKinter -