<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>
<channel>
	<title>Comments on: Writing a Widget Using Cairo and PyGTK 2.8</title>
	<atom:link href="http://www.oluyede.org/blog/2005/12/03/writing-a-widget-using-cairo-and-pygtk-28/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.oluyede.org/blog/2005/12/03/writing-a-widget-using-cairo-and-pygtk-28/</link>
	<description>Everything considered harmful</description>
	<pubDate>Sat, 11 Oct 2008 23:21:50 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.2</generator>
		<item>
		<title>By: PDI^2 :: Ruby-GNOME2, i binding dimenticati :: January :: 2006</title>
		<link>http://www.oluyede.org/blog/2005/12/03/writing-a-widget-using-cairo-and-pygtk-28/#comment-440</link>
		<dc:creator>PDI^2 :: Ruby-GNOME2, i binding dimenticati :: January :: 2006</dc:creator>
		<pubDate>Thu, 12 Jan 2006 15:08:38 +0000</pubDate>
		<guid isPermaLink="false">http://www.oluyede.org/blog/2005/12/03/writing-a-widget-using-cairo-and-pygtk-28/#comment-440</guid>
		<description>&lt;p&gt;[...] Colgo l&#8217;occasione invece per fare un port dell&#8217;applicazione che aveva tradotto lawrence da C a python, per mostrare come usare insieme Cairo e Gtk. Io ho fatto le prove su ubuntu breezy badger e su win32 e funzionano, per altre distro non garantisco [...]&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>[...] Colgo l&#8217;occasione invece per fare un port dell&#8217;applicazione che aveva tradotto lawrence da C a python, per mostrare come usare insieme Cairo e Gtk. Io ho fatto le prove su ubuntu breezy badger e su win32 e funzionano, per altre distro non garantisco [...]</p>]]></content:encoded>
	</item>
	<item>
		<title>By: riffraff</title>
		<link>http://www.oluyede.org/blog/2005/12/03/writing-a-widget-using-cairo-and-pygtk-28/#comment-342</link>
		<dc:creator>riffraff</dc:creator>
		<pubDate>Wed, 07 Dec 2005 14:17:09 +0000</pubDate>
		<guid isPermaLink="false">http://www.oluyede.org/blog/2005/12/03/writing-a-widget-using-cairo-and-pygtk-28/#comment-342</guid>
		<description>&lt;p&gt;emh.. code got deleted:
require 'cairo'
require 'gtk2'&lt;/p&gt;

&lt;p&gt;class EggClockFace &#60; Gtk::DrawingArea
  def initialize
    super
    self.redraw_on_allocate=true
    signal_connect "expose_event" do &#124;widget,event&#124;
      ctx= widget.window.create_cairo_context
      ctx.rectangle(event.area.x, event.area.y,
                    event.area.width, event.area.height)
      ctx.clip
      draw(ctx)
      false
    end
  end
  def draw(ctx)
        rect = allocation()
        x = rect.x + rect.width / 2.0
        y = rect.y + rect.height / 2.0&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;    radius = [rect.width / 2.0, rect.height / 2.0].min - 5

    # clock back
    ctx.arc(x, y, radius, 0, 2.0 * Math::PI)
    ctx.set_source_rgb(1, 1, 1)
    ctx.fill_preserve()
    ctx.set_source_rgb(0, 0, 0)
    ctx.stroke()

    for i in 0..11
        inset = 0.1 * radius

        ctx.move_to(x + (radius - inset) * Math.cos(i * Math::PI / 6.0),
                        y + (radius - inset) * Math.sin(i * Math::PI / 6.0))
        ctx.line_to(x + radius * Math.cos(i * Math::PI / 6.0),
                        y + radius * Math.sin(i * Math::PI / 6.0))
        ctx.stroke()
    end
    ctx.stroke()
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;end
end&lt;/p&gt;

&lt;p&gt;Gtk.init
window = Gtk::Window.new
clock = EggClockFace.new&lt;/p&gt;

&lt;p&gt;window.add(clock)
window.signal_connect "destroy" do
 Gtk.main_quit
end
window.show_all()&lt;/p&gt;

&lt;p&gt;Gtk.main()&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>emh.. code got deleted:
require &#8216;cairo&#8217;
require &#8216;gtk2&#8242;</p>

<p>class EggClockFace &lt; Gtk::DrawingArea
  def initialize
    super
    self.redraw_on_allocate=true
    signal_connect &#8220;expose_event&#8221; do |widget,event|
      ctx= widget.window.create_cairo_context
      ctx.rectangle(event.area.x, event.area.y,
                    event.area.width, event.area.height)
      ctx.clip
      draw(ctx)
      false
    end
  end
  def draw(ctx)
        rect = allocation()
        x = rect.x + rect.width / 2.0
        y = rect.y + rect.height / 2.0</p>

<pre><code>    radius = [rect.width / 2.0, rect.height / 2.0].min - 5

    # clock back
    ctx.arc(x, y, radius, 0, 2.0 * Math::PI)
    ctx.set_source_rgb(1, 1, 1)
    ctx.fill_preserve()
    ctx.set_source_rgb(0, 0, 0)
    ctx.stroke()

    for i in 0..11
        inset = 0.1 * radius

        ctx.move_to(x + (radius - inset) * Math.cos(i * Math::PI / 6.0),
                        y + (radius - inset) * Math.sin(i * Math::PI / 6.0))
        ctx.line_to(x + radius * Math.cos(i * Math::PI / 6.0),
                        y + radius * Math.sin(i * Math::PI / 6.0))
        ctx.stroke()
    end
    ctx.stroke()
</code></pre>

<p>end
end</p>

<p>Gtk.init
window = Gtk::Window.new
clock = EggClockFace.new</p>

<p>window.add(clock)
window.signal_connect &#8220;destroy&#8221; do
 Gtk.main_quit
end
window.show_all()</p>

<p>Gtk.main()</p>]]></content:encoded>
	</item>
	<item>
		<title>By: riffraff</title>
		<link>http://www.oluyede.org/blog/2005/12/03/writing-a-widget-using-cairo-and-pygtk-28/#comment-341</link>
		<dc:creator>riffraff</dc:creator>
		<pubDate>Wed, 07 Dec 2005 14:15:41 +0000</pubDate>
		<guid isPermaLink="false">http://www.oluyede.org/blog/2005/12/03/writing-a-widget-using-cairo-and-pygtk-28/#comment-341</guid>
		<description>&lt;p&gt;I know you were trying to redo this in ruby..
I got it working with this:&lt;/p&gt;

&lt;p&gt;require 'cairo'
require 'gtk2'&lt;/p&gt;

&lt;p&gt;class EggClockFace&lt;/p&gt;

&lt;p&gt;by installing first rcairo-1.0.0 and then ruby-gnome2-0.14.1 from source on ubuntu breezy (and after installing a boatload of xyz-dev packages with apt). The code could be more rubyified, anyway, but my box is dead ATM.&lt;/p&gt;

&lt;p&gt;No time to blog it, though ;)&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>I know you were trying to redo this in ruby..
I got it working with this:</p>

<p>require &#8216;cairo&#8217;
require &#8216;gtk2&#8242;</p>

<p>class EggClockFace</p>

<p>by installing first rcairo-1.0.0 and then ruby-gnome2-0.14.1 from source on ubuntu breezy (and after installing a boatload of xyz-dev packages with apt). The code could be more rubyified, anyway, but my box is dead ATM.</p>

<p>No time to blog it, though <img src='http://www.oluyede.org/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>]]></content:encoded>
	</item>
	<item>
		<title>By: Lawrence</title>
		<link>http://www.oluyede.org/blog/2005/12/03/writing-a-widget-using-cairo-and-pygtk-28/#comment-336</link>
		<dc:creator>Lawrence</dc:creator>
		<pubDate>Tue, 06 Dec 2005 09:59:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.oluyede.org/blog/2005/12/03/writing-a-widget-using-cairo-and-pygtk-28/#comment-336</guid>
		<description>&lt;p&gt;Thanks for the reply Sebastian!&lt;/p&gt;

&lt;p&gt;1 - there's no compelling reason to use super() instead of the old method in a single inheritance situation (anyway I corrected)&lt;/p&gt;

&lt;p&gt;2 - ok for the floating point division&lt;/p&gt;

&lt;p&gt;3 - draw() is an explicit override&lt;/p&gt;

&lt;p&gt;4 - self.context is just a matter of style,  I wrote the conversion quickly and this should be also a mistake :)&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Thanks for the reply Sebastian!</p>

<p>1 - there&#8217;s no compelling reason to use super() instead of the old method in a single inheritance situation (anyway I corrected)</p>

<p>2 - ok for the floating point division</p>

<p>3 - draw() is an explicit override</p>

<p>4 - self.context is just a matter of style,  I wrote the conversion quickly and this should be also a mistake <img src='http://www.oluyede.org/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>]]></content:encoded>
	</item>
	<item>
		<title>By: Sebastian Rittau</title>
		<link>http://www.oluyede.org/blog/2005/12/03/writing-a-widget-using-cairo-and-pygtk-28/#comment-335</link>
		<dc:creator>Sebastian Rittau</dc:creator>
		<pubDate>Tue, 06 Dec 2005 01:23:19 +0000</pubDate>
		<guid isPermaLink="false">http://www.oluyede.org/blog/2005/12/03/writing-a-widget-using-cairo-and-pygtk-28/#comment-335</guid>
		<description>&lt;p&gt;Great to see that you converted this tutorial to Python. Many thanks! Here are some questions/suggestions, though:&lt;/p&gt;

&lt;p&gt;def &lt;strong&gt;init&lt;/strong&gt;(self):
      gtk.DrawingArea.&lt;strong&gt;init&lt;/strong&gt;(self)&lt;/p&gt;

&lt;p&gt;I would recommend to use the super operator:&lt;/p&gt;

&lt;p&gt;def &lt;strong&gt;init&lt;/strong&gt;(self):
      super(EggClockFace, self).&lt;strong&gt;init&lt;/strong&gt;()&lt;/p&gt;

&lt;hr /&gt;

&lt;p&gt;rect = self.get_allocation()
  x = rect.x + rect.width / 2
  y = rect.y + rect.height / 2&lt;/p&gt;

&lt;p&gt;It's probably better to make sure (for now) that floating point numbers are used for the division:&lt;/p&gt;

&lt;p&gt;rect = self.get_allocation()
  x = rect.x + rect.width / 2.0
  y = rect.y + rect.height / 2.0&lt;/p&gt;

&lt;p&gt;Or if you want to force an integer division:&lt;/p&gt;

&lt;p&gt;rect = self.get_allocation()
  x = rect.x + rect.width // 2
  y = rect.y + rect.height // 2&lt;/p&gt;

&lt;hr /&gt;

&lt;p&gt;def expose(self, widget, event):
      self.context = widget.window.cairo_create()&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;  self.draw(self.context)
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Well, self.draw is actually an inherited method from gtk.Widget. I would recommend to rename that method to draw_face or something similar.&lt;/p&gt;

&lt;p&gt;Also, why do you store the context in a member?&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Great to see that you converted this tutorial to Python. Many thanks! Here are some questions/suggestions, though:</p>

<p>def <strong>init</strong>(self):
      gtk.DrawingArea.<strong>init</strong>(self)</p>

<p>I would recommend to use the super operator:</p>

<p>def <strong>init</strong>(self):
      super(EggClockFace, self).<strong>init</strong>()</p>

<hr />

<p>rect = self.get_allocation()
  x = rect.x + rect.width / 2
  y = rect.y + rect.height / 2</p>

<p>It&#8217;s probably better to make sure (for now) that floating point numbers are used for the division:</p>

<p>rect = self.get_allocation()
  x = rect.x + rect.width / 2.0
  y = rect.y + rect.height / 2.0</p>

<p>Or if you want to force an integer division:</p>

<p>rect = self.get_allocation()
  x = rect.x + rect.width // 2
  y = rect.y + rect.height // 2</p>

<hr />

<p>def expose(self, widget, event):
      self.context = widget.window.cairo_create()</p>

<pre><code>  self.draw(self.context)
</code></pre>

<p>Well, self.draw is actually an inherited method from gtk.Widget. I would recommend to rename that method to draw_face or something similar.</p>

<p>Also, why do you store the context in a member?</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Rafael Villar Burke</title>
		<link>http://www.oluyede.org/blog/2005/12/03/writing-a-widget-using-cairo-and-pygtk-28/#comment-333</link>
		<dc:creator>Rafael Villar Burke</dc:creator>
		<pubDate>Mon, 05 Dec 2005 10:12:15 +0000</pubDate>
		<guid isPermaLink="false">http://www.oluyede.org/blog/2005/12/03/writing-a-widget-using-cairo-and-pygtk-28/#comment-333</guid>
		<description>&lt;p&gt;Nice article!. This article is now included (as a link to your blog) in the articles section in the pygtk.org website. We'd like to have a copy of it too in our site just in case your blog changes its address or it gets unavaliable. Would you mind it?.&lt;/p&gt;

&lt;p&gt;Thanks for your work and letting others enjoy it.&lt;/p&gt;

&lt;p&gt;Rafael&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Nice article!. This article is now included (as a link to your blog) in the articles section in the pygtk.org website. We&#8217;d like to have a copy of it too in our site just in case your blog changes its address or it gets unavaliable. Would you mind it?.</p>

<p>Thanks for your work and letting others enjoy it.</p>

<p>Rafael</p>]]></content:encoded>
	</item>
</channel>
</rss>
