<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2chinesetwfull.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:media="http://search.yahoo.com/mrss/" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" version="2.0">

<channel>
	<title>代码回音</title>
	
	<link>http://www.codecho.com</link>
	<description>聆听代码的回音</description>
	<lastBuildDate>Wed, 30 May 2012 12:48:40 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/codecho" /><feedburner:info xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" uri="codecho" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><media:keywords>python,c/c,java,filter,driver</media:keywords><media:category scheme="http://www.itunes.com/dtds/podcast-1.0.dtd">Technology/Software How-To</media:category><itunes:explicit>no</itunes:explicit><itunes:keywords>python,c/c,java,filter,driver</itunes:keywords><itunes:subtitle>writing some diary about my life, and some notes about some kinds of language like java,c/c++, python, etc.</itunes:subtitle><itunes:summary>writing some diary about my life, and some notes about some kinds of language like java,c/c++, python, etc.</itunes:summary><itunes:category text="Technology"><itunes:category text="Software How-To" /></itunes:category><feedburner:feedFlare xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" href="http://add.my.yahoo.com/rss?url=http%3A%2F%2Ffeeds.feedburner.com%2Fcodecho" src="http://us.i1.yimg.com/us.yimg.com/i/us/my/addtomyyahoo4.gif">Subscribe with My Yahoo!</feedburner:feedFlare><feedburner:feedFlare xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" href="http://www.newsgator.com/ngs/subscriber/subext.aspx?url=http%3A%2F%2Ffeeds.feedburner.com%2Fcodecho" src="http://www.newsgator.com/images/ngsub1.gif">Subscribe with NewsGator</feedburner:feedFlare><feedburner:feedFlare xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" href="http://feeds.my.aol.com/add.jsp?url=http%3A%2F%2Ffeeds.feedburner.com%2Fcodecho" src="http://o.aolcdn.com/favorites.my.aol.com/webmaster/ffclient/webroot/locale/en-US/images/myAOLButtonSmall.gif">Subscribe with My AOL</feedburner:feedFlare><feedburner:feedFlare xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" href="http://www.bloglines.com/sub/http://feeds.feedburner.com/codecho" src="http://www.bloglines.com/images/sub_modern11.gif">Subscribe with Bloglines</feedburner:feedFlare><feedburner:feedFlare xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" href="http://www.netvibes.com/subscribe.php?url=http%3A%2F%2Ffeeds.feedburner.com%2Fcodecho" src="http://www.netvibes.com/img/add2netvibes.gif">Subscribe with Netvibes</feedburner:feedFlare><feedburner:feedFlare xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" href="http://fusion.google.com/add?feedurl=http%3A%2F%2Ffeeds.feedburner.com%2Fcodecho" src="http://buttons.googlesyndication.com/fusion/add.gif">Subscribe with Google</feedburner:feedFlare><feedburner:feedFlare xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" href="http://www.pageflakes.com/subscribe.aspx?url=http%3A%2F%2Ffeeds.feedburner.com%2Fcodecho" src="http://www.pageflakes.com/ImageFile.ashx?instanceId=Static_4&amp;fileName=ATP_blu_91x17.gif">Subscribe with Pageflakes</feedburner:feedFlare><feedburner:feedFlare xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" href="http://www.plusmo.com/add?url=http%3A%2F%2Ffeeds.feedburner.com%2Fcodecho" src="http://plusmo.com/res/graphics/fbplusmo.gif">Subscribe with Plusmo</feedburner:feedFlare><feedburner:feedFlare xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" href="http://www.thefreedictionary.com/_/hp/AddRSS.aspx?http%3A%2F%2Ffeeds.feedburner.com%2Fcodecho" src="http://img.tfd.com/hp/addToTheFreeDictionary.gif">Subscribe with The Free Dictionary</feedburner:feedFlare><feedburner:feedFlare xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" href="http://www.bitty.com/manual/?contenttype=rssfeed&amp;contentvalue=http%3A%2F%2Ffeeds.feedburner.com%2Fcodecho" src="http://www.bitty.com/img/bittychicklet_91x17.gif">Subscribe with Bitty Browser</feedburner:feedFlare><feedburner:feedFlare xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" href="http://www.live.com/?add=http%3A%2F%2Ffeeds.feedburner.com%2Fcodecho" src="http://tkfiles.storage.msn.com/x1piYkpqHC_35nIp1gLE68-wvzLZO8iXl_JMledmJQXP-XTBOLfmQv4zhj4MhcWEJh_GtoBIiAl1Mjh-ndp9k47If7hTaFno0mxW9_i3p_5qQw">Subscribe with Live.com</feedburner:feedFlare><feedburner:feedFlare xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" href="http://mix.excite.eu/add?feedurl=http%3A%2F%2Ffeeds.feedburner.com%2Fcodecho" src="http://image.excite.co.uk/mix/addtomix.gif">Subscribe with Excite MIX</feedburner:feedFlare><feedburner:feedFlare xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" href="http://www.webwag.com/wwgthis.php?url=http%3A%2F%2Ffeeds.feedburner.com%2Fcodecho" src="http://www.webwag.com/images/wwgthis.gif">Subscribe with Webwag</feedburner:feedFlare><feedburner:feedFlare xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" href="http://www.podcastready.com/oneclick_bookmark.php?url=http%3A%2F%2Ffeeds.feedburner.com%2Fcodecho" src="http://www.podcastready.com/images/podcastready_button.gif">Subscribe with Podcast Ready</feedburner:feedFlare><feedburner:feedFlare xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" href="http://www.wikio.com/subscribe?url=http%3A%2F%2Ffeeds.feedburner.com%2Fcodecho" src="http://www.wikio.com/shared/img/add2wikio.gif">Subscribe with Wikio</feedburner:feedFlare><feedburner:feedFlare xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" href="http://www.dailyrotation.com/index.php?feed=http%3A%2F%2Ffeeds.feedburner.com%2Fcodecho" src="http://www.dailyrotation.com/rss-dr2.gif">Subscribe with Daily Rotation</feedburner:feedFlare><item>
		<title>wxPython:如何使用剪贴板</title>
		<link>http://www.codecho.com/wxpython-how-to-use-the-clipboard/</link>
		<comments>http://www.codecho.com/wxpython-how-to-use-the-clipboard/#comments</comments>
		<pubDate>Wed, 30 May 2012 12:46:53 +0000</pubDate>
		<dc:creator>Leyond</dc:creator>
				<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://www.codecho.com/?p=132312</guid>
		<description><![CDATA[经常使用电脑的都知道，可以复制和张贴文本。但是他们也许不知道，当拷贝文本的时候，它时被存在在叫做剪贴板的地方。多数程度都提供了访问剪贴板的某种的方法，不论是程序自身提供的还是系统剪贴板，它能提供一种将文本拷贝到其他应用的功能。wxpython GUI也提供了对剪贴板的存储访问，甚是是拷贝图片。来看看例子。 import wx ######################################################################## class ClipboardPanel(wx.Panel): """""" #---------------------------------------------------------------------- def __init__(self, parent): """Constructor""" wx.Panel.__init__(self, parent) lbl = wx.StaticText(self, label="Enter text to copy to clipboard:") self.text = wx.TextCtrl(self, style=wx.TE_MULTILINE) copyBtn = wx.Button(self, label="Copy") copyBtn.Bind(wx.EVT_BUTTON, self.onCopy) copyFlushBtn = wx.Button(self, label="Copy and Flush") copyFlushBtn.Bind(wx.EVT_BUTTON, self.onCopyAndFlush) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(lbl, 0, wx.ALL, 5) sizer.Add(self.text, 1, wx.EXPAND) sizer.Add(copyBtn, 0, wx.ALL&#124;wx.CENTER, [...]]]></description>
			<content:encoded><![CDATA[<p>经常使用电脑的都知道，可以复制和张贴文本。但是他们也许不知道，当拷贝文本的时候，它时被存在在叫做剪贴板的地方。多数程度都提供了访问剪贴板的某种的方法，不论是程序自身提供的还是系统剪贴板，它能提供一种将文本拷贝到其他应用的功能。wxpython GUI也提供了对剪贴板的存储访问，甚是是拷贝图片。来看看例子。</p>
<p><img class="size-full wp-image-132313 aligncenter" title="clipboard-wxpython" src="http://www.codecho.com/wp-content/uploads/2012/05/clipboard-wxpython.png" alt="clipboard-wxpython" width="401" height="251" /><span id="more-132312"></span></p>
<pre class="brush:py">import wx

########################################################################
class ClipboardPanel(wx.Panel):
    """"""

    #----------------------------------------------------------------------
    def __init__(self, parent):
        """Constructor"""
        wx.Panel.__init__(self, parent)

        lbl = wx.StaticText(self, label="Enter text to copy to clipboard:")
        self.text = wx.TextCtrl(self, style=wx.TE_MULTILINE)
        copyBtn = wx.Button(self, label="Copy")
        copyBtn.Bind(wx.EVT_BUTTON, self.onCopy)
        copyFlushBtn = wx.Button(self, label="Copy and Flush")
        copyFlushBtn.Bind(wx.EVT_BUTTON, self.onCopyAndFlush)

        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(lbl, 0, wx.ALL, 5)
        sizer.Add(self.text, 1, wx.EXPAND)
        sizer.Add(copyBtn, 0, wx.ALL|wx.CENTER, 5)
        sizer.Add(copyFlushBtn, 0, wx.ALL|wx.CENTER, 5)
        self.SetSizer(sizer)

    #----------------------------------------------------------------------
    def onCopy(self, event):
        """"""
        self.dataObj = wx.TextDataObject()
        self.dataObj.SetText(self.text.GetValue())
        if wx.TheClipboard.Open():
            wx.TheClipboard.SetData(self.dataObj)
            wx.TheClipboard.Close()
        else:
            wx.MessageBox("Unable to open the clipboard", "Error")

    #----------------------------------------------------------------------
    def onCopyAndFlush(self, event):
        """"""
        self.dataObj = wx.TextDataObject()
        self.dataObj.SetText(self.text.GetValue())
        if wx.TheClipboard.Open():
            wx.TheClipboard.SetData(self.dataObj)
            wx.TheClipboard.Flush()
        else:
            wx.MessageBox("Unable to open the clipboard", "Error")

        self.GetParent().Close()

########################################################################
class ClipboardFrame(wx.Frame):
    """"""

    #----------------------------------------------------------------------
    def __init__(self):
        """Constructor"""
        wx.Frame.__init__(self, None, title="Clipboard Tutorial")
        panel = ClipboardPanel(self)
        self.Show()

if __name__ == "__main__":
    app = wx.App(False)
    frame = ClipboardFrame()
    app.MainLoop()</pre>
<p>这是一段简单的代码，界面包含两个按钮。copy按钮则是将文本框的文本拷贝出来，能让你张贴到任何位置。下一个按钮，在拷贝文件之后关闭界面，所以后者支持即时在程序关闭之后，你依旧可以张贴拷贝的文本。</p>
<p>程序中最重要的部分是wx.TextDataObject,这个控件保存了来自了文本框中的文本。如果你想拷贝图片，需要使用wx.BitmapDataObject，然后将其传给wx.BitMap对象。其他一样。</p>
<p>原文：<a title="http://www.blog.pythonlibrary.org/2012/05/25/wxpython-how-to-use-the-clipboard/" href="http://www.blog.pythonlibrary.org/2012/05/25/wxpython-how-to-use-the-clipboard/">http://www.blog.pythonlibrary.org/2012/05/25/wxpython-how-to-use-the-clipboard/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.codecho.com/wxpython-how-to-use-the-clipboard/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>繁忙的五月</title>
		<link>http://www.codecho.com/a-buys-may-in-2012/</link>
		<comments>http://www.codecho.com/a-buys-may-in-2012/#comments</comments>
		<pubDate>Sat, 26 May 2012 13:37:38 +0000</pubDate>
		<dc:creator>Leyond</dc:creator>
				<category><![CDATA[存在与活]]></category>
		<category><![CDATA[Life]]></category>

		<guid isPermaLink="false">http://www.codecho.com/?p=132310</guid>
		<description><![CDATA[又是很长时间没有更新啦。 其实这已不完全是勤快与否的问题了。有些时候下班之后的确什么也不想动了，或者是脑袋一片空白，无从下手。工作跟读书时的明显区别是，大学读书时代晚上还是希望能学点东西，因为白天有点荒废了。工作时白天消耗的大批精力，到晚上只想好好休息。 昨日有个项目投产，发现自己在程序中把一个数字敲错了。还好投产前我再次检查代码的时候被我发现，这个神秘的数字连同事检查的时候都很难被发现。当我发现的时候吓了一身冷汗。测试的时候居然没有发现这个BUG。 有些时候发现自己做事不够细致。今后要多加注意。所以需要多一次CHECKING自己做的事情。 我想等手上的项目投产之后，想放个年假休息下。给自己放松下。 呵呵，今天煲汤了。牛肉土豆汤。味道还不错！]]></description>
			<content:encoded><![CDATA[<p>又是很长时间没有更新啦。</p>
<p>其实这已不完全是勤快与否的问题了。有些时候下班之后的确什么也不想动了，或者是脑袋一片空白，无从下手。工作跟读书时的明显区别是，大学读书时代晚上还是希望能学点东西，因为白天有点荒废了。工作时白天消耗的大批精力，到晚上只想好好休息。</p>
<p>昨日有个项目投产，发现自己在程序中把一个数字敲错了。还好投产前我再次检查代码的时候被我发现，这个神秘的数字连同事检查的时候都很难被发现。当我发现的时候吓了一身冷汗。测试的时候居然没有发现这个BUG。</p>
<p>有些时候发现自己做事不够细致。今后要多加注意。所以需要多一次CHECKING自己做的事情。</p>
<p>我想等手上的项目投产之后，想放个年假休息下。给自己放松下。</p>
<p>呵呵，今天煲汤了。牛肉土豆汤。味道还不错！</p>
]]></content:encoded>
			<wfw:commentRss>http://www.codecho.com/a-buys-may-in-2012/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>少说话</title>
		<link>http://www.codecho.com/talk-less/</link>
		<comments>http://www.codecho.com/talk-less/#comments</comments>
		<pubDate>Tue, 15 May 2012 12:27:14 +0000</pubDate>
		<dc:creator>Leyond</dc:creator>
				<category><![CDATA[存在与活]]></category>
		<category><![CDATA[Life]]></category>

		<guid isPermaLink="false">http://www.codecho.com/?p=132309</guid>
		<description><![CDATA[不知道是天气热，还是什么缘故。 最近话特别多。话多容易出错~ 还是多做事，少说话。少说闲话~]]></description>
			<content:encoded><![CDATA[<p>不知道是天气热，还是什么缘故。</p>
<p>最近话特别多。话多容易出错~</p>
<p>还是多做事，少说话。少说闲话~</p>
]]></content:encoded>
			<wfw:commentRss>http://www.codecho.com/talk-less/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>wxPython：动态添加和删除Widget</title>
		<link>http://www.codecho.com/add-and-remove-widgets-dynamically-in-wxpython/</link>
		<comments>http://www.codecho.com/add-and-remove-widgets-dynamically-in-wxpython/#comments</comments>
		<pubDate>Fri, 11 May 2012 23:31:09 +0000</pubDate>
		<dc:creator>Leyond</dc:creator>
				<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://www.codecho.com/?p=132306</guid>
		<description><![CDATA[原文：wxPython: Adding and Removing Widgets Dynamically 我不断看到有人问如何在wxPython程序中动态添加和删除Widget，其实，这并不难，所以我决定是时候写一个关于这方面的简单教程。 这个例子很简单，它能运行用户添加或者移除按钮，首先我们将创建一个如上图的窗口，然后当用户按下“Add”按钮时，你将会看到如下图的变化。 从图中可以看到你添加了多个按钮。同样可以按”Remove”移除按钮。下面来看下代码，然后再做个简单的解释。 import wx ######################################################################## class MyPanel(wx.Panel): """""" #---------------------------------------------------------------------- def __init__(self, parent): """Constructor""" wx.Panel.__init__(self, parent) self.number_of_buttons = 0 self.frame = parent self.mainSizer = wx.BoxSizer(wx.VERTICAL) controlSizer = wx.BoxSizer(wx.HORIZONTAL) self.widgetSizer = wx.BoxSizer(wx.VERTICAL) self.addButton = wx.Button(self, label="Add") self.addButton.Bind(wx.EVT_BUTTON, self.onAddWidget) controlSizer.Add(self.addButton, 0, wx.CENTER&#124;wx.ALL, 5) self.removeButton = wx.Button(self, label="Remove") self.removeButton.Bind(wx.EVT_BUTTON, self.onRemoveWidget) controlSizer.Add(self.removeButton, 0, [...]]]></description>
			<content:encoded><![CDATA[<p>原文：<a title="Permanent Link: wxPython: Adding and Removing Widgets Dynamically" href="http://www.blog.pythonlibrary.org/2012/05/05/wxpython-adding-and-removing-widgets-dynamically/" rel="bookmark">wxPython: Adding and Removing Widgets Dynamically</a></p>
<p><img class="size-full wp-image-132307 aligncenter" title="212x103xdynamic.png.pagespeed.ic.b-ANWpSf4R" src="http://www.codecho.com/wp-content/uploads/2012/05/212x103xdynamic.png.pagespeed.ic_.b-ANWpSf4R.png" alt="wxpython" width="212" height="103" /></p>
<p>我不断看到有人问如何在wxPython程序中动态添加和删除Widget，其实，这并不难，所以我决定是时候写一个关于这方面的简单教程。</p>
<p>这个例子很简单，它能运行用户添加或者移除按钮，首先我们将创建一个如上图的窗口，然后当用户按下“Add”按钮时，你将会看到如下图的变化。<span id="more-132306"></span></p>
<p><img class="size-full wp-image-132308 aligncenter" title="dynamic2" src="http://www.codecho.com/wp-content/uploads/2012/05/dynamic2.png" alt="wxpython" width="340" height="235" /></p>
<p>从图中可以看到你添加了多个按钮。同样可以按”Remove”移除按钮。下面来看下代码，然后再做个简单的解释。</p>
<pre class="brush:py">import wx

########################################################################
class MyPanel(wx.Panel):
    """"""

    #----------------------------------------------------------------------
    def __init__(self, parent):
        """Constructor"""
        wx.Panel.__init__(self, parent)
        self.number_of_buttons = 0
        self.frame = parent

        self.mainSizer = wx.BoxSizer(wx.VERTICAL)
        controlSizer = wx.BoxSizer(wx.HORIZONTAL)
        self.widgetSizer = wx.BoxSizer(wx.VERTICAL)

        self.addButton = wx.Button(self, label="Add")
        self.addButton.Bind(wx.EVT_BUTTON, self.onAddWidget)
        controlSizer.Add(self.addButton, 0, wx.CENTER|wx.ALL, 5)

        self.removeButton = wx.Button(self, label="Remove")
        self.removeButton.Bind(wx.EVT_BUTTON, self.onRemoveWidget)
        controlSizer.Add(self.removeButton, 0, wx.CENTER|wx.ALL, 5)

        self.mainSizer.Add(controlSizer, 0, wx.CENTER)
        self.mainSizer.Add(self.widgetSizer, 0, wx.CENTER|wx.ALL, 10)

        self.SetSizer(self.mainSizer)

    #----------------------------------------------------------------------
    def onAddWidget(self, event):
        """"""
        self.number_of_buttons += 1
        label = "Button %s" %  self.number_of_buttons
        name = "button%s" % self.number_of_buttons
        new_button = wx.Button(self, label=label, name=name)
        self.widgetSizer.Add(new_button, 0, wx.ALL, 5)
        self.frame.fSizer.Layout()
        self.frame.Fit()

    #----------------------------------------------------------------------
    def onRemoveWidget(self, event):
        """"""
        if self.widgetSizer.GetChildren():
            self.widgetSizer.Hide(self.number_of_buttons-1)
            self.widgetSizer.Remove(self.number_of_buttons-1)
            self.number_of_buttons -= 1
            self.frame.fSizer.Layout()
            self.frame.Fit()

########################################################################
class MyFrame(wx.Frame):
    """"""

    #----------------------------------------------------------------------
    def __init__(self):
        """Constructor"""
        wx.Frame.__init__(self, parent=None, title="Add / Remove Buttons")
        self.fSizer = wx.BoxSizer(wx.VERTICAL)
        panel = MyPanel(self)
        self.fSizer.Add(panel, 1, wx.EXPAND)
        self.SetSizer(self.fSizer)
        self.Fit()
        self.Show()

#----------------------------------------------------------------------
if __name__ == "__main__":
    app = wx.App(False)
    frame = MyFrame()
    app.MainLoop()</pre>
<p>代码还是比较直接了当的，所以注重看几个重点。</p>
<p>首先是在显示窗口之前调用了Frame的Fit()。通常是不使用这个函数，但这里使用该函数是为了解决添加或者删除按钮带来的窗口不能自适应问题。</p>
<p>其次在onAddWidget和onRemoveWidget方法中调用了Layout函数来更新和布局新增或者删除的按钮。如果移除该函数，当删除按钮时，窗口就不能更新大小。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.codecho.com/add-and-remove-widgets-dynamically-in-wxpython/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>折腾的证件</title>
		<link>http://www.codecho.com/passport-2012/</link>
		<comments>http://www.codecho.com/passport-2012/#comments</comments>
		<pubDate>Tue, 08 May 2012 12:47:40 +0000</pubDate>
		<dc:creator>Leyond</dc:creator>
				<category><![CDATA[存在与活]]></category>
		<category><![CDATA[Life]]></category>

		<guid isPermaLink="false">http://www.codecho.com/?p=132305</guid>
		<description><![CDATA[这几天都在办理证件，要多折腾有多折腾。 证件应该是10号到期，所以上个月劳务公司就开始安排续签了。昨天把证件拿过去贴心签注，我呢则需要在上班时间把证件送过去，好在不远来回也不过半个小时。麻烦的是当天下午六点半之前又要将证件取回，否则就不要回家了。 今天到出入境事务厅打指模，好在可以申请公务出差。下午将证件取回。好在这下终于将证件办理完毕。前前后跑中介公司五次，出入境一次。]]></description>
			<content:encoded><![CDATA[<p>这几天都在办理证件，要多折腾有多折腾。</p>
<p>证件应该是10号到期，所以上个月劳务公司就开始安排续签了。昨天把证件拿过去贴心签注，我呢则需要在上班时间把证件送过去，好在不远来回也不过半个小时。麻烦的是当天下午六点半之前又要将证件取回，否则就不要回家了。</p>
<p>今天到出入境事务厅打指模，好在可以申请公务出差。下午将证件取回。好在这下终于将证件办理完毕。前前后跑中介公司五次，出入境一次。</p>
<p><img style="margin: 0px 10px 0px 0px" src="http://www.codecho.com/wp-content/uploads/2012/05/passport_stamps.jpg" /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.codecho.com/passport-2012/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>晒PP</title>
		<link>http://www.codecho.com/show-pps/</link>
		<comments>http://www.codecho.com/show-pps/#comments</comments>
		<pubDate>Sat, 05 May 2012 03:42:59 +0000</pubDate>
		<dc:creator>Leyond</dc:creator>
				<category><![CDATA[存在与活]]></category>
		<category><![CDATA[Life]]></category>

		<guid isPermaLink="false">http://www.codecho.com/?p=132303</guid>
		<description><![CDATA[本周日子过得有点快。估计是一天假期，还有一天去香港。 去香港，其实不是去游玩的。我们是去参加香港银行学会主办的一个论坛。本来接到通知的时候说是粤语交流的，所以就报名了。后来被通知到说改成英文了。我自知英文能力不足以参加这种会议，但是既然之前报名了，我们还是决定启程。能了解下最新的科技技术在银行中的应用也是非常不错的。 早上六点左右就起床了，赶往澳门外港码头，乘坐8点钟的喷射飞船到香港。大概九点钟左右就到了，乘坐三四站地铁就到了湾仔。只是第一次去香港，所以寻找会议厅的过程中有点曲折。不过我们还是挺顺利的，因为其他几位早到的同事告诉我们了会议厅的楼层。 会议结束后，我和小菜还去了西洋菜街，本想去看看那里的电子产品是否比澳门便宜些，不过很失望，都是差不多的价钱，所以就没买了。 由于第二天还要上班，所以需要一天来回。一天对香港不能有多少了解，匆匆而来，匆匆而去。 很郁闷的是，那天我连吃两顿麦当劳。]]></description>
			<content:encoded><![CDATA[<p>本周日子过得有点快。估计是一天假期，还有一天去香港。</p>
<p>去香港，其实不是去游玩的。我们是去参加香港银行学会主办的一个论坛。本来接到通知的时候说是粤语交流的，所以就报名了。后来被通知到说改成英文了。我自知英文能力不足以参加这种会议，但是既然之前报名了，我们还是决定启程。能了解下最新的科技技术在银行中的应用也是非常不错的。<img style="margin: 0px 10px 0px 0px" src="http://www.codecho.com/wp-content/uploads/2012/05/hkpp.jpg" width="573" height="432" /></p>
<p><span id="more-132303"></span>
<p><img style="margin: 0px 10px 0px 0px" src="http://www.codecho.com/wp-content/uploads/2012/05/boat.jpg" width="570" height="430" /></p>
<p>早上六点左右就起床了，赶往澳门外港码头，乘坐8点钟的喷射飞船到香港。大概九点钟左右就到了，乘坐三四站地铁就到了湾仔。只是第一次去香港，所以寻找会议厅的过程中有点曲折。不过我们还是挺顺利的，因为其他几位早到的同事告诉我们了会议厅的楼层。</p>
<p><img style="margin: 0px 10px 0px 0px" src="http://www.codecho.com/wp-content/uploads/2012/05/hkbf.jpg" width="578" height="436" /></p>
<p>会议结束后，我和小菜还去了西洋菜街，本想去看看那里的电子产品是否比澳门便宜些，不过很失望，都是差不多的价钱，所以就没买了。</p>
<p>由于第二天还要上班，所以需要一天来回。一天对香港不能有多少了解，匆匆而来，匆匆而去。</p>
<p>很郁闷的是，那天我连吃两顿麦当劳。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.codecho.com/show-pps/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Matplotlib只保存部分区域图像(Subplot)</title>
		<link>http://www.codecho.com/only-save-subplot-in-matplotlib/</link>
		<comments>http://www.codecho.com/only-save-subplot-in-matplotlib/#comments</comments>
		<pubDate>Tue, 01 May 2012 12:20:51 +0000</pubDate>
		<dc:creator>Leyond</dc:creator>
				<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://www.codecho.com/?p=132297</guid>
		<description><![CDATA[以前做毕业设计的时候，有时候想把数据的几幅图都写在一块，但是又想把每张图独立保存下来。当时没有花费太多心思，只好注释掉部分代码，逐次运行保存结果。 不过还是有办法处理的。有个Savefig函数中有个参数: savefig(fname, dpi=None, facecolor='w', edgecolor='w', orientation='portrait', papertype=None, format=None, transparent=False, bbox_inches=None, pad_inches=0.1): bbox-inches,可以用于选择需要保存的图像区域。 例子： import matplotlib.pyplot as plt import matplotlib as mpl import numpy as np # Make an example plot with two subplots... fig = plt.figure() ax1 = fig.add_subplot(2,1,1) ax1.plot(range(10), 'b-') ax2 = fig.add_subplot(2,1,2) ax2.plot(range(20), 'r^') # Save the full figure... fig.savefig('full_figure.png') # Save [...]]]></description>
			<content:encoded><![CDATA[<p>以前做毕业设计的时候，有时候想把数据的几幅图都写在一块，但是又想把每张图独立保存下来。当时没有花费太多心思，只好注释掉部分代码，逐次运行保存结果。</p>
<p>不过还是有办法处理的。有个Savefig函数中有个参数:</p>
<pre>savefig(fname, dpi=None, facecolor='w', edgecolor='w',
        orientation='portrait', papertype=None, format=None,
        transparent=False, bbox_inches=None, pad_inches=0.1):</pre>
<p>bbox-inches,可以用于选择需要保存的图像区域。<br />
<span id="more-132297"></span><br />
例子：</p>
<pre class="brush:py">import matplotlib.pyplot as plt
import matplotlib as mpl
import numpy as np

# Make an example plot with two subplots...
fig = plt.figure()
ax1 = fig.add_subplot(2,1,1)
ax1.plot(range(10), 'b-')

ax2 = fig.add_subplot(2,1,2)
ax2.plot(range(20), 'r^')

# Save the full figure...
fig.savefig('full_figure.png')

# Save just the portion _inside_ the second axis's boundaries
extent = ax2.get_window_extent().transformed(fig.dpi_scale_trans.inverted())
fig.savefig('ax2_figure.png', bbox_inches=extent)

# Pad the saved area by 10% in the x-direction and 20% in the y-direction
fig.savefig('ax2_figure_expanded.png', bbox_inches=extent.expanded(1.1, 1.2))</pre>
<p>程序运行结果：</p>
<p>1. 整幅图</p>
<p><img class="alignnone  wp-image-132298" title="3sgY8" src="http://www.codecho.com/wp-content/uploads/2012/05/3sgY8.png" alt="matplotlib" width="569" height="427" /></p>
<p>2. 第二幅子图：</p>
<p><img class="alignnone  wp-image-132299" title="38DPX" src="http://www.codecho.com/wp-content/uploads/2012/05/38DPX.png" alt="matplotlib" width="566" height="199" /></p>
<p>3. 分别将x和y轴延伸10%和20%</p>
<p><img class="alignnone  wp-image-132300" title="xc8AX" src="http://www.codecho.com/wp-content/uploads/2012/05/xc8AX.png" alt="matplotlib" width="568" height="217" /><br />
来源：<a title="http://stackoverflow.com/questions/4325733/save-a-subplot-in-matplotlib" href="http://stackoverflow.com/questions/4325733/save-a-subplot-in-matplotlib" target="_blank">http://stackoverflow.com/questions/4325733/save-a-subplot-in-matplotlib</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.codecho.com/only-save-subplot-in-matplotlib/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Ubuntu安装Matplotlib</title>
		<link>http://www.codecho.com/install-matplotlib-on-ubuntu-12-04/</link>
		<comments>http://www.codecho.com/install-matplotlib-on-ubuntu-12-04/#comments</comments>
		<pubDate>Tue, 01 May 2012 00:52:16 +0000</pubDate>
		<dc:creator>Leyond</dc:creator>
				<category><![CDATA[Python]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://www.codecho.com/?p=132295</guid>
		<description><![CDATA[回想整个安装过程，ubuntu下安装matplotlib的复杂度远远比windows下复杂的多，相对双击就能解决问题的，现在你需要时不时的解决编译带来的各种问题。 系统默认是安装了python 2.7的，但是安装其他package的时候还是提示你安装python-dev:(SystemError: Cannot compile &#8216;Python.h&#8217;. Perhaps you need to install python-dev&#124;python-devel.) sudo apt-get install python-dev 安装之后，开始准备Matplotlib所需Numpy,Matplotlib。两个package都可以从对应的官网下载。Google自行搜索&#8230;&#8230; 先安装numpy: python setup.py build sudo python setup.py install --prefix=/usr/local 之后开始安装matplotlib,这下编译matplotlib就没有之前那样一帆风顺了。 1. gcc: error trying to exec &#8216;cc1plus&#8217;: execvp: No such file or directory 解决方法：sudo apt-get install build-essential 2. src/ft2font.h:13:22: fatal error: ft2build.h: No such file or directory 解决方法：sudo [...]]]></description>
			<content:encoded><![CDATA[<p>回想整个安装过程，ubuntu下安装matplotlib的复杂度远远比windows下复杂的多，相对双击就能解决问题的，现在你需要时不时的解决编译带来的各种问题。</p>
<p>系统默认是安装了python 2.7的，但是安装其他package的时候还是提示你安装python-dev:(SystemError: Cannot compile &#8216;Python.h&#8217;. Perhaps you need to install python-dev|python-devel.)</p>
<pre class="brush:plain">sudo apt-get install python-dev</pre>
<p>安装之后，开始准备Matplotlib所需Numpy,Matplotlib。两个package都可以从对应的官网下载。Google自行搜索&#8230;&#8230;<span id="more-132295"></span></p>
<p>先安装numpy:</p>
<pre class="brush:plain">python setup.py build
sudo python setup.py install --prefix=/usr/local</pre>
<p>之后开始安装matplotlib,这下编译matplotlib就没有之前那样一帆风顺了。</p>
<p>1. gcc: error trying to exec &#8216;cc1plus&#8217;: execvp: No such file or directory<br />
解决方法：sudo apt-get install build-essential</p>
<p>2. src/ft2font.h:13:22: fatal error: ft2build.h: No such file or directory<br />
解决方法：sudo apt-get install  libfreetype6-dev</p>
<p>3. src/backend_agg.cpp:3:17: fatal error: png.h: No such file or directory<br />
解决方法：sudo apt-get install libpng-dev</p>
<p>解决以上问题之后，发现可以正确编译matplotlib了：</p>
<pre class="brush:plain">python setup.py build
sudo python setup.py install</pre>
<p>检测下之前安装的情况：</p>
<p>&gt;&gt;&gt; import numpy<br />
&gt;&gt;&gt; print numpy.version.version<br />
1.6.1<br />
&gt;&gt;&gt; import matplotlib<br />
&gt;&gt;&gt; print matplotlib.__version__<br />
0.99.3<br />
到此，基本搞定。接下里，运行个Sample试试看。</p>
<pre class="brush:py">from pylab import *

t = arange(0.0, 2.0, 0.01)
s = sin(2*pi*t)
plot(t, s, linewidth=1.0)

xlabel('time (s)')
ylabel('voltage (mV)')
title('About as simple as it gets, folks')
grid(True)
show()</pre>
<p>终端执行:python hello.py 没有报错，也没有弹出图框。怎么回事？ 我尝试把代码中每一条都手动在终端python模式下输入，结果输入show()的时候，错误提示：<br />
Your currently selected backend, &#8216;agg&#8217; does not support show().<br />
Please select a GUI backend in your matplotlibrc file (&#8216;/usr/local/lib/python2.7/dist-packages/matplotlib/mpl-data/matplotlibrc&#8217;)<br />
or with matplotlib.use()<br />
(backend, matplotlib.matplotlib_fname()))</p>
<p>当然你如果只想要看结果，那么可以直接把它保存成图片，用<code>savefig</code>(&#8216;figure.png&#8217;)来替代前面的show()函数。但是如果要交互式的话，还需解决前面的问题。</p>
<p>这个问题，我找了很久，发现”this happened because your matplotlib backend is set to FltkAgg, GTK, GTKAgg, GTKCairo, TkAgg , Wx or WxAgg they required a GUI that why error occur.” To solve this you must specific other backend that not required GUI (Agg, Cairo, PS, PDF or SVG ) when use matplotlib like this  in code:</p>
<pre class="brush:py">import matplotlib
matplotlib.use('Agg')</pre>
<p>期间，我按装过Cairo,可是还是出现错误，后来发现一个比较简单的方法,用wxpython：<br />
sudo aptitude install python-wxtools<br />
然后在代码中使用的是matplotlib.use(&#8216;WXAgg&#8217;)</p>
<p>你也可以修改/usr/local/lib/python2.7/dist-packages/matplotlib/mpl-data目录下的matplotlibrc这个文件内容中的：</p>
<p># &#8216;module://my_backend&#8217;<br />
backend      : WXAgg</p>
<p>这样就可以了。测试：</p>
<pre class="brush:py">from pylab import *

t = arange(0.0, 2.0, 0.01)
s = sin(2*pi*t)
plot(t, s, linewidth=1.0)

xlabel('time (s)')
ylabel('voltage (mV)')
title('About as simple as it gets, folks')
grid(True)
show()</pre>
<p><img class="alignnone  wp-image-132296" title="matplotlib" src="http://www.codecho.com/wp-content/uploads/2012/04/matplotlib.png" alt="matplotlib" width="558" height="418" /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.codecho.com/install-matplotlib-on-ubuntu-12-04/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Ubuntu12.04英文系统安装IBus输入法</title>
		<link>http://www.codecho.com/install-ibus-on-ubuntu-12-04-of-english-version/</link>
		<comments>http://www.codecho.com/install-ibus-on-ubuntu-12-04-of-english-version/#comments</comments>
		<pubDate>Sat, 28 Apr 2012 02:49:22 +0000</pubDate>
		<dc:creator>Leyond</dc:creator>
				<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://www.codecho.com/?p=132294</guid>
		<description><![CDATA[今天在虚拟机中安装了Ubuntu 12.04，系统是英文版本的，我能接受，但是苦于没有中文输入法。 起先，我是安装SCIM，结果我折腾了半天，发现其只能在lib-office下使用。firefox,文字编辑器中都不能调出SCIM。无奈将其卸载。换IBUS。 安装方法： 在终端输入: $sudo add-apt-repository ppa:shawn-p-huang/ppa $sudo apt-get update $sudo apt-get install ibus-gtk ibus-qt4 ibus-pinyin ibus-pinyin-db-open-phrase    (其实只需要这一步就够了，其它步骤重复了)  接下来，再 任务栏-输入法-重新启动后，即可使用。 安装常用的拼音输入法ibus-pinyin： 在终端输入:  $sudo apt-get install ibus-pinyin ibus-pinyin-db-android 安装完后点击左上角的 Dash home，输入ibus，回车。ibus启动后，在桌面上方的launcher会出现一个小键盘图标。右键它，点击preference进行属性设置,需要手动设置Input Method,在下拉框中能找到之前安装的输入法。 在英文环境下默认是不启动的，需要设置下：在language suport中，把keyboard input method system选为Ibus即可。]]></description>
			<content:encoded><![CDATA[<p>今天在虚拟机中安装了Ubuntu 12.04，系统是英文版本的，我能接受，但是苦于没有中文输入法。</p>
<p>起先，我是安装SCIM，结果我折腾了半天，发现其只能在lib-office下使用。firefox,文字编辑器中都不能调出SCIM。无奈将其卸载。换IBUS。</p>
<p>安装方法：</p>
<p>在终端输入:</p>
<p>$sudo add-apt-repository ppa:shawn-p-huang/ppa</p>
<p>$sudo apt-get update</p>
<p>$sudo apt-get install ibus-gtk ibus-qt4 ibus-pinyin ibus-pinyin-db-open-phrase    (其实只需要这一步就够了，其它步骤重复了)  接下来，再 任务栏-输入法-重新启动后，即可使用。</p>
<p>安装常用的拼音输入法ibus-pinyin：</p>
<p>在终端输入:  $sudo apt-get install ibus-pinyin ibus-pinyin-db-android</p>
<p>安装完后点击左上角的 Dash home，输入ibus，回车。ibus启动后，在桌面上方的launcher会出现一个小键盘图标。右键它，点击preference进行属性设置,需要手动设置Input Method,在下拉框中能找到之前安装的输入法。</p>
<p>在英文环境下默认是不启动的，需要设置下：在language suport中，把keyboard input method system选为Ibus即可。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.codecho.com/install-ibus-on-ubuntu-12-04-of-english-version/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>下周去香港</title>
		<link>http://www.codecho.com/hk-next-week/</link>
		<comments>http://www.codecho.com/hk-next-week/#comments</comments>
		<pubDate>Thu, 26 Apr 2012 12:02:53 +0000</pubDate>
		<dc:creator>Leyond</dc:creator>
				<category><![CDATA[存在与活]]></category>
		<category><![CDATA[Life]]></category>

		<guid isPermaLink="false">http://www.codecho.com/?p=132292</guid>
		<description><![CDATA[今天去拿到香港的签注，三个月可以两次往返的。 去香港不是去旅游，是参见一个高科技在银行的应用的一个论坛。听说是英文发言的，最让人担心的是讨论也是用英文。 这几天一直都在跟测试，发现一切都不是那么容易。用户、开发商，都需要好好沟通，彼此协作。 夏天估计是要到了，有点困。]]></description>
			<content:encoded><![CDATA[<p>今天去拿到香港的签注，三个月可以两次往返的。</p>
<p>去香港不是去旅游，是参见一个高科技在银行的应用的一个论坛。听说是英文发言的，最让人担心的是讨论也是用英文。</p>
<p>这几天一直都在跟测试，发现一切都不是那么容易。用户、开发商，都需要好好沟通，彼此协作。</p>
<p>夏天估计是要到了，有点困。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.codecho.com/hk-next-week/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	<media:rating>nonadult</media:rating></channel>
</rss>

