Hello all, new to the list (hopefully this has not been asked) I've created a global canvas called *main-canvas* and have attached a few shapes to it. (create-line* *main-canvas* `(,x ,y ,x2 ,y2) :tags "line")
Am I specifying the tag correctly for the new line instance or does it need to be in a list? Also, how would I tell a canvas to remove all and only items with the "line" tag attached?
Sincerely, Ryan
On Mon, Oct 10, 2016 at 09:47:39PM -0600, Ryan wrote:
Hello all,
Hello!
new to the list (hopefully this has not been asked) I've created a global canvas called *main-canvas* and have attached a few shapes to it. (create-line* *main-canvas* `(,x ,y ,x2 ,y2) :tags "line")
Am I specifying the tag correctly for the new line instance or does it need to be in a list?
Never tried this way (does it actually works), i usually use itemconfigure for that:
(itemconfigure canvas object "tag" "tag-name")
Bye! C.
Based on a cursory check, there doesn't seem to be a way to do directly. The tk command you want is "<widget> delete <tag>"[0], but ltk has only got methods to use integer IDs with the delete command. It's pretty easy to write your own function for it, though:
(defun delete-tagged (canvas tag) (check-type tag string) (format-wish "~a delete {~a}" (wish-pathname canvas) tag) canvas)
will probably do the trick.
As a general pattern, the best way I've found to get around the ltk libs are to 1) consult the docs, and then failing that, 2) find the tk command you want (the manual pages for tk are pretty thorough), then open up the tk source and search around for strings that could be that command (usually in a call to FORMAT-WISH). It helps a lot to have a (very) basic working knowledge of tcl, so you might try to find a quick hello-world sort of tutorial for it. That should make reading the command definitions much easier.
-Matt Stickney
[0] https://www.tcl.tk/man/tcl8.4/TkCmd/canvas.htm#M49
On Wed, Oct 12, 2016 at 12:27 PM, cage cage@katamail.com wrote:
On Mon, Oct 10, 2016 at 09:47:39PM -0600, Ryan wrote:
Hello all,
Hello!
new to the list (hopefully this has not been asked) I've created a global canvas called *main-canvas* and have attached a few shapes to it. (create-line* *main-canvas* `(,x ,y ,x2 ,y2) :tags "line")
Am I specifying the tag correctly for the new line instance or does it need to be in a list?
Never tried this way (does it actually works), i usually use itemconfigure for that:
(itemconfigure canvas object "tag" "tag-name")
Bye! C.
On Wed, Oct 12, 2016 at 4:02 PM, Matthew Stickney mtstickney@gmail.com wrote:
then open up the tk source and search around for strings that could be that command
Sorry, I mean the LTK source. Having to read the tk source itself would be considerably more involved.
Hmm I seem to be missing
(wish-pathname ...)
Is it a standard LTk function? Thanks for confirming that LTk is indeed missing the "delete by tag" command. The format-wish is a nice little option until people can officially add the newest features. I really like Tk conceptually. It is nice to have a universal GUI shell that is language agnostic and not browser based.
On 10/12/2016 02:03 PM, Matthew Stickney wrote:
On Wed, Oct 12, 2016 at 4:02 PM, Matthew Stickney mtstickney@gmail.com wrote:
then open up the tk source and search around for strings that could be that command
Sorry, I mean the LTK source. Having to read the tk source itself would be considerably more involved.
Sorry, was going from memory and mis-copied it. You want LTK:WIDGET-PATH instead.
Ltk is really good about being easy to extend, which is useful for things like starkits or tcl extensions that don't really belong in a tk binding. I've found that the major drawback to Tk is that it's tricky to build new parts out of existing widgets[0]. It's got the most straightforward and least bizarre widget API I've seen in any GUI toolkit, though -- worthy of emulation, IMO.
[0] Technically, Tk widgets don't really exhibit "closure" -- you can't build a widget out of other widgets, without resorting to one of the object-based shims around Tk. There is some information about creating so-called "megawidgets", but it's not as simple as you would hope.
On Wed, Oct 12, 2016 at 7:29 PM, Ryan pixeloutlaw@gmail.com wrote:
Hmm I seem to be missing
(wish-pathname ...)
Is it a standard LTk function? Thanks for confirming that LTk is indeed missing the "delete by tag" command. The format-wish is a nice little option until people can officially add the newest features. I really like Tk conceptually. It is nice to have a universal GUI shell that is language agnostic and not browser based.
On 10/12/2016 02:03 PM, Matthew Stickney wrote:
On Wed, Oct 12, 2016 at 4:02 PM, Matthew Stickney mtstickney@gmail.com wrote:
then open up the tk source and search around for strings that could be that command
Sorry, I mean the LTK source. Having to read the tk source itself would be considerably more involved.
Thank you all for getting me over this issue! I used the techniques you prescribed with great success.
(format-wish "~a delete {~a}" (widget-path canvas) tag)
And set the tag attribute like so to attach a "line" attribute to lines (so other shapes are preserved on deletion). (itemconfigure canvas line-instance "tag" "line")
I'm working on a 2D diagramming tool for light personal use.
On 10/13/2016 12:44 PM, Matthew Stickney wrote:
Sorry, was going from memory and mis-copied it. You want LTK:WIDGET-PATH instead.
Ltk is really good about being easy to extend, which is useful for things like starkits or tcl extensions that don't really belong in a tk binding. I've found that the major drawback to Tk is that it's tricky to build new parts out of existing widgets[0]. It's got the most straightforward and least bizarre widget API I've seen in any GUI toolkit, though -- worthy of emulation, IMO.
[0] Technically, Tk widgets don't really exhibit "closure" -- you can't build a widget out of other widgets, without resorting to one of the object-based shims around Tk. There is some information about creating so-called "megawidgets", but it's not as simple as you would hope.
On Wed, Oct 12, 2016 at 7:29 PM, Ryan pixeloutlaw@gmail.com wrote:
Hmm I seem to be missing
(wish-pathname ...)
Is it a standard LTk function? Thanks for confirming that LTk is indeed missing the "delete by tag" command. The format-wish is a nice little option until people can officially add the newest features. I really like Tk conceptually. It is nice to have a universal GUI shell that is language agnostic and not browser based.
On 10/12/2016 02:03 PM, Matthew Stickney wrote:
On Wed, Oct 12, 2016 at 4:02 PM, Matthew Stickney mtstickney@gmail.com wrote:
then open up the tk source and search around for strings that could be that command
Sorry, I mean the LTK source. Having to read the tk source itself would be considerably more involved.