<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
    <title>Imdiot&#39;s Blog</title>
    <id>http://imdiot.appspot.com/</id>
    <subtitle>记录点滴</subtitle>
    <link href="http://imdiot.appspot.com" />
    <link href="http://imdiot.appspot.com/feed" rel="self" />
    <updated>2011-04-06T03:44:26Z</updated>
    <author>
      <name>sunshine1985115</name>
    </author>

  <entry>
      <link href="http://imdiot.appspot.com/2011-04-6-161001"/>
      <id>http://imdiot.appspot.com/entry/</id>
      <title>请前往此处</title>
      <content type="html"><![CDATA[
      <a href="http://imdiot.wordpress.com/"><span style="font-size:x-large;">http://imdiot.wordpress.com/</span></a>
      
                <h4>相关阅读：</h4>
                  <ul>
                
                  <li><a href="http://imdiot.appspot.com/2010-06-19-19001">About</a></li>
                
                </ul>
                
                <p>本文网址:<a href="http://imdiot.appspot.com/2011-04-6-161001">http://imdiot.appspot.com/2011-04-6-161001</a></p>

      ]]></content>
      <author>
          <name>imdiot</name>
      </author>
      <updated>2011-04-06T03:44:26Z</updated>
  </entry>

  <entry>
      <link href="http://imdiot.appspot.com/2010-12-28-61001"/>
      <id>http://imdiot.appspot.com/entry/</id>
      <title>PySVN checkout时中文路径的解决</title>
      <content type="html"><![CDATA[
      <p>在玩PySVN时发现如果文件路径出现中文的话会出现"Can't convert string from 'UTF-8' to native encoding:"错误</p>
<p><br />
</p>
<p>祭出谷歌娘，发现早在05年就已经有了解决方法了</p>
<p><br />
</p>
<p><br />
<pre class="brush: python; ruler: true; first-line: 1">import locale
language_code, encoding = locale.getdefaultlocale()
if language_code is None:
    language_code = 'en_GB'
if encoding is None:
    encoding = 'UTF-8'
if encoding.lower() == 'utf':
    encoding = 'UTF-8'
locale.setlocale( locale.LC_ALL, '%s.%s' % (language_code, encoding))</pre>
</p>
      
                <h4>相关阅读：</h4>
                  <ul>
                
                  <li><a href="http://imdiot.appspot.com/2010-07-25-26001">有关python的反编译</a></li>
                
                  <li><a href="http://imdiot.appspot.com/2010-07-18-25001">python2.5到2.6字节码指令变化点点发现(想到什么再写什么)</a></li>
                
                  <li><a href="http://imdiot.appspot.com/2010-06-27-20001">简单的gnome自动换壁纸</a></li>
                
                  <li><a href="http://imdiot.appspot.com/2010-04-16-11001">AVL tree</a></li>
                
                  <li><a href="http://imdiot.appspot.com/2010-02-6-2001">有关写xmms2 client的一个很奇怪的问题</a></li>
                
                </ul>
                
                <p>本文网址:<a href="http://imdiot.appspot.com/2010-12-28-61001">http://imdiot.appspot.com/2010-12-28-61001</a></p>

      ]]></content>
      <author>
          <name>imdiot</name>
      </author>
      <updated>2010-12-28T09:04:12Z</updated>
  </entry>

  <entry>
      <link href="http://imdiot.appspot.com/2010-09-23-36001"/>
      <id>http://imdiot.appspot.com/entry/</id>
      <title>Rhythmbox文件夹视图浏览的插件</title>
      <content type="html"><![CDATA[
      <p><span style="font-size:medium;">介绍</span></p><p>Rhythmbox浏览音乐时只能按照音乐文件的信息来分类</p><p>但有时有许多音乐文件的信息并不完<span style="font-size:xx-small;">整且</span>音乐文件又很多的时候 按照音乐信息分类就不如直接按照目录分类清晰了</p><p>所以就写了一个文件夹视图的插件</p><p>文件夹视图的根目录是读取自rhythmbox首选项中的音乐文件存放位置的</p><p><span style="font-size:medium;">项目地址</span></p><p><a href="http://code.google.com/p/folderview/">http://code.google.com/p/folderview/</a></p><p><span style="font-size:medium;">截图</span></p><p><img src="http://imdiot.appspot.com/media/agZpbWRpb3RyDQsSBU1lZGlhGLmRAgw/Screenshot-%E9%9F%B3%E4%B9%90%E6%92%AD%E6%94%BE%E5%99%A8.png" width="560" height="380" /><br /></p><p><span style="font-size:medium;">安装</span></p><p><span style="font-size:xx-small;">svn checkout http://folderview.googlecode.com/svn/trunk/ folderview</span></p><p><span style="font-size:xx-small;">cp -R folderview/FolderView ~/.gnome2/rhythmbox/plugins/ 或&nbsp;cp -R folderview/FolderView&nbsp;/usr/lib/rhythmbox/plugins/</span></p><p><span style="font-size:medium; ">使用</span></p><p><span style="font-size:xx-small;">启动Rhythmbox</span></p><p><span style="font-size:xx-small;">菜单栏 编辑-&gt;插件</span></p><p><span style="font-size:xx-small;">勾选“文件夹视图”</span></p><p><span style="font-size:medium; "><br /></span></p>
      
                <p>本文网址:<a href="http://imdiot.appspot.com/2010-09-23-36001">http://imdiot.appspot.com/2010-09-23-36001</a></p>

      ]]></content>
      <author>
          <name>Idiot</name>
      </author>
      <updated>2010-09-23T09:36:33Z</updated>
  </entry>

  <entry>
      <link href="http://imdiot.appspot.com/2010-09-13-31001"/>
      <id>http://imdiot.appspot.com/entry/</id>
      <title>修改ibus的颜色</title>
      <content type="html"><![CDATA[
      <p>看久了千篇一律的ibus输入法的输入框总会有点腻了的感觉</p>
<p>so 稍微hack了一下代码改了一下颜色~</p>
<p><br />
</p>
<p>原版ibus-pinyin</p>
<p><img src="http://imdiotimgie.appspot.com/image/9001/" /><br />
</p>
<p>改版ibus-pinyin</p>
<p><img src="http://imdiotimgie.appspot.com/image/6001/" /><br />
</p>
<p>改版ibus-sunpinyin</p>
<p><img src="http://imdiotimgie.appspot.com/image/8001/" /><br />
</p>
<p>改版ibus-cloud-pinyin</p>
<p><img src="http://imdiotimgie.appspot.com/image/7001/" /><br />
</p>
<p>这下有了点fcitx的感觉了吧~~~</p>
<p>只是自己修改玩玩 所以没有深入研究代码</p>
<p><br />
</p>
<pre class="brush: python; ruler: true; first-line: 1">*** candidatepanel.py	2010-09-13 14:08:16.000000000 +0800
--- /home/yangguang/Desktop/candidatepanel.py	2010-09-13 12:26:28.000000000 +0800
***************
*** 87,98 ****
          for i in range(0, 16):
              label1 = Label("%c." % ("1234567890abcdef"[i]))
              label1.set_alignment(0.0, 0.5)
-             label1.modify_fg(gtk.STATE_NORMAL, gtk.gdk.Color("#013BC5"))
              label1.show()
  
              label2 = Label()
              label2.set_alignment(0.0, 0.5)
-             label2.modify_fg(gtk.STATE_NORMAL, gtk.gdk.Color("#69A0EC"))
              label1.show()
  
              if self.__orientation == ibus.ORIENTATION_VERTICAL:
--- 87,96 ----
***************
*** 100,110 ****
                  label2.set_property("xpad", 8)
                  ebox1 = EventBox()
                  ebox1.set_no_show_all(True)
-                 ebox1.modify_bg(gtk.STATE_NORMAL, gtk.gdk.Color("#FFFFFF"))
                  ebox1.add(label1)
                  ebox2 = EventBox()
                  ebox2.set_no_show_all(True)
-                 ebox2.modify_bg(gtk.STATE_NORMAL, gtk.gdk.Color("#FFFFFF"))
                  ebox2.add(label2)
                  self.__vbox1.pack_start(ebox1, False, False, 2)
                  self.__vbox2.pack_start(ebox2, False, False, 2)
--- 98,106 ----
***************
*** 116,122 ****
                  hbox.pack_start(label2, False, False, 1)
                  ebox = EventBox()
                  ebox.set_no_show_all(True)
-                 ebox.modify_bg(gtk.STATE_NORMAL, gtk.gdk.Color("#FFFFFF"))
                  ebox.add(hbox)
                  self.pack_start(ebox, False, False, 4)
                  self.__candidates.append((ebox,))
--- 112,117 ----
***************
*** 148,159 ****
              if i == focus_candidate and show_cursor:
                  if attrs == None:
                      attrs = pango.AttrList()
!                 #color = self.__labels[i][1].style.base[gtk.STATE_SELECTED]
!                 #print color
                  end_index = len(text.encode("utf8"))
!                 #attr = pango.AttrBackground(color.red, color.green, color.blue, 0, end_index)
!                 #attrs.change(attr)
!                 color = gtk.gdk.Color("#FF55FF")
                  attr = pango.AttrForeground(color.red, color.green, color.blue, 0, end_index)
                  attrs.insert(attr)
  
--- 143,153 ----
              if i == focus_candidate and show_cursor:
                  if attrs == None:
                      attrs = pango.AttrList()
!                 color = self.__labels[i][1].style.base[gtk.STATE_SELECTED]
                  end_index = len(text.encode("utf8"))
!                 attr = pango.AttrBackground(color.red, color.green, color.blue, 0, end_index)
!                 attrs.change(attr)
!                 color = self.__labels[i][1].style.text[gtk.STATE_SELECTED]
                  attr = pango.AttrForeground(color.red, color.green, color.blue, 0, end_index)
                  attrs.insert(attr)
  
***************
*** 229,236 ****
          self.__moved_cursor_location = None
  
          self.__recreate_ui()
-         
-         self.__viewport.modify_bg(gtk.STATE_NORMAL, gtk.gdk.Color("#FFFFFF"))
  
      def __handle_move_end_cb(self, handle):
          # store moved location
--- 223,228 ----
***************
*** 251,257 ****
  
          # create aux label
          self.__aux_label = Label(self.__aux_string)
-         self.__aux_label.modify_fg(gtk.STATE_NORMAL, gtk.gdk.Color("#EB50A0"))
          self.__aux_label.set_attributes(self.__aux_attrs)
          self.__aux_label.set_alignment(0.0, 0.5)
          self.__aux_label.set_padding(8, 0)
--- 243,248 ----
***************
*** 526,532 ****
      table = ibus.LookupTable()
      table.append_candidate(ibus.Text("AAA"))
      table.append_candidate(ibus.Text("BBB"))
-     table.append_label(ibus.Text("CCC"))
      cp = CandidatePanel()
      cp.show_all()
      cp.update_lookup_table(table, True)
--- 517,522 ----
</pre>
      
                <h4>相关阅读：</h4>
                  <ul>
                
                  <li><a href="http://imdiot.appspot.com/2010-02-11-4002">对ibus输入法不跟随下了次狠手</a></li>
                
                </ul>
                
                <p>本文网址:<a href="http://imdiot.appspot.com/2010-09-13-31001">http://imdiot.appspot.com/2010-09-13-31001</a></p>

      ]]></content>
      <author>
          <name>Idiot</name>
      </author>
      <updated>2010-09-13T06:48:23Z</updated>
  </entry>

  <entry>
      <link href="http://imdiot.appspot.com/2010-08-31-30001"/>
      <id>http://imdiot.appspot.com/entry/</id>
      <title>关于PyGTK+pyinotify</title>
      <content type="html"><![CDATA[
      首先是pyinotify官网上的一个例子
<pre class="brush: python; ruler: true; first-line: 1">import pyinotify

wm = pyinotify.WatchManager()  # Watch Manager
mask = pyinotify.IN_DELETE | pyinotify.IN_CREATE  # watched events

class EventHandler(pyinotify.ProcessEvent):
    def process_IN_CREATE(self, event):
        print "Creating:", event.pathname

    def process_IN_DELETE(self, event):
        print "Removing:", event.pathname

handler = EventHandler()
notifier = pyinotify.Notifier(wm, handler)
wdd = wm.add_watch('/tmp', mask, rec=True)

notifier.loop()</pre>
<p>在这个例子中最后一行的<span class="n">notifier</span><span class="o">.</span><span class="n">loop</span><span class="p">()是inotify自己的loop实现</span></p>
<p><span class="p">但如果想要PyGTK中使用inotify的话notifify的loop会和GTK的loop发生冲突</span></p>
<p>所以要做下小的修改</p>
<pre class="brush: python; ruler: true; first-line: 1">import pyinotify
import gobject
import gtk

gobject.threads_init()

wm = pyinotify.WatchManager()  # Watch Manager
mask = pyinotify.IN_DELETE | pyinotify.IN_CREATE  # watched events

class EventHandler(pyinotify.ProcessEvent):
    def process_IN_CREATE(self, event):
        print "Creating:", event.pathname

    def process_IN_DELETE(self, event):
        print "Removing:", event.pathname


def _quit(widget):
    notifier.stop()
    gtk.main_quit()

handler = EventHandler()
notifier = pyinotify.ThreadedNotifier(wm, handler)
wdd = wm.add_watch('/tmp', mask, rec=True)
notifier.start()

win=gtk.Window()
win.connect("destroy",_quit)
win.show()
gtk.main()</pre>
<p></p>
      
                <h4>相关阅读：</h4>
                  <ul>
                
                  <li><a href="http://imdiot.appspot.com/2010-08-16-28001">PYGTK自定义的小控件</a></li>
                
                  <li><a href="http://imdiot.appspot.com/2010-04-16-11001">AVL tree</a></li>
                
                </ul>
                
                <p>本文网址:<a href="http://imdiot.appspot.com/2010-08-31-30001">http://imdiot.appspot.com/2010-08-31-30001</a></p>

      ]]></content>
      <author>
          <name>Idiot</name>
      </author>
      <updated>2010-08-31T04:18:42Z</updated>
  </entry>

  <entry>
      <link href="http://imdiot.appspot.com/2010-08-16-28001"/>
      <id>http://imdiot.appspot.com/entry/</id>
      <title>PYGTK自定义的小控件</title>
      <content type="html"><![CDATA[
      <p>首先要说的是gif这256色太坑人了……</p><p><img src="http://imdiotimgie.appspot.com/image/4001/" /></p><p>然后……既然看不清就说明一下：半透明、异形、渐隐、边缘光滑 木有了</p><p>结束…………</p>
      
                <h4>相关阅读：</h4>
                  <ul>
                
                  <li><a href="http://imdiot.appspot.com/2010-08-31-30001">关于PyGTK+pyinotify</a></li>
                
                  <li><a href="http://imdiot.appspot.com/2010-04-16-11001">AVL tree</a></li>
                
                </ul>
                
                <p>本文网址:<a href="http://imdiot.appspot.com/2010-08-16-28001">http://imdiot.appspot.com/2010-08-16-28001</a></p>

      ]]></content>
      <author>
          <name>Idiot</name>
      </author>
      <updated>2010-08-16T10:25:03Z</updated>
  </entry>

  <entry>
      <link href="http://imdiot.appspot.com/2010-07-26-26002"/>
      <id>http://imdiot.appspot.com/entry/</id>
      <title>翻唱李健《向往》莫拍砖 只是娱乐娱乐嘛～</title>
      <content type="html"><![CDATA[
      <p>5sing的flash控件不能手动开始……</p><p>so 还是贴链接好了</p><p><a href="http://l.5sing.com/player.swf?songtype=fc&amp;songid=2461006">http://l.5sing.com/player.swf?songtype=fc&amp;songid=2461006</a></p>
      
                <p>本文网址:<a href="http://imdiot.appspot.com/2010-07-26-26002">http://imdiot.appspot.com/2010-07-26-26002</a></p>

      ]]></content>
      <author>
          <name>Idiot</name>
      </author>
      <updated>2010-07-26T08:21:30Z</updated>
  </entry>

  <entry>
      <link href="http://imdiot.appspot.com/2010-07-25-26001"/>
      <id>http://imdiot.appspot.com/entry/</id>
      <title>有关python的反编译</title>
      <content type="html"><![CDATA[
      <p>最近把买了一直还没看的《Python源码剖析》看了看 获益颇多 直接导致了对python的反编译产生了不小的兴趣</p><p>google一番后找到了两份可供参考的代码：&nbsp;1、<a href="http://www.crazy-compilers.com/">decompyle</a>&nbsp;2、<a href="http://users.cs.cf.ac.uk/J.P.Giddy/python/decompiler/decompiler.html">decompile</a></p><p><br /></p><p>1&nbsp;<a href="http://www.crazy-compilers.com/">decompyle</a>是传说中反编译效果最好的 但已经成为了商业软件 目前在网上可以找到的只支持到了python2.3 但听说成为商业软件后好像也没赚多少钱…… 不过却有不少基于开源版decompyle的修改版 试了试 在google code上的一个<a href="http://code.google.com/p/unpyc/">unpyc</a>是一个既支持python2.6且能跑的起来的</p><p>2 decompile好像就不怎么有名了……而且我也没有成功的跑起来……</p><p><br /></p><p>看了看这两个的代码</p><p>1&nbsp;<a href="http://www.crazy-compilers.com/">decompyle</a>用的是编译原理的方法 用的是<a href="http://pages.cpsc.ucalgary.ca/~aycock/spark/">Spark</a>解析器/编译器框架 通过<a href="http://pages.cpsc.ucalgary.ca/~aycock/spark/">Spark</a>来定义python bytecode的句法规则、构建AST树、代码生成，在pyc-&gt;bytecode时可能是因为那时python还没有dis这个模块 所以用的是手工都取分析的方法……</p><p>2&nbsp;<a href="http://users.cs.cf.ac.uk/J.P.Giddy/python/decompiler/decompiler.html">decompile</a>则是借鉴了python虚拟机执行时的方法 python虚拟机通过bytecode来决定当前该做怎样的动作 根据bytecode所对应的虚拟机的操作来生成反编译代码</p><p><br /></p><p>1&nbsp;<a href="http://www.crazy-compilers.com/">decompyle</a>的方法思路清晰 但对<a href="http://pages.cpsc.ucalgary.ca/~aycock/spark/">Spark</a>的理解比较费事……而且对编译原理的知识要求的比较多……如果没学过编译原理的话基本是一头雾水…… 但想修改、扩充起来可能会方便的多</p><p>2&nbsp;<a href="http://users.cs.cf.ac.uk/J.P.Giddy/python/decompiler/decompiler.html">decompile</a>的方法……简单……很容易理解 除了简单好像就没什么了……</p><p><br /></p><p>PS:拿python的反编译做毕设会不会比较有趣呢…………</p>
      
                <h4>相关阅读：</h4>
                  <ul>
                
                  <li><a href="http://imdiot.appspot.com/2010-12-28-61001">PySVN checkout时中文路径的解决</a></li>
                
                  <li><a href="http://imdiot.appspot.com/2010-07-18-25001">python2.5到2.6字节码指令变化点点发现(想到什么再写什么)</a></li>
                
                  <li><a href="http://imdiot.appspot.com/2010-06-27-20001">简单的gnome自动换壁纸</a></li>
                
                  <li><a href="http://imdiot.appspot.com/2010-04-16-11001">AVL tree</a></li>
                
                  <li><a href="http://imdiot.appspot.com/2010-02-6-2001">有关写xmms2 client的一个很奇怪的问题</a></li>
                
                </ul>
                
                <p>本文网址:<a href="http://imdiot.appspot.com/2010-07-25-26001">http://imdiot.appspot.com/2010-07-25-26001</a></p>

      ]]></content>
      <author>
          <name>Idiot</name>
      </author>
      <updated>2010-07-25T15:22:48Z</updated>
  </entry>

  <entry>
      <link href="http://imdiot.appspot.com/2010-07-18-25001"/>
      <id>http://imdiot.appspot.com/entry/</id>
      <title>python2.5到2.6字节码指令变化点点发现(想到什么再写什么)</title>
      <content type="html"><![CDATA[
      <p>《Python源码剖析》中用的Python版本为2.5.2</p><p>书中所写对</p><p>d = {"1":1, "2":2}字典创建语句所得到的字节码为(略有删减):</p><p>BUILD_MAP</p><p>DUP_TOP</p><p>LOAD_CONST (1)</p><p>ROT_TWO</p><p>LOAD_CONST ('1')</p><p>STORE_SUBSCR</p><p>DUP_TOP</p><p>LOAD_CONST (2)</p><p>ROT_TWO</p><p>LOAD_CONST ('2')</p><p>STORE_SUBSCR</p><p>STORE_NAME (d)</p><p>其中会有对此对栈顶字典元素的重复创建和栈顶两元素的对调</p><p><br /></p><p>而在我正在使用的2.6.5版本中 该语句的字节码已变为(略有删减):</p><p></p><p>BUILD_MAP</p><p>LOAD_CONST (1)</p><p>LOAD_CONST ('1')</p><p>STORE_MAP &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</p><p>LOAD_CONST (2)</p><p>LOAD_CONST ('2')</p><p>STORE_MAP &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</p><p>STORE_NAME (d)</p><p>操作已经简化为了直接取出两元素作为键和值插入到字典中</p><p>同时STORE_SUBSCR的功能也有了相应的变化</p><p><br /></p><p>………………</p><p>……………</p><p>…………</p><p>………</p><p>……</p><p>…</p><div><br /></div>
      
                <h4>相关阅读：</h4>
                  <ul>
                
                  <li><a href="http://imdiot.appspot.com/2010-12-28-61001">PySVN checkout时中文路径的解决</a></li>
                
                  <li><a href="http://imdiot.appspot.com/2010-07-25-26001">有关python的反编译</a></li>
                
                  <li><a href="http://imdiot.appspot.com/2010-06-27-20001">简单的gnome自动换壁纸</a></li>
                
                  <li><a href="http://imdiot.appspot.com/2010-04-16-11001">AVL tree</a></li>
                
                  <li><a href="http://imdiot.appspot.com/2010-02-6-2001">有关写xmms2 client的一个很奇怪的问题</a></li>
                
                </ul>
                
                <p>本文网址:<a href="http://imdiot.appspot.com/2010-07-18-25001">http://imdiot.appspot.com/2010-07-18-25001</a></p>

      ]]></content>
      <author>
          <name>Idiot</name>
      </author>
      <updated>2010-07-18T12:03:02Z</updated>
  </entry>

  <entry>
      <link href="http://imdiot.appspot.com/2010-06-27-20001"/>
      <id>http://imdiot.appspot.com/entry/</id>
      <title>简单的gnome自动换壁纸</title>
      <content type="html"><![CDATA[
      <p>闲的没事写着玩玩</p><pre style="width:96%; padding: 2px; border: 1px solid #888;white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;"><span style="color: rgb(136, 0, 0); ">#!/usr/bin/env python</span><span style="color: rgb(0, 0, 0); "><br /></span><span style="color: rgb(136, 0, 0); "># -*- coding: utf-8 -*-</span><span style="color: rgb(0, 0, 0); "><br /><br /></span><span style="color: rgb(0, 0, 136); ">import</span><span style="color: rgb(0, 0, 0); "> gconf<br /></span><span style="color: rgb(0, 0, 136); ">import</span><span style="color: rgb(0, 0, 0); "> os<br /></span><span style="color: rgb(0, 0, 136); ">import</span><span style="color: rgb(0, 0, 0); "> gobject<br /></span><span style="color: rgb(0, 0, 136); ">import</span><span style="color: rgb(0, 0, 0); "> gtk<br /><br /></span><span style="color: rgb(0, 0, 136); ">class</span><span style="color: rgb(0, 0, 0); "> </span><span style="color: rgb(102, 0, 102); ">Auto_wp</span><span style="color: rgb(102, 102, 0); ">:</span><span style="color: rgb(0, 0, 0); "><br />&nbsp; &nbsp; </span><span style="color: rgb(0, 0, 136); ">def</span><span style="color: rgb(0, 0, 0); "> __init__</span><span style="color: rgb(102, 102, 0); ">(</span><span style="color: rgb(0, 0, 136); ">self</span><span style="color: rgb(102, 102, 0); ">,</span><span style="color: rgb(0, 0, 0); "> wp_dir</span><span style="color: rgb(102, 102, 0); ">):</span><span style="color: rgb(0, 0, 0); "><br />&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: rgb(0, 0, 136); ">self</span><span style="color: rgb(102, 102, 0); ">.</span><span style="color: rgb(0, 0, 0); ">wp_dir &nbsp; &nbsp; </span><span style="color: rgb(102, 102, 0); ">=</span><span style="color: rgb(0, 0, 0); "> wp_dir<br />&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: rgb(0, 0, 136); ">self</span><span style="color: rgb(102, 102, 0); ">.</span><span style="color: rgb(0, 0, 0); ">file_list &nbsp;</span><span style="color: rgb(102, 102, 0); ">=</span><span style="color: rgb(0, 0, 0); "> </span><span style="color: rgb(102, 102, 0); ">[]</span><span style="color: rgb(0, 0, 0); "><br />&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: rgb(0, 0, 136); ">self</span><span style="color: rgb(102, 102, 0); ">.</span><span style="color: rgb(0, 0, 0); ">index &nbsp; &nbsp; &nbsp;</span><span style="color: rgb(102, 102, 0); ">=</span><span style="color: rgb(0, 0, 0); "> </span><span style="color: rgb(0, 102, 102); ">0</span><span style="color: rgb(0, 0, 0); "><br />&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: rgb(0, 0, 136); ">self</span><span style="color: rgb(102, 102, 0); ">.</span><span style="color: rgb(0, 0, 0); ">client &nbsp; &nbsp; </span><span style="color: rgb(102, 102, 0); ">=</span><span style="color: rgb(0, 0, 0); "> gconf</span><span style="color: rgb(102, 102, 0); ">.</span><span style="color: rgb(0, 0, 0); ">client_get_default</span><span style="color: rgb(102, 102, 0); ">()</span><span style="color: rgb(0, 0, 0); "><br />&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: rgb(0, 0, 136); ">self</span><span style="color: rgb(102, 102, 0); ">.</span><span style="color: rgb(0, 0, 0); ">get_file_list</span><span style="color: rgb(102, 102, 0); ">(</span><span style="color: rgb(0, 0, 136); ">self</span><span style="color: rgb(102, 102, 0); ">.</span><span style="color: rgb(0, 0, 0); ">wp_dir</span><span style="color: rgb(102, 102, 0); ">)</span><span style="color: rgb(0, 0, 0); "><br />&nbsp; &nbsp; &nbsp; &nbsp; gobject</span><span style="color: rgb(102, 102, 0); ">.</span><span style="color: rgb(0, 0, 0); ">timeout_add</span><span style="color: rgb(102, 102, 0); ">(</span><span style="color: rgb(0, 102, 102); ">10000</span><span style="color: rgb(102, 102, 0); ">,</span><span style="color: rgb(0, 0, 0); "> </span><span style="color: rgb(0, 0, 136); ">self</span><span style="color: rgb(102, 102, 0); ">.</span><span style="color: rgb(0, 0, 0); ">change_wp</span><span style="color: rgb(102, 102, 0); ">)</span><span style="color: rgb(0, 0, 0); "><br />&nbsp; &nbsp; &nbsp; &nbsp; gtk</span><span style="color: rgb(102, 102, 0); ">.</span><span style="color: rgb(0, 0, 0); ">main</span><span style="color: rgb(102, 102, 0); ">()</span><span style="color: rgb(0, 0, 0); "><br /><br />&nbsp; &nbsp; </span><span style="color: rgb(0, 0, 136); ">def</span><span style="color: rgb(0, 0, 0); "> get_file_list</span><span style="color: rgb(102, 102, 0); ">(</span><span style="color: rgb(0, 0, 136); ">self</span><span style="color: rgb(102, 102, 0); ">,</span><span style="color: rgb(0, 0, 0); "> wp_dir</span><span style="color: rgb(102, 102, 0); ">):</span><span style="color: rgb(0, 0, 0); "><br />&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: rgb(0, 0, 136); ">for</span><span style="color: rgb(0, 0, 0); "> parent</span><span style="color: rgb(102, 102, 0); ">,</span><span style="color: rgb(0, 0, 0); "> dirnames</span><span style="color: rgb(102, 102, 0); ">,</span><span style="color: rgb(0, 0, 0); "> filenames </span><span style="color: rgb(0, 0, 136); ">in</span><span style="color: rgb(0, 0, 0); "> os</span><span style="color: rgb(102, 102, 0); ">.</span><span style="color: rgb(0, 0, 0); ">walk</span><span style="color: rgb(102, 102, 0); ">(</span><span style="color: rgb(0, 0, 0); ">wp_dir</span><span style="color: rgb(102, 102, 0); ">):</span><span style="color: rgb(0, 0, 0); "><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: rgb(0, 0, 136); ">for</span><span style="color: rgb(0, 0, 0); "> filename </span><span style="color: rgb(0, 0, 136); ">in</span><span style="color: rgb(0, 0, 0); "> filenames</span><span style="color: rgb(102, 102, 0); ">:</span><span style="color: rgb(0, 0, 0); "><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: rgb(0, 0, 136); ">self</span><span style="color: rgb(102, 102, 0); ">.</span><span style="color: rgb(0, 0, 0); ">file_list</span><span style="color: rgb(102, 102, 0); ">.</span><span style="color: rgb(0, 0, 0); ">append</span><span style="color: rgb(102, 102, 0); ">(</span><span style="color: rgb(0, 0, 0); ">os</span><span style="color: rgb(102, 102, 0); ">.</span><span style="color: rgb(0, 0, 0); ">path</span><span style="color: rgb(102, 102, 0); ">.</span><span style="color: rgb(0, 0, 0); ">join</span><span style="color: rgb(102, 102, 0); ">(</span><span style="color: rgb(0, 0, 0); ">parent</span><span style="color: rgb(102, 102, 0); ">,</span><span style="color: rgb(0, 0, 0); "> filename</span><span style="color: rgb(102, 102, 0); ">))</span><span style="color: rgb(0, 0, 0); "><br /><br />&nbsp; &nbsp; </span><span style="color: rgb(0, 0, 136); ">def</span><span style="color: rgb(0, 0, 0); "> change_wp</span><span style="color: rgb(102, 102, 0); ">(</span><span style="color: rgb(0, 0, 136); ">self</span><span style="color: rgb(102, 102, 0); ">):</span><span style="color: rgb(0, 0, 0); "><br />&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: rgb(0, 0, 136); ">print</span><span style="color: rgb(0, 0, 0); "> </span><span style="color: rgb(0, 0, 136); ">self</span><span style="color: rgb(102, 102, 0); ">.</span><span style="color: rgb(0, 0, 0); ">file_list</span><span style="color: rgb(102, 102, 0); ">[</span><span style="color: rgb(0, 0, 136); ">self</span><span style="color: rgb(102, 102, 0); ">.</span><span style="color: rgb(0, 0, 0); ">index</span><span style="color: rgb(102, 102, 0); ">]</span><span style="color: rgb(0, 0, 0); "><br />&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: rgb(0, 0, 136); ">self</span><span style="color: rgb(102, 102, 0); ">.</span><span style="color: rgb(0, 0, 0); ">client</span><span style="color: rgb(102, 102, 0); ">.</span><span style="color: rgb(0, 0, 0); ">set_string</span><span style="color: rgb(102, 102, 0); ">(</span><span style="color: rgb(0, 136, 0); ">'/desktop/gnome/background/picture_filename'</span><span style="color: rgb(102, 102, 0); ">,</span><span style="color: rgb(0, 0, 136); ">self</span><span style="color: rgb(102, 102, 0); ">.</span><span style="color: rgb(0, 0, 0); ">file_list</span><span style="color: rgb(102, 102, 0); ">[</span><span style="color: rgb(0, 0, 136); ">self</span><span style="color: rgb(102, 102, 0); ">.</span><span style="color: rgb(0, 0, 0); ">index</span><span style="color: rgb(102, 102, 0); ">])</span><span style="color: rgb(0, 0, 0); "><br />&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: rgb(0, 0, 136); ">self</span><span style="color: rgb(102, 102, 0); ">.</span><span style="color: rgb(0, 0, 0); ">index </span><span style="color: rgb(102, 102, 0); ">+=</span><span style="color: rgb(0, 0, 0); "> </span><span style="color: rgb(0, 102, 102); ">1</span><span style="color: rgb(0, 0, 0); "><br />&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: rgb(0, 0, 136); ">if</span><span style="color: rgb(0, 0, 0); "> </span><span style="color: rgb(0, 0, 136); ">self</span><span style="color: rgb(102, 102, 0); ">.</span><span style="color: rgb(0, 0, 0); ">index </span><span style="color: rgb(102, 102, 0); ">&gt;=</span><span style="color: rgb(0, 0, 0); "> len</span><span style="color: rgb(102, 102, 0); ">(</span><span style="color: rgb(0, 0, 136); ">self</span><span style="color: rgb(102, 102, 0); ">.</span><span style="color: rgb(0, 0, 0); ">file_list</span><span style="color: rgb(102, 102, 0); ">):</span><span style="color: rgb(0, 0, 0); "><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: rgb(0, 0, 136); ">self</span><span style="color: rgb(102, 102, 0); ">.</span><span style="color: rgb(0, 0, 0); ">index </span><span style="color: rgb(102, 102, 0); ">=</span><span style="color: rgb(0, 0, 0); "> </span><span style="color: rgb(0, 102, 102); ">0</span><span style="color: rgb(0, 0, 0); "><br />&nbsp; &nbsp; &nbsp; &nbsp; gobject</span><span style="color: rgb(102, 102, 0); ">.</span><span style="color: rgb(0, 0, 0); ">timeout_add</span><span style="color: rgb(102, 102, 0); ">(</span><span style="color: rgb(0, 102, 102); ">10000</span><span style="color: rgb(102, 102, 0); ">,</span><span style="color: rgb(0, 0, 0); "> </span><span style="color: rgb(0, 0, 136); ">self</span><span style="color: rgb(102, 102, 0); ">.</span><span style="color: rgb(0, 0, 0); ">change_wp</span><span style="color: rgb(102, 102, 0); ">)</span><span style="color: rgb(0, 0, 0); "><br /><br /></span><span style="color: rgb(0, 0, 136); ">if</span><span style="color: rgb(0, 0, 0); "> __name__ </span><span style="color: rgb(102, 102, 0); ">==</span><span style="color: rgb(0, 0, 0); "> </span><span style="color: rgb(0, 136, 0); ">"__main__"</span><span style="color: rgb(102, 102, 0); ">:</span><span style="color: rgb(0, 0, 0); "><br />&nbsp; &nbsp; </span><span style="color: rgb(102, 0, 102); ">Auto_wp</span><span style="color: rgb(102, 102, 0); ">(</span><span style="color: rgb(0, 136, 0); ">'/home/yangguang/图片/background/down'</span><span style="color: rgb(102, 102, 0); ">)</span></pre>
      
                <h4>相关阅读：</h4>
                  <ul>
                
                  <li><a href="http://imdiot.appspot.com/2010-12-28-61001">PySVN checkout时中文路径的解决</a></li>
                
                  <li><a href="http://imdiot.appspot.com/2010-07-25-26001">有关python的反编译</a></li>
                
                  <li><a href="http://imdiot.appspot.com/2010-07-18-25001">python2.5到2.6字节码指令变化点点发现(想到什么再写什么)</a></li>
                
                  <li><a href="http://imdiot.appspot.com/2010-05-29-15001">将mutter作为默认窗口管理器</a></li>
                
                  <li><a href="http://imdiot.appspot.com/2010-04-16-11001">AVL tree</a></li>
                
                </ul>
                
                <p>本文网址:<a href="http://imdiot.appspot.com/2010-06-27-20001">http://imdiot.appspot.com/2010-06-27-20001</a></p>

      ]]></content>
      <author>
          <name>Idiot</name>
      </author>
      <updated>2010-06-27T14:50:03Z</updated>
  </entry>

</feed>
