<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress.com" -->
<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/"
	>

<channel>
	<title>pygtk &amp;laquo; WordPress.com Tag Feed</title>
	<link>http://en.wordpress.com/tag/pygtk/</link>
	<description>Feed of posts on WordPress.com tagged "pygtk"</description>
	<pubDate>Sun, 29 Nov 2009 06:50:31 +0000</pubDate>

	<generator>http://en.wordpress.com/tags/</generator>
	<language>en</language>

<item>
<title><![CDATA[Charla "Introducción al Desarrollo de Aplicaciones con PyGTK" en IRC]]></title>
<link>http://tecnotaku.wordpress.com/2009/11/20/charla-introduccion-al-desarrollo-de-aplicaciones-con-pygtk-en-irc/</link>
<pubDate>Fri, 20 Nov 2009 16:14:58 +0000</pubDate>
<dc:creator>zero2004</dc:creator>
<guid>http://tecnotaku.wordpress.com/2009/11/20/charla-introduccion-al-desarrollo-de-aplicaciones-con-pygtk-en-irc/</guid>
<description><![CDATA[La asociación de GNOME Hispano anunció con este mensaje en su lista de correo la próxima charla ]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><div id="HOTWordsTxt">
<p>La asociación de <a href="http://es.gnome.org/">GNOME  Hispano</a> anunció con <a href="http://mail.gnome.org/archives/gnome-hispano-list/2009-November/msg00014.html">este  mensaje</a> en su lista de correo la próxima charla <em>&#8220;Introducción  al Desarrollo de Aplicaciones con PyGTK&#8221;</em> a llevarse a cabo el  próxmo <strong>Sábado 21 de Noviembre</strong> en el marco de sus <a href="http://es.gnome.org/Eventos/CharlasIRC">Charlas IRC</a> mensuales.  La charla se realizará el canal <code>#gnome-hispano</code> de <strong>irc.gnome.org</strong> a las 17 hrs. UTC (14:00 hrs. de Argentina, si no me equivoco) y estará  a cargo de Alejandro Valdés, un miembro de la comunidad de GNOME.</p>
<p>La temática de la charla estará dividida en dos partes:</p>
<ol>
<li>Un poco de teoría: programación por  <a href="http://www.vivalinux.com.ar/eventos/charla-desarrollo-pygtk-gnome-irc#">eventos</a>, widgets, <em>signals</em>,  <em>callbacks</em>, etc.</li>
<li>Ejercicios: Partiendo desde un ejemplo interactivo con Python,  pasado por ejemplos con/sin señales, ejemplos con/sin  libglade/gtkbuilder, ejemplos con/sin clases, terminando con algunos  ejemplos de como utilizar algunos cosas  <a href="http://www.vivalinux.com.ar/eventos/charla-desarrollo-pygtk-gnome-irc#">interesantes</a> como gconf, vte,  treeview, gettext, etc.</li>
</ol>
<ul>
<li>Artículo completo en <a href="http://diariolinux.com/2009/11/15/charla-irc-de-noviembre-gnome-hispano/">DiarioLinux</a>.</li>
</ul>
</div>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Wiithon 1.1 publicado!]]></title>
<link>http://blogricardo.wordpress.com/2009/11/20/wiithon-1-1-publicado/</link>
<pubDate>Fri, 20 Nov 2009 03:16:00 +0000</pubDate>
<dc:creator>makiolo</dc:creator>
<guid>http://blogricardo.wordpress.com/2009/11/20/wiithon-1-1-publicado/</guid>
<description><![CDATA[Actualizado: sábado, 21 de noviembre de 2009 Bueno por fin publicamos la nueva versión tras casi 5 m]]></description>
<content:encoded><![CDATA[Actualizado: sábado, 21 de noviembre de 2009 Bueno por fin publicamos la nueva versión tras casi 5 m]]></content:encoded>
</item>
<item>
<title><![CDATA[Turpial: Un cliente Twitter para GNU/Linux con todos los hierros]]></title>
<link>http://damncorner.wordpress.com/2009/11/19/turpial-un-cliente-twitter-para-gnulinux-con-todos-los-hierros/</link>
<pubDate>Thu, 19 Nov 2009 03:41:00 +0000</pubDate>
<dc:creator>satanas82</dc:creator>
<guid>http://damncorner.wordpress.com/2009/11/19/turpial-un-cliente-twitter-para-gnulinux-con-todos-los-hierros/</guid>
<description><![CDATA[Turpial es un cliente Twitter multi-interfaz escrito en Python que he estado desarrollando con el pa]]></description>
<content:encoded><![CDATA[Turpial es un cliente Twitter multi-interfaz escrito en Python que he estado desarrollando con el pa]]></content:encoded>
</item>
<item>
<title><![CDATA[Glossário virtual em Python e Glade - parte II]]></title>
<link>http://icaju.wordpress.com/2009/11/16/glossario-virtual-em-python-e-glade-parte-ii/</link>
<pubDate>Mon, 16 Nov 2009 19:43:08 +0000</pubDate>
<dc:creator>Mamutti</dc:creator>
<guid>http://icaju.wordpress.com/2009/11/16/glossario-virtual-em-python-e-glade-parte-ii/</guid>
<description><![CDATA[Na primeira parte deste tutorial você viu como montar o ambiente de desenvolvimento necessário para ]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p style="text-align:justify;">Na <a href="http://icaju.wordpress.com/2009/10/08/glossario-virtual-em-python-e-glade-parte-i/">primeira parte</a> deste tutorial você viu como montar o ambiente de desenvolvimento necessário para criar o glossário, e definimos um dialeto CSV para ser usado ao ler e gravar os arquivos com os termos do glossário. Nessa parte, você verá como fazer o programa ler e gravar esses arquivos CSV.<!--more--></p>
<p style="text-align:justify;">Antes de escrever o código, é necessário conhecer as funções <em>reader</em> e <em>writer</em> do módulo CSV. Como o próprio nome diz, <em>reader</em> serve para ler o CSV. Ela recebe um dialeto e um objeto iterável contendo strings (como uma lista ou um arquivo) e retorna outro objeto iterável, dessa vez com os campos do CSV já separados de acordo com o dialeto. Exemplo:</p>
<p><code>reader = csv.reader(arquivo, dialect="excel")</code></p>
<p style="text-align:justify;">No nosso caso, usar uma lista com os campos (termo e significado) não faz muito sentido, pois um dicionário com os termos como chaves, e os significados como seus valores, cumpriria bem melhor o papel. Assim, na hora de pesquisar um significado, basta chamar:</p>
<p><code>dicionario[termo]</code></p>
<p style="text-align:justify;">E na hora de gravar ou criar um novo termo, basta chamar:</p>
<p><code>dicionario[termo] = significado</code></p>
<p style="text-align:justify;">Mais na frente faremos algumas modificações no dicionário do Python (a tipo <em>dict</em>) para adaptá-lo melhor às necessidades de um glossário, mas por enquanto só precisamos de uma função que receba o caminho do arquivo CSV e retorne um dicionário comum. <a href="http://icaju.pastebin.com/f6d187e9a">Veja o código da função</a>.</p>
<p style="text-align:justify;">Repare que quando há uma exceção IOError ao abrir o arquivo, caso ele exista, é lançada uma exceção do tipo ArquivosError, que nada mais é do que uma classe de exceção vazia. Classe de exceção é uma classe que herda da classe base para todas as exceções no Python, a <em> Exception</em>. Pra que criar uma classe de exceção vazia? Para organizar nosso programa e dar um tratamento especial a esses erros na interface gráfica. <a href="http://icaju.pastebin.com/f6683fa98">Veja o código da classe  ArquivosError</a>.</p>
<p style="text-align:justify;">O próximo passo é criar a função que vai gravar os novos termos e as alterações que foram feitas no glossário do arquivo a partir do qual ele foi carregado. Para isso, utilizaremos a função writer que, assim como reader, recebe um arquivo e um dialeto retornando um objeto com os métodos write e writerows. Write escreve um registro por vez, e writerows recebe um iterável e escreve cada registro dentro dele no arquivo. Exemplo:</p>
<p><code>registro = ('C', 'Linguagem de programação.')</code><br />
<code>f = file('arquivo.csv', 'w')</code></p>
<p><code>writer = csv.writer(f, dialect='excel')</code><br />
<code>writer.write(registro)</code></p>
<p><code>registros = {'Flash':'Uma tecnologia para estragar sites.', 'Assembler':'Não é o nome de uma linguagem'}</code><br />
<code>writer.writerows(registros.items())</code></p>
<p style="text-align:justify;">O que precisamos no nosso módulo de arquivos, é uma função que receba um dicionário com os dados a serem gravados no arquivo, e receba um caminho de arquivo para gravar esses dados. Lembra quando eu disse que vamos criar um dicionário personalizado? Um dos recursos do nosso dicionário é que ele armazenará no atributo <em>path</em> uma string com o caminho do arquivo de onde ele foi lido, assim a nossa função de gravar só precisa receber o glossário, ou seja, o nosso dicionário especial. <a href="http://icaju.pastebin.com/f3e126363">Veja o código da função</a>.</p>
<p style="text-align:justify;">Note que nas duas funções eu usei o módulo <em>codecs</em> para abrir os arquivos, e usei a &#8220;constante&#8221; <em>CODIFICACAO</em> para informar a função <em>open()</em>, a codificação do arquivo. O módulo <em>codecs</em> é uma mão na roda na hora de mexer com arquivos de texto, porque ele evita diversos problemas de codificação. Ao ler um arquivo, ele usa a codificação informada para converter o conteúdo em Unicode (uma espécie de codificação universal), e ao gravar ele transforma as strings Unicode de volta em strings codificadas, de forma transparente. <a href="http://nerdson.com/blog/decifra-me-ou-dvorak/">Eu � Unicode</a>. <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p style="text-align:justify;">Você pode atribuir a <em>CODIFICACAO</em> o charset que quiser (eu gosto de usar sempre <em>utf-8</em>). Basta que ao salvar o CSV em outros programas (como editores de planilha), você tenha o cuidado de usar sempre a mesma codificação para evitar que o texto apareça todo zoado no glossário.</p>
<p style="text-align:justify;">Com essa parte do tutorial finalizamos o nosso módulo de ler arquivos. Veja <a href="http://icaju.pastebin.com/f13c5b854">aqui</a> o código completo, comentado e documentado do módulo. Na próxima parte do tutorial, faremos o nosso &#8220;model&#8221; e  mostrarei como personalizar o dicionário do Python, incluindo o atributo <em>path</em> e otras cositas más.</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Cairo, PyWebKit y PyGTK: Semana de Pruebas]]></title>
<link>http://damncorner.wordpress.com/2009/10/23/cairo-pywebkit-y-pygtk-semana-de-pruebas/</link>
<pubDate>Fri, 23 Oct 2009 03:03:00 +0000</pubDate>
<dc:creator>satanas82</dc:creator>
<guid>http://damncorner.wordpress.com/2009/10/23/cairo-pywebkit-y-pygtk-semana-de-pruebas/</guid>
<description><![CDATA[Esta ha sido una semana de pruebas, pruebas y más pruebas. Estoy trabajando en eso de mejorar las in]]></description>
<content:encoded><![CDATA[Esta ha sido una semana de pruebas, pruebas y más pruebas. Estoy trabajando en eso de mejorar las in]]></content:encoded>
</item>
<item>
<title><![CDATA[Proste GUI -&gt; Zaawansowany edytor?]]></title>
<link>http://middleofdreams.wordpress.com/2009/10/21/proste-gui-zaawansowany-edytor/</link>
<pubDate>Wed, 21 Oct 2009 10:29:27 +0000</pubDate>
<dc:creator>middleofdreams</dc:creator>
<guid>http://middleofdreams.wordpress.com/2009/10/21/proste-gui-zaawansowany-edytor/</guid>
<description><![CDATA[Parę postów wcześniej opublikowałem gui do programu povray z paroma podstawowymi opcjami. Tak jakoś ]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Parę postów wcześniej opublikowałem gui do programu povray z paroma podstawowymi opcjami. Tak jakoś wyszło, że projekt powoli przeradza się w zaawansowany edytor.<br />
Założenia:</p>
<ul>
<li>odbiegające od norm gui (wiekszość opcji po lewej stronie programu)</li>
<li>kolorowanie składni</li>
<li>możliwość dodawania gotowych obiektów do projektu</li>
<li>2 tryby widoku &#8211; samo gui do renderowania i edytor</li>
</ul>
<p>Póki co tyle.  W co się to rozrośnie zobaczymy w swoim czasie.  Na razie zamieszczam 3 zrzuty ekranu:</p>
<p><a href="http://middleofdreams.wordpress.com/files/2009/10/gpov11.png"><img class="aligncenter size-thumbnail wp-image-99" title="gpov1" src="http://middleofdreams.wordpress.com/files/2009/10/gpov11.png?w=123" alt="gpov1" width="123" height="150" /></a></p>
<p><a href="http://middleofdreams.wordpress.com/files/2009/10/gpov2.png"><img class="aligncenter size-thumbnail wp-image-100" title="gpov2" src="http://middleofdreams.wordpress.com/files/2009/10/gpov2.png?w=150" alt="gpov2" width="150" height="124" /></a><a href="http://middleofdreams.wordpress.com/files/2009/10/gpov3.png"></a></p>
<p><a href="http://middleofdreams.wordpress.com/files/2009/10/gpov3.png"><img class="aligncenter size-thumbnail wp-image-101" title="gpov3" src="http://middleofdreams.wordpress.com/files/2009/10/gpov3.png?w=150" alt="gpov3" width="150" height="123" /></a></p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[pygtk - Atualizar Barras de Progresso no meio da função (sem threads)]]></title>
<link>http://pythonlog.wordpress.com/2009/10/19/pygtk-progress-bars/</link>
<pubDate>Mon, 19 Oct 2009 23:49:47 +0000</pubDate>
<dc:creator>nosklo</dc:creator>
<guid>http://pythonlog.wordpress.com/2009/10/19/pygtk-progress-bars/</guid>
<description><![CDATA[&lt;kbum&gt; como eu poderia fazer uma barra de progresso que atualize de acordo com a execuçao de d]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><pre>&#60;kbum&#62; como eu poderia fazer uma barra de progresso que atualize
de acordo com a execuçao de determinado trecho do codigo?
&#60;kbum&#62; nosklo, conhece alguma soluçao pra esse caso?
&#60;nosklo&#62; kbum: a barra de progresso nao atualiza sozinha.
vc precisa atualiza-la.
&#60;kbum&#62; certo
&#60;kbum&#62; eu to pensando numa forma de "atualiza-la"
&#60;kbum&#62; pq se fosse um laço eu atualizaria facil facil
&#60;kbum&#62; mas sao metodos que estao executando
&#60;epx&#62; é, atualizar andamento sempre eh chato
&#60;nosklo&#62; kbum: tem um jeito de facilitar usando geradores
&#60;nosklo&#62; kbum: xo fazer um exemplo
&#60;kbum&#62; nosklo, desculpa, mas tenho que sair agora, agradeço pela ajuda,
mas tenho que ir, se nao perco carona pra voltar pra cidade!
</pre>
<p>Bom, foi feito um exemplo e aqui está:</p>
<p><!--more-->Primeiro criei uma classe <span style="color:#0000FF;font-weight:bold;">GlibYield</span>. Ela simplesmente pega um iterável e agenda seu próximo passo usando glib.idle_add(). Criei três funções que servem de ganchos para subclasses desta classe.</p>
<p>A idéia aqui é que a função que está sendo monitorada será escrita com uma série de yields que a tornarão um gerador. Este gerador então será consumido a cada passo, e pode-se fazer qualquer coisa entre estes passos.</p>
<p>Na listagem abaixo, eu usei glib.timeout_add(1000, &#8230;) ao invés de glib.idle_add(&#8230;), para que demore mesmo um tempo entre cada passo. Ao usar em um caso real, <strong>troque pela linha glib.idle_add() comentada</strong>.</p>
<pre><span style="color:#008000;font-weight:bold;">import</span> <span style="color:#0000FF;font-weight:bold;">pygtk</span>
pygtk<span style="color:#666666;">.</span>require(<span style="color:#BA2121;">'2.0'</span>)
<span style="color:#008000;font-weight:bold;">import</span> <span style="color:#0000FF;font-weight:bold;">gtk</span>
<span style="color:#008000;font-weight:bold;">import</span> <span style="color:#0000FF;font-weight:bold;">glib</span>

<span style="color:#008000;font-weight:bold;">class</span> <span style="color:#0000FF;font-weight:bold;">GlibYield</span>(<span style="color:#008000;">object</span>):
    <span style="color:#008000;font-weight:bold;">def</span> <span style="color:#0000FF;">__call__</span>(<span style="color:#008000;">self</span>, iterable, <span style="color:#666666;">*</span>args, <span style="color:#666666;">**</span>kwds):
        obj <span style="color:#666666;">=</span> <span style="color:#008000;">self</span><span style="color:#666666;">.</span>before_start(<span style="color:#666666;">*</span>args, <span style="color:#666666;">**</span>kwds)
        glib<span style="color:#666666;">.</span>timeout_add(<span style="color:#666666;">1000</span>, <span style="color:#008000;">self</span><span style="color:#666666;">.</span>step, <span style="color:#008000;">iter</span>(iterable), obj)
<span style="color:#408080;font-style:italic;">#        glib.idle_add(self.step, iter(iterator), obj)</span>

    <span style="color:#008000;font-weight:bold;">def</span> <span style="color:#0000FF;">step</span>(<span style="color:#008000;">self</span>, iterator, obj):
        <span style="color:#008000;font-weight:bold;">try</span>:
            data <span style="color:#666666;">=</span> <span style="color:#008000;">next</span>(iterator)
        <span style="color:#008000;font-weight:bold;">except</span> <span style="color:#D2413A;font-weight:bold;">StopIteration</span>:
            <span style="color:#008000;">self</span><span style="color:#666666;">.</span>on_end(obj)
        <span style="color:#008000;font-weight:bold;">else</span>:
            obj <span style="color:#666666;">=</span> <span style="color:#008000;">self</span><span style="color:#666666;">.</span>on_step(data, obj)
            glib<span style="color:#666666;">.</span>timeout_add(<span style="color:#666666;">1000</span>, <span style="color:#008000;">self</span><span style="color:#666666;">.</span>step, iterator, obj)
<span style="color:#408080;font-style:italic;">#            glib.idle_add(self.step, iterator, obj)</span>
        <span style="color:#008000;font-weight:bold;">return</span> <span style="color:#008000;">False</span>

    <span style="color:#008000;font-weight:bold;">def</span> <span style="color:#0000FF;">before_start</span>(<span style="color:#008000;">self</span>, <span style="color:#666666;">*</span>args, <span style="color:#666666;">**</span>kwds): <span style="color:#008000;font-weight:bold;">pass</span>
    <span style="color:#008000;font-weight:bold;">def</span> <span style="color:#0000FF;">on_step</span>(<span style="color:#008000;">self</span>, data, monitor_obj): <span style="color:#008000;font-weight:bold;">pass</span>
    <span style="color:#008000;font-weight:bold;">def</span> <span style="color:#0000FF;">on_end</span>(<span style="color:#008000;">self</span>, monitor_obj):  <span style="color:#008000;font-weight:bold;">pass</span>
</pre>
<p>Criei então uma subclasse de GlibYield que cria uma barra de progresso em um certo container (que você passa como parâmetro) e a atualiza com os valores que vem da função sendo executada:</p>
<pre><span style="color:#008000;font-weight:bold;">class</span> <span style="color:#0000FF;font-weight:bold;">GtkProgressCreator</span>(GlibYield):
    <span style="color:#008000;font-weight:bold;">def</span> <span style="color:#0000FF;">__init__</span>(<span style="color:#008000;">self</span>, container):
        <span style="color:#008000;">self</span><span style="color:#666666;">.</span>_container <span style="color:#666666;">=</span> container

    <span style="color:#008000;font-weight:bold;">def</span> <span style="color:#0000FF;">before_start</span>(<span style="color:#008000;">self</span>, title<span style="color:#666666;">=</span><span style="color:#BA2121;">'Aguarde...'</span>):
        pb <span style="color:#666666;">=</span> gtk<span style="color:#666666;">.</span>ProgressBar()
        <span style="color:#008000;font-weight:bold;">if</span> title:
            pb<span style="color:#666666;">.</span>set_text(title)
        <span style="color:#008000;">self</span><span style="color:#666666;">.</span>_container<span style="color:#666666;">.</span>pack_start(pb, <span style="color:#008000;">True</span>, <span style="color:#008000;">True</span>, <span style="color:#666666;">0</span>) <span style="color:#408080;font-style:italic;"># TODO: incluir formas de customizar isso</span>
        pb<span style="color:#666666;">.</span>show()
        <span style="color:#008000;font-weight:bold;">return</span> pb

    <span style="color:#008000;font-weight:bold;">def</span> <span style="color:#0000FF;">on_step</span>(<span style="color:#008000;">self</span>, data, pb):
        pb<span style="color:#666666;">.</span>set_fraction(data)
        <span style="color:#008000;font-weight:bold;">return</span> pb

    <span style="color:#008000;font-weight:bold;">def</span> <span style="color:#0000FF;">on_end</span>(<span style="color:#008000;">self</span>, pb):
        pb<span style="color:#666666;">.</span>destroy()
</pre>
<p>Aqui temos um exemplo da utilização da classe. O método calcula() é uma função geradora. Ao clicar no botão, ele é executado, criando um objeto gerador, que é passado para o GtkProgressCreator. Este então cria uma barra de progresso, e a atualiza toda vez que o gerador dá um yield, reagendando o próximo passo pela glib.</p>
<pre><span style="color:#008000;font-weight:bold;">class</span> <span style="color:#0000FF;font-weight:bold;">TestStep</span>(<span style="color:#008000;">object</span>):
    <span style="color:#008000;font-weight:bold;">def</span> <span style="color:#0000FF;">clicou</span>(<span style="color:#008000;">self</span>, widget, data):
        <span style="color:#008000;font-weight:bold;">print</span> <span style="color:#BA2121;">"Calculando..."</span>
        <span style="color:#408080;font-style:italic;"># Executa a funcao no GtkProgressCreator</span>
        <span style="color:#008000;">self</span><span style="color:#666666;">.</span>pc(<span style="color:#008000;">self</span><span style="color:#666666;">.</span>calcula(<span style="color:#666666;">15</span>, <span style="color:#666666;">14</span>, <span style="color:#666666;">5</span>))

    <span style="color:#008000;font-weight:bold;">def</span> <span style="color:#0000FF;">calcula</span>(<span style="color:#008000;">self</span>, n1, n2, n3):
        r <span style="color:#666666;">=</span> n1 <span style="color:#666666;">+</span> n2
        <span style="color:#008000;font-weight:bold;">yield</span> <span style="color:#666666;">0.25</span> <span style="color:#408080;font-style:italic;">#cada yield atualiza a barra de progresso e libera a GUI</span>

        r <span style="color:#666666;">=</span> r <span style="color:#666666;">*</span> n3
        <span style="color:#008000;font-weight:bold;">print</span> <span style="color:#BA2121;">'Estamos na metade...'</span>
        <span style="color:#008000;font-weight:bold;">yield</span> <span style="color:#666666;">0.5</span>

        r <span style="color:#666666;">=</span> r <span style="color:#666666;">/</span> n1
        <span style="color:#008000;font-weight:bold;">yield</span> <span style="color:#666666;">0.75</span>

        r <span style="color:#666666;">=</span> r <span style="color:#666666;">^</span> n2
        <span style="color:#008000;font-weight:bold;">yield</span> <span style="color:#666666;">1</span>

        <span style="color:#008000;font-weight:bold;">print</span> <span style="color:#BA2121;">'RESULTADO ENCONTRADO: '</span>, r

    <span style="color:#008000;font-weight:bold;">def</span> <span style="color:#0000FF;">delete_event</span>(<span style="color:#008000;">self</span>, widget, event, data<span style="color:#666666;">=</span><span style="color:#008000;">None</span>):
        gtk<span style="color:#666666;">.</span>main_quit()
        <span style="color:#008000;font-weight:bold;">return</span> <span style="color:#008000;">False</span>

    <span style="color:#008000;font-weight:bold;">def</span> <span style="color:#0000FF;">__init__</span>(<span style="color:#008000;">self</span>):
        <span style="color:#008000;">self</span><span style="color:#666666;">.</span>window <span style="color:#666666;">=</span> gtk<span style="color:#666666;">.</span>Window(gtk<span style="color:#666666;">.</span>WINDOW_TOPLEVEL)
        <span style="color:#008000;">self</span><span style="color:#666666;">.</span>window<span style="color:#666666;">.</span>set_title(<span style="color:#BA2121;">"Teste de Step!"</span>)
        <span style="color:#008000;">self</span><span style="color:#666666;">.</span>window<span style="color:#666666;">.</span>connect(<span style="color:#BA2121;">"delete_event"</span>, <span style="color:#008000;">self</span><span style="color:#666666;">.</span>delete_event)
        <span style="color:#008000;">self</span><span style="color:#666666;">.</span>window<span style="color:#666666;">.</span>set_border_width(<span style="color:#666666;">10</span>)
        <span style="color:#008000;">self</span><span style="color:#666666;">.</span>box1 <span style="color:#666666;">=</span> gtk<span style="color:#666666;">.</span>VBox(<span style="color:#008000;">False</span>, <span style="color:#666666;">0</span>)
        <span style="color:#008000;">self</span><span style="color:#666666;">.</span>window<span style="color:#666666;">.</span>add(<span style="color:#008000;">self</span><span style="color:#666666;">.</span>box1)
        <span style="color:#008000;">self</span><span style="color:#666666;">.</span>button1 <span style="color:#666666;">=</span> gtk<span style="color:#666666;">.</span>Button(<span style="color:#BA2121;">"Calcular"</span>)
        <span style="color:#008000;">self</span><span style="color:#666666;">.</span>button1<span style="color:#666666;">.</span>connect(<span style="color:#BA2121;">"clicked"</span>, <span style="color:#008000;">self</span><span style="color:#666666;">.</span>clicou, <span style="color:#666666;">1</span>)
        <span style="color:#008000;">self</span><span style="color:#666666;">.</span>box1<span style="color:#666666;">.</span>pack_start(<span style="color:#008000;">self</span><span style="color:#666666;">.</span>button1, <span style="color:#008000;">True</span>, <span style="color:#008000;">True</span>, <span style="color:#666666;">0</span>)
        <span style="color:#008000;">self</span><span style="color:#666666;">.</span>button1<span style="color:#666666;">.</span>show()
        <span style="color:#008000;">self</span><span style="color:#666666;">.</span>box1<span style="color:#666666;">.</span>show()
        <span style="color:#008000;">self</span><span style="color:#666666;">.</span>window<span style="color:#666666;">.</span>show()

        <span style="color:#408080;font-style:italic;"># Cria um progresscreator que criara barras de progresso em box1</span>
        <span style="color:#008000;">self</span><span style="color:#666666;">.</span>pc <span style="color:#666666;">=</span> GtkProgressCreator(<span style="color:#008000;">self</span><span style="color:#666666;">.</span>box1)

<span style="color:#008000;font-weight:bold;">def</span> <span style="color:#0000FF;">main</span>():
    gtk<span style="color:#666666;">.</span>main()

<span style="color:#008000;font-weight:bold;">if</span> __name__ <span style="color:#666666;">==</span> <span style="color:#BA2121;">"__main__"</span>:
    s <span style="color:#666666;">=</span> TestStep()
    main()
</pre>
<p>Existem alguns problemas com esta implementação &#8211; A principal é que ela não é boa com operações que duram muito tempo entre os yields, pois a GUI ficará travada nestes pontos. Nestes casos demorados, a operação geralmente depende de fatores externos &#8211; leitura de arquivos, acesso de rede &#8211; e aí o melhor seria utilizar as funções corretas da glib para eses casos (glib.io_add_watch). O gerador então poderia até injetar os resultados de cada chamada destas de volta na função através do http://docs.python.org/reference/expressions.html#generator.send ; Até pensei em escrever algo assim e atualizar depois o post.</p>
<p>Porém eu desisti. Porque melhor que tudo isso é usar twisted com um reactor GTK. Twisted possui deferreds &#8211; na verdade este código acima foi inspirado no http://twistedmatrix.com/documents/current/api/twisted.internet.defer.html#inlineCallbacks e é uma &#8220;versão pobre&#8221; deste esquema.</p>
<p>Mesmo assim foi divertido escrevê-la, e funciona! Veja como ficou ao clicar 4 vezes no botão rapidamente:</p>
<div id="attachment_29" class="wp-caption aligncenter" style="width: 180px"><img class="size-full wp-image-29" title="Janela do TesteStep" src="http://pythonlog.wordpress.com/files/2009/10/testestep.jpg" alt="4 barras de progresso atualizadas independentemente" width="170" height="151" /><p class="wp-caption-text">4 barras de progresso atualizadas independentemente</p></div>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[ImageSlicer Progress...]]></title>
<link>http://blockofcode.wordpress.com/2009/10/19/imageslicer-progress/</link>
<pubDate>Mon, 19 Oct 2009 08:52:54 +0000</pubDate>
<dc:creator>blockofcode</dc:creator>
<guid>http://blockofcode.wordpress.com/2009/10/19/imageslicer-progress/</guid>
<description><![CDATA[The past two weeks I have been working on a small tool to slice images using Python, PIL and pygtk. ]]></description>
<content:encoded><![CDATA[The past two weeks I have been working on a small tool to slice images using Python, PIL and pygtk. ]]></content:encoded>
</item>
<item>
<title><![CDATA[GPov - proste GUI do povray.]]></title>
<link>http://middleofdreams.wordpress.com/2009/10/14/gpov-proste-gui-do-povray/</link>
<pubDate>Wed, 14 Oct 2009 10:07:43 +0000</pubDate>
<dc:creator>middleofdreams</dc:creator>
<guid>http://middleofdreams.wordpress.com/2009/10/14/gpov-proste-gui-do-povray/</guid>
<description><![CDATA[Za namową przyjaciela napisałem bardzo proste GUI do obsługi povraya. Przydaje się to szczególnie gd]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Za namową przyjaciela napisałem bardzo proste GUI do obsługi povraya. Przydaje się to szczególnie gdy nie chce się za każdym razem pisać długiego polecenia do zrenderowania kolejnego obrazka. Przy okazji nie zaśmieca się .bash_history <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>Póki co program:</p>
<ul>
<li>pozwala wybrać rozdzielczość</li>
<li>pozwala ustawić jakość (0-9) oraz włączyć antialiasing</li>
<li>zapamiętuje ostatnio wybrane parametry i plik</li>
<li>otwiera wybrany plik w aplikacji medit.</li>
</ul>
<div id="attachment_45" class="wp-caption aligncenter" style="width: 310px"><a href="http://middleofdreams.wordpress.com/files/2009/10/gpov1.png"><img class="size-medium wp-image-45" title="gpov" src="http://middleofdreams.wordpress.com/files/2009/10/gpov1.png?w=300" alt="GPov - gui dla povray" width="300" height="211" /></a><p class="wp-caption-text">GPov - gui dla povray</p></div>
<p style="text-align:center;"><strong><a title="linux gui for povray" href="http://www.speedyshare.com/213950316.html">POBIERZ</a></strong></p>
<p>Na razie tylko w języku polskim. W najbliższym czasie pewnie pojawi się wersja po angielsku.</p>
<p>Kto wie&#8230; może kiedyś pokuszę się na cały edytor do povray&#8217;a.</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[GCounter 0.4]]></title>
<link>http://middleofdreams.wordpress.com/2009/10/11/gcounter-0-4/</link>
<pubDate>Sun, 11 Oct 2009 08:01:53 +0000</pubDate>
<dc:creator>middleofdreams</dc:creator>
<guid>http://middleofdreams.wordpress.com/2009/10/11/gcounter-0-4/</guid>
<description><![CDATA[Yesterday I released GCounter 0.3 and today version 0.4 is out. Changes: some bugs fixed add tray ic]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Yesterday I released GCounter 0.3 and today version 0.4 is out.</p>
<p>Changes:</p>
<ul>
<li>some bugs fixed</li>
<li>add tray icon support</li>
<li>whole app split as 2 .py files</li>
<li>Reset default settings and Clear action history don&#8217;t need to restart app anymore.</li>
</ul>
<p>You can download it from <a href="http://www.speedyshare.com/861202754.html">HERE</a>.</p>
<p>And still &#8211; if you find some bugs or have a suggestion please mail to me.</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[pyGTK i ikona w tacce]]></title>
<link>http://middleofdreams.wordpress.com/2009/10/11/pygtk-i-ikona-w-tacce/</link>
<pubDate>Sun, 11 Oct 2009 07:53:47 +0000</pubDate>
<dc:creator>middleofdreams</dc:creator>
<guid>http://middleofdreams.wordpress.com/2009/10/11/pygtk-i-ikona-w-tacce/</guid>
<description><![CDATA[Wbrew pozorom obługa ikony w tacce w pyGTK jest bardzo proste. Na sam początek wywołujemy samą ikonę]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Wbrew pozorom obługa ikony w tacce w pyGTK jest bardzo proste. Na sam początek wywołujemy samą ikonę, potem zajmiemy się jej atrybutami:</p>
<blockquote><p>self.mojaikona = gtk.StatusIcon()</p></blockquote>
<p>Teraz wypadałoby nadać ikonie jakiś wygląd. Myśle, że dwa najbardziej przydatne sposoby to:</p>
<blockquote><p>self.mojaicona.set_from_stock(gtk.STOCK_FIND)</p></blockquote>
<p>i</p>
<blockquote><p>self.mojaikona.set_from_file(&#8220;/home/kuba/mojprogram/mojaikona.png&#8221;)</p></blockquote>
<p>Myślę, że obie metody są wystarczająco zrozumiałe same w sobie. Aby ikona reagowała na kliknięcia wystarczy podpiąć sygnały:</p>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">self.staticon.connect(&#8220;activate&#8221;, self.activate)</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;"><span style="white-space:pre;"> </span>#self.staticon.connect(&#8220;popup_menu&#8221;, self.popup)</div>
<blockquote><p>self.mojaikona.connect(&#8220;activate&#8221;, activate)</p>
<p>self.mojaikona.connect(&#8220;popup_menu&#8221;, popup)</p></blockquote>
<p>Pierwsze dotyczy kliknięcia lewym przyciskiem myszy, drugie prawym. Oczywiście dane funkcje należy zdefiniować w kodzie. Na przykład:</p>
<blockquote><p>def self.activate(self,widget):</p>
<p>tu jakieś polecenia</p></blockquote>
<p>i tyle <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Teraz wystarczy ustawić widoczność ikony na True:</p>
<blockquote><p>self.mojaikona.set_visible(True)</p></blockquote>
<p>I po włączeniu programu mamy działającą ikone w Tray&#8217;u <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[GCounter 0.3]]></title>
<link>http://middleofdreams.wordpress.com/2009/10/10/gcounter-0-3/</link>
<pubDate>Sat, 10 Oct 2009 12:02:29 +0000</pubDate>
<dc:creator>middleofdreams</dc:creator>
<guid>http://middleofdreams.wordpress.com/2009/10/10/gcounter-0-3/</guid>
<description><![CDATA[Hi, I just release version 0.3 of my GCounter. App is using sudo for standard commands and pm-suspen]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Hi, I just release version 0.3 of my GCounter. App is using sudo for standard commands and pm-suspend for suspend option. You can also enter your own commands.</p>
<p>TO DO:<br />
- multilanguage support (now &#8211; only english)<br />
- tray icon<br />
- more preferences (not only sudo etc)</p>
<p>You can download it from <a href="http://www.speedyshare.com/486915571.html">HERE</a>.</p>
<p><img class="alignnone size-full wp-image-6" title="gcounter 0.3" src="http://middleofdreams.wordpress.com/files/2009/10/gcounter.png" alt="gcounter 0.3" width="393" height="307" /></p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Glossário virtual em Python e Glade - parte I]]></title>
<link>http://icaju.wordpress.com/2009/10/08/glossario-virtual-em-python-e-glade-parte-i/</link>
<pubDate>Thu, 08 Oct 2009 03:06:28 +0000</pubDate>
<dc:creator>Mamutti</dc:creator>
<guid>http://icaju.wordpress.com/2009/10/08/glossario-virtual-em-python-e-glade-parte-i/</guid>
<description><![CDATA[Mês passado fiz um trabalho de equipe no curso técnico para a disciplina Inglês Técnico &#8211; III,]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p style="text-align:justify;">Mês passado fiz um trabalho de equipe no curso técnico para a disciplina Inglês Técnico &#8211; III, que era escrever um glossário com termos relacionados a software, e outras equipes pesquisariam outros temas. Além disso era necessário desenvolver uma forma de visualizar os termos no computador, e o resultado foi este programinha em <a href="http://pt.wikipedia.org/wiki/Python">Python</a> e <a href="http://pt.wikipedia.org/wiki/Glade">Glade</a>:</p>
<p><img style="max-width:800px;" src="http://icaju.files.wordpress.com/2009/10/glossario.png" alt="" /></p>
<p style="text-align:justify;">É bem simples, mas como muita gente que eu conheço tem curiosidade em relação ao Python e ao Glade este post será o primeiro mostrando passo-a-passo como fazer um programa parecido com o do meu trabalho. Parecido porque vou tentar melhorar o código do atual pra não passar vergonha aqui nas interwebs. <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p style="text-align:justify;">Se você está no Linux, basta instalar o Glade e provavelmente já terá tudo que precisa pra começar instalado aí. Quando muito falta instalar o PyGTK. Caso esteja no Windows, a coisa complica um pouco: você precisa baixar o interpretador <a href="http://python.org/ftp/python/2.6.3/python-2.6.3.msi">Python</a>, o <a href="http://ftp.gnome.org/pub/gnome/binaries/win32/gtk+/2.16/gtk+-bundle_2.16.6-20090911_win32.zip">GTK</a>, o <a href="http://ftp.gnome.org/pub/GNOME/binaries/win32/glade3/3.6/glade3-3.6.4-installer.exe">Glade</a> (link para a versão sem GTK embutido), o <a href="http://ftp.gnome.org/pub/GNOME/binaries/win32/pygtk/2.12/pygtk-2.12.1-3.win32-py2.6.exe">PyGTK</a>, <a href="http://ftp.gnome.org/pub/GNOME/binaries/win32/pygobject/2.14/pygobject-2.14.2-2.win32-py2.6.exe">PyGObject</a> e o <a href="http://ftp.gnome.org/pub/GNOME/binaries/win32/pycairo/1.4/pycairo-1.4.12-2.win32-py2.6.exe">PyCairo</a> e instalá-los (nessa ordem).</p>
<p style="text-align:justify;">Dica: a instalação do GTK pelo arquivo do link é um porre, então instale o <a href="http://download.geany.org/geany-0.18_setup.exe">Geany</a>, um IDE peso-leve, que fará essa tarefa por você e já serve para escrever os códigos que criaremos. Além de Python ele suporta várias outras linguagens, <a href="http://icaju.wordpress.com/2008/12/22/aprendendo-a-programar-com-pascal-e-software-livre/">como Pascal</a>, C, C++, Ruby, Java, C#, PHP, etc. Se correu tudo bem até aqui está pronto o seu ambiente de desenvolvimento.</p>
<p style="text-align:justify;">Vamos para o código! O projeto  usa como forma de armazenamento  arquivos no formato <a href="http://pt.wikipedia.org/wiki/Comma-separated_values">CSV</a>, permitindo assim abrir e editar o glossário como uma planilha do Excel ou do Calc. Felizmente o Python já traz na sua biblioteca padrão um módulo capaz de gerenciar a leitura e gravação desses arquivos. No entanto, estou repensando o código para que ele fique mais modular, de forma que você possa mudar essa característica sem ter de mexer no resto do código.</p>
<p style="text-align:justify;">Apesar de existir uma <a href="http://tools.ietf.org/html/rfc4180">especificação para o formato CSV</a> é necessário apelar para auto-detecção ou definir o dialeto que será usado porque nem todos os programas usam os mesmo símbolos na hora de trabalhar com esses arquivos. Como auto-detecção é algo sujeito a falhas vamos definir o nosso próprio dialeto CSV. O que é feito na seguinte classe: (salve-a em um arquivo chamado &#8220;arquivos.py&#8221; que será o módulo de acesso aos arquivos do nosso programa)</p>
<p style="text-align:justify;">Veja o código <a href="http://icaju.pastebin.com/fd72b7c1">aqui</a>. O WordPress estava bagunçando a indentação toda. =/</p>
<ul>
<li style="text-align:justify;">&#8220;delimiter&#8221; é o caractere usado para separar os campos de um registro. No nosso caso os registros possuem dois campos: termo e descrição;</li>
<li style="text-align:justify;">&#8220;quotechar&#8221; é o caractere usado para aspas;</li>
<li style="text-align:justify;">&#8220;doublequote&#8221; quando verdadeiro (True) coloca dois quotechars seguidos caso no meio de um campo exista um quotechar, por exemplo: &#8220;aspas duplas são assim&#8221;", ficaria assim &#8220;aspas duplas são assim&#8221;"&#8221;;</li>
<li style="text-align:justify;">&#8220;skipinitialspace&#8221; quando verdadeiro determina que o parser deve ignorar espaços no começo dos campos;</li>
<li style="text-align:justify;">&#8220;lineterminator&#8221; diz qual o padrão usado para quebrar a linha, ou seja, indicar o fim do registro. O formato padrão de quebra de linha no *nix é &#8220;\n&#8221; mas se a IETF manda eu colocar o padrão do Windows eu coloco <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> ;</li>
<li style="text-align:justify;">&#8220;quoting&#8221; indica o comportamento do módulo quanto ao uso das aspas. csv.QUOTE_ALL significa que todos os campos do registro devem estar entre aspas;</li>
<li style="text-align:justify;">Por fim, a última linha registra o dialeto que acabamos de criar para ser usado pelo módulo na interpretação e gravação do arquivo.</li>
</ul>
<p style="text-align:justify;">Pra não tornar a leitura muito cansativa vou encerrar este artigo por aqui. Na próxima &#8220;aula&#8221; finalizaremos a parte que mexe com os arquivos e começaremos a desenhar a interface no Glade. Quaisquer dúvidas estou à disposição nos comentários. Até lá!</p>
<div id="_mcePaste" style="overflow:hidden;position:absolute;left:-10000px;top:474px;width:1px;height:1px;">import csv</p>
<p>class DialetoCSV(csv.Dialect):<br />
&#8221;&#8217;Define o dialeto usado nos arquivos CSV contendo os glossários seguindo<br />
a especificação RFC4180.&#8221;&#8217;<br />
delimiter = &#8216;,&#8217;<br />
quotechar = &#8216;&#8221;&#8216;<br />
doublequote = True<br />
skipinitialspace = True<br />
lineterminator = &#8216;\r\n&#8217;<br />
quoting = csv.QUOTE_ALL</p>
<p>csv.register_dialect(&#8216;default&#8217;, DialetoCSV)</p>
</div>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[CrunchyFrog 0.4.1 released]]></title>
<link>http://andialbrecht.wordpress.com/2009/10/01/crunchyfrog-0-4-1-released/</link>
<pubDate>Thu, 01 Oct 2009 08:01:36 +0000</pubDate>
<dc:creator>Andi Albrecht</dc:creator>
<guid>http://andialbrecht.wordpress.com/2009/10/01/crunchyfrog-0-4-1-released/</guid>
<description><![CDATA[A new bugfix release for CrunchyFrog is out in the wild. There are not much visible changes, but a f]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p><span style="background-color:#ffffff;">A new bugfix release for <a title="CrunchyFrog Homepage" href="http://crunchyfrog.googlecode.com">CrunchyFrog</a> is out in the wild. There are not much visible changes, but a few bug fixes under the hood. One visible change is the option to give the SQL editor much more space by hiding all other UI elements in the main window. Here&#8217;s a screenshot:</span></p>
<div id="attachment_327" class="wp-caption aligncenter" style="width: 310px"><a href="http://andialbrecht.wordpress.com/files/2009/10/cf_full_editor.png"><img class="size-medium wp-image-327" title="cf_full_editor" src="http://andialbrecht.wordpress.com/files/2009/10/cf_full_editor.png?w=300" alt="SQL editor eating up all space" width="300" height="200" /></a><p class="wp-caption-text">SQL editor eating up all space</p></div>
<p>The second screenshot shows the new highlighting of errors in the editor. In this case there&#8217;s no table called &#8220;actor&#8221;. When the execution of a statement results in a SQL error, CrunchyFrog now tries to find the position of the error in the SQL editor, highlights the corresponding part in your SQL statement and moves the cursor to the right place. I found it very handy to have the cursor in place to correct the error and run the statement again without searching the error before.</p>
<div id="attachment_328" class="wp-caption aligncenter" style="width: 310px"><a href="http://andialbrecht.wordpress.com/files/2009/10/cf_errors.png"><img class="size-medium wp-image-328" title="cf_errors" src="http://andialbrecht.wordpress.com/files/2009/10/cf_errors.png?w=300" alt="ups... an error occurred" width="300" height="200" /></a><p class="wp-caption-text">ups... an error occurred</p></div>
<p>If you&#8217;re interested in the other, non-visible changes, please read the <a title="Change Log" href="http://packages.python.org/crunchyfrog/changes.html#release-0-4-1-oct-1-2009">full list of changes</a> or just go straight to the<a href="http://code.google.com/p/crunchyfrog/"> project page</a> and give it a try <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Thanks to everyone who contributed to this release by sending patches and submitting issues on the <a title="Issue Tracker" href="http://code.google.com/p/crunchyfrog/issues/list">tracker</a>!</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[New Project: sxs]]></title>
<link>http://misspent.wordpress.com/2009/09/19/new-project-sxs/</link>
<pubDate>Sat, 19 Sep 2009 20:10:21 +0000</pubDate>
<dc:creator>abingham</dc:creator>
<guid>http://misspent.wordpress.com/2009/09/19/new-project-sxs/</guid>
<description><![CDATA[I started a new project today called sxs (short for &#8220;side-by-side&#8221;). It&#8217;s another ]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>I started a new project today called sxs (short for &#8220;side-by-side&#8221;). It&#8217;s another translation tool, this one designed to help me read things like newspaper articles. The basic premise is that it takes the source text, splits it into sentences, and then displays each sentence with its translation immediately below it.</p>
<div id="attachment_209" class="wp-caption alignnone" style="width: 405px"><a href="http://misspent.wordpress.com/files/2009/09/screenshot-sidebyside.png"><img src="http://misspent.wordpress.com/files/2009/09/screenshot-sidebyside.png" alt="Screenshot sxs in action" title="Screenshot-SideBySide" width="395" height="337" class="size-full wp-image-209" /></a><p class="wp-caption-text">Screenshot sxs in action</p></div>
<p>It&#8217;s largely functional now, with the glaring exception that it only translates to English. That&#8217;s on the hit-list, and it&#8217;s largely a matter of UI work. </p>
<p>My &#8220;sentence detection&#8221; algorithm is also pretty rudimentary, but I think I&#8217;ll finesse that as I use the program. It&#8217;s deficiencies haven&#8217;t really bothered me yet, so it may not get much more love.</p>
<p>You can <a href="http://code.google.com/p/sxs/">get sxs here</a>.</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[gWakeOnLan 0.2]]></title>
<link>http://ubuntrucchi.wordpress.com/2009/09/13/gwakeonlan-0-2/</link>
<pubDate>Sat, 12 Sep 2009 23:04:01 +0000</pubDate>
<dc:creator>Muflone</dc:creator>
<guid>http://ubuntrucchi.wordpress.com/2009/09/13/gwakeonlan-0-2/</guid>
<description><![CDATA[Pubblicata la nuova versione 0.2 di gWakeOnLan, il programma che consente l&#8217;accensione di altr]]></description>
<content:encoded><![CDATA[Pubblicata la nuova versione 0.2 di gWakeOnLan, il programma che consente l&#8217;accensione di altr]]></content:encoded>
</item>
<item>
<title><![CDATA[Accendere computer in rete con gWakeOnLan]]></title>
<link>http://ubuntrucchi.wordpress.com/2009/09/06/accendere-computer-in-rete-con-gwakeonlan/</link>
<pubDate>Sat, 05 Sep 2009 23:04:02 +0000</pubDate>
<dc:creator>Muflone</dc:creator>
<guid>http://ubuntrucchi.wordpress.com/2009/09/06/accendere-computer-in-rete-con-gwakeonlan/</guid>
<description><![CDATA[Nato da una richiesta di un programma del genere, finora inesistente, vede la luce gWakeOnLan, un pr]]></description>
<content:encoded><![CDATA[Nato da una richiesta di un programma del genere, finora inesistente, vede la luce gWakeOnLan, un pr]]></content:encoded>
</item>
<item>
<title><![CDATA[Removing decoration in xfwm or metacity (again)]]></title>
<link>http://xrunhprof.wordpress.com/2009/09/05/removing-decoration-in-xfwm-or-metacity-again/</link>
<pubDate>Sat, 05 Sep 2009 09:22:07 +0000</pubDate>
<dc:creator>xrunhprof</dc:creator>
<guid>http://xrunhprof.wordpress.com/2009/09/05/removing-decoration-in-xfwm-or-metacity-again/</guid>
<description><![CDATA[Here is a simpler version of this post, using PyGTK: #! /usr/bin/python from gtk.gdk import * w=wind]]></description>
<content:encoded><![CDATA[Here is a simpler version of this post, using PyGTK: #! /usr/bin/python from gtk.gdk import * w=wind]]></content:encoded>
</item>
<item>
<title><![CDATA[pygtkscintilla, some documentation written]]></title>
<link>http://pygabriel.wordpress.com/2009/09/02/pygtkscintilla-some-documentation-written/</link>
<pubDate>Wed, 02 Sep 2009 16:04:38 +0000</pubDate>
<dc:creator>gabrielelanaro</dc:creator>
<guid>http://pygabriel.wordpress.com/2009/09/02/pygtkscintilla-some-documentation-written/</guid>
<description><![CDATA[I&#8217;ve written some documentation about pygtkscintilla project (svn version) The sourceforge pag]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>I&#8217;ve written some documentation about pygtkscintilla project (svn version)<br />
The sourceforge page:<br />
<a href="http://sourceforge.net/projects/pygtksci/">http://sourceforge.net/projects/pygtksci/</a></p>
<p>The documentation:<br />
<a href="http://pygtksci.sourceforge.net">http://pygtksci.sourceforge.net</a></p>
<p>The wiki for bugs, status, other info:<br />
<a href="https://sourceforge.net/apps/trac/pygtksci/wiki">https://sourceforge.net/apps/trac/pygtksci/wiki</a></p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Videoguida alla realizzazione di Camera Cafè Player]]></title>
<link>http://ubuntrucchi.wordpress.com/2009/08/21/videoguida-alla-realizzazione-di-camera-cafe-player/</link>
<pubDate>Fri, 21 Aug 2009 00:56:03 +0000</pubDate>
<dc:creator>Muflone</dc:creator>
<guid>http://ubuntrucchi.wordpress.com/2009/08/21/videoguida-alla-realizzazione-di-camera-cafe-player/</guid>
<description><![CDATA[Sull&#8217;altro mio blog dedicato allo sviluppo in PyGtk ho iniziato la pubblicazione di una videog]]></description>
<content:encoded><![CDATA[Sull&#8217;altro mio blog dedicato allo sviluppo in PyGtk ho iniziato la pubblicazione di una videog]]></content:encoded>
</item>
<item>
<title><![CDATA[Camera Cafè Player 0.2]]></title>
<link>http://ubuntrucchi.wordpress.com/2009/08/20/camera-cafe-player-0-2/</link>
<pubDate>Thu, 20 Aug 2009 21:00:11 +0000</pubDate>
<dc:creator>Muflone</dc:creator>
<guid>http://ubuntrucchi.wordpress.com/2009/08/20/camera-cafe-player-0-2/</guid>
<description><![CDATA[Rilascio urgente di Camera Cafè Player 0.2 che corregge un&#8217;incompatibilità in presenza di Gesp]]></description>
<content:encoded><![CDATA[Rilascio urgente di Camera Cafè Player 0.2 che corregge un&#8217;incompatibilità in presenza di Gesp]]></content:encoded>
</item>
<item>
<title><![CDATA[pygtkscintilla preliminary version released 0.0.1]]></title>
<link>http://pygabriel.wordpress.com/2009/08/10/scintilla-preliminary-version-released-0-0-1/</link>
<pubDate>Mon, 10 Aug 2009 21:47:12 +0000</pubDate>
<dc:creator>gabrielelanaro</dc:creator>
<guid>http://pygabriel.wordpress.com/2009/08/10/scintilla-preliminary-version-released-0-0-1/</guid>
<description><![CDATA[I&#8217;ve packaged in a rough manner the gtkscintilla module, follow the instruction in the trac wi]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>I&#8217;ve packaged in a rough manner the gtkscintilla module,<br />
follow the instruction in the <a href="https://sourceforge.net/apps/trac/pygtksci/wiki" target="_blank">trac wiki</a>, if you have problem or want to tell me something, leave a comment!</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Wrapping GObject for pygtk - a real world example]]></title>
<link>http://pygabriel.wordpress.com/2009/08/01/wrapping-gobject-for-pygtk-a-real-world-example/</link>
<pubDate>Sat, 01 Aug 2009 16:52:09 +0000</pubDate>
<dc:creator>gabrielelanaro</dc:creator>
<guid>http://pygabriel.wordpress.com/2009/08/01/wrapping-gobject-for-pygtk-a-real-world-example/</guid>
<description><![CDATA[How I wrapped scintilla In this article I will tell you my journey wrapping pygtkscintilla, I think ]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><h2>How I wrapped scintilla</h2>
<p>In this article I will tell you my journey wrapping pygtkscintilla, I think this could be useful to tell other people which mistakes I made and how I&#8217;ve solved them.</p>
<h3>Know your enemy</h3>
<p>To solve a problem you have to gather all possible information relate to this problem. Scintilla has a scary interface that have nothing to do with a well-formatted gtk-widget.</p>
<p>The interface is a very important thing. If you wanto to wrap scintilla you have to learn the basics of its usage.  Fortunately there was bait, an example  to test scintilla, it&#8217;s cast gold.</p>
<p>Here&#8217;s the code:</p>
<pre class="brush: cpp;">
/* bait.c */
#include &lt;gtk/gtk.h&gt;

#include &lt;Scintilla.h&gt;
#include &lt;SciLexer.h&gt;
#define PLAT_GTK 1
#include &lt;ScintillaWidget.h&gt;

static int exit_app(GtkWidget*w, GdkEventAny*e, gpointer p) {
 gtk_main_quit();
 return w&amp;#124;&amp;#124;e&amp;#124;&amp;#124;p&amp;#124;&amp;#124;1;    // Avoid warnings
}

int main(int argc, char **argv) {
 GtkWidget *app;
 GtkWidget *editor;
 ScintillaObject *sci;

 gtk_init(&amp;argc, &amp;argv);
 app = gtk_window_new(GTK_WINDOW_TOPLEVEL);
 editor = scintilla_new();
 sci = SCINTILLA(editor);

 gtk_container_add(GTK_CONTAINER(app), editor);
 gtk_signal_connect(GTK_OBJECT(app), &quot;delete_event&quot;,
 GTK_SIGNAL_FUNC(exit_app), 0);

 scintilla_set_id(sci, 0);
 gtk_widget_set_usize(editor, 500, 300);

#define SSM(m, w, l) scintilla_send_message(sci, m, w, l)

 SSM(SCI_STYLECLEARALL, 0, 0);
</pre>
<p>And this is the Makefile associated:</p>
<pre class="brush: bash;">
##### Makefile #####
# Make file for bait on Linux or compatible OS
# Released to the public domain 2000 by Neil Hodgson neilh@scintilla.org
# This makefile tested with GCC 3.2 and GNOME 2.0

.SUFFIXES: .c .o .h .a

INCLUDEDIRS=-I../scintilla/include
CXXFLAGS= -DGTK -DSCI_LEXER -W -Wall -fPIC
LEXEROBJS=$(wildcard ../scintilla/gtk/Lex*.o)

all: bait

.c.o:
 gcc `pkg-config --cflags gtk+-2.0` $(INCLUDEDIRS) $(CXXFLAGS) -c $&lt; -o $@
bait: bait.o $(LEXEROBJS) ../scintilla/bin/scintilla.a
 gcc `pkg-config --libs gtk+-2.0 gthread-2.0` -lstdc++ -DGTK $^ -o $@
clean:
 rm -rf bait *.o
</pre>
<p>I noticed:</p>
<ol>
<li>How to initialize a scintilla editor</li>
<li>How to interact with it. It uses just the SSM macro:  scintilla_send_message function.</li>
<li>With the Makefile associated, how to compile and run it.</li>
</ol>
<p>Once I&#8217;ve done this,  I needed a good interface to respond codegen (utility used to wrap gtk widgets, explained in the <a href="http://pygabriel.wordpress.com/2009/07/22/wrapping-gobjects-for-pygtk/" target="_blank">wrapping tutorial</a>).</p>
<h3>It&#8217;s time to start wrapping</h3>
<p>There was 2 possibilities:</p>
<ol>
<li>Write myself the widget in C.</li>
<li>Search the web for someone that have already done this.</li>
</ol>
<p>I&#8217;m really lazy, I searched a lot on the web and I&#8217;ve found some alternatives:</p>
<ul>
<li>The geany editor: there was some files that wrapped the scintilla interface in a more convenient manner, however it wasn&#8217;t well-formatted because they don&#8217;t use intensively the C/GObject system.</li>
<li>The anjuta editor:  They use a well formatted editor widget that wraps scintilla but there were interdependencies related to anjuta.</li>
<li>The most natural GtkScintilla: someone have done this work long time ago, after some days I noticed that it was a very good starting point.</li>
</ul>
<p>note: I discovered all this things browsing in the project files, reading headers and source files ( I felt like a true hacker).</p>
<p>I haven&#8217;t modified the gtkscintilla.h header and I generated definition files. Next I wrote a simple override file and the initialization module (if you don&#8217;t understand this first read the <a href="http://pygabriel.wordpress.com/2009/07/22/wrapping-gobjects-for-pygtk/" target="_blank">wrapping tutorial</a>).</p>
<p>With no problem I generated the wrapper, cool! (pygtk team have done a great work with codegen, I&#8217;m sad they didn&#8217;t write any documentation)</p>
<p>Now comes the hard part&#8230;</p>
<h3>Compiling</h3>
<p>Welcome in the hell. Scintilla is distribuited as a static library, scintilla.a but the python module I needed was a shared library. I browsed in a sea of pain, errors, errors and errors, my module wouldn&#8217;t compile.</p>
<p>The problem is that you can&#8217;t link a static library to a shared library, the compiler tell you that you have to recompile your files with the -fPIC option. I ignored what the compiler told me, and I tried a lot of  dirty ways to make it work, without success&#8230;</p>
<p>After about 4 days of depression I was sorry with the wisdom of gcc compiler and I was gone in the scintilla/gtk directory to modify the makefile that compiles the scintilla stuff.</p>
<p>In the original makefile there was the compilation command without the -fPIC option and the command &#8220;ar&#8221; to make a static library.</p>
<p>The compilation commands:</p>
<pre class="brush: bash;">
.cxx.o:
 $(CC) $(CONFIGFLAGS) $(CXXFLAGS) -c $&lt;
.c.o:
 $(CCOMP) $(CONFIGFLAGS) $(CXXFLAGS) -w -c $&lt;
</pre>
<p>Becomes:</p>
<pre class="brush: bash;">
 .cxx.o:
 $(CC) $(CONFIGFLAGS) $(CXXFLAGS) -fPIC -c $&lt;
 .c.o:
 $(CCOMP) $(CONFIGFLAGS) $(CXXFLAGS) -fPIC -w -c $&lt;
</pre>
<p>And I modified the creation of the library from static (compressed with ar) to shared (compiled with gcc -shared)</p>
<p>Before:</p>
<pre class="brush: bash;">
COMPLIB= ../bin/scintilla.a
AR= ar
// other things //

$(COMPLIB): DocumentAccessor.o WindowAccessor.o KeyWords.o StyleContext.o \
 CharClassify.o Decoration.o Document.o PerLine.o CallTip.o \
 ScintillaBase.o ContractionState.o Editor.o ExternalLexer.o PropSet.o PlatGTK.o \
 KeyMap.o LineMarker.o PositionCache.o ScintillaGTK.o CellBuffer.o ViewStyle.o \
 RESearch.o RunStyles.o Style.o Indicator.o AutoComplete.o UniConversion.o XPM.o \
 $(MARSHALLER) $(LEXOBJS)
 $(AR) rc $@ $^
</pre>
<p>After:</p>
<pre class="brush: bash;">
COMPLIB= ../bin/scintilla.so # MODIFIED
AR= ar
// other things //

$(COMPLIB): DocumentAccessor.o WindowAccessor.o KeyWords.o StyleContext.o \
 CharClassify.o Decoration.o Document.o PerLine.o CallTip.o \
 ScintillaBase.o ContractionState.o Editor.o ExternalLexer.o PropSet.o PlatGTK.o \
 KeyMap.o LineMarker.o PositionCache.o ScintillaGTK.o CellBuffer.o ViewStyle.o \
 RESearch.o RunStyles.o Style.o Indicator.o AutoComplete.o UniConversion.o XPM.o \
 $(MARSHALLER) $(LEXOBJS)
 gcc -shared -o $@ $^ # MODIFIED
</pre>
<p>After recompiling scintilla I obtained my shared library scintilla.so !!! After this I clearly compiled and linked (reference the <a href="http://pygabriel.wordpress.com/2009/07/31/wrapping-pygtk-widgets-what-you-should-know/">basics tutorial</a>) my python module and run it without (too much) problems!</p>
<p>I post the pygtkscintilla makefile that compiled and linked the python module:</p>
<pre class="brush: bash;">
DEFS=`pkg-config --variable=defsdir pygtk-2.0`
CFLAGS=-I/usr/include/python2.6 `pkg-config --cflags gtk+-2.0 pygtk-2.0 gthread-2.0`  -I. -I..
CXXFLAGS=-DGTK2  
LDFLAGS=`pkg-config --libs gtk+-2.0 pygtk-2.0 pygobject-2.0 gthread-2.0`
LEXEROBJS=$(wildcard ~/workspace/pygtkscintilla/scintilla/gtk/Lex*.o)

all: gtkscintilla-wrap.c gtkscintilla-module.o gtkscintilla.o gtkscintilla.so

gtkscintilla-wrap.c: gtkscintilla.defs gtkscintilla.override
 python /usr/share/pygobject/2.0/codegen/codegen.py \
 --override gtkscintilla.override \
 --prefix gtkscintilla gtkscintilla.defs &gt; $@

# Here's the magic!
gtkscintilla.so: gtkscintilla-wrap.o gtkscintilla.o  gtkscintilla-module.o
 gcc -shared  $(LDFLAGS) -L~/workspace/pygtkscintilla/scintilla/bin -lscintilla  $^ -o $@

gtkscintilla-wrap.o: gtkscintilla-wrap.c
 gcc $(CFLAGS) -fPIC -c $^ -o $@
gtkscintilla.o: gtkscintilla.c
 gcc $(CFLAGS) -fPIC -c $^ -o $@
gtkscintilla-module.o: gtkscintilla-module.c
 gcc  $(CFLAGS) -fPIC -c   $^ -o $@

clean:
 rm -f gtkscintilla.so gtkscintilla-wrap.c gtkscintilla.o gtkscintilla-module.o
</pre>
<p>Ok I&#8217;ve finished telling my story. I hope that my errors can help you!</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Help, wrapping Scintilla for pygtk]]></title>
<link>http://pygabriel.wordpress.com/2009/07/28/help-wrapping-scintilla-for-pygtk/</link>
<pubDate>Tue, 28 Jul 2009 12:40:07 +0000</pubDate>
<dc:creator>gabrielelanaro</dc:creator>
<guid>http://pygabriel.wordpress.com/2009/07/28/help-wrapping-scintilla-for-pygtk/</guid>
<description><![CDATA[Just why? Scintilla is a the powerful text editor widget.  I&#8217;s used by a lot of applications, ]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><h2>Just why?</h2>
<p style="text-align:left;"><a href="http://www.scintilla.org" target="_blank">Scintilla</a> is <del datetime="2009-07-28T11:47:52+00:00">a</del> the powerful text editor widget.  I&#8217;s used by a lot of applications, it&#8217;s something like this:<br />
<img class="aligncenter" title="Scintilla editor from scite" src="http://www.conticello.it/images/programmi/scite.png" alt="" width="355" height="363" /></p>
<p style="text-align:left;">Scintilla is for GTK+ but this f*** widget doesn&#8217;t follow standards from GTK+/GObject.</p>
<p style="text-align:left;">In the actual state of things there isn&#8217;t a good pygtk IDE/editor written in pygtk (there&#8217;s pida but uses embedded editors  like vim and emacs), and I think the reason is that there isn&#8217;t a scintilla wrapper. To make a comparison with pyqt there&#8217;s the fairly complete <a href="http://eric-ide.python-projects.org/">eric</a>.</p>
<p style="text-align:left;">The code source editor for pygtk  is pygtksourceview but this widget hasn&#8217;t the code-completion feature and the code folding feauture that in my opinion are fundamental. These features will be implented in near(?) future and I will use it, but I (maybe we) need a powerful editor now.</p>
<p style="text-align:left;">I want to wrap scintilla for pygtk, it was wrapped sometime ago by Roberto Cavada but it&#8217;s outdated  and his mail isn&#8217;t reachable.</p>
<h2>The current state of things</h2>
<ul>
<li>found <a href="http://sourceforge.net/projects/moleskine/files/">GtkScintilla</a> widget, a  well-formatted GObject scintilla distribution. It&#8217;s outdated but it&#8217;s a good starting point to write another GObject to wrap.</li>
<li>I generate the wrapper  (cfr <a href="http://pygabriel.wordpress.com/2009/07/22/wrapping-gobjects-for-pygtk/">Wrapping Gobject</a>) for GtkScintilla but I can&#8217;t compile it &#8230; frustrating.</li>
<li>In next days I will test a little the scintilla distribution to focus the design and to learn to compile all the things&#8230; I need.</li>
</ul>
<p>There&#8217;s a lot of work to do, it&#8217;s very hard, every help is accepted (everyone can partecipate, also without experience. Just tell me in comments or via e-mail).</p>
<p>Wish me good luck!</p>
</div>]]></content:encoded>
</item>

</channel>
</rss>
