Bob Greschke | 1 Sep 20:07 2009

Canvas tag bindings not going away?

Doesn't ACanvas.delete(ALL) get rid of bindings too?  I'm drawing  
regular map dots (create_oval) on a Canvas "map" and each one gets a  
Tag, like "P1", "P2", etc.  I do a tag_bind to <Button-3> to get a  
popup menu item for each dot.  Everything works fine.

I then have two radiobuttons, one for a regular map (described above),  
and one for drawing the dots a different color depending on  
elevation.  When the Redraw button is hit with the elevation map mode  
selected the canvas gets cleared, the background color gets changed,  
a .delete(ALL) is done (and a .find_all() returns ()), I redraw the  
create_oval()s with the same kind of Tags ("P1", "P2", etc.), but  
without doing a tag_bind to <Button-3> (same bunch of code, just with  
an if-statement to control which kind of dot gets drawn).  The new  
dots still react to a <Button-3> event like as if the TAG is still  
bound to the <Button-3> event.  If I start all over, but draw the  
elevation map first then the dots don't do the popup menu.  If I then  
redraw with the normal map option the popup menu bind gets bound to  
the dots from that point on.

Do I have to loop through all of the items and delete the tags before  
doing the .delete(ALL) or something?  This could be major.  I use a  
lot of Tags and binds on a lot of Canvases, but I've never noticed  
this before.  It's doing this on several OSs and versions of  
everything, so it must be me.

Thanks!

Bob
Michael Lange | 1 Sep 20:57 2009
Picon

Re: Canvas tag bindings not going away?

Hi Bob,

On Tue, 1 Sep 2009 12:07:45 -0600
Bob Greschke <bob <at> passcal.nmt.edu> wrote:

> Doesn't ACanvas.delete(ALL) get rid of bindings too?  I'm drawing  
> regular map dots (create_oval) on a Canvas "map" and each one gets a  
> Tag, like "P1", "P2", etc.  I do a tag_bind to <Button-3> to get a  
> popup menu item for each dot.  Everything works fine.
> 
> I then have two radiobuttons, one for a regular map (described
> above), and one for drawing the dots a different color depending on  
> elevation.  When the Redraw button is hit with the elevation map
> mode selected the canvas gets cleared, the background color gets
> changed, a .delete(ALL) is done (and a .find_all() returns ()), I
> redraw the create_oval()s with the same kind of Tags ("P1", "P2",
> etc.), but without doing a tag_bind to <Button-3> (same bunch of
> code, just with an if-statement to control which kind of dot gets
> drawn).  The new dots still react to a <Button-3> event like as if
> the TAG is still bound to the <Button-3> event.  If I start all over,
> but draw the elevation map first then the dots don't do the popup
> menu.  If I then redraw with the normal map option the popup menu
> bind gets bound to the dots from that point on.
> 
> Do I have to loop through all of the items and delete the tags
> before doing the .delete(ALL) or something?  This could be major.  I
> use a lot of Tags and binds on a lot of Canvases, but I've never
> noticed this before.  It's doing this on several OSs and versions of  
> everything, so it must be me.
> 
(Continue reading)

Bob Greschke | 1 Sep 22:08 2009

Re: Canvas tag bindings not going away?

> If I understand you correctly, what you describe is what I think that
> tag bindings are supposed to do. I tried the following:
>
>>>> from Tkinter import *
>>>> c = Canvas()
>>>> c.pack()
>>>> def test(ev):
> ...     print 'foo'
> ...
>>>> c.tag_bind('tag_foo', '<1>', test)
>>>> c.create_rectangle(0, 0, 100, 100, fill='blue', tags=('tag_foo'))
> 1
>>>> foo
> foo
> foo
> foo
>
> The "foo"s at the end of the snippet are of course from clicking the
> blue rectangle. The point here is, that the tag-binding is obviously
> active without any items being created, and I believe that is exactly
> what it is for; if you want the binding to be removed when the item is
> deleted, you should bind to the item-id instead, or maybe use
> tag_unbind() to remove the bindings.
>
> I hope this helps
>
> Michael

You are too smart.  I've only been goofing with this stuff for about 7  
years.  Looking through my code I now understand that I didn't know  
(Continue reading)

Greg Ewing | 2 Sep 00:23 2009
Picon
Picon

Re: Canvas tag bindings not going away?

Bob Greschke wrote:
> I redraw the  create_oval()s 
> with the same kind of Tags ("P1", "P2", etc.), but  without doing a 
> tag_bind to <Button-3> ...  The new  dots still react to 
> a <Button-3> event like as if the TAG is still  bound to the <Button-3> 
> event.

It probably is. You've told the canvas "<Button-3> on any
item tagged with "P3" does this", and haven't rescinded that
instruction.

In other words, the tag bindings are associated with the
canvas itself, not the individual items.

It sounds like you will indeed have to undo the tag
bindings explicitly.

Alternatively, come up with a tagging scheme that allows
you to re-use the same tags for the same bindings, instead
of inventing a new tag for each canvas item that you want
to bind an event to.

--

-- 
Greg
simha | 2 Sep 18:33 2009
Picon

Draw a table in Python 3.1


Hi all. I am very new to the world of python. I am desining a GUI using the
tkinter module and would like to include a table of 6 columns and n rows. I
am developing this code in windows xp. I downloaded a tktable module. But
not able to install this. Please help me in this regard. Thanks in advance
--

-- 
View this message in context: http://www.nabble.com/Draw-a-table-in-Python-3.1-tp25261023p25261023.html
Sent from the Python - tkinter-discuss mailing list archive at Nabble.com.
Peter Milliken | 4 Sep 00:42 2009
Picon

Re: Draw a table in Python 3.1

So what was the problem? 


I am assuming you are referring to the tktable available from http://tktable.sourceforge.net/?

Peter

On Thu, Sep 3, 2009 at 2:33 AM, simha <supersimha <at> gmail.com> wrote:

Hi all. I am very new to the world of python. I am desining a GUI using the
tkinter module and would like to include a table of 6 columns and n rows. I
am developing this code in windows xp. I downloaded a tktable module. But
not able to install this. Please help me in this regard. Thanks in advance
--
View this message in context: http://www.nabble.com/Draw-a-table-in-Python-3.1-tp25261023p25261023.html
Sent from the Python - tkinter-discuss mailing list archive at Nabble.com.

_______________________________________________
Tkinter-discuss mailing list
Tkinter-discuss <at> python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss

_______________________________________________
Tkinter-discuss mailing list
Tkinter-discuss <at> python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss
Peter Milliken | 4 Sep 01:13 2009
Picon

Re: Draw a table in Python 3.1

BTW, I have been looking at the Tktable from that source and it doesn't look like a straightforward process at all! Despite the fact the author of README.txt claims you can build it with cygwin if TEA is installed (not really clear what TEA is although I found a web-page, but the configure script tells me I have it installed on my system :-)), I certainly can't! 


If you then try and go down the route of using Visual Studio then you run into having to have Tcl8.4 installed - which I don't and since Tcl appears to be up to 8.5 and 8.6 makes it even harder!

So I would suggest that you contact the folk at the sourceforge project and ask somebody to email you a pre-built windows set of binaries (and ask them to work a bit harder on getting their Windows/cygwin port working :-)).

Peter

On Fri, Sep 4, 2009 at 8:42 AM, Peter Milliken <peter.milliken <at> gmail.com> wrote:
So what was the problem? 

I am assuming you are referring to the tktable available from http://tktable.sourceforge.net/?

Peter


On Thu, Sep 3, 2009 at 2:33 AM, simha <supersimha <at> gmail.com> wrote:

Hi all. I am very new to the world of python. I am desining a GUI using the
tkinter module and would like to include a table of 6 columns and n rows. I
am developing this code in windows xp. I downloaded a tktable module. But
not able to install this. Please help me in this regard. Thanks in advance
--
View this message in context: http://www.nabble.com/Draw-a-table-in-Python-3.1-tp25261023p25261023.html
Sent from the Python - tkinter-discuss mailing list archive at Nabble.com.

_______________________________________________
Tkinter-discuss mailing list
Tkinter-discuss <at> python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss


_______________________________________________
Tkinter-discuss mailing list
Tkinter-discuss <at> python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss
Guilherme Polo | 4 Sep 02:59 2009
Picon

Re: Draw a table in Python 3.1

2009/9/3 Peter Milliken <peter.milliken <at> gmail.com>:
> BTW, I have been looking at the Tktable from that source and it doesn't look
> like a straightforward process at all! Despite the fact the author of
> README.txt claims you can build it with cygwin if TEA is installed (not
> really clear what TEA is although I found a web-page, but the configure
> script tells me I have it installed on my system :-)), I certainly can't!
> If you then try and go down the route of using Visual Studio then you run
> into having to have Tcl8.4 installed - which I don't and since Tcl appears
> to be up to 8.5 and 8.6 makes it even harder!
> So I would suggest that you contact the folk at the sourceforge project and
> ask somebody to email you a pre-built windows set of binaries (and ask them
> to work a bit harder on getting their Windows/cygwin port working :-)).
> Peter
>

I would suggest using the Tcl/Tk distribution from ActiveState, that
is what I've done to (easily) use tktable on Windows before.

--

-- 
-- Guilherme H. Polo Goncalves
simha | 4 Sep 10:08 2009
Picon

Re: Draw a table in Python 3.1


Hi Guilherme Polo,
  Can you please me in a little detail how to install tktable module with
the python 3.1 version. I really need it badly and since you have used it,
can you please read me through the steps. Also if you have a working Tktable
module, can you please provide it to me. My mail id is supersimha <at> gmail.com
Thanks in advance

Guilherme Polo wrote:
> 
> 2009/9/3 Peter Milliken <peter.milliken <at> gmail.com>:
>> BTW, I have been looking at the Tktable from that source and it doesn't
>> look
>> like a straightforward process at all! Despite the fact the author of
>> README.txt claims you can build it with cygwin if TEA is installed (not
>> really clear what TEA is although I found a web-page, but the configure
>> script tells me I have it installed on my system :-)), I certainly can't!
>> If you then try and go down the route of using Visual Studio then you run
>> into having to have Tcl8.4 installed - which I don't and since Tcl
>> appears
>> to be up to 8.5 and 8.6 makes it even harder!
>> So I would suggest that you contact the folk at the sourceforge project
>> and
>> ask somebody to email you a pre-built windows set of binaries (and ask
>> them
>> to work a bit harder on getting their Windows/cygwin port working :-)).
>> Peter
>>
> 
> I would suggest using the Tcl/Tk distribution from ActiveState, that
> is what I've done to (easily) use tktable on Windows before.
> 
> 
> -- 
> -- Guilherme H. Polo Goncalves
> _______________________________________________
> Tkinter-discuss mailing list
> Tkinter-discuss <at> python.org
> http://mail.python.org/mailman/listinfo/tkinter-discuss
> 
> 

--

-- 
View this message in context: http://www.nabble.com/Draw-a-table-in-Python-3.1-tp25261023p25289513.html
Sent from the Python - tkinter-discuss mailing list archive at Nabble.com.
Harm Kirchhoff | 7 Sep 03:28 2009
Picon

Draw a table in Python 3.1

I looked into the same problem a while ago and I was not able to make the Tktable gadget work on windows.
If you ever manage, it would be great if you could post a detailed step-to-step list.

I found an alternative that worked even better in my case. 
There is a MultiListBox gadget (several versions exist) that emulates a table by putting a number of
synchronized lists next to each other. It features sorting, so that the table can be resorted by any column
at a mouse click and some other good features. Bigest set back is that it is not good for numerical
calculations. The fields are left adjusted and summing up &c. is optically not nice to implement.

HK

Gmane