<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>bobpeers -&#62; blog &#187; glade</title>
	<atom:link href="http://blog.bobpeers.com/tag/glade/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.bobpeers.com</link>
	<description>Better late than never</description>
	<lastBuildDate>Fri, 24 Jun 2011 12:34:48 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Creating Linux Applications Using PyGTK</title>
		<link>http://blog.bobpeers.com/2008/09/30/creating-linux-applications-using-pygtk/</link>
		<comments>http://blog.bobpeers.com/2008/09/30/creating-linux-applications-using-pygtk/#comments</comments>
		<pubDate>Tue, 30 Sep 2008 10:06:04 +0000</pubDate>
		<dc:creator>Bob Peers</dc:creator>
				<category><![CDATA[Computing]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[glade]]></category>
		<category><![CDATA[gui]]></category>
		<category><![CDATA[pygtk]]></category>
		<category><![CDATA[pyhon]]></category>

		<guid isPermaLink="false">http://blog.bobpeers.com/2008/09/30/creating-linux-applications-using-pygtk/</guid>
		<description><![CDATA[I&#8217;ve looked at using python to create GUIs in Linux a few times but coming from a background of using Visual Basic it seemed very different and the learning curve a bit steep. This time I decided to really give it a new try and I have to say that it&#8217;s way easier than I [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve looked at using python to create GUIs in Linux a few times but coming from a background of using Visual Basic it seemed very different and the learning curve a bit steep. This time I decided to really give it a new try and I have to say that it&#8217;s way easier than I expected.</p>
<p>My first recommendation is to use <a href="http://glade.gnome.org/">glade-3</a>. Last time I used glade-2 but I have a real problem with the multiple windows concept as windows keep disappearing behind other application windows. If you use gtk.Builder then the glade file created by glade-3 needs to be converted to a compatible xml file before it can be loaded, but this is easy to achieve with the following command.</p>
<pre>$ gtk-builder-convert gui.glade gui.xml</pre>
<p>From there I was amazed how easy it was to attach events and quickly write code, a very basic example to load an xml file an attach events is shown here.</p>
<p>This is the xml file created by using glade and running gtk-builder-convert. It&#8217;s just a window containing a button.</p>
<pre>&lt;?xml version="1.0"?>
&lt;!--Generated with glade3 3.4.4 on Tue Sep 30 11:46:18 2008 -->
&lt;interface>
  &lt;object class="GtkWindow" id="window1">
    &lt;signal handler="on_window1_destroy" name="destroy"/>
    &lt;child>
      &lt;object class="GtkButton" id="button1">
        &lt;property name="visible">True&lt;/property>
        &lt;property name="can_focus">True&lt;/property>
        &lt;property name="receives_default">True&lt;/property>
        &lt;property name="label" translatable="yes">gtk-close&lt;/property>
        &lt;property name="use_stock">True&lt;/property>
        &lt;signal handler="on_button1_clicked" name="clicked"/>
      &lt;/object>
    &lt;/child>
  &lt;/object>
&lt;/interface>
</pre>
<p>This is the python code to run the gui, very simple indeed.</p>
<pre>#!/usr/bin/env python 

import pygtk
import gtk
pygtk.require("2.0") 

class GUI(object):
  def __init__(self):
      builder = gtk.Builder()
      builder.add_from_file("GUI.xml")
      builder.connect_signals(self)
      self.window1 = builder.get_object("window1")
      self.window1.show()

  def on_window1_destroy(self,widget,data=None):
      gtk.main_quit()

  def on_button1_clicked(self,widget,data=None):
      gtk.main_quit()  

if __name__ == "__main__":
  app = GUI()
  gtk.main()
</pre>
<p>To run just save the python file as gui.py, chmod +x the python file and then run using ./gui.py. Just make sure the xml file is in the same directory as the python file.</p>
<p>I&#8217;ll post more pygtk as I learn but so far I&#8217;m amazed how easy it is to create very professional looking applications in a very short time. There are thousands of tutorials on pygtk on the net but I found this one very useful.</p>
<p><a href="http://www.micahcarrick.com/12-24-2007/gtk-glade-tutorial-part-1.html">http://www.micahcarrick.com/12-24-2007/gtk-glade-tutorial-part-1.html</a></p>
<p><!--[if IE]><iframe frameborder="0" allowTransparency="true" class="addtoany_special_service twitter_tweet" src="http://platform.twitter.com/widgets/tweet_button.html?url=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F09%2F30%2Fcreating-linux-applications-using-pygtk%2F&amp;counturl=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F09%2F30%2Fcreating-linux-applications-using-pygtk%2F&amp;count=none&amp;text=Creating%20Linux%20Applications%20Using%20PyGTK" scrolling="no" style="border:none;overflow:hidden;width:55px;height:20px"></iframe><![endif]--><!--[if !IE]><!--><iframe class="addtoany_special_service twitter_tweet" src="http://platform.twitter.com/widgets/tweet_button.html?url=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F09%2F30%2Fcreating-linux-applications-using-pygtk%2F&amp;counturl=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F09%2F30%2Fcreating-linux-applications-using-pygtk%2F&amp;count=none&amp;text=Creating%20Linux%20Applications%20Using%20PyGTK" scrolling="no" style="border:none;overflow:hidden;width:55px;height:20px"></iframe><!--<![endif]--><!--[if IE]><iframe frameborder="0" allowTransparency="true" class="addtoany_special_service facebook_like" src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F09%2F30%2Fcreating-linux-applications-using-pygtk%2F&amp;layout=button_count&amp;show_faces=false&amp;width=75&amp;action=like&amp;colorscheme=light&amp;height=20&amp;ref=addtoany" scrolling="no" style="border:none;overflow:hidden;width:90px;height:21px"></iframe><![endif]--><!--[if !IE]><!--><iframe class="addtoany_special_service facebook_like" src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F09%2F30%2Fcreating-linux-applications-using-pygtk%2F&amp;layout=button_count&amp;show_faces=false&amp;width=75&amp;action=like&amp;colorscheme=light&amp;height=20&amp;ref=addtoany" scrolling="no" style="border:none;overflow:hidden;width:90px;height:21px"></iframe><!--<![endif]--><!--[if IE]><iframe frameborder="0" allowTransparency="true" class="addtoany_special_service google_plusone" src="https://plusone.google.com/u/0/_/%2B1/fastbutton?url=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F09%2F30%2Fcreating-linux-applications-using-pygtk%2F&amp;size=medium&amp;count=false" scrolling="no" style="border:none;overflow:hidden;width:32px;height:20px"></iframe><![endif]--><!--[if !IE]><!--><iframe class="addtoany_special_service google_plusone" src="https://plusone.google.com/u/0/_/%2B1/fastbutton?url=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F09%2F30%2Fcreating-linux-applications-using-pygtk%2F&amp;size=medium&amp;count=false" scrolling="no" style="border:none;overflow:hidden;width:32px;height:20px"></iframe><!--<![endif]--><a class="a2a_button_google_bookmarks" href="http://www.addtoany.com/add_to/google_bookmarks?linkurl=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F09%2F30%2Fcreating-linux-applications-using-pygtk%2F&amp;linkname=Creating%20Linux%20Applications%20Using%20PyGTK" title="Google Bookmarks" rel="nofollow" target="_blank"><img src="http://blog.bobpeers.com/wp-content/plugins/add-to-any/icons/google.png" width="16" height="16" alt="Google Bookmarks"/></a><a class="a2a_button_evernote" href="http://www.addtoany.com/add_to/evernote?linkurl=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F09%2F30%2Fcreating-linux-applications-using-pygtk%2F&amp;linkname=Creating%20Linux%20Applications%20Using%20PyGTK" title="Evernote" rel="nofollow" target="_blank"><img src="http://blog.bobpeers.com/wp-content/plugins/add-to-any/icons/evernote.png" width="16" height="16" alt="Evernote"/></a><a class="a2a_button_google_gmail" href="http://www.addtoany.com/add_to/google_gmail?linkurl=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F09%2F30%2Fcreating-linux-applications-using-pygtk%2F&amp;linkname=Creating%20Linux%20Applications%20Using%20PyGTK" title="Google Gmail" rel="nofollow" target="_blank"><img src="http://blog.bobpeers.com/wp-content/plugins/add-to-any/icons/gmail.png" width="16" height="16" alt="Google Gmail"/></a><a class="a2a_button_hotmail" href="http://www.addtoany.com/add_to/hotmail?linkurl=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F09%2F30%2Fcreating-linux-applications-using-pygtk%2F&amp;linkname=Creating%20Linux%20Applications%20Using%20PyGTK" title="Hotmail" rel="nofollow" target="_blank"><img src="http://blog.bobpeers.com/wp-content/plugins/add-to-any/icons/live.png" width="16" height="16" alt="Hotmail"/></a><a class="a2a_button_wordpress" href="http://www.addtoany.com/add_to/wordpress?linkurl=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F09%2F30%2Fcreating-linux-applications-using-pygtk%2F&amp;linkname=Creating%20Linux%20Applications%20Using%20PyGTK" title="WordPress" rel="nofollow" target="_blank"><img src="http://blog.bobpeers.com/wp-content/plugins/add-to-any/icons/wordpress.png" width="16" height="16" alt="WordPress"/></a><a class="a2a_button_linkedin" href="http://www.addtoany.com/add_to/linkedin?linkurl=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F09%2F30%2Fcreating-linux-applications-using-pygtk%2F&amp;linkname=Creating%20Linux%20Applications%20Using%20PyGTK" title="LinkedIn" rel="nofollow" target="_blank"><img src="http://blog.bobpeers.com/wp-content/plugins/add-to-any/icons/linkedin.png" width="16" height="16" alt="LinkedIn"/></a><a class="a2a_button_facebook" href="http://www.addtoany.com/add_to/facebook?linkurl=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F09%2F30%2Fcreating-linux-applications-using-pygtk%2F&amp;linkname=Creating%20Linux%20Applications%20Using%20PyGTK" title="Facebook" rel="nofollow" target="_blank"><img src="http://blog.bobpeers.com/wp-content/plugins/add-to-any/icons/facebook.png" width="16" height="16" alt="Facebook"/></a><a class="a2a_button_delicious" href="http://www.addtoany.com/add_to/delicious?linkurl=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F09%2F30%2Fcreating-linux-applications-using-pygtk%2F&amp;linkname=Creating%20Linux%20Applications%20Using%20PyGTK" title="Delicious" rel="nofollow" target="_blank"><img src="http://blog.bobpeers.com/wp-content/plugins/add-to-any/icons/delicious.png" width="16" height="16" alt="Delicious"/></a><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F09%2F30%2Fcreating-linux-applications-using-pygtk%2F&amp;title=Creating%20Linux%20Applications%20Using%20PyGTK" id="wpa2a_2"><img src="http://blog.bobpeers.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://blog.bobpeers.com/2008/09/30/creating-linux-applications-using-pygtk/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>

