This is for example a create_text:
How could I delete this with a button?
martineauA Gentle Introduction to Making HTML5 Canvas Interactive 86 Comments. If you want to make something that you’ve drawn move, you have to clear the entire canvas and redraw all of the objects with one or more of them in a new location. To keep track of each object, but we’ll also need a var for the canvas, the canvas’ 2d context.
1 Answer
One way to do it is by using the object ID that all Canvas
object constructors return:
Then afterwards you can use the Canvas
object's delete()
method list like this:
Another way is to attach a tag to the Canvas
object, and use that:
And then pass the tag to the delete()
method instead of the object ID:
The name of a tag can be any string that does not contain white space or periods.
Tags are more powerful because you can give the same one to multiple objects and then act on them as a group. Conversely, an object can have more than one tag attached to it by specifying a tuple of them: i.e. tag=('1234', '@special', 'posn:13,42')
in the constructor call.
To make this happen when a Button
is clicked, you would need to also define a function or method that makes a call to one of the above Canvas
methods when it's called. Then, when creating the button widget, specify its name via the command=
configuration option.
For example (within a class
definiton):
Not the answer you're looking for? Browse other questions tagged pythontkintertkinter-canvas or ask your own question.
I know canvas can't editing text from field.
I try to make this http://jsfiddle.net/0n60y65o/4/
but it can make new text on canvas not change a text on canvas.
I hope someone tell me workflow and component for build editor this site http://customerscanvas.com/demos/Editor.aspx?header=1-sided%20Business%20Card&design=BusinessCard1&downloadEnabled=true&backgroundButtonEnabled=true&rectEllipseButtonsEnabled=false (sorry I'm not spam, it's for example live site)On that site, you can change style/edit text, add a text, add a image etc.
1 Answer
You have to clear the canvas, which can be done be resetting the width, and redraw the text, so basically you could just do the same thing as when you're first creating it, everytime the text changes, like this :
adeneoadeneo