<?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>Dan Bishop &#187; Reference</title>
	<atom:link href="http://www.danbishop.org/category/reference/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.danbishop.org</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Fri, 28 May 2010 07:16:25 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Programming with PyGTK and Glade</title>
		<link>http://www.danbishop.org/2010/02/02/programming-with-pygtk-and-glade/</link>
		<comments>http://www.danbishop.org/2010/02/02/programming-with-pygtk-and-glade/#comments</comments>
		<pubDate>Tue, 02 Feb 2010 16:17:19 +0000</pubDate>
		<dc:creator>Dan Bishop</dc:creator>
				<category><![CDATA[Reference]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[glade]]></category>
		<category><![CDATA[gtk]]></category>
		<category><![CDATA[guide]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://www.danbishop.org/?p=209</guid>
		<description><![CDATA[This is my translation of Florian Diesch&#8217;s guide found here: http://www.florian-diesch.de/doc/python-und-glade/online/einleitung.html I translated this guide as there doesn&#8217;t seem to be anything about using gtkbuilder and glade, rather than the older libGlade, with python. The guide is not yet complete, but I will keep working on it over the coming weeks. Dieser Werk bzw. Inhalt [...]]]></description>
			<content:encoded><![CDATA[<p>This is my translation of Florian Diesch&#8217;s guide found here: <a href="http://www.florian-diesch.de/doc/python-und-glade/online/einleitung.html" onclick="pageTracker._trackPageview('/outgoing/www.florian-diesch.de/doc/python-und-glade/online/einleitung.html?referer=');">http://www.florian-diesch.de/doc/python-und-glade/online/einleitung.html</a></p>
<p>I translated this guide as there doesn&#8217;t seem to be anything about using gtkbuilder and glade, rather than the older libGlade, with python. The guide is not yet complete, but I will keep working on it over the coming weeks.</p>
<p>Dieser Werk bzw. Inhalt ist unter einer <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/3.0/de/" onclick="pageTracker._trackPageview('/outgoing/creativecommons.org/licenses/by-nc-sa/3.0/de/?referer=');">Creative Commons-Lizenz</a> lizenziert. This work is released under a creative commons licence (cc-by-nc-sa).</p>
<p><span id="more-209"></span></p>
<h1>Introduction</h1>
<p>This guide should give you a first look at how to use the programming language Python and the interface designer Glade.</p>
<p>I will concentrate on the Python code rather than the use of Glade, which is already well documented in the Glade Interface Designer Handbook.</p>
<p>This text neither should, nor can be used as a replacement for the PyGTK Reference Manual, or the offical PyGTK Tutorial.</p>
<p>I will take it as a given that you have experience with Python and that you are working with Glade 3.6.x on Linux and that your project is saved in the GTKBuilder format for GTK 2.16.</p>
<h1>Signals and Events</h1>
<p>Like many libraries for graphical user interfaces, GTK is event driven. A central event loop waits until something happens then forwards the control onto the routines responsible for the processing of the event.</p>
<p>In order to process events, GTK uses signals: control elements and other objects react to events, which the corresponding signals trigger. Using these signals, you can control callbacks, which will then always be called, so that the corresponding signal will be triggered.</p>
<address>Note:</address>
<address>It is conventional to name callbacks &#8216;on_OBJECTNAME_SIGNALNAME&#8217; E.g. the &#8216;pressed&#8217; signal of the object bt_ok (an ok button) would be &#8216;on_bt_ok_pressed&#8217;.</address>
<p>Signals make the connection between the user interface and the program&#8217;s code such that: every action of the user triggers one or more signals, which you can connect to with callbacks, in order to react to the user&#8217;s request. In addition, signals are often used to enable different parts of the program to communicate with one another. Therefore, a GTK program often contains very many signal callback routines.</p>
<h1>Connecting to Signals</h1>
<p>Using the method gtk.Widget.connect() you can connect a callback with a signal.</p>
<p>Instead of this, you can use gtk.Builder.connect_signals() to automatically connect all callbacks with their corresponding signals.</p>
<p>Additionally, you must specify the name of the callback in the signal properties of the gui element in Glade.</p>
<p>Whilst a callback is being called, the main loop cannot process any signals. Therefore, the interface doesn&#8217;t react to the mouse, or the keyboard and also, changes to the interface elements are usually seen only after completion of the routine.</p>
<p>Therefore, in a callback which is activated by the keyboard/mouse, it is often useful to trigger a handler, for example a progress bar, using the following lines of code:</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">while</span> gtk.<span style="color: black;">events_pending</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>:
      gtk.<span style="color: black;">main_iteration</span> <span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></pre></div></div>

<h1>Important Functions</h1>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;">gtk.<span style="color: black;">main</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></pre></div></div>

<p>Starts the main loop.</p>
<p>This function is normally called after you have shown the main window of your program.</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;">gtk.<span style="color: black;">main_quit</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></pre></div></div>

<p>This function ends the main loop. It is usually called in the callback for the delete-even signal of your main window.</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;">gtk.<span style="color: black;">events_pending</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></pre></div></div>

<p>returns:	True if an event is waiting to be processed, otherwise False</p>
<p>Checks whether there is currently an event waiting to be processed.</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;">gtk.<span style="color: black;">main_iteration</span><span style="color: black;">&#40;</span>block=<span style="color: #008000;">True</span><span style="color: black;">&#41;</span></pre></div></div>

<p>Parameter:	block – True, if the function should wait an event has been processed.</p>
<p>Executes a single iteration of the main loop.</p>
<p>This function is typically called together with</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;">gtk.<span style="color: black;">events_pending</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></pre></div></div>

<p> in order to execute all queued events.</p>
<h1>Example</h1>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">def</span> on_window1_delete_event<span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, <span style="color: #66cc66;">*</span>args<span style="color: black;">&#41;</span>:
     gtk.<span style="color: black;">main_quit</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></pre></td></tr></table></div>

<p>This is the on_window1_delete_event, the callback for the delete-event signal of window &#8220;window1&#8243;. Should this window be destroyed (closed), then gtk.main_quit() will be called, so as to end the main loop and with that, the program itself.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.danbishop.org/2010/02/02/programming-with-pygtk-and-glade/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>MySQL Data Types</title>
		<link>http://www.danbishop.org/2009/01/07/mysql-data-types/</link>
		<comments>http://www.danbishop.org/2009/01/07/mysql-data-types/#comments</comments>
		<pubDate>Wed, 07 Jan 2009 13:28:03 +0000</pubDate>
		<dc:creator>Dan Bishop</dc:creator>
				<category><![CDATA[Reference]]></category>
		<category><![CDATA[mysql]]></category>

		<guid isPermaLink="false">http://www.danbishop.org/?p=75</guid>
		<description><![CDATA[I couldn&#8217;t find a nice table with all the data types and the limits associated with them in it, so I thought I&#8217;d trawl the web for each individual one and make one. This table is by no means exhaustive, but it does contain most of the common ones and will be updated as I [...]]]></description>
			<content:encoded><![CDATA[<p>I couldn&#8217;t find a nice table with all the data types and the limits associated with them in it, so I thought I&#8217;d trawl the web for each individual one and make one. This table is by no means exhaustive, but it does contain most of the common ones and will be updated as I need to use more of them for <a href="http://www.weblex.org/" target="_blank" onclick="pageTracker._trackPageview('/outgoing/www.weblex.org/?referer=');">WebLex</a> it also assumes that mysql 4.1 or greater is being used. Else some default values might be incorrect.</p>
<table border="1" cellspacing="2" cellpadding="2" width="550">
<tbody>
<tr>
<th scope="col"> Data Type</th>
<th scope="col"> What can it hold?</th>
</tr>
<tr>
<td>INT/INTEGER</td>
<td>An integer in the range  -2147483648 to 2147483647. Or, if set to unsigned the range is 0 to 4294967295.</td>
</tr>
<tr>
<td>TINYINT</td>
<td>An integer in the range  -128 to 127. Or, if set to unsigned the range is 0 to 255.</td>
</tr>
<tr>
<td>SMALLINT</td>
<td>An integer in the range  -32768 to 32767. Or, if set to unsigned the range is 0 to 65535.</td>
</tr>
<tr>
<td>MEDIUMINT</td>
<td>An integer in the range  -8388608 to 8388607. Or, if set to unsigned the range is 0 to 16777215.</td>
</tr>
<tr>
<td>BIGINT</td>
<td>An integer in the range  -9223372036854775808 to 9223372036854775807. Or, if set to unsigned the range is 0 to 18446744073709551615.</td>
</tr>
<tr>
<td>TEXT</td>
<td>Contains text upto a maximum length of 65535 characters.</td>
</tr>
<tr>
<td>TINYEXT</td>
<td>Contains text upto a maximum length of 255 characters.</td>
</tr>
<tr>
<td>MEDIUMTEXT</td>
<td>Contains text upto a maximum length of 16777215 characters.</td>
</tr>
<tr>
<td>LONGTEXT</td>
<td>Contains text upto a maximum length of 4294967295 characters.</td>
</tr>
<tr>
<td>ENUM(&#8216;x&#8217;,'y&#8217;,'z&#8217;,&#8230;)</td>
<td>Can only have a value as specified, by you, in the list of values in brackets. In this case it could only take &#8216;x&#8217;, &#8216;y&#8217;, or &#8216;z&#8217;. It can also take NULL or the special &#8220;&#8221; error value specified when the table is created. You can specify a maximum of 65535 values for an ENUM to take.</td>
</tr>
<tr>
<td>SET(&#8216;x&#8217;,'y&#8217;,'z&#8217;,&#8230;)</td>
<td>Very similar to ENUM except that more than one value can be assigned, so data could be both &#8216;x&#8217; and &#8216;y&#8217;, or &#8216;y&#8217; AND &#8216;z&#8217;. However, only 64 different values can be specified in a set.</td>
</tr>
<tr>
<td>CHAR(x)</td>
<td>Holds x characters, where 0≤x≤255. The default value of x (i.e. if just &#8220;CHAR&#8221; is used) is 1. If a value is entered that is less than x characters long, it will be appended with spaces until it is x characters long. However, upon retrieval, these spaces will be removed automatically.</td>
</tr>
<tr>
<td>VARCHAR(x)</td>
<td>Similar to char, except x is considered an &#8220;upto&#8221; value. Values are stored using only as many characters as they contain, plus an extra byte recording the length of the value. Any trailing spaces are removed from the value when it is stored in the database.</td>
</tr>
</tbody>
</table>
]]></content:encoded>
			<wfw:commentRss>http://www.danbishop.org/2009/01/07/mysql-data-types/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
