Reputation: 49
I created a canvas and inside I put an image. I also can change the properties of the watermark text and would like to update the text on the canvas when I make some changes. I created the text inside of the canvas with create_text and when I initialize the program, I created a variable. text_variable = canvas.create_text(...) However, I couldn't also adjust the opacity of the text.
Problems:
I expect:
Change the text when I change some properties from the edit menu
Add opacity adjustment to the text
self.watermark_display = self.display_canvas.create_text(self.watermark_start_position_x, self.watermark_start_position_y, text="Plese write your watermark!", font=(self.fonttype.get(),self.fontsize.get()),fill=self.color_choice)
def update_watermark_display(self):
self.display_canvas.itemconfig(self.watermark_display, self.watermark_start_position_x, self.watermark_start_position_y, text="Plese write your watermark!", font=(self.fonttype.get(),self.fontsize.get()),fill=self.color_choice)
When I try to do with this way, I got Type Error.
self.display_canvas.itemconfig(self.watermark_display, self.watermark_start_position_x, self.watermark_start_position_y, text="Plese write your watermark!", font=(self.fonttype.get(),self.fontsize.get()),fill=self.color_choice)
TypeError: Canvas.itemconfigure() takes from 2 to 3 positional arguments but 4 were given
Upvotes: 1
Views: 591
Reputation: 385970
You cannot use itemconfig
to change the coordinates. Instead, use the coords
method for the coordinates, and itemconfig
for the item configuration.
self.display_canvas.itemconfig(
self.watermark_display,
text="Plese write your watermark!",
font=(self.fonttype.get(),self.fontsize.get()),
fill=self.color_choice
)
self.display_canvas.coords(
self.watermark_display,
self.watermark_start_position_x,
self.watermark_start_position_y
)
Upvotes: 1