Thanks.<br>I will add a function to detect the &quot;brush_like_tools&quot;.<br><br>Gonzalo <br><br><div class="gmail_quote">On Thu, Jun 3, 2010 at 4:03 AM, James Cameron <span dir="ltr">&lt;<a href="mailto:quozl@laptop.org">quozl@laptop.org</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div class="im">On Wed, Jun 02, 2010 at 08:03:29PM -0300, Gonzalo Odiard wrote:<br>
&gt; &gt;From 3ac11e0be2adc0c805788c38ab90b3226d625a89 Mon Sep 17 00:00:00 2001<br>
&gt; From: Gonzalo Odiard &lt;<a href="mailto:godiard@gmail.com">godiard@gmail.com</a>&gt;<br>
&gt; Date: Wed, 2 Jun 2010 20:01:10 -0300<br>
&gt; Subject: [PATCH] hide brush when mouse leave area<br>
&gt;<br>
&gt; ---<br>
&gt;  Area.py |   15 ++++++++++++++-<br>
&gt;  1 files changed, 14 insertions(+), 1 deletions(-)<br>
&gt;<br>
&gt; diff --git a/Area.py b/Area.py<br>
&gt; index 8a5e523..c83f38f 100644<br>
&gt; --- a/Area.py<br>
&gt; +++ b/Area.py<br>
&gt; @@ -97,11 +97,15 @@ class Area(gtk.DrawingArea):<br>
&gt;                  gtk.gdk.BUTTON_PRESS_MASK |<br>
&gt;                  gtk.gdk.BUTTON_RELEASE_MASK|<br>
&gt;                  gtk.gdk.EXPOSURE_MASK |<br>
&gt; +                gtk.gdk.LEAVE_NOTIFY_MASK|<br>
&gt; +                gtk.gdk.ENTER_NOTIFY_MASK|<br>
<br>
</div>Unnecessary change of spacing for expression.<br>
<div class="im"><br>
&gt;                  gtk.gdk.KEY_PRESS_MASK)<br>
&gt;<br>
&gt;          self.connect(&quot;expose_event&quot;,self.expose)<br>
&gt;          self.connect(&quot;motion_notify_event&quot;, self.mousemove)<br>
&gt;          self.connect(&quot;button_press_event&quot;, self.mousedown)<br>
&gt; +        self.connect(&quot;leave_notify_event&quot;, self.mouseleave)<br>
&gt; +        self.connect(&quot;enter_notify_event&quot;, self.mouseenter)<br>
&gt;          self.connect(&quot;button_release_event&quot;, self.mouseup)<br>
&gt;          self.connect(&quot;key_press_event&quot;, self.key_press)<br>
&gt;<br>
&gt; @@ -353,8 +357,17 @@ class Area(gtk.DrawingArea):<br>
&gt;              self.desenha = True<br>
&gt;          widget.queue_draw()<br>
&gt;<br>
&gt; -<br>
&gt; +    def mouseleave(self,widget,event):<br>
&gt; +        if self.tool[&#39;name&#39;] in [&#39;pencil&#39;,&#39;eraser&#39;,&#39;brush&#39;,&#39;rainbow&#39;]:<br>
<br>
</div>We are seeing this test more and more.  What pain you will experience<br>
when you add another tool name to that list.  Perhaps it should be a<br>
list in the object attributes, or even a function.<br>
<br>
&gt; +            self.drawing = True<br>
<div class="im">&gt; +            widget.queue_draw_area(self.x_cursor-size, self.y_cursor-size,<br>
&gt; size*2, size*2)<br>
<br>
</div>size is not defined, generates traceback in log.<br>
<br>
&gt;<br>
&gt; +    def mouseenter(self,widget,event):<br>
<div class="im">&gt; +        if self.tool[&#39;name&#39;] in [&#39;pencil&#39;,&#39;eraser&#39;,&#39;brush&#39;,&#39;rainbow&#39;]:<br>
&gt; +            self.drawing = False<br>
&gt; +            widget.queue_draw_area(self.x_cursor-size, self.y_cursor-size,<br>
&gt; size*2, size*2)<br>
<br>
</div>size is not defined.<br>
<br>
The call to queue_draw_area could be factored.<br>
<br>
Counter-proposal:<br>
<br>
>From e0b197a8b8058399c557d4e591b2cac4833ffdf2 Mon Sep 17 00:00:00 2001<br>
From: James Cameron &lt;<a href="mailto:quozl@laptop.org">quozl@laptop.org</a>&gt;<br>
Date: Thu, 3 Jun 2010 16:59:10 +1000<br>
<div class="im">Subject: [PATCH] hide brush when mouse leave area<br>
<br>
</div>Adds an enter and leave event handler for the drawing area, in order<br>
to draw or not draw the outline cursor.<br>
<br>
Tested-by: James Cameron &lt;<a href="mailto:quozl@laptop.org">quozl@laptop.org</a>&gt;<br>
---<br>
 Area.py |   20 +++++++++++++++++---<br>
 1 files changed, 17 insertions(+), 3 deletions(-)<br>
<div class="im"><br>
diff --git a/Area.py b/Area.py<br>
</div>index 570d093..a7f0bd0 100644<br>
<div class="im">--- a/Area.py<br>
+++ b/Area.py<br>
@@ -97,11 +97,15 @@ class Area(gtk.DrawingArea):<br>
                 gtk.gdk.BUTTON_PRESS_MASK |<br>
                 gtk.gdk.BUTTON_RELEASE_MASK|<br>
                 gtk.gdk.EXPOSURE_MASK |<br>
</div>-                gtk.gdk.KEY_PRESS_MASK)<br>
<div class="im">-<br>
+                gtk.gdk.LEAVE_NOTIFY_MASK |<br>
+                gtk.gdk.ENTER_NOTIFY_MASK |<br>
+                gtk.gdk.KEY_PRESS_MASK)<br>
+<br>
         self.connect(&quot;expose_event&quot;,self.expose)<br>
         self.connect(&quot;motion_notify_event&quot;, self.mousemove)<br>
         self.connect(&quot;button_press_event&quot;, self.mousedown)<br>
+        self.connect(&quot;leave_notify_event&quot;, self.mouseleave)<br>
+        self.connect(&quot;enter_notify_event&quot;, self.mouseenter)<br>
         self.connect(&quot;button_release_event&quot;, self.mouseup)<br>
         self.connect(&quot;key_press_event&quot;, self.key_press)<br>
<br>
</div>@@ -353,8 +357,18 @@ class Area(gtk.DrawingArea):<br>
<div class="im">             self.desenha = True<br>
         widget.queue_draw()<br>
<br>
+    def mouseleave(self, widget, event):<br>
+        if self.tool[&#39;name&#39;] in [&#39;pencil&#39;,&#39;eraser&#39;,&#39;brush&#39;,&#39;rainbow&#39;]:<br>
+            self.drawing = True<br>
</div><div class="im">+            size = self.tool[&#39;line size&#39;]<br>
</div>+            widget.queue_draw_area(self.x_cursor-size, self.y_cursor-size, size*2, size*2)<br>
<div class="im">+<br>
+    def mouseenter(self, widget, event):<br>
+        if self.tool[&#39;name&#39;] in [&#39;pencil&#39;,&#39;eraser&#39;,&#39;brush&#39;,&#39;rainbow&#39;]:<br>
+            self.drawing = False<br>
</div><div class="im">+            size = self.tool[&#39;line size&#39;]<br>
</div>+            widget.queue_draw_area(self.x_cursor-size, self.y_cursor-size, size*2, size*2)<br>
<div class="im"><br>
-<br>
     def mousemove(self,widget,event):<br>
         &quot;&quot;&quot;Make the Area object (GtkDrawingArea) recognize that the mouse is moving.<br>
<br>
--<br>
</div>1.7.1<br>
<div><div></div><div class="h5"><br>
--<br>
James Cameron<br>
<a href="http://quozl.linux.org.au/" target="_blank">http://quozl.linux.org.au/</a><br>
</div></div></blockquote></div><br><br>