<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.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:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>The Mouse Vs. The Python</title>
	
	<link>http://www.blog.pythonlibrary.org</link>
	<description>Python Programming from the Frontlines</description>
	<lastBuildDate>Tue, 14 Feb 2012 20:16:01 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/TheMouseVsThePython" /><feedburner:info uri="themousevsthepython" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>wxPython: All about Menus</title>
		<link>http://feedproxy.google.com/~r/TheMouseVsThePython/~3/iLuB9OJMJsg/</link>
		<comments>http://www.blog.pythonlibrary.org/2012/02/14/wxpython-all-about-menus/#comments</comments>
		<pubDate>Tue, 14 Feb 2012 20:16:01 +0000</pubDate>
		<dc:creator>Mike</dc:creator>
				<category><![CDATA[Cross-Platform]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[wxPython]]></category>

		<guid isPermaLink="false">http://www.blog.pythonlibrary.org/?p=2207</guid>
		<description><![CDATA[Menus are ubiquitous. They&#8217;re in almost all desktop programs. You use them for editing preferences or configuring your program. In wxPython, there are several menu options to choose from. The most familiar is probably wx.Menu. But there are are popup menus and a pure Python implementation known as FlatMenu. We will just be covering wx.Menu [...]]]></description>
			<content:encoded><![CDATA[<p>Menus are ubiquitous. They&#8217;re in almost all desktop programs. You use them for editing preferences or configuring your program. In wxPython, there are several menu options to choose from. The most familiar is probably wx.Menu. But there are are popup menus and a pure Python implementation known as FlatMenu. We will just be covering wx.Menu and popup menus here because they&#8217;re related to each other. FlatMenu also includes a toolbar API, so you&#8217;ll have to wait for another article that will just cover that widget all by itself. Let&#8217;s get this menu party started!<span id="more-2207"></span></p>
<h3>A Simple Menu Example</h3>
<p>
<p>
<a href="http://www.blog.pythonlibrary.org/wp-content/uploads/2012/02/menu_one.png"><img src="http://www.blog.pythonlibrary.org/wp-content/uploads/2012/02/menu_one-300x187.png" alt="" title="menu_one.png" width="300" height="187" class="aligncenter size-medium wp-image-2208" /></a></p>
<p>We&#8217;ll start with something really simple: a menu with just an Exit MenuItem. Here&#8217;s the code:</p>
<pre class="python"><span style="color: #ff7700;font-weight:bold;">import</span> wx
&nbsp;
<span style="color: #808080; font-style: italic;">########################################################################</span>
<span style="color: #ff7700;font-weight:bold;">class</span> MyForm<span style="color: black;">&#40;</span>wx.<span style="color: black;">Frame</span><span style="color: black;">&#41;</span>:
    <span style="color: #483d8b;">&quot;&quot;</span><span style="color: #483d8b;">&quot;&quot;</span><span style="color: #483d8b;">&quot;&quot;</span>
&nbsp;
    <span style="color: #808080; font-style: italic;">#----------------------------------------------------------------------</span>
    <span style="color: #ff7700;font-weight:bold;">def</span> <span style="color: #0000cd;">__init__</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span><span style="color: black;">&#41;</span>:
        <span style="color: #483d8b;">&quot;&quot;</span><span style="color: #483d8b;">&quot;Constructor&quot;</span><span style="color: #483d8b;">&quot;&quot;</span>
        wx.<span style="color: black;">Frame</span>.<span style="color: #0000cd;">__init__</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, <span style="color: #008000;">None</span>, title=<span style="color: #483d8b;">&quot;wx.Menu Tutorial&quot;</span><span style="color: black;">&#41;</span>
&nbsp;
        <span style="color: #008000;">self</span>.<span style="color: black;">panel</span> = wx.<span style="color: black;">Panel</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, wx.<span style="color: black;">ID_ANY</span><span style="color: black;">&#41;</span>
&nbsp;
        menuBar = wx.<span style="color: black;">MenuBar</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
        fileMenu = wx.<span style="color: black;">Menu</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
        exitMenuItem = fileMenu.<span style="color: black;">Append</span><span style="color: black;">&#40;</span>wx.<span style="color: black;">NewId</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>, <span style="color: #483d8b;">&quot;Exit&quot;</span>,
                                       <span style="color: #483d8b;">&quot;Exit the application&quot;</span><span style="color: black;">&#41;</span>
        menuBar.<span style="color: black;">Append</span><span style="color: black;">&#40;</span>fileMenu, <span style="color: #483d8b;">&quot;&amp;File&quot;</span><span style="color: black;">&#41;</span>
        <span style="color: #008000;">self</span>.<span style="color: black;">Bind</span><span style="color: black;">&#40;</span>wx.<span style="color: black;">EVT_MENU</span>, <span style="color: #008000;">self</span>.<span style="color: black;">onExit</span>, exitMenuItem<span style="color: black;">&#41;</span>
        <span style="color: #008000;">self</span>.<span style="color: black;">SetMenuBar</span><span style="color: black;">&#40;</span>menuBar<span style="color: black;">&#41;</span>
&nbsp;
    <span style="color: #808080; font-style: italic;">#----------------------------------------------------------------------</span>
    <span style="color: #ff7700;font-weight:bold;">def</span> onExit<span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, event<span style="color: black;">&#41;</span>:
        <span style="color: #483d8b;">&quot;&quot;</span><span style="color: #483d8b;">&quot;&quot;</span><span style="color: #483d8b;">&quot;&quot;</span>
        <span style="color: #008000;">self</span>.<span style="color: black;">Close</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">#----------------------------------------------------------------------</span>
<span style="color: #808080; font-style: italic;"># Run the program</span>
<span style="color: #ff7700;font-weight:bold;">if</span> __name__ == <span style="color: #483d8b;">&quot;__main__&quot;</span>:
    app = wx.<span style="color: black;">App</span><span style="color: black;">&#40;</span><span style="color: #008000;">False</span><span style="color: black;">&#41;</span>
    frame = MyForm<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>.<span style="color: black;">Show</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
    app.<span style="color: black;">MainLoop</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></pre>
<p>Let&#8217;s break this down a little. To create the menubar, we instantiate an instance of wx.MenuBar. Then we create a an instance of wx.Menu that we call <strong>filemenu</strong>. Finally, to add the &#8220;Exit&#8221; item, we append some data to it. In essence, we are appending a wx.MenuItem, but this is kind of a shortcut since we didn&#8217;t actually create a wx.MenuItem instance first. We&#8217;ll show how to do that in our next example though. Note that when we append the item, we have to pass an id, a label string and a status string. That last one will show up in the Status bar when you hover over the menu item, assuming you have a status bar. Note that to attach an event handler to a menu item, you need use the EVT_MENU event and bind it to the frame. Next we append the Menu itself to the MenuBar object and pass it a string too, which in this case is &#8220;File&#8221;. Finally we call the frame&#8217;s <strong>SetMenuBar</strong> method to attach the menu bar to the frame. </p>
<h3>Adding a Picture to a Menu</h3>
<p>
<p>
That&#8217;s all there is to creating a menu! Now let&#8217;s look at a more complex example! <em>Note: to follow the example below, you&#8217;ll need to use your own image file.</em></p>
<p><a href="http://www.blog.pythonlibrary.org/wp-content/uploads/2012/02/menu_two.png"><img src="http://www.blog.pythonlibrary.org/wp-content/uploads/2012/02/menu_two-300x187.png" alt="" title="menu_two.png" width="300" height="187" class="aligncenter size-medium wp-image-2213" /></a></p>
<pre class="python"><span style="color: #ff7700;font-weight:bold;">import</span> wx
&nbsp;
<span style="color: #808080; font-style: italic;">########################################################################</span>
<span style="color: #ff7700;font-weight:bold;">class</span> MyForm<span style="color: black;">&#40;</span>wx.<span style="color: black;">Frame</span><span style="color: black;">&#41;</span>:
    <span style="color: #483d8b;">&quot;&quot;</span><span style="color: #483d8b;">&quot;&quot;</span><span style="color: #483d8b;">&quot;&quot;</span>
&nbsp;
    <span style="color: #808080; font-style: italic;">#----------------------------------------------------------------------</span>
    <span style="color: #ff7700;font-weight:bold;">def</span> <span style="color: #0000cd;">__init__</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span><span style="color: black;">&#41;</span>:
        <span style="color: #483d8b;">&quot;&quot;</span><span style="color: #483d8b;">&quot;Constructor&quot;</span><span style="color: #483d8b;">&quot;&quot;</span>
        wx.<span style="color: black;">Frame</span>.<span style="color: #0000cd;">__init__</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, <span style="color: #008000;">None</span>, title=<span style="color: #483d8b;">&quot;wx.Menu Tutorial&quot;</span><span style="color: black;">&#41;</span>
&nbsp;
        <span style="color: #008000;">self</span>.<span style="color: black;">panel</span> = wx.<span style="color: black;">Panel</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, wx.<span style="color: black;">ID_ANY</span><span style="color: black;">&#41;</span>
&nbsp;
        <span style="color: #808080; font-style: italic;"># create the menubar</span>
        menuBar = wx.<span style="color: black;">MenuBar</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
&nbsp;
        <span style="color: #808080; font-style: italic;"># create the first menu (starting on left)</span>
        carMenu = wx.<span style="color: black;">Menu</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
        carMenu.<span style="color: black;">Append</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">101</span>, <span style="color: #483d8b;">&quot;&amp;Ford&quot;</span>, <span style="color: #483d8b;">&quot;An American Automaker&quot;</span><span style="color: black;">&#41;</span>
        carMenu.<span style="color: black;">Append</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">102</span>, <span style="color: #483d8b;">&quot;&amp;Nissan&quot;</span>, <span style="color: #483d8b;">&quot;&quot;</span><span style="color: black;">&#41;</span>
        carMenu.<span style="color: black;">Append</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">103</span>, <span style="color: #483d8b;">&quot;&amp;Toyota&quot;</span>, <span style="color: #483d8b;">&quot;Buy Japanese!&quot;</span><span style="color: black;">&#41;</span>
        carMenu.<span style="color: black;">Append</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">104</span>, <span style="color: #483d8b;">&quot;&amp;Close&quot;</span>, <span style="color: #483d8b;">&quot;Close the application&quot;</span><span style="color: black;">&#41;</span>
&nbsp;
        <span style="color: #808080; font-style: italic;"># add a picture to a menu</span>
        picMenu = wx.<span style="color: black;">Menu</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
        item = wx.<span style="color: black;">MenuItem</span><span style="color: black;">&#40;</span>picMenu, wx.<span style="color: black;">ID_ANY</span>, <span style="color: #483d8b;">&quot;Snake&quot;</span>, <span style="color: #483d8b;">&quot;This menu has a picture!&quot;</span><span style="color: black;">&#41;</span>
        img = wx.<span style="color: black;">Image</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'snake32.bmp'</span>, wx.<span style="color: black;">BITMAP_TYPE_ANY</span><span style="color: black;">&#41;</span>
        item.<span style="color: black;">SetBitmap</span><span style="color: black;">&#40;</span>wx.<span style="color: black;">BitmapFromImage</span><span style="color: black;">&#40;</span>img<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
        picMenu.<span style="color: black;">AppendItem</span><span style="color: black;">&#40;</span>item<span style="color: black;">&#41;</span>
&nbsp;
        <span style="color: #808080; font-style: italic;"># add menus to menubar</span>
        menuBar.<span style="color: black;">Append</span><span style="color: black;">&#40;</span>carMenu, <span style="color: #483d8b;">&quot;&amp;Vehicles&quot;</span><span style="color: black;">&#41;</span>
        menuBar.<span style="color: black;">Append</span><span style="color: black;">&#40;</span>picMenu, <span style="color: #483d8b;">&quot;&amp;Picture&quot;</span><span style="color: black;">&#41;</span>
        <span style="color: #008000;">self</span>.<span style="color: black;">SetMenuBar</span><span style="color: black;">&#40;</span>menuBar<span style="color: black;">&#41;</span>
&nbsp;
    <span style="color: #808080; font-style: italic;">#----------------------------------------------------------------------</span>
    <span style="color: #ff7700;font-weight:bold;">def</span> onExit<span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, event<span style="color: black;">&#41;</span>:
        <span style="color: #483d8b;">&quot;&quot;</span><span style="color: #483d8b;">&quot;&quot;</span><span style="color: #483d8b;">&quot;&quot;</span>
        <span style="color: #008000;">self</span>.<span style="color: black;">Close</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">#----------------------------------------------------------------------</span>
<span style="color: #808080; font-style: italic;"># Run the program</span>
<span style="color: #ff7700;font-weight:bold;">if</span> __name__ == <span style="color: #483d8b;">&quot;__main__&quot;</span>:
    app = wx.<span style="color: black;">App</span><span style="color: black;">&#40;</span><span style="color: #008000;">False</span><span style="color: black;">&#41;</span>
    frame = MyForm<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>.<span style="color: black;">Show</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
    app.<span style="color: black;">MainLoop</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></pre>
<p>This example is similar to the first one. The main difference is that we add multiple items to out <strong>File </strong>menu and we have two menus. Note that this time, we actually specify our ID numbers explicitly. This usually isn&#8217;t recommended as you might accidentally shadow one of wx&#8217;s required IDs. However, you do see examples of this from time to time on the web, so you should be aware of this practice. The next big difference doesn&#8217;t come until we get to the <strong>picMenu</strong>. Here we actually create a wx.MenuItem and add a picture to it via wx.Image and the MenuItem&#8217;s <strong>SetBitmap</strong> method. The rest is pretty much the same.</p>
<p>Now we will spend some time looking at how to add radio and check buttons to our menu.</p>
<h3>Adding Radio or Check Buttons</h3>
<p>
<p>
<a href="http://www.blog.pythonlibrary.org/wp-content/uploads/2012/02/menu_check.png"><img src="http://www.blog.pythonlibrary.org/wp-content/uploads/2012/02/menu_check-300x187.png" alt="" title="menu_check.png" width="300" height="187" class="aligncenter size-medium wp-image-2215" /></a></p>
<p>Adding a radio or check button to your menu is actually pretty easy. Let&#8217;s take a moment and see how it&#8217;s done!</p>
<pre class="python"><span style="color: #808080; font-style: italic;"># radiocheck.py</span>
<span style="color: #ff7700;font-weight:bold;">import</span> wx
&nbsp;
<span style="color: #808080; font-style: italic;">########################################################################</span>
<span style="color: #ff7700;font-weight:bold;">class</span> MyForm<span style="color: black;">&#40;</span>wx.<span style="color: black;">Frame</span><span style="color: black;">&#41;</span>:
    <span style="color: #483d8b;">&quot;&quot;</span><span style="color: #483d8b;">&quot;&quot;</span><span style="color: #483d8b;">&quot;&quot;</span>
&nbsp;
    <span style="color: #808080; font-style: italic;">#----------------------------------------------------------------------</span>
    <span style="color: #ff7700;font-weight:bold;">def</span> <span style="color: #0000cd;">__init__</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span><span style="color: black;">&#41;</span>:
        <span style="color: #483d8b;">&quot;&quot;</span><span style="color: #483d8b;">&quot;Constructor&quot;</span><span style="color: #483d8b;">&quot;&quot;</span>
        wx.<span style="color: black;">Frame</span>.<span style="color: #0000cd;">__init__</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, <span style="color: #008000;">None</span>, title=<span style="color: #483d8b;">&quot;wx.Menu Tutorial&quot;</span><span style="color: black;">&#41;</span>
&nbsp;
        <span style="color: #008000;">self</span>.<span style="color: black;">panel</span> = wx.<span style="color: black;">Panel</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, wx.<span style="color: black;">ID_ANY</span><span style="color: black;">&#41;</span>
&nbsp;
        <span style="color: #808080; font-style: italic;"># Create menu bar</span>
        menuBar = wx.<span style="color: black;">MenuBar</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
&nbsp;
        <span style="color: #808080; font-style: italic;"># Create radio menu</span>
        radioMenu = wx.<span style="color: black;">Menu</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
        idleItem = radioMenu.<span style="color: black;">Append</span><span style="color: black;">&#40;</span>wx.<span style="color: black;">NewId</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>, <span style="color: #483d8b;">&quot;IDLE&quot;</span>,
                                   <span style="color: #483d8b;">&quot;a Python shell using tcl/tk as GUI&quot;</span>,
                                   wx.<span style="color: black;">ITEM_RADIO</span><span style="color: black;">&#41;</span>
        pyCrustItem = radioMenu.<span style="color: black;">Append</span><span style="color: black;">&#40;</span>wx.<span style="color: black;">NewId</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>,<span style="color: #483d8b;">&quot;PyCrust&quot;</span>,
                                      <span style="color: #483d8b;">&quot;a Python shell using wxPython as GUI&quot;</span>,
                                      wx.<span style="color: black;">ITEM_RADIO</span><span style="color: black;">&#41;</span>
        psiItem = radioMenu.<span style="color: black;">Append</span><span style="color: black;">&#40;</span>wx.<span style="color: black;">NewId</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>, <span style="color: #483d8b;">&quot;psi&quot;</span>,
                                  <span style="color: #483d8b;">&quot;a simple Python shell using wxPython as GUI&quot;</span>,
                                  wx.<span style="color: black;">ITEM_RADIO</span><span style="color: black;">&#41;</span>
        menuBar.<span style="color: black;">Append</span><span style="color: black;">&#40;</span>radioMenu, <span style="color: #483d8b;">&quot;&amp;Radio&quot;</span><span style="color: black;">&#41;</span>
&nbsp;
        <span style="color: #808080; font-style: italic;"># create check menu</span>
        checkMenu = wx.<span style="color: black;">Menu</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
        wgItem = checkMenu.<span style="color: black;">Append</span><span style="color: black;">&#40;</span>wx.<span style="color: black;">NewId</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>, <span style="color: #483d8b;">&quot;Wells Fargo&quot;</span>, <span style="color: #483d8b;">&quot;&quot;</span>, wx.<span style="color: black;">ITEM_CHECK</span><span style="color: black;">&#41;</span>
        citiItem = checkMenu.<span style="color: black;">Append</span><span style="color: black;">&#40;</span>wx.<span style="color: black;">NewId</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>, <span style="color: #483d8b;">&quot;Citibank&quot;</span>, <span style="color: #483d8b;">&quot;&quot;</span>, wx.<span style="color: black;">ITEM_CHECK</span><span style="color: black;">&#41;</span>
        geItem = checkMenu.<span style="color: black;">Append</span><span style="color: black;">&#40;</span>wx.<span style="color: black;">NewId</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>, <span style="color: #483d8b;">&quot;GE Money Bank&quot;</span>, <span style="color: #483d8b;">&quot;&quot;</span>, wx.<span style="color: black;">ITEM_CHECK</span><span style="color: black;">&#41;</span>
        menuBar.<span style="color: black;">Append</span><span style="color: black;">&#40;</span>checkMenu, <span style="color: #483d8b;">&quot;&amp;Check&quot;</span><span style="color: black;">&#41;</span>
&nbsp;
        <span style="color: #808080; font-style: italic;"># Attach menu bar to frame</span>
        <span style="color: #008000;">self</span>.<span style="color: black;">SetMenuBar</span><span style="color: black;">&#40;</span>menuBar<span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">#----------------------------------------------------------------------</span>
<span style="color: #808080; font-style: italic;"># Run the program</span>
<span style="color: #ff7700;font-weight:bold;">if</span> __name__ == <span style="color: #483d8b;">&quot;__main__&quot;</span>:
    app = wx.<span style="color: black;">App</span><span style="color: black;">&#40;</span><span style="color: #008000;">False</span><span style="color: black;">&#41;</span>
    frame = MyForm<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>.<span style="color: black;">Show</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
    app.<span style="color: black;">MainLoop</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></pre>
<p>Yes, as you can see, all you have to do is add a wx.ITEM_RADIO or wx.ITEM_CHECK flag as the <strong>kind </strong>parameter, which is the 4th parameter. Why is it called &#8220;kind&#8221; rather than &#8220;style&#8221; like other widgets? Well, while discussing this on the wxPython IRC channel, Robin Dunn (creator of wxPython) pointed out that it may be because these are different kinds of menu items. </p>
<h3>Sub-Menus</h3>
<p>
<p>
The wxPython library also supports sub-menus. Here&#8217;s a really simple example to show you how it&#8217;s done.</p>
<pre class="python"><span style="color: #808080; font-style: italic;"># submenu.py</span>
<span style="color: #ff7700;font-weight:bold;">import</span> wx
&nbsp;
<span style="color: #808080; font-style: italic;">########################################################################</span>
<span style="color: #ff7700;font-weight:bold;">class</span> MyForm<span style="color: black;">&#40;</span>wx.<span style="color: black;">Frame</span><span style="color: black;">&#41;</span>:
    <span style="color: #483d8b;">&quot;&quot;</span><span style="color: #483d8b;">&quot;&quot;</span><span style="color: #483d8b;">&quot;&quot;</span>
&nbsp;
    <span style="color: #808080; font-style: italic;">#----------------------------------------------------------------------</span>
    <span style="color: #ff7700;font-weight:bold;">def</span> <span style="color: #0000cd;">__init__</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span><span style="color: black;">&#41;</span>:
        <span style="color: #483d8b;">&quot;&quot;</span><span style="color: #483d8b;">&quot;Constructor&quot;</span><span style="color: #483d8b;">&quot;&quot;</span>
        wx.<span style="color: black;">Frame</span>.<span style="color: #0000cd;">__init__</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, <span style="color: #008000;">None</span>, title=<span style="color: #483d8b;">&quot;wx.Menu Tutorial&quot;</span><span style="color: black;">&#41;</span>
&nbsp;
        <span style="color: #008000;">self</span>.<span style="color: black;">panel</span> = wx.<span style="color: black;">Panel</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, wx.<span style="color: black;">ID_ANY</span><span style="color: black;">&#41;</span>
&nbsp;
        menuBar = wx.<span style="color: black;">MenuBar</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
        fileMenu = wx.<span style="color: black;">Menu</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
        openMenuItem = fileMenu.<span style="color: black;">Append</span><span style="color: black;">&#40;</span>wx.<span style="color: black;">NewId</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>, <span style="color: #483d8b;">&quot;Open&quot;</span><span style="color: black;">&#41;</span>
&nbsp;
        <span style="color: #808080; font-style: italic;"># create a submenu</span>
        subMenu = wx.<span style="color: black;">Menu</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
        historyMenuItem = subMenu.<span style="color: black;">Append</span><span style="color: black;">&#40;</span>wx.<span style="color: black;">NewId</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>, <span style="color: #483d8b;">&quot;Show History&quot;</span><span style="color: black;">&#41;</span>
        fileMenu.<span style="color: black;">AppendMenu</span><span style="color: black;">&#40;</span>wx.<span style="color: black;">NewId</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>, <span style="color: #483d8b;">&quot;History&quot;</span>, subMenu<span style="color: black;">&#41;</span>
&nbsp;
        exitMenuItem = fileMenu.<span style="color: black;">Append</span><span style="color: black;">&#40;</span>wx.<span style="color: black;">NewId</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>, <span style="color: #483d8b;">&quot;Exit&quot;</span>,
                                       <span style="color: #483d8b;">&quot;Exit the application&quot;</span><span style="color: black;">&#41;</span>
        menuBar.<span style="color: black;">Append</span><span style="color: black;">&#40;</span>fileMenu, <span style="color: #483d8b;">&quot;&amp;File&quot;</span><span style="color: black;">&#41;</span>
        <span style="color: #008000;">self</span>.<span style="color: black;">Bind</span><span style="color: black;">&#40;</span>wx.<span style="color: black;">EVT_MENU</span>, <span style="color: #008000;">self</span>.<span style="color: black;">onExit</span>, exitMenuItem<span style="color: black;">&#41;</span>
        <span style="color: #008000;">self</span>.<span style="color: black;">SetMenuBar</span><span style="color: black;">&#40;</span>menuBar<span style="color: black;">&#41;</span>
&nbsp;
    <span style="color: #808080; font-style: italic;">#----------------------------------------------------------------------</span>
    <span style="color: #ff7700;font-weight:bold;">def</span> onExit<span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, event<span style="color: black;">&#41;</span>:
        <span style="color: #483d8b;">&quot;&quot;</span><span style="color: #483d8b;">&quot;&quot;</span><span style="color: #483d8b;">&quot;&quot;</span>
        <span style="color: #008000;">self</span>.<span style="color: black;">Close</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">#----------------------------------------------------------------------</span>
<span style="color: #808080; font-style: italic;"># Run the program</span>
<span style="color: #ff7700;font-weight:bold;">if</span> __name__ == <span style="color: #483d8b;">&quot;__main__&quot;</span>:
    app = wx.<span style="color: black;">App</span><span style="color: black;">&#40;</span><span style="color: #008000;">False</span><span style="color: black;">&#41;</span>
    frame = MyForm<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>.<span style="color: black;">Show</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
    app.<span style="color: black;">MainLoop</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></pre>
<p>The key here is that instead of using the filemenu&#8217;s Append method, we instead use its AppendMenu method. As the name implies, it allows the programmer to actually append a menu instead of a menu item. Yup, that&#8217;s it!</p>
<h3>Pop-up Menus (AKA: ContextMenus)</h3>
<p>
<p>
Pop-up menus are the kind you see when you right-click on a link in a browser or on a file. They are also known as Context Menus. Here is a fairly trivial example for you to study:</p>
<pre class="python"><span style="color: #808080; font-style: italic;"># submenu.py</span>
<span style="color: #ff7700;font-weight:bold;">import</span> wx
&nbsp;
<span style="color: #808080; font-style: italic;">########################################################################</span>
<span style="color: #ff7700;font-weight:bold;">class</span> MyForm<span style="color: black;">&#40;</span>wx.<span style="color: black;">Frame</span><span style="color: black;">&#41;</span>:
    <span style="color: #483d8b;">&quot;&quot;</span><span style="color: #483d8b;">&quot;&quot;</span><span style="color: #483d8b;">&quot;&quot;</span>
&nbsp;
    <span style="color: #808080; font-style: italic;">#----------------------------------------------------------------------</span>
    <span style="color: #ff7700;font-weight:bold;">def</span> <span style="color: #0000cd;">__init__</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span><span style="color: black;">&#41;</span>:
        <span style="color: #483d8b;">&quot;&quot;</span><span style="color: #483d8b;">&quot;Constructor&quot;</span><span style="color: #483d8b;">&quot;&quot;</span>
        wx.<span style="color: black;">Frame</span>.<span style="color: #0000cd;">__init__</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, <span style="color: #008000;">None</span>, title=<span style="color: #483d8b;">&quot;Popup Menu Tutorial&quot;</span><span style="color: black;">&#41;</span>
&nbsp;
        panel = wx.<span style="color: black;">Panel</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, wx.<span style="color: black;">ID_ANY</span><span style="color: black;">&#41;</span>
&nbsp;
        lbl = wx.<span style="color: black;">StaticText</span><span style="color: black;">&#40;</span>panel, label=<span style="color: #483d8b;">&quot;Right click anywhere!&quot;</span><span style="color: black;">&#41;</span>
        <span style="color: #008000;">self</span>.<span style="color: black;">Bind</span><span style="color: black;">&#40;</span>wx.<span style="color: black;">EVT_CONTEXT_MENU</span>, <span style="color: #008000;">self</span>.<span style="color: black;">onContext</span><span style="color: black;">&#41;</span>
&nbsp;
    <span style="color: #808080; font-style: italic;">#----------------------------------------------------------------------</span>
    <span style="color: #ff7700;font-weight:bold;">def</span> onContext<span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, event<span style="color: black;">&#41;</span>:
        <span style="color: #483d8b;">&quot;&quot;</span><span style="color: #483d8b;">&quot;
        Create and show a Context Menu
        &quot;</span><span style="color: #483d8b;">&quot;&quot;</span>
&nbsp;
        <span style="color: #808080; font-style: italic;"># only do this part the first time so the events are only bound once </span>
        <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #ff7700;font-weight:bold;">not</span> <span style="color: #008000;">hasattr</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, <span style="color: #483d8b;">&quot;popupID1&quot;</span><span style="color: black;">&#41;</span>:
            <span style="color: #008000;">self</span>.<span style="color: black;">popupID1</span> = wx.<span style="color: black;">NewId</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
            <span style="color: #008000;">self</span>.<span style="color: black;">itemTwoId</span> = wx.<span style="color: black;">NewId</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
            <span style="color: #008000;">self</span>.<span style="color: black;">itemThreeId</span> = wx.<span style="color: black;">NewId</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
            <span style="color: #008000;">self</span>.<span style="color: black;">Bind</span><span style="color: black;">&#40;</span>wx.<span style="color: black;">EVT_MENU</span>, <span style="color: #008000;">self</span>.<span style="color: black;">onPopup</span>, <span style="color: #008000;">id</span>=<span style="color: #008000;">self</span>.<span style="color: black;">popupID1</span><span style="color: black;">&#41;</span>
            <span style="color: #008000;">self</span>.<span style="color: black;">Bind</span><span style="color: black;">&#40;</span>wx.<span style="color: black;">EVT_MENU</span>, <span style="color: #008000;">self</span>.<span style="color: black;">onPopup</span>, <span style="color: #008000;">id</span>=<span style="color: #008000;">self</span>.<span style="color: black;">itemTwoId</span><span style="color: black;">&#41;</span>
            <span style="color: #008000;">self</span>.<span style="color: black;">Bind</span><span style="color: black;">&#40;</span>wx.<span style="color: black;">EVT_MENU</span>, <span style="color: #008000;">self</span>.<span style="color: black;">onExit</span>, <span style="color: #008000;">id</span>=<span style="color: #008000;">self</span>.<span style="color: black;">itemThreeId</span><span style="color: black;">&#41;</span>
&nbsp;
        <span style="color: #808080; font-style: italic;"># build the menu</span>
        menu = wx.<span style="color: black;">Menu</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
        itemOne = menu.<span style="color: black;">Append</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span>.<span style="color: black;">popupID1</span>, <span style="color: #483d8b;">&quot;ItemOne&quot;</span><span style="color: black;">&#41;</span>
        itemTwo = menu.<span style="color: black;">Append</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span>.<span style="color: black;">itemTwoId</span>, <span style="color: #483d8b;">&quot;ItemTwo&quot;</span><span style="color: black;">&#41;</span>
        itemThree = menu.<span style="color: black;">Append</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span>.<span style="color: black;">itemThreeId</span>, <span style="color: #483d8b;">&quot;Exit&quot;</span><span style="color: black;">&#41;</span>
&nbsp;
        <span style="color: #808080; font-style: italic;"># show the popup menu</span>
        <span style="color: #008000;">self</span>.<span style="color: black;">PopupMenu</span><span style="color: black;">&#40;</span>menu<span style="color: black;">&#41;</span>
        menu.<span style="color: black;">Destroy</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
&nbsp;
    <span style="color: #808080; font-style: italic;">#----------------------------------------------------------------------</span>
    <span style="color: #ff7700;font-weight:bold;">def</span> onExit<span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, event<span style="color: black;">&#41;</span>:
        <span style="color: #483d8b;">&quot;&quot;</span><span style="color: #483d8b;">&quot;
        Exit program
        &quot;</span><span style="color: #483d8b;">&quot;&quot;</span>
        <span style="color: #008000;">self</span>.<span style="color: black;">Close</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
&nbsp;
    <span style="color: #808080; font-style: italic;">#----------------------------------------------------------------------</span>
    <span style="color: #ff7700;font-weight:bold;">def</span> onPopup<span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, event<span style="color: black;">&#41;</span>:
        <span style="color: #483d8b;">&quot;&quot;</span><span style="color: #483d8b;">&quot;
        Print the label of the menu item selected
        &quot;</span><span style="color: #483d8b;">&quot;&quot;</span>
        itemId = event.<span style="color: black;">GetId</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
        menu = event.<span style="color: black;">GetEventObject</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
        menuItem = menu.<span style="color: black;">FindItemById</span><span style="color: black;">&#40;</span>itemId<span style="color: black;">&#41;</span>
        <span style="color: #ff7700;font-weight:bold;">print</span> menuItem.<span style="color: black;">GetLabel</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">#----------------------------------------------------------------------</span>
<span style="color: #808080; font-style: italic;"># Run the program</span>
<span style="color: #ff7700;font-weight:bold;">if</span> __name__ == <span style="color: #483d8b;">&quot;__main__&quot;</span>:
    app = wx.<span style="color: black;">App</span><span style="color: black;">&#40;</span><span style="color: #008000;">False</span><span style="color: black;">&#41;</span>
    frame = MyForm<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>.<span style="color: black;">Show</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
    app.<span style="color: black;">MainLoop</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></pre>
<p>To begin, we bind wx.EVT_CONTEXT_MENU to the frame. This allows us to right-click anywhere and fire the context menu event, which will create and show our popup menu. The code in the <strong>onContext</strong> method is based loosely on the wxPython demo for the popup menu. As you can see, we use a conditional statement to check if we&#8217;ve already bound the menu events. If we have, we don&#8217;t bind them again. Next we create our menu in much the same way as before. Finally, we call the frame&#8217;s <strong>PopupMenu</strong> method and pass it our new menu. This will show the menu to the user. When the user clicks on a menu item, it will fire an event and the menu will be destroyed.</p>
<p>The first two menu items are both bound to our <strong>onPopup</strong> method. This allows us to see how we can get access to the Menu and the MenuItem attributes. You can get the menu&#8217;s id with the event and the Menu itself with the event&#8217;s GetEventObject method. Then you can use the menu&#8217;s FindItemById method to get a handle to the menu item itself. Finally we print out the menu item&#8217;s label.</p>
<h3>Wrapping Up</h3>
<p>
<p>
Now you should know most of the menu methods and how to create them, bind events and make different kinds of menu items. You even know how to create popup menus! Now you can make your applications have fancy menus too.</p>
<h3>Further Reading</h3>
<p>
<ul>
<li><a href="http://www.blog.pythonlibrary.org/2008/07/02/wxpython-working-with-menus-toolbars-and-accelerators/" title="wxPython: Working with Menus, Toolbars and Accelerators" target="_blank">wxPython: Working with Menus, Toolbars and Accelerators</a></li>
<li>Working with Menus &#8211; <a href="http://wiki.wxpython.org/WorkingWithMenus" target="_blank">wxPython Wiki</a></li>
<li>Menus and Toolbars &#8211; <a href="http://zetcode.com/wxpython/menustoolbars/" target="_blank">Zetcode</a></li>
</ul>
<h3>Source</h3>
<p>
<ul>
<li><a href='http://www.blog.pythonlibrary.org/wp-content/uploads/2012/02/menus.zip'>menus.zip</a></li>
<li><a href='http://www.blog.pythonlibrary.org/wp-content/uploads/2012/02/menus.tar'>menus.tar</a></li>
</ul>
<img src="http://feeds.feedburner.com/~r/TheMouseVsThePython/~4/iLuB9OJMJsg" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.blog.pythonlibrary.org/2012/02/14/wxpython-all-about-menus/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://www.blog.pythonlibrary.org/2012/02/14/wxpython-all-about-menus/</feedburner:origLink></item>
		<item>
		<title>Reportlab: Converting Hundreds of Images Into PDFs</title>
		<link>http://feedproxy.google.com/~r/TheMouseVsThePython/~3/-mv6kjGIHZE/</link>
		<comments>http://www.blog.pythonlibrary.org/2012/01/07/reportlab-converting-hundreds-of-images-into-pdfs/#comments</comments>
		<pubDate>Sun, 08 Jan 2012 01:36:41 +0000</pubDate>
		<dc:creator>Mike</dc:creator>
				<category><![CDATA[Python]]></category>
		<category><![CDATA[Reportlab]]></category>

		<guid isPermaLink="false">http://www.blog.pythonlibrary.org/?p=2188</guid>
		<description><![CDATA[I was recently asked to convert a few hundred images into PDF pages. A friend of mine draws comics and my brother wanted to be able to read them on a tablet. Alas, if you had a bunch of files named something like this: 'Jia_01.Jpg', 'Jia_02.Jpg', 'Jia_09.Jpg', 'Jia_10.Jpg', 'Jia_11.Jpg', 'Jia_101.Jpg' the Android tablet would reorder [...]]]></description>
			<content:encoded><![CDATA[<p>I was recently asked to convert a few hundred images into PDF pages. A friend of mine draws comics and my brother wanted to be able to read them on a tablet. Alas, if you had a bunch of files named something like this: </p>
<p><code><br />
'Jia_01.Jpg', 'Jia_02.Jpg', 'Jia_09.Jpg', 'Jia_10.Jpg', 'Jia_11.Jpg', 'Jia_101.Jpg'<br />
</code></p>
<p>the Android tablet would reorder them into something like this:</p>
<p><code><br />
'Jia_01.Jpg', 'Jia_02.Jpg', 'Jia_09.Jpg', 'Jia_10.Jpg', 'Jia_101.Jpg', 'Jia_11.Jpg'<br />
</code></p>
<p>And it got pretty confusing the more files you had that were out of order. Sadly, even Python sorts files this way. I tried using the <strong>glob</strong> module on the directly and then sorting the result and got the exact same issue. So the first thing I had to do was find some kind of sorting algorithm that could sort them correctly. It should be noted that Windows 7 can sort the files correctly in its file system, even though Python cannot. <span id="more-2188"></span></p>
<p>After a little searching on Google, I found the following script on <a href="# http://stackoverflow.com/questions/2669059/how-to-sort-alpha-numeric-set-in-python" target="_blank">StackOverflow</a>:</p>
<pre class="python"><span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">re</span>
&nbsp;
<span style="color: #808080; font-style: italic;">#----------------------------------------------------------------------</span>
<span style="color: #ff7700;font-weight:bold;">def</span> sorted_nicely<span style="color: black;">&#40;</span> l <span style="color: black;">&#41;</span>:
    <span style="color: #483d8b;">&quot;&quot;</span><span style="color: #483d8b;">&quot;
    Sort the given iterable in the way that humans expect.
    &quot;</span><span style="color: #483d8b;">&quot;&quot;</span>
    convert = <span style="color: #ff7700;font-weight:bold;">lambda</span> text: <span style="color: #008000;">int</span><span style="color: black;">&#40;</span>text<span style="color: black;">&#41;</span> <span style="color: #ff7700;font-weight:bold;">if</span> text.<span style="color: black;">isdigit</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span> <span style="color: #ff7700;font-weight:bold;">else</span> text
    alphanum_key = <span style="color: #ff7700;font-weight:bold;">lambda</span> key: <span style="color: black;">&#91;</span> convert<span style="color: black;">&#40;</span>c<span style="color: black;">&#41;</span> <span style="color: #ff7700;font-weight:bold;">for</span> c <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: #dc143c;">re</span>.<span style="color: black;">split</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'([0-9]+)'</span>, key<span style="color: black;">&#41;</span> <span style="color: black;">&#93;</span>
    <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #008000;">sorted</span><span style="color: black;">&#40;</span>l, key = alphanum_key<span style="color: black;">&#41;</span></pre>
<p>That worked perfectly! Now I just had to find a way to put each comic page on their own PDF page. Fortunately, the <a href="http://www.reportlab.com/software/opensource/" target="_blank">reportlab</a> library makes this pretty easy to accomplish. You just need to iterate over the images and insert them one at a time onto a page. It&#8217;s easier to just look at the code, so let&#8217;s do that:</p>
<pre class="python"><span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">glob</span>
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">os</span>
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">re</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">from</span> reportlab.<span style="color: black;">lib</span>.<span style="color: black;">pagesizes</span> <span style="color: #ff7700;font-weight:bold;">import</span> letter
<span style="color: #ff7700;font-weight:bold;">from</span> reportlab.<span style="color: black;">platypus</span> <span style="color: #ff7700;font-weight:bold;">import</span> SimpleDocTemplate, Paragraph, Image, PageBreak
<span style="color: #ff7700;font-weight:bold;">from</span> reportlab.<span style="color: black;">lib</span>.<span style="color: black;">units</span> <span style="color: #ff7700;font-weight:bold;">import</span> inch
&nbsp;
<span style="color: #808080; font-style: italic;">#----------------------------------------------------------------------</span>
<span style="color: #ff7700;font-weight:bold;">def</span> sorted_nicely<span style="color: black;">&#40;</span> l <span style="color: black;">&#41;</span>:
    <span style="color: #483d8b;">&quot;&quot;</span><span style="color: #483d8b;">&quot;
    # http://stackoverflow.com/questions/2669059/how-to-sort-alpha-numeric-set-in-python
&nbsp;
    Sort the given iterable in the way that humans expect.
    &quot;</span><span style="color: #483d8b;">&quot;&quot;</span>
    convert = <span style="color: #ff7700;font-weight:bold;">lambda</span> text: <span style="color: #008000;">int</span><span style="color: black;">&#40;</span>text<span style="color: black;">&#41;</span> <span style="color: #ff7700;font-weight:bold;">if</span> text.<span style="color: black;">isdigit</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span> <span style="color: #ff7700;font-weight:bold;">else</span> text
    alphanum_key = <span style="color: #ff7700;font-weight:bold;">lambda</span> key: <span style="color: black;">&#91;</span> convert<span style="color: black;">&#40;</span>c<span style="color: black;">&#41;</span> <span style="color: #ff7700;font-weight:bold;">for</span> c <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: #dc143c;">re</span>.<span style="color: black;">split</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'([0-9]+)'</span>, key<span style="color: black;">&#41;</span> <span style="color: black;">&#93;</span>
    <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #008000;">sorted</span><span style="color: black;">&#40;</span>l, key = alphanum_key<span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">#----------------------------------------------------------------------</span>
<span style="color: #ff7700;font-weight:bold;">def</span> create_comic<span style="color: black;">&#40;</span>fname, front_cover, back_cover, path<span style="color: black;">&#41;</span>:
    <span style="color: #483d8b;">&quot;&quot;</span><span style="color: #483d8b;">&quot;&quot;</span><span style="color: #483d8b;">&quot;&quot;</span>
    filename = <span style="color: #dc143c;">os</span>.<span style="color: black;">path</span>.<span style="color: black;">join</span><span style="color: black;">&#40;</span>path, fname + <span style="color: #483d8b;">&quot;.pdf&quot;</span><span style="color: black;">&#41;</span>
    doc = SimpleDocTemplate<span style="color: black;">&#40;</span>filename,pagesize=letter,
                            rightMargin=<span style="color: #ff4500;">72</span>,leftMargin=<span style="color: #ff4500;">72</span>,
                            topMargin=<span style="color: #ff4500;">72</span>,bottomMargin=<span style="color: #ff4500;">18</span><span style="color: black;">&#41;</span>
    Story=<span style="color: black;">&#91;</span><span style="color: black;">&#93;</span>
    width = <span style="color: #ff4500;">7.5</span><span style="color: #66cc66;">*</span>inch
    height = <span style="color: #ff4500;">9.5</span><span style="color: #66cc66;">*</span>inch
&nbsp;
    pictures = sorted_nicely<span style="color: black;">&#40;</span><span style="color: #dc143c;">glob</span>.<span style="color: #dc143c;">glob</span><span style="color: black;">&#40;</span>path + <span style="color: #483d8b;">&quot;<span style="color: #000099; font-weight: bold;">\\</span>%s*&quot;</span> <span style="color: #66cc66;">%</span> fname<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
&nbsp;
    Story.<span style="color: black;">append</span><span style="color: black;">&#40;</span>Image<span style="color: black;">&#40;</span>front_cover, width, height<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
    Story.<span style="color: black;">append</span><span style="color: black;">&#40;</span>PageBreak<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
&nbsp;
    x = <span style="color: #ff4500;">0</span>
    page_nums = <span style="color: black;">&#123;</span><span style="color: #ff4500;">100</span>:<span style="color: #483d8b;">'%s_101-200.pdf'</span>, <span style="color: #ff4500;">200</span>:<span style="color: #483d8b;">'%s_201-300.pdf'</span>,
                 <span style="color: #ff4500;">300</span>:<span style="color: #483d8b;">'%s_301-400.pdf'</span>, <span style="color: #ff4500;">400</span>:<span style="color: #483d8b;">'%s_401-500.pdf'</span>,
                 <span style="color: #ff4500;">500</span>:<span style="color: #483d8b;">'%s_end.pdf'</span><span style="color: black;">&#125;</span>
    <span style="color: #ff7700;font-weight:bold;">for</span> pic <span style="color: #ff7700;font-weight:bold;">in</span> pictures:
        parts = pic.<span style="color: black;">split</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;<span style="color: #000099; font-weight: bold;">\\</span>&quot;</span><span style="color: black;">&#41;</span>
        p = parts<span style="color: black;">&#91;</span><span style="color: #ff4500;">-1</span><span style="color: black;">&#93;</span>.<span style="color: black;">split</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;%s&quot;</span> <span style="color: #66cc66;">%</span> fname<span style="color: black;">&#41;</span>
        page_num = <span style="color: #008000;">int</span><span style="color: black;">&#40;</span>p<span style="color: black;">&#91;</span><span style="color: #ff4500;">-1</span><span style="color: black;">&#93;</span>.<span style="color: black;">split</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;.&quot;</span><span style="color: black;">&#41;</span><span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span>
        <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;page_num =&gt; &quot;</span>, page_num
&nbsp;
        im = Image<span style="color: black;">&#40;</span>pic, width, height<span style="color: black;">&#41;</span>
        Story.<span style="color: black;">append</span><span style="color: black;">&#40;</span>im<span style="color: black;">&#41;</span>
        Story.<span style="color: black;">append</span><span style="color: black;">&#40;</span>PageBreak<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
&nbsp;
        <span style="color: #ff7700;font-weight:bold;">if</span> page_num <span style="color: #ff7700;font-weight:bold;">in</span> page_nums.<span style="color: black;">keys</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>:
            <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;%s created&quot;</span> <span style="color: #66cc66;">%</span> filename
            doc.<span style="color: black;">build</span><span style="color: black;">&#40;</span>Story<span style="color: black;">&#41;</span>
            filename = <span style="color: #dc143c;">os</span>.<span style="color: black;">path</span>.<span style="color: black;">join</span><span style="color: black;">&#40;</span>path, page_nums<span style="color: black;">&#91;</span>page_num<span style="color: black;">&#93;</span> <span style="color: #66cc66;">%</span> fname<span style="color: black;">&#41;</span>
            doc = SimpleDocTemplate<span style="color: black;">&#40;</span>filename,
                                    pagesize=letter,
                                    rightMargin=<span style="color: #ff4500;">72</span>,leftMargin=<span style="color: #ff4500;">72</span>,
                                    topMargin=<span style="color: #ff4500;">72</span>,bottomMargin=<span style="color: #ff4500;">18</span><span style="color: black;">&#41;</span>
            Story=<span style="color: black;">&#91;</span><span style="color: black;">&#93;</span>
        <span style="color: #ff7700;font-weight:bold;">print</span> pic
        x += <span style="color: #ff4500;">1</span>
&nbsp;
    Story.<span style="color: black;">append</span><span style="color: black;">&#40;</span>Image<span style="color: black;">&#40;</span>back_cover, width, height<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
    doc.<span style="color: black;">build</span><span style="color: black;">&#40;</span>Story<span style="color: black;">&#41;</span>
    <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;%s created&quot;</span> <span style="color: #66cc66;">%</span> filename
&nbsp;
<span style="color: #808080; font-style: italic;">#----------------------------------------------------------------------</span>
<span style="color: #ff7700;font-weight:bold;">if</span> __name__ == <span style="color: #483d8b;">&quot;__main__&quot;</span>:
    path = r<span style="color: #483d8b;">&quot;C:<span style="color: #000099; font-weight: bold;">\U</span>sers<span style="color: #000099; font-weight: bold;">\M</span>ike<span style="color: #000099; font-weight: bold;">\D</span>esktop<span style="color: #000099; font-weight: bold;">\S</span>am's Comics&quot;</span>
    front_cover = <span style="color: #dc143c;">os</span>.<span style="color: black;">path</span>.<span style="color: black;">join</span><span style="color: black;">&#40;</span>path, <span style="color: #483d8b;">&quot;FrontCover.jpg&quot;</span><span style="color: black;">&#41;</span>
    back_cover = <span style="color: #dc143c;">os</span>.<span style="color: black;">path</span>.<span style="color: black;">join</span><span style="color: black;">&#40;</span>path, <span style="color: #483d8b;">&quot;BackCover2.jpg&quot;</span><span style="color: black;">&#41;</span>
    create_comic<span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;Jia_&quot;</span>, front_cover, back_cover, path<span style="color: black;">&#41;</span></pre>
<p>Let&#8217;s break this down a bit. As usual, you have some necessary imports that are required for this code to work. You&#8217;ll note we also have that <strong>sorted_nicely</strong> function that we talked about earlier is in this code too. The main function is called <strong>create_comic</strong> and takes four arguments: fname, front_cover, back_cover, path. If you have used the reportlab toolkit before, then you&#8217;ll recognize the SimpleDocTemplate and the Story list as they&#8217;re straight out of the reportlab tutorial.</p>
<p>Anyway, you loop over the sorted pictures and add the image to the Story along with a PageBreak object. The reason there&#8217;s a conditional in the loop is because I discovered that if I tried to build the PDF with all 400+ images, I would run into a memory error. So I broke it up into a series of PDF documents that were 100 pages or less. At the end of the document, you have to call the <strong>doc</strong> object&#8217;s <strong>build</strong> method to actually create the PDF document.</p>
<p>Now you know how I ended up writing a whole slew of images into multiple PDF documents. Theoretically, you could use PyPdf to knit all the resulting PDFs together into one PDF, but I didn&#8217;t try it. You might end up with another memory error. I&#8217;ll leave that as an exercise for the reader.</p>
<h2>Source Code</h2>
<ul>
<li><a href='http://www.blog.pythonlibrary.org/wp-content/uploads/2012/01/comic_maker.zip'>comic_maker.zip</a></li>
<li><a href='http://www.blog.pythonlibrary.org/wp-content/uploads/2012/01/comic_maker.tar'>comic_maker.tar</a></li>
</ul>
<img src="http://feeds.feedburner.com/~r/TheMouseVsThePython/~4/-mv6kjGIHZE" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.blog.pythonlibrary.org/2012/01/07/reportlab-converting-hundreds-of-images-into-pdfs/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		<feedburner:origLink>http://www.blog.pythonlibrary.org/2012/01/07/reportlab-converting-hundreds-of-images-into-pdfs/</feedburner:origLink></item>
		<item>
		<title>January 2012 Pyowa Wrap Up</title>
		<link>http://feedproxy.google.com/~r/TheMouseVsThePython/~3/Tkfed3R44aI/</link>
		<comments>http://www.blog.pythonlibrary.org/2012/01/07/january-2012-pyowa-wrap-up/#comments</comments>
		<pubDate>Sat, 07 Jan 2012 16:06:00 +0000</pubDate>
		<dc:creator>Mike</dc:creator>
				<category><![CDATA[Pyowa]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[wxPython]]></category>

		<guid isPermaLink="false">http://www.blog.pythonlibrary.org/?p=2183</guid>
		<description><![CDATA[Last Thursday (the 5th) I attended Pyowa, the local Iowa Python Users group I founded a few years ago. We had Scott Peterson from Principal Financial Group come and talk to us about Library Gadget, a cool Django-based website he created to track what library books his family has checked out. Now he has lots [...]]]></description>
			<content:encoded><![CDATA[<p>Last Thursday (the 5th) I attended <a href="http://www.pyowa.org/" target="_blank">Pyowa</a>, the local Iowa Python Users group I founded a few years ago. We had Scott Peterson from Principal Financial Group come and talk to us about <a href="http://www.librarygadget.com/" target="_blank">Library Gadget</a>, a cool Django-based website he created to track what library books his family has checked out. Now he has lots of users using his website. It not only tracks the books you have borrowed, but it&#8217;ll auto-renew them if it can and let you know if you&#8217;re books are overdue.</p>
<p>He spent most of his time talking about the backend stuff behind the website though. Such as why he chose Amazon Web Services, how he uses <a href="http://projects.puppetlabs.com/projects/puppet" target="_blank">Puppet</a>, <a href="http://vagrantup.com/docs/getting-started/setup.html" target="_blank">Vagrant</a> and <a href="http://docs.fabfile.org/en/1.3.3/index.html" target="_blank">Fabric</a> to manage his server&#8217;s settings and back them up.</p>
<p>The second talk was done by myself and I spoke on my <a href="http://www.medialocker.pythonlibrary.org/" target="_blank">MediaLocker</a> project, an open source wxPython application that is supposed to help you track your media library. Most of my time was spent telling the story behind the project and showing a demo. Then I took some questions. </p>
<p>Overall, I&#8217;d say that we had a really good meeting with 10 people showing up. Next month, on February 2nd, we&#8217;re bringing in the BIG guns though. We have <a href="http://www.doughellmann.com/" target="_blank">Doug Hellman</a> and <a href="http://holdenweb.com/" target="_blank">Steve Holden</a> scheduled to Skype in and talk to us.</p>
<p>Doug Hellman is the author of <a href="http://www.amazon.com/gp/product/0321767349/ref=as_li_ss_tl?ie=UTF8&#038;tag=thmovsthpy-20&#038;linkCode=as2&#038;camp=1789&#038;creative=390957&#038;creativeASIN=0321767349" target="_blank" rel="nofollow">The Python Standard Library By Example</a>, is a senior developer with Racemi, Inc., and communications director of the Python Software Foundation. He has programmed with Python since version 1.4, and has worked on multiple platforms in mapping, medical publishing, banking, and data center automation. Hellmann was previously columnist and editor-in-chief for Python Magazine and, since 2007, has blogged the popular Python Module of the Week</p>
<p>Steve Holden is chairman of the Python Software Foundation and author of <a href="http://www.amazon.com/gp/product/0735710902/ref=as_li_ss_tl?ie=UTF8&#038;tag=thmovsthpy-20&#038;linkCode=as2&#038;camp=1789&#038;creative=390957&#038;creativeASIN=0735710902" target="_blank" rel="nofollow">Python Web Programming</a>. He owns Python consulting business and does Python training.</p>
<img src="http://feeds.feedburner.com/~r/TheMouseVsThePython/~4/Tkfed3R44aI" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.blog.pythonlibrary.org/2012/01/07/january-2012-pyowa-wrap-up/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.blog.pythonlibrary.org/2012/01/07/january-2012-pyowa-wrap-up/</feedburner:origLink></item>
		<item>
		<title>Top Ten Articles of 2011</title>
		<link>http://feedproxy.google.com/~r/TheMouseVsThePython/~3/sqYpktlUpnw/</link>
		<comments>http://www.blog.pythonlibrary.org/2011/12/31/top-ten-articles-of-2011/#comments</comments>
		<pubDate>Sun, 01 Jan 2012 05:59:27 +0000</pubDate>
		<dc:creator>Mike</dc:creator>
				<category><![CDATA[Advocacy]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Top ten]]></category>

		<guid isPermaLink="false">http://www.blog.pythonlibrary.org/?p=2175</guid>
		<description><![CDATA[Everyone likes retrospective articles. I&#8217;m not sure why, but lists just pull people in. Last year, my top ten list was pretty popular, so this year I&#8217;m going to do it again. This year I hit 247,901 visits and 345,452 page views over the course of the year compared with 137,727 visits and 213,814 page [...]]]></description>
			<content:encoded><![CDATA[<p>Everyone likes retrospective articles. I&#8217;m not sure why, but lists just pull people in. Last year, my <a href="http://www.blog.pythonlibrary.org/2010/12/30/top-ten-articles-of-2010/" target="_blank">top ten list</a> was pretty popular, so this year I&#8217;m going to do it again. This year I hit 247,901 visits and 345,452 page views over the course of the year compared with 137,727 visits and 213,814 page views last year. </p>
<ol>
<li><a href="http://www.blog.pythonlibrary.org/2010/03/08/a-simple-step-by-step-reportlab-tutorial/" target="_blank">A Simple Step-by-Step Reportlab Tutorial</a></li>
<p> with 16,378 page views, posted 03/08/2010</p>
<li><a href="http://www.blog.pythonlibrary.org/2010/05/14/how-to-send-email-with-python/" target="_blank">How to Send Email with Python</a> with 11,459 page views, posted 05/14/2010</li>
<li><a href="http://www.blog.pythonlibrary.org/2010/08/12/a-cx_freeze-tutorial-build-a-binary-series/" target="_blank">A cx_Freeze Tutorial</a> – Build a Binary Series! with 9,735 page views, posted 08/12/2010</li>
<li><a href="http://www.blog.pythonlibrary.org/2010/07/16/python-and-microsoft-office-using-pywin32/" target="_blank">Python and Microsoft Office – Using PyWin32</a> with 9,336 page views, posted 07/16/2010</li>
<li><a href="http://www.blog.pythonlibrary.org/2010/02/03/another-step-by-step-sqlalchemy-tutorial-part-1-of-2/" target="_blank">Another Step-by-Step SqlAlchemy Tutorial</a> (part 1 of 2) with 7,990 page views, posted 02/03/2010</li>
<li><a href="http://www.blog.pythonlibrary.org/2010/11/12/python-parsing-xml-with-minidom/" target="_blank">Python: Parsing XML with minidom</a> with 7,900 page views, posted 11/12/2010</li>
<li><a href="http://www.blog.pythonlibrary.org/2010/05/15/manipulating-pdfs-with-python-and-pypdf/" target="_blank">Manipulating PDFs with Python and pyPdf</a> with 7,304 page views, posted 05/15/2010</li>
<li><a href="http://www.blog.pythonlibrary.org/2011/01/04/wxpython-wx-listctrl-tips-and-tricks/" target="_blank">wxPython: wx.ListCtrl Tips and Tricks</a> with 7,265 page views, posted 01/04/2011</li>
<li><a href="http://www.blog.pythonlibrary.org/2010/09/21/reportlab-tables-creating-tables-in-pdfs-with-python/" target="_blank">Reportlab Tables – Creating Tables in PDFs with Python</a> with 6,634 page views, posted 09/21/2010</li>
<li><a href="http://www.blog.pythonlibrary.org/2010/09/04/python-101-how-to-open-a-file-or-program/" target="_blank">Python 101: How to Open a File or Program</a> with 6,440 page views, posted 09/04/2010</li>
</ol>
<p>Last time, I thought I&#8217;d get some articles written about other GUI toolkits during 2011, but I never really got into any. Instead, I wrote a lot of wxPython articles. As you can tell from the list above, they weren&#8217;t super popular with only one making the top ten. Maybe this year I&#8217;ll spread out a bit and actually look at some of the other GUI toolkits. I&#8217;m also planning to write more on the topics that made it into my top ten list two years running such as reportlab and SqlAlchemy. If you can think of anything involving those 3 topics that you&#8217;d like to know more about, feel free to ask in the comments and I&#8217;ll consider writing about it. </p>
<p>I hope you&#8217;re ready for another rocking year of Python programming. I know I am! </p>
<img src="http://feeds.feedburner.com/~r/TheMouseVsThePython/~4/sqYpktlUpnw" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.blog.pythonlibrary.org/2011/12/31/top-ten-articles-of-2011/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		<feedburner:origLink>http://www.blog.pythonlibrary.org/2011/12/31/top-ten-articles-of-2011/</feedburner:origLink></item>
		<item>
		<title>New Year’s Python Meme – #2012pythonmeme</title>
		<link>http://feedproxy.google.com/~r/TheMouseVsThePython/~3/Dkvj6LOIozM/</link>
		<comments>http://www.blog.pythonlibrary.org/2011/12/21/new-years-python-meme-2012pythonmeme/#comments</comments>
		<pubDate>Thu, 22 Dec 2011 02:15:30 +0000</pubDate>
		<dc:creator>Mike</dc:creator>
				<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://www.blog.pythonlibrary.org/?p=2161</guid>
		<description><![CDATA[I was reading the Python blog feed yesterday and stumbled on Tarek Ziade&#8217;s Python Meme article. I thought it sounded like a fun idea, so here&#8217;s my answers to his questions. 1. What’s the coolest Python application, framework or library you have discovered in 2011? I can&#8217;t think of anything new that I&#8217;ve really used [...]]]></description>
			<content:encoded><![CDATA[<p>I was reading the Python blog feed yesterday and stumbled on Tarek Ziade&#8217;s <a href="http://tarekziade.wordpress.com/2011/12/20/new-years-python-meme-2/" target="_blank">Python Meme article</a>. I thought it sounded like a fun idea, so here&#8217;s my answers to his questions. <span id="more-2161"></span></p>
<p><strong>1. What’s the coolest Python application, framework or library you have discovered in 2011?</strong></p>
<p>I can&#8217;t think of anything new that I&#8217;ve really used this year. However, this was the year that I started using the <a href="http://pypi.python.org/pypi/ObjectListView" target="_blank">ObjectListView </a>widget in wxPython pretty extensively. It&#8217;s a great wrapper around the wx.ListCtrl that just makes it super easy to use. This is also the year that I started working on a big <a href="http://turbogears.org/" target="_blank">TurboGears 2</a> project, but I haven&#8217;t decided if it&#8217;s my favorite yet.</p>
<p><strong>2. What new programming technique did you learn in 2011?</strong></p>
<p>Lately I&#8217;ve taken to keeping my code more organized and structured than I have in the past, splitting my components into different modules, refactoring a lot more, trying to follow the Model-View-Controller schema more, etc. I have also started using <a href="http://mercurial.selenic.com/" target="_blank">Mercurial</a> source control and <a href="https://bitbucket.org/" target="_blank">BitBucket</a> much more this year. I&#8217;m still not an expert in using them, but I know enough to keep my source mostly safe.</p>
<p><strong>3. What’s the name of the open source project you contributed the most in 2011? What did you do?</strong></p>
<p><strong>wxPython</strong>. I write a lot of documentation for it on my wiki and I help lots of people with understanding it on the wxPython mailing list and on StackOverflow.</p>
<p><strong>4. What was the Python blog or website you read the most in 2011?</strong></p>
<p>Umm, this is a tough one. I read <a href="http://ramblings.timgolden.me.uk/" target="_blank">Tim Golden&#8217;s</a> a lot with a dash of <a href="http://jessenoller.com/" target="_blank">Jesse Noller</a> and <a href="http://blog.doughellmann.com/" target="_blank">Doug Hellman</a>. I like <a href="http://www.dabeaz.com/blog.html" target="_blank">David Beazley</a> too, but he doesn&#8217;t write much.</p>
<p><strong>5. What are the three top things you want to learn in 2012?</strong></p>
<p>I need to get a better handle on Mercurial branching and merging. Learning more TurboGears and maybe another Python web framework. Testing (I know some, but not enough, especially as related to GUIs).</p>
<p><strong>6. What are the top software, app or lib you wish someone would write in 2012?</strong></p>
<p>I wish there was a better eBay wrapper. I&#8217;d like to write my own sniper script. Another nice one would be some kind of all-in-one script that could create my bit.ly link for my blog post and then submit it to the various major tech sites for me.</p>
<p>Want to do your own list? here’s how:</p>
<ul>
<li>copy-paste the questions and answer to them in your blog</li>
<li>tweet it with the <a href="https://twitter.com/#!/search/%232012pythonmeme" target="_blank">#2012pythonmeme</a> hashtag</li>
</ul>
<img src="http://feeds.feedburner.com/~r/TheMouseVsThePython/~4/Dkvj6LOIozM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.blog.pythonlibrary.org/2011/12/21/new-years-python-meme-2012pythonmeme/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://www.blog.pythonlibrary.org/2011/12/21/new-years-python-meme-2012pythonmeme/</feedburner:origLink></item>
		<item>
		<title>Book Review: Numpy 1.5 Beginner’s Guide</title>
		<link>http://feedproxy.google.com/~r/TheMouseVsThePython/~3/eTl5v5GzdHQ/</link>
		<comments>http://www.blog.pythonlibrary.org/2011/12/15/book-review-numpy-1-5-beginners-guide/#comments</comments>
		<pubDate>Fri, 16 Dec 2011 01:04:06 +0000</pubDate>
		<dc:creator>Mike</dc:creator>
				<category><![CDATA[Books]]></category>
		<category><![CDATA[Book Review]]></category>

		<guid isPermaLink="false">http://www.blog.pythonlibrary.org/?p=2147</guid>
		<description><![CDATA[This is an unorthodox review of Numpy 1.5 Beginner&#8217;s Guide by Ivan Idris. I have to say two things right off before we get into the review: This book was given to me in ebook and physical form directly from Packt Publishing I actually don&#8217;t think I have enough math to review this On that [...]]]></description>
			<content:encoded><![CDATA[<p>This is an unorthodox review of <em>Numpy 1.5 Beginner&#8217;s Guide</em> by <a href="http://ivanidris.net/wordpress/" target="_blank">Ivan Idris</a>. I have to say two things right off before we get into the review:</p>
<ul>
<li>This book was given to me in ebook and physical form directly from Packt Publishing</li>
<li>I actually don&#8217;t think I have enough math to review this</li>
</ul>
<p>On that second one, I took college Calculus, but this book talks about terms I either don&#8217;t remember or they just weren&#8217;t covered. I had Statistics I and II as well, but the author deals more with matrix manipulation and linear algebra. I think my old Finance and Accounting classes helped the most, but that was at the end of the book.<span id="more-2147"></span></p>
<h2>The Book&#8217;s Audience</h2>
<p>So who is this book actually aimed at? I think it&#8217;s aimed at high level mathematicians, scientists and stock market number crunchers. The prose is pretty good, if a bit dry. Most of the book is made up of a section introduction, a problem, how to solve it with NumPy / Matplotlib and some code examples. The code examples are snippets instead of full fledged runnable code, but you should be able to piece together most of it easily. The author doesn&#8217;t spend time importing libraries or creating fancy classes, so all the examples are very straight-forward, especially if you already understand the math equations. Note that the equations are not explained, so if you don&#8217;t know them, you&#8217;ll have to do some digging yourself.</p>
<h2>What is Covered</h2>
<p>Oodles and oodles of equations and math terms. For example, you&#8217;ll learn how to do various moving averages, Bollinger bands, trend lines, factorials, matrices (lots and lots of &#8216;em),  hanning, hamming, ufuncs, Lissajous curves, determinants, Fourier transforms, various logarithms, matrice sorting and lots more. All of that is within NumPy with occasional SciPy stuff thrown in. The examples focused on the stock market and finance and seemed to work well within that context. </p>
<p>Near the end of the book, in chapter 9, the author switches gears slightly and discusses Matplotlib a little more in depth. He had been using it off and on in previous chapters, but he covers a lot more of its basic functions in this chapter. Then in the 10th and final chapter, he delves in SciPy and even manages to mention SciKits.</p>
<p>I noticed a few minor grammatical or sentence structure issues here and there, but this is one of the better written Packt books. </p>
<h2>Wrapping Up</h2>
<p>As I mentioned, I don&#8217;t really understand a lot of this book due to the high level math. It saddens me that I either didn&#8217;t cover this when I was in high school or college or that I&#8217;ve managed to forget so much of it. However, while the author doesn&#8217;t spend much time explaining the examples, I think that the quick nature in which it is written, works. Feel free to download <a href="http://www.packtpub.com/sites/default/files/5306OS-Chapter-3-Get-into-Terms-with-Commonly-Used-Functions.pdf?utm_source=packtpub&#038;utm_medium=free&#038;utm_campaign=pdf" target="_blank">Chapter 3</a> to get a taste of what it&#8217;s like. If you&#8217;re into this sort of thing or want to learn how to apply this sort of thing in Python, than I think this book may be right up your alley.</p>
<table>
<tr>
<td><a href="http://www.blog.pythonlibrary.org/wp-content/uploads/2010/12/numpy_book.jpg"><img src="http://www.blog.pythonlibrary.org/wp-content/uploads/2010/12/numpy_book-241x300.jpg" alt="" title="numpy_book_cover" width="241" height="300" class="aligncenter size-medium wp-image-2061" /></a></td>
<td>
<h3>Numpy 1.5 Beginner&#8217;s Guide</h3>
<p><p>By Ivan Idris</p>
<p><strong><a href="http://www.amazon.com/gp/product/1849515301/ref=as_li_ss_tl?ie=UTF8&#038;tag=thmovsthpy-20&#038;linkCode=as2&#038;camp=217145&#038;creative=399373&#038;creativeASIN=1849515301" rel="nofollow">Buy from Amazon</a></strong></p>
<p><strong><a href="http://www.packtpub.com/numpy-1-5-using-real-world-examples-beginners-guide/book">Packt</a></strong></br>
</td>
</tr>
</table>
<img src="http://feeds.feedburner.com/~r/TheMouseVsThePython/~4/eTl5v5GzdHQ" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.blog.pythonlibrary.org/2011/12/15/book-review-numpy-1-5-beginners-guide/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<feedburner:origLink>http://www.blog.pythonlibrary.org/2011/12/15/book-review-numpy-1-5-beginners-guide/</feedburner:origLink></item>
		<item>
		<title>wxPython Project Phoenix Documentation Beta Released</title>
		<link>http://feedproxy.google.com/~r/TheMouseVsThePython/~3/eqv_cCQrlo8/</link>
		<comments>http://www.blog.pythonlibrary.org/2011/12/14/wxpython-phoenix-documentation-beta-released/#comments</comments>
		<pubDate>Wed, 14 Dec 2011 17:15:25 +0000</pubDate>
		<dc:creator>Mike</dc:creator>
				<category><![CDATA[wxPython]]></category>

		<guid isPermaLink="false">http://www.blog.pythonlibrary.org/?p=2142</guid>
		<description><![CDATA[The wxPython project&#8217;s Phoenix release is slowly coming along. Phoenix is the codename for the new wxPython that will support both Python 2.x and 3.x. Anyway, Andrea Gavana has put together some autogenerated documentation using Sphinx on top of Doxygen. You can read about the announcement including any known issues on the wxPython mailing list. [...]]]></description>
			<content:encoded><![CDATA[<p>The wxPython project&#8217;s Phoenix release is slowly coming along. Phoenix is the codename for the new wxPython that will support both Python 2.x and 3.x. Anyway, Andrea Gavana has put together some <a href="http://xoomer.virgilio.it/infinity77/Phoenix/main.html" target="_blank">autogenerated documentation</a> using Sphinx on top of Doxygen. You can read about the announcement including any known issues on the wxPython <a href="https://groups.google.com/forum/#!topic/wxpython-users/kz2b6LY7A5I" target="_blank">mailing list</a>.</p>
<p>For those of you who are brave, you can also read about a snapshot build of Phoenix <a href=" https://groups.google.com/forum/#!topic/wxpython-dev/b_PfRG3LOXY" target="_blank">here</a> or download the a tarball <a href="http://wxpython.org/Phoenix/snapshot-builds/" target="_blank">here</a>. Note: These tarballs are only for Mac and Window users and they are not completely working.</p>
<p>For those of you who don&#8217;t know anything about Project Phoenix, you can read about it on the <a href="http://wiki.wxpython.org/ProjectPhoenix" target="_blank">wxPython wiki</a>.</p>
<img src="http://feeds.feedburner.com/~r/TheMouseVsThePython/~4/eqv_cCQrlo8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.blog.pythonlibrary.org/2011/12/14/wxpython-phoenix-documentation-beta-released/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://www.blog.pythonlibrary.org/2011/12/14/wxpython-phoenix-documentation-beta-released/</feedburner:origLink></item>
		<item>
		<title>wxPython 101: Creating Taskbar Icons</title>
		<link>http://feedproxy.google.com/~r/TheMouseVsThePython/~3/wa38KVuGjWE/</link>
		<comments>http://www.blog.pythonlibrary.org/2011/12/13/wxpython-101-creating-taskbar-icons/#comments</comments>
		<pubDate>Wed, 14 Dec 2011 02:27:30 +0000</pubDate>
		<dc:creator>Mike</dc:creator>
				<category><![CDATA[Python]]></category>
		<category><![CDATA[wxPython]]></category>

		<guid isPermaLink="false">http://www.blog.pythonlibrary.org/?p=1997</guid>
		<description><![CDATA[Have you ever wondered how to create those little status icons in the Windows System Tray that usually appear on the lower right of your screen? The wxPython toolkit provides a pretty simple way to do just that and this article will walk you through the process. Working the Code For reasons I don&#8217;t quite [...]]]></description>
			<content:encoded><![CDATA[<p>Have you ever wondered how to create those little status icons in the Windows System Tray that usually appear on the lower right of your screen? The wxPython toolkit provides a pretty simple way to do just that and this article will walk you through the process.<span id="more-1997"></span></p>
<h2>Working the Code</h2>
<p>For reasons I don&#8217;t quite understand, the wx component we want is wx.TaskBarIcon. I assume it&#8217;s called that because the System Tray is part of the TaskBar or maybe they don&#8217;t differentiate between the TaskBar and the tray area in other operating systems. Anyway, first you need an icon to use. You can get your image wherever you like. In this example, we&#8217;re going to use an an &#8220;envelope&#8221; image that I turned into Python code using wxPython&#8217;s handy img2py utility. When you run an image through img2py, you&#8217;ll end up with something like this:</p>
<pre class="python"><span style="color: #808080; font-style: italic;">#----------------------------------------------------------------------</span>
<span style="color: #808080; font-style: italic;"># This file was generated by img2py.py</span>
<span style="color: #808080; font-style: italic;">#</span>
<span style="color: #ff7700;font-weight:bold;">from</span> wx <span style="color: #ff7700;font-weight:bold;">import</span> ImageFromStream, BitmapFromImage
<span style="color: #ff7700;font-weight:bold;">from</span> wx <span style="color: #ff7700;font-weight:bold;">import</span> EmptyIcon
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">cStringIO</span>, <span style="color: #dc143c;">zlib</span>
&nbsp;
&nbsp;
<span style="color: #ff7700;font-weight:bold;">def</span> getData<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>:
    <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #dc143c;">zlib</span>.<span style="color: black;">decompress</span><span style="color: black;">&#40;</span>
<span style="color: #483d8b;">'x<span style="color: #000099; font-weight: bold;">\x</span>da<span style="color: #000099; font-weight: bold;">\x</span>01<span style="color: #000099; font-weight: bold;">\x</span>86<span style="color: #000099; font-weight: bold;">\x</span>01y<span style="color: #000099; font-weight: bold;">\x</span>fe<span style="color: #000099; font-weight: bold;">\x</span>89PNG<span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\x</span>1a<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\x</span>00<span style="color: #000099; font-weight: bold;">\x</span>00<span style="color: #000099; font-weight: bold;">\x</span>00<span style="color: #000099; font-weight: bold;">\r</span>IHDR<span style="color: #000099; font-weight: bold;">\x</span>00<span style="color: #000099; font-weight: bold;">\x</span>00<span style="color: #000099; font-weight: bold;">\x</span>00 <span style="color: #000099; font-weight: bold;">\x</span>00<span style="color: #000099; font-weight: bold;">\</span>
<span style="color: #000099; font-weight: bold;">\x</span>00<span style="color: #000099; font-weight: bold;">\x</span>00 <span style="color: #000099; font-weight: bold;">\x</span>08<span style="color: #000099; font-weight: bold;">\x</span>06<span style="color: #000099; font-weight: bold;">\x</span>00<span style="color: #000099; font-weight: bold;">\x</span>00<span style="color: #000099; font-weight: bold;">\x</span>00szz<span style="color: #000099; font-weight: bold;">\x</span>f4<span style="color: #000099; font-weight: bold;">\x</span>00<span style="color: #000099; font-weight: bold;">\x</span>00<span style="color: #000099; font-weight: bold;">\x</span>00<span style="color: #000099; font-weight: bold;">\x</span>04sBIT<span style="color: #000099; font-weight: bold;">\x</span>08<span style="color: #000099; font-weight: bold;">\x</span>08<span style="color: #000099; font-weight: bold;">\x</span>08<span style="color: #000099; font-weight: bold;">\x</span>08|<span style="color: #000099; font-weight: bold;">\</span>
<span style="color: #000099; font-weight: bold;">\x</span>08d<span style="color: #000099; font-weight: bold;">\x</span>88<span style="color: #000099; font-weight: bold;">\x</span>00<span style="color: #000099; font-weight: bold;">\x</span>00<span style="color: #000099; font-weight: bold;">\x</span>01=IDATX<span style="color: #000099; font-weight: bold;">\x</span>85<span style="color: #000099; font-weight: bold;">\x</span>ed<span style="color: #000099; font-weight: bold;">\x</span>97[<span style="color: #000099; font-weight: bold;">\x</span>9a<span style="color: #000099; font-weight: bold;">\x</span>83 <span style="color: #000099; font-weight: bold;">\x</span>0c<span style="color: #000099; font-weight: bold;">\x</span>85Ol<span style="color: #000099; font-weight: bold;">\x</span>f7<span style="color: #000099; font-weight: bold;">\x</span>1566#<span style="color: #000099; font-weight: bold;">\x</span>ec<span style="color: #000099; font-weight: bold;">\</span>
<span style="color: #000099; font-weight: bold;">\x</span>ac,<span style="color: #000099; font-weight: bold;">\x</span>ace<span style="color: #000099; font-weight: bold;">\x</span>1e<span style="color: #000099; font-weight: bold;">\x</span>e4b <span style="color: #000099; font-weight: bold;">\x</span>fa<span style="color: #000099; font-weight: bold;">\x</span>a9<span style="color: #000099; font-weight: bold;">\x</span>a3<span style="color: #000099; font-weight: bold;">\x</span>e5<span style="color: #000099; font-weight: bold;">\x</span>c5&lt;<span style="color: #000099; font-weight: bold;">\x</span>15$9<span style="color: #000099; font-weight: bold;">\x</span>7fO<span style="color: #000099; font-weight: bold;">\x</span>c0<span style="color: #000099; font-weight: bold;">\x</span>0b<span style="color: #000099; font-weight: bold;">\x</span>d1<span style="color: #000099; font-weight: bold;">\x</span>f0@<span style="color: #000099; font-weight: bold;">\x</span>cf<span style="color: #000099; font-weight: bold;">\</span>
<span style="color: #000099; font-weight: bold;">\x</span>18<span style="color: #000099; font-weight: bold;">\x</span>ba<span style="color: #000099; font-weight: bold;">\x</span>aa<span style="color: #000099; font-weight: bold;">\x</span>df<span style="color: #000099; font-weight: bold;">\x</span>007<span style="color: #000099; font-weight: bold;">\x</span>00<span style="color: #000099; font-weight: bold;">\x</span>80g<span style="color: #000099; font-weight: bold;">\x</span>fa1<span style="color: #000099; font-weight: bold;">\x</span>fe<span style="color: #000099; font-weight: bold;">\x</span>fe<span style="color: #000099; font-weight: bold;">\x</span>84o<span style="color: #000099; font-weight: bold;">\x</span>89ZkA<span style="color: #000099; font-weight: bold;">\x</span>c3<span style="color: #000099; font-weight: bold;">\x</span>83<span style="color: #000099; font-weight: bold;">\x</span>04<span style="color: #000099; font-weight: bold;">\x</span>00<span style="color: #000099; font-weight: bold;">\x</span>00<span style="color: #000099; font-weight: bold;">\</span>
<span style="color: #000099; font-weight: bold;">\x</span>8c<span style="color: #000099; font-weight: bold;">\x</span>e3x<span style="color: #000099; font-weight: bold;">\x</span>a1,<span style="color: #000099; font-weight: bold;">\x</span>01<span style="color: #000099; font-weight: bold;">\x</span>08p<span style="color: #000099; font-weight: bold;">\x</span>ce<span style="color: #000099; font-weight: bold;">\x</span>89Y<span style="color: #000099; font-weight: bold;">\x</span>d1<span style="color: #000099; font-weight: bold;">\x</span>82<span style="color: #000099; font-weight: bold;">\x</span>fa<span style="color: #000099; font-weight: bold;">\x</span>e2y<span style="color: #000099; font-weight: bold;">\x</span>c2P<span style="color: #000099; font-weight: bold;">\x</span>c5<span style="color: #000099; font-weight: bold;">\x</span>1b<span style="color: #000099; font-weight: bold;">\x</span>00c<span style="color: #000099; font-weight: bold;">\x</span>cc<span style="color: #000099; font-weight: bold;">\x</span>05<span style="color: #000099; font-weight: bold;">\</span>
<span style="color: #000099; font-weight: bold;">\x</span>10Sg<span style="color: #000099; font-weight: bold;">\x</span>9ds0<span style="color: #000099; font-weight: bold;">\x</span>c6<span style="color: #000099; font-weight: bold;">\x</span>ac<span style="color: #000099; font-weight: bold;">\x</span>030<span style="color: #000099; font-weight: bold;">\x</span>f3<span style="color: #000099; font-weight: bold;">\x</span>05<span style="color: #000099; font-weight: bold;">\x</span>10<span style="color: #000099; font-weight: bold;">\x</span>94<span style="color: #000099; font-weight: bold;">\x</span>c5<span style="color: #000099; font-weight: bold;">\x</span>99y<span style="color: #000099; font-weight: bold;">\x</span>1d<span style="color: #000099; font-weight: bold;">\x</span>e0<span style="color: #000099; font-weight: bold;">\\</span><span style="color: #000099; font-weight: bold;">\x</span>88<span style="color: #000099; font-weight: bold;">\x</span>c9z<span style="color: #000099; font-weight: bold;">\x</span>e7l<span style="color: #000099; font-weight: bold;">\</span>
<span style="color: #000099; font-weight: bold;">\x</span>147<span style="color: #000099; font-weight: bold;">\x</span>ea*<span style="color: #000099; font-weight: bold;">\x</span>f5<span style="color: #000099; font-weight: bold;">\x</span>18<span style="color: #000099; font-weight: bold;">\x</span>fe<span style="color: #000099; font-weight: bold;">\x</span>0fB<span style="color: #000099; font-weight: bold;">\x</span>f6<span style="color: #000099; font-weight: bold;">\x</span>bc<span style="color: #000099; font-weight: bold;">\x</span>fcs<span style="color: #000099; font-weight: bold;">\x</span>fd<span style="color: #000099; font-weight: bold;">\x</span>90-<span style="color: #000099; font-weight: bold;">\x</span>de<span style="color: #000099; font-weight: bold;">\x</span>07<span style="color: #000099; font-weight: bold;">\x</span>8eC<span style="color: #000099; font-weight: bold;">\x</span>c8<span style="color: #000099; font-weight: bold;">\x</span>9e<span style="color: #000099; font-weight: bold;">\x</span>17<span style="color: #000099; font-weight: bold;">\</span>
<span style="color: #000099; font-weight: bold;">\x</span>dbI]<span style="color: #000099; font-weight: bold;">\x</span>bdz#:<span style="color: #000099; font-weight: bold;">\x</span>06Q<span style="color: #000099; font-weight: bold;">\x</span>f7<span style="color: #000099; font-weight: bold;">\x</span>bc8<span style="color: #000099; font-weight: bold;">\x</span>b2<span style="color: #000099; font-weight: bold;">\x</span>1b`<span style="color: #000099; font-weight: bold;">\x</span>1f<span style="color: #000099; font-weight: bold;">\x</span>c4R<span style="color: #000099; font-weight: bold;">\x</span>cf<span style="color: #000099; font-weight: bold;">\x</span>83<span style="color: #000099; font-weight: bold;">\x</span>b8<span style="color: #000099; font-weight: bold;">\x</span>be<span style="color: #000099; font-weight: bold;">\x</span>1b %<span style="color: #000099; font-weight: bold;">\x</span>16<span style="color: #000099; font-weight: bold;">\x</span>08<span style="color: #000099; font-weight: bold;">\</span>
<span style="color: #000099; font-weight: bold;">\x</span>12<span style="color: #000099; font-weight: bold;">\x</span>f3Z<span style="color: #000099; font-weight: bold;">\x</span>cfu<span style="color: #000099; font-weight: bold;">\x</span>e1<span style="color: #000099; font-weight: bold;">\x</span>dd<span style="color: #000099; font-weight: bold;">\x</span>0eL<span style="color: #000099; font-weight: bold;">\x</span>89<span style="color: #000099; font-weight: bold;">\x</span>de<span style="color: #000099; font-weight: bold;">\x</span>bf<span style="color: #000099; font-weight: bold;">\x</span>c0<span style="color: #000099; font-weight: bold;">\x</span>cc3<span style="color: #000099; font-weight: bold;">\'</span>lU<span style="color: #000099; font-weight: bold;">\x</span>b0=<span style="color: #000099; font-weight: bold;">\x</span>e7<span style="color: #000099; font-weight: bold;">\x</span>cc<span style="color: #000099; font-weight: bold;">\x</span>0c<span style="color: #000099; font-weight: bold;">\x</span>ef<span style="color: #000099; font-weight: bold;">\</span>
<span style="color: #000099; font-weight: bold;">\x</span>fd<span style="color: #000099; font-weight: bold;">\x</span>02<span style="color: #000099; font-weight: bold;">\x</span>88<span style="color: #000099; font-weight: bold;">\x</span>8c<span style="color: #000099; font-weight: bold;">\x</span>a7:<span style="color: #000099; font-weight: bold;">\x</span>1b<span style="color: #000099; font-weight: bold;">\x</span>13<span style="color: #000099; font-weight: bold;">\x</span>bd<span style="color: #000099; font-weight: bold;">\x</span>f7<span style="color: #000099; font-weight: bold;">\x</span>d1<span style="color: #000099; font-weight: bold;">\x</span>ca<span style="color: #000099; font-weight: bold;">\x</span>90<span style="color: #000099; font-weight: bold;">\x</span>0b<span style="color: #000099; font-weight: bold;">\'</span><span style="color: #000099; font-weight: bold;">\x</span>b1:<span style="color: #000099; font-weight: bold;">\x</span>8a<span style="color: #000099; font-weight: bold;">\x</span>f8<span style="color: #000099; font-weight: bold;">\x</span>b4&gt;A<span style="color: #000099; font-weight: bold;">\</span>
<span style="color: #000099; font-weight: bold;">\x</span>94|<span style="color: #000099; font-weight: bold;">\x</span>dd<span style="color: #000099; font-weight: bold;">\x</span>81E<span style="color: #000099; font-weight: bold;">\x</span>80)y~|(<span style="color: #000099; font-weight: bold;">\x</span>17<span style="color: #000099; font-weight: bold;">\x</span>d6<span style="color: #000099; font-weight: bold;">\x</span>a2<span style="color: #000099; font-weight: bold;">\x</span>15&quot;0<span style="color: #000099; font-weight: bold;">\x</span>87<span style="color: #000099; font-weight: bold;">\x</span>e8`<span style="color: #000099; font-weight: bold;">\x</span>c9<span style="color: #000099; font-weight: bold;">\x</span>df<span style="color: #000099; font-weight: bold;">\x</span>00@<span style="color: #000099; font-weight: bold;">\x</span>d9v<span style="color: #000099; font-weight: bold;">\x</span>19<span style="color: #000099; font-weight: bold;">\x</span>b2<span style="color: #000099; font-weight: bold;">\</span>
<span style="color: #000099; font-weight: bold;">\x</span>f0|}-&lt;<span style="color: #000099; font-weight: bold;">\x</span>1f3<span style="color: #000099; font-weight: bold;">\x</span>9bXo<span style="color: #000099; font-weight: bold;">\x</span>e3<span style="color: #000099; font-weight: bold;">\x</span>1e(<span style="color: #000099; font-weight: bold;">\x</span>e2u<span style="color: #000099; font-weight: bold;">\x</span>cf<span style="color: #000099; font-weight: bold;">\x</span>ea<span style="color: #000099; font-weight: bold;">\x</span>cd<span style="color: #000099; font-weight: bold;">\x</span>b4},<span style="color: #000099; font-weight: bold;">\x</span>f7<span style="color: #000099; font-weight: bold;">\x</span>c4<span style="color: #000099; font-weight: bold;">\n</span>@<span style="color: #000099; font-weight: bold;">\x</span>b1<span style="color: #000099; font-weight: bold;">\x</span>fd<span style="color: #000099; font-weight: bold;">\x</span>98<span style="color: #000099; font-weight: bold;">\</span>
<span style="color: #000099; font-weight: bold;">\x</span>d0<span style="color: #000099; font-weight: bold;">\x</span>dax<span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\x</span>a2y<span style="color: #000099; font-weight: bold;">\x</span>18<span style="color: #000099; font-weight: bold;">\x</span>b5q<span style="color: #000099; font-weight: bold;">\x</span>1e<span style="color: #000099; font-weight: bold;">\x</span>c8<span style="color: #000099; font-weight: bold;">\x</span>a6<span style="color: #000099; font-weight: bold;">\x</span>87<span style="color: #000099; font-weight: bold;">\x</span>d1<span style="color: #000099; font-weight: bold;">\x</span>99<span style="color: #000099; font-weight: bold;">\x</span>d6<span style="color: #000099; font-weight: bold;">\x</span>eb<span style="color: #000099; font-weight: bold;">\x</span>e3<span style="color: #000099; font-weight: bold;">\x</span>aaz<span style="color: #000099; font-weight: bold;">\x</span>fa0<span style="color: #000099; font-weight: bold;">\x</span>e9<span style="color: #000099; font-weight: bold;">\</span>
<span style="color: #000099; font-weight: bold;">\x</span>f5J<span style="color: #000099; font-weight: bold;">\x</span>96<span style="color: #000099; font-weight: bold;">\x</span>01<span style="color: #000099; font-weight: bold;">\x</span>c2<span style="color: #000099; font-weight: bold;">\x</span>e7<span style="color: #000099; font-weight: bold;">\x</span>fd5<span style="color: #000099; font-weight: bold;">\x</span>00<span style="color: #000099; font-weight: bold;">\x</span>00-@<span style="color: #000099; font-weight: bold;">\x</span>af<span style="color: #000099; font-weight: bold;">\x</span>e8<span style="color: #000099; font-weight: bold;">\x</span>feZ~<span style="color: #000099; font-weight: bold;">\x</span>03t<span style="color: #000099; font-weight: bold;">\x</span>07<span style="color: #000099; font-weight: bold;">\x</span>f8<span style="color: #000099; font-weight: bold;">\x</span>03<span style="color: #000099; font-weight: bold;">\x</span>82<span style="color: #000099; font-weight: bold;">\x</span>ac<span style="color: #000099; font-weight: bold;">\</span>
<span style="color: #000099; font-weight: bold;">\x</span>a4VT<span style="color: #000099; font-weight: bold;">\x</span>fd<span style="color: #000099; font-weight: bold;">\x</span>cd<span style="color: #000099; font-weight: bold;">\x</span>a3<span style="color: #000099; font-weight: bold;">\x</span>00<span style="color: #000099; font-weight: bold;">\x</span>00<span style="color: #000099; font-weight: bold;">\x</span>00<span style="color: #000099; font-weight: bold;">\x</span>00IEND<span style="color: #000099; font-weight: bold;">\x</span>aeB`<span style="color: #000099; font-weight: bold;">\x</span>82<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\x</span>a7<span style="color: #000099; font-weight: bold;">\x</span>a9<span style="color: #000099; font-weight: bold;">\x</span>a8'</span> <span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">def</span> getBitmap<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>:
    <span style="color: #ff7700;font-weight:bold;">return</span> BitmapFromImage<span style="color: black;">&#40;</span>getImage<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">def</span> getImage<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>:
    stream = <span style="color: #dc143c;">cStringIO</span>.<span style="color: #dc143c;">StringIO</span><span style="color: black;">&#40;</span>getData<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
    <span style="color: #ff7700;font-weight:bold;">return</span> ImageFromStream<span style="color: black;">&#40;</span>stream<span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">def</span> getIcon<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>:
    icon = EmptyIcon<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
    icon.<span style="color: black;">CopyFromBitmap</span><span style="color: black;">&#40;</span>getBitmap<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
    <span style="color: #ff7700;font-weight:bold;">return</span> icon</pre>
<p>The image data is all in the <strong>getData</strong> function. I am going to call this file &#8220;email_ico.py&#8221;. We&#8217;ll import it into our main program and call its <strong>getIcon</strong> method to acquire the icon we want to use. Let&#8217;s take a look at the main application now:</p>
<pre class="python"><span style="color: #ff7700;font-weight:bold;">import</span> wx
<span style="color: #ff7700;font-weight:bold;">from</span> mail_ico <span style="color: #ff7700;font-weight:bold;">import</span> getIcon
&nbsp;
<span style="color: #808080; font-style: italic;">########################################################################</span>
<span style="color: #ff7700;font-weight:bold;">class</span> MailIcon<span style="color: black;">&#40;</span>wx.<span style="color: black;">TaskBarIcon</span><span style="color: black;">&#41;</span>:
    TBMENU_RESTORE = wx.<span style="color: black;">NewId</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
    TBMENU_CLOSE   = wx.<span style="color: black;">NewId</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
    TBMENU_CHANGE  = wx.<span style="color: black;">NewId</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
    TBMENU_REMOVE  = wx.<span style="color: black;">NewId</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
&nbsp;
    <span style="color: #808080; font-style: italic;">#----------------------------------------------------------------------</span>
    <span style="color: #ff7700;font-weight:bold;">def</span> <span style="color: #0000cd;">__init__</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, frame<span style="color: black;">&#41;</span>:
        wx.<span style="color: black;">TaskBarIcon</span>.<span style="color: #0000cd;">__init__</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span><span style="color: black;">&#41;</span>
        <span style="color: #008000;">self</span>.<span style="color: black;">frame</span> = frame
&nbsp;
        <span style="color: #808080; font-style: italic;"># Set the image</span>
        <span style="color: #008000;">self</span>.<span style="color: black;">tbIcon</span> = getIcon<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
&nbsp;
        <span style="color: #008000;">self</span>.<span style="color: black;">SetIcon</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span>.<span style="color: black;">tbIcon</span>, <span style="color: #483d8b;">&quot;Test&quot;</span><span style="color: black;">&#41;</span>
&nbsp;
        <span style="color: #808080; font-style: italic;"># bind some events</span>
        <span style="color: #008000;">self</span>.<span style="color: black;">Bind</span><span style="color: black;">&#40;</span>wx.<span style="color: black;">EVT_MENU</span>, <span style="color: #008000;">self</span>.<span style="color: black;">OnTaskBarClose</span>, <span style="color: #008000;">id</span>=<span style="color: #008000;">self</span>.<span style="color: black;">TBMENU_CLOSE</span><span style="color: black;">&#41;</span>
        <span style="color: #008000;">self</span>.<span style="color: black;">Bind</span><span style="color: black;">&#40;</span>wx.<span style="color: black;">EVT_TASKBAR_LEFT_DOWN</span>, <span style="color: #008000;">self</span>.<span style="color: black;">OnTaskBarLeftClick</span><span style="color: black;">&#41;</span>
&nbsp;
    <span style="color: #808080; font-style: italic;">#----------------------------------------------------------------------</span>
    <span style="color: #ff7700;font-weight:bold;">def</span> CreatePopupMenu<span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, evt=<span style="color: #008000;">None</span><span style="color: black;">&#41;</span>:
        <span style="color: #483d8b;">&quot;&quot;</span><span style="color: #483d8b;">&quot;
        This method is called by the base class when it needs to popup
        the menu for the default EVT_RIGHT_DOWN event.  Just create
        the menu how you want it and return it from this function,
        the base class takes care of the rest.
        &quot;</span><span style="color: #483d8b;">&quot;&quot;</span>
        menu = wx.<span style="color: black;">Menu</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
        menu.<span style="color: black;">Append</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span>.<span style="color: black;">TBMENU_RESTORE</span>, <span style="color: #483d8b;">&quot;Open Program&quot;</span><span style="color: black;">&#41;</span>
        menu.<span style="color: black;">Append</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span>.<span style="color: black;">TBMENU_CHANGE</span>, <span style="color: #483d8b;">&quot;Show all the Items&quot;</span><span style="color: black;">&#41;</span>
        menu.<span style="color: black;">AppendSeparator</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
        menu.<span style="color: black;">Append</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span>.<span style="color: black;">TBMENU_CLOSE</span>,   <span style="color: #483d8b;">&quot;Exit Program&quot;</span><span style="color: black;">&#41;</span>
        <span style="color: #ff7700;font-weight:bold;">return</span> menu
&nbsp;
    <span style="color: #808080; font-style: italic;">#----------------------------------------------------------------------</span>
    <span style="color: #ff7700;font-weight:bold;">def</span> OnTaskBarActivate<span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, evt<span style="color: black;">&#41;</span>:
        <span style="color: #483d8b;">&quot;&quot;</span><span style="color: #483d8b;">&quot;&quot;</span><span style="color: #483d8b;">&quot;&quot;</span>
        <span style="color: #ff7700;font-weight:bold;">pass</span>
&nbsp;
    <span style="color: #808080; font-style: italic;">#----------------------------------------------------------------------</span>
    <span style="color: #ff7700;font-weight:bold;">def</span> OnTaskBarClose<span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, evt<span style="color: black;">&#41;</span>:
        <span style="color: #483d8b;">&quot;&quot;</span><span style="color: #483d8b;">&quot;
        Destroy the taskbar icon and frame from the taskbar icon itself
        &quot;</span><span style="color: #483d8b;">&quot;&quot;</span>
        <span style="color: #008000;">self</span>.<span style="color: black;">frame</span>.<span style="color: black;">Close</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
&nbsp;
    <span style="color: #808080; font-style: italic;">#----------------------------------------------------------------------</span>
    <span style="color: #ff7700;font-weight:bold;">def</span> OnTaskBarLeftClick<span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, evt<span style="color: black;">&#41;</span>:
        <span style="color: #483d8b;">&quot;&quot;</span><span style="color: #483d8b;">&quot;
        Create the right-click menu
        &quot;</span><span style="color: #483d8b;">&quot;&quot;</span>
        menu = <span style="color: #008000;">self</span>.<span style="color: black;">tbIcon</span>.<span style="color: black;">CreatePopupMenu</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
        <span style="color: #008000;">self</span>.<span style="color: black;">PopupMenu</span><span style="color: black;">&#40;</span>menu<span style="color: black;">&#41;</span>
        menu.<span style="color: black;">Destroy</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">########################################################################</span>
<span style="color: #ff7700;font-weight:bold;">class</span> MyForm<span style="color: black;">&#40;</span>wx.<span style="color: black;">Frame</span><span style="color: black;">&#41;</span>:
&nbsp;
    <span style="color: #808080; font-style: italic;">#----------------------------------------------------------------------</span>
    <span style="color: #ff7700;font-weight:bold;">def</span> <span style="color: #0000cd;">__init__</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span><span style="color: black;">&#41;</span>:
        wx.<span style="color: black;">Frame</span>.<span style="color: #0000cd;">__init__</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, <span style="color: #008000;">None</span>, wx.<span style="color: black;">ID_ANY</span>, <span style="color: #483d8b;">&quot;Tutorial&quot;</span>, size=<span style="color: black;">&#40;</span><span style="color: #ff4500;">500</span>,<span style="color: #ff4500;">500</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
        panel = wx.<span style="color: black;">Panel</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span><span style="color: black;">&#41;</span>
        <span style="color: #008000;">self</span>.<span style="color: black;">tbIcon</span> = MailIcon<span style="color: black;">&#40;</span><span style="color: #008000;">self</span><span style="color: black;">&#41;</span>
        <span style="color: #008000;">self</span>.<span style="color: black;">Bind</span><span style="color: black;">&#40;</span>wx.<span style="color: black;">EVT_CLOSE</span>, <span style="color: #008000;">self</span>.<span style="color: black;">onClose</span><span style="color: black;">&#41;</span>
&nbsp;
    <span style="color: #808080; font-style: italic;">#----------------------------------------------------------------------</span>
    <span style="color: #ff7700;font-weight:bold;">def</span> onClose<span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, evt<span style="color: black;">&#41;</span>:
        <span style="color: #483d8b;">&quot;&quot;</span><span style="color: #483d8b;">&quot;
        Destroy the taskbar icon and the frame
        &quot;</span><span style="color: #483d8b;">&quot;&quot;</span>
        <span style="color: #008000;">self</span>.<span style="color: black;">tbIcon</span>.<span style="color: black;">RemoveIcon</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
        <span style="color: #008000;">self</span>.<span style="color: black;">tbIcon</span>.<span style="color: black;">Destroy</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
        <span style="color: #008000;">self</span>.<span style="color: black;">Destroy</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">#----------------------------------------------------------------------</span>
<span style="color: #808080; font-style: italic;"># Run the program</span>
<span style="color: #ff7700;font-weight:bold;">if</span> __name__ == <span style="color: #483d8b;">&quot;__main__&quot;</span>:
    app = wx.<span style="color: black;">App</span><span style="color: black;">&#40;</span><span style="color: #008000;">False</span><span style="color: black;">&#41;</span>
    frame = MyForm<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>.<span style="color: black;">Show</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
    app.<span style="color: black;">MainLoop</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></pre>
<p>The first class is basically copied straight out of the wxPython demo and simplified slightly. You can look there if you need a more complete example. Anyway, we bind a couple events in our sub-classed TaskBarIcon that allow us to close the application and show a menu, respectively. You will also note that we set the icon we created in the <strong>__init__</strong> simply by calling its <strong>SetIcon</strong> method and passing in a string for its tooltip.</p>
<p>In the close method, we call the frame directly that we want it to close. A better method would be to use pubsub here. If you want to pause a moment and read about pubsub, I&#8217;ve written a little <a href="http://www.blog.pythonlibrary.org/2010/06/27/wxpython-and-pubsub-a-simple-tutorial/" target="_blank">post </a>about it too. The rest of the code is pretty self-explanatory.</p>
<p>Now we can move on to the wx.Frame sub-class. Here we basically just instantiate the TaskBarIcon class that we created earlier and we bind the frame to <strong>EVT_CLOSE</strong>. You might wonder about this. There are some got&#8217;chas with using the TaskBarIcon on Windows. If I just tell the frame to close, it closes just fine, but the icon remains and Python just kind of hangs in lala land. If you only allow the user to close using the task bar icon&#8217;s right-click menu, then you could just add a <strong>RemoveIcon</strong> method and a self.Destroy() there and you&#8217;d be good to go (for some reason, RemoveIcon isn&#8217;t enough to get rid of the TaskBarIcon, so you also need to tell it to Destroy itself too) But if you allow the user to press the little &#8220;x&#8221; in the upper right-hand corner, then you&#8217;ll need to catch <strong>EVT_CLOSE</strong> and deal with it appropriately. When you do catch this event, you can NOT just call <strong>self.Close()</strong> or you&#8217;ll end up in an infinite loop, which is why we call <strong>self.Destroy()</strong> instead. </p>
<h2>Wrapping Up</h2>
<p>Now you should be able to create your own TaskBarIcon application. I highly recommend looking at the wxPython demo to see what else you can do with it. I think adding an icon can add a bit of polish to your application, especially if you need to have it running hidden for a while and then make it pop-up at the user&#8217;s command.</p>
<h2>Further Reading</h2>
<ul>
<li><a href="http://wiki.wxpython.org/FlashingTaskbarIcon" target="_blank">Create a Flashing TaskBarIcon</a></li>
<li><a href="http://www.techniqal.com/blog/2005/07/20/creating-a-task-bar-icon-in-wxpython/" target="_blank">Another blog&#8217;s</a> take on this subject</li>
<li>The TaskBarIcon <a href="http://www.wxpython.org/docs/api/wx.TaskBarIcon-class.html" target="_blank">documentation</a></li>
</ul>
<h2>Source</h2>
<ul>
<li><a href='http://www.blog.pythonlibrary.org/wp-content/uploads/2011/12/TBI_src.tar'>TBI_src.tar</a></li>
<li><a href='http://www.blog.pythonlibrary.org/wp-content/uploads/2011/12/TBI_src.zip'>TBI_src.zip</a></li>
</ul>
<img src="http://feeds.feedburner.com/~r/TheMouseVsThePython/~4/wa38KVuGjWE" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.blog.pythonlibrary.org/2011/12/13/wxpython-101-creating-taskbar-icons/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		<feedburner:origLink>http://www.blog.pythonlibrary.org/2011/12/13/wxpython-101-creating-taskbar-icons/</feedburner:origLink></item>
		<item>
		<title>PyCon USA Registration is Open and Tutorials Are Up</title>
		<link>http://feedproxy.google.com/~r/TheMouseVsThePython/~3/tX_VeH5fv-0/</link>
		<comments>http://www.blog.pythonlibrary.org/2011/12/12/pycon-usa-registration-is-open-and-tutorials-are-up/#comments</comments>
		<pubDate>Tue, 13 Dec 2011 02:26:26 +0000</pubDate>
		<dc:creator>Mike</dc:creator>
				<category><![CDATA[Advocacy]]></category>
		<category><![CDATA[PyCon]]></category>
		<category><![CDATA[PyCon 2012]]></category>

		<guid isPermaLink="false">http://www.blog.pythonlibrary.org/?p=2133</guid>
		<description><![CDATA[The 2012 Python Conference USA opened Registration today. The official announcement doesn&#8217;t mention it, but I&#8217;m pretty sure there&#8217;s an attendance cap on this conference too of 1500 just like last year. You should sign up early not only because of the limited attendance, but because there are &#8220;Early Bird&#8221; rates which are cheaper! The [...]]]></description>
			<content:encoded><![CDATA[<p>The 2012 Python Conference USA opened Registration today. The <a href="http://pycon.blogspot.com/2011/12/registration-for-pycon-2012-opened.html" target="_blank">official announcement</a> doesn&#8217;t mention it, but I&#8217;m pretty sure there&#8217;s an attendance cap on this conference too of 1500 just like last year. You should sign up early not only because of the limited attendance, but because there are &#8220;Early Bird&#8221; rates which are cheaper!</p>
<p>The complete schedule isn&#8217;t done yet, but you can whet your appetite by checking out the <a href="http://pycon.blogspot.com/2011/12/announcing-pycon-2012-tutorials.html" target="_blank">list of tutorials</a> that were released last week. </p>
<p>I have enjoyed all the PyCons I&#8217;ve attended so far. They are a great place to learn new things, show others your talent, network with like-minded people and just relax too. This year, the conference will be in Santa Clara, California. If you can&#8217;t afford to go, they even offer Financial Assistance. So why are you waiting? </p>
<img src="http://feeds.feedburner.com/~r/TheMouseVsThePython/~4/tX_VeH5fv-0" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.blog.pythonlibrary.org/2011/12/12/pycon-usa-registration-is-open-and-tutorials-are-up/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.blog.pythonlibrary.org/2011/12/12/pycon-usa-registration-is-open-and-tutorials-are-up/</feedburner:origLink></item>
		<item>
		<title>ANN: MediaLocker – A wxPython App to Track Your Media</title>
		<link>http://feedproxy.google.com/~r/TheMouseVsThePython/~3/ZQ0OhP1Aol4/</link>
		<comments>http://www.blog.pythonlibrary.org/2011/12/09/ann-medialocker-%e2%80%93-a-wxpython-app-to-track-your-media/#comments</comments>
		<pubDate>Fri, 09 Dec 2011 14:11:01 +0000</pubDate>
		<dc:creator>Mike</dc:creator>
				<category><![CDATA[Cross-Platform]]></category>
		<category><![CDATA[wxPython]]></category>
		<category><![CDATA[MediaLocker]]></category>

		<guid isPermaLink="false">http://www.blog.pythonlibrary.org/?p=2112</guid>
		<description><![CDATA[Background ================ This is the first release of a real project that I&#8217;ve been involved in. I had written an article last month that inspired Werner Bruhin to want to take it and make it into a demonstration program for new wxPython programmers in how to do MVC and CRUD while interfacing with a database. [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.blog.pythonlibrary.org/wp-content/uploads/2011/12/medialocker1.png"><img src="http://www.blog.pythonlibrary.org/wp-content/uploads/2011/12/medialocker1-300x168.png" alt="" title="medialocker_windows" width="300" height="168" class="aligncenter size-medium wp-image-2120" /></a></p>
<p>Background<br />
================</p>
<p>This is the first release of a real project that I&#8217;ve been involved in. I had written an article last month that inspired Werner Bruhin to want to take it and make it into a demonstration program for new wxPython programmers in how to do MVC and CRUD while interfacing with a database. Thus, MediaLocker was born. We hope you like it.</p>
<p>Description<br />
================</p>
<p>A wxPython database application that can help you keep track of your media. Currently, it only tracks your Book library. You can read more about the project’s development in the following two articles:</p>
<ul>
<li><a href="http://www.blog.pythonlibrary.org/2011/11/30/improving-medialocker-wxpython-sqlalchemy-and-mvc/" target="_blank">Improving MediaLocker: wxPython, SQLAlchemy and MVC</a></li>
<li><a href="http://www.blog.pythonlibrary.org/2011/11/10/wxpython-and-sqlalchemy-an-intro-to-mvc-and-crud/" target="_blank">wxPython and SQLAlchemy: An Intro to MVC and CRUD</a></li>
</ul>
<p>Requirements<br />
================</p>
<p>- Python 2.6+<br />
- wxPython 2.8.11+ with the new pubsub (download <a href='http://www.blog.pythonlibrary.org/wp-content/uploads/2011/12/pubsub.zip'>here</a>) or wxPython 2.9.3<br />
- <a href="http://www.sqlalchemy.org" target="_blank">SQLAlchemy </a>0.7.3+<br />
- <a href="http://pypi.python.org/pypi/ObjectListView" target="_blank">ObjectListView </a>1.2</p>
<p>Configuration<br />
================</p>
<p>After you have downloaded the source, run &#8220;python setup_lib.py develop&#8221; in the main folder before you try to run &#8220;mediaLocker.py&#8221;. If you are on wxPython 2.8, download the pubsub path (above) and extract it to &#8220;C:\Python27\Lib\site-packages\wx-2.9.2-msw\wx\lib&#8221; (or wherever your wxPython is installed).</p>
<p>Source<br />
================</p>
<p>You can download the source from BitBucket: <a href="https://bitbucket.org/driscollis/medialocker" target="_blank">https://bitbucket.org/driscollis/medialocker<br />
</a> </p>
<p>You can also just download a snapshot of the current files here (uploaded 2011.12.09 @ 1138 hrs CST):</p>
<ul>
<li><a href='http://www.blog.pythonlibrary.org/wp-content/uploads/2011/12/medialocker.zip'>medialocker.zip</a></li>
<li><a href='http://www.blog.pythonlibrary.org/wp-content/uploads/2011/12/medialocker.tar'>medialocker.tar</a></li>
<li>Or just download from the tip on <a href="https://bitbucket.org/driscollis/medialocker/downloads" target="_blank">bitbucket</a></li>
</ul>
<p>How you can help<br />
================</p>
<p>Download the software and report bugs on BitBucket. We also happily accept feature requests, especially if they include patches or code.</p>
<p><em>Note: This has only been tested on Windows XP and 7</em></p>
<img src="http://feeds.feedburner.com/~r/TheMouseVsThePython/~4/ZQ0OhP1Aol4" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.blog.pythonlibrary.org/2011/12/09/ann-medialocker-%e2%80%93-a-wxpython-app-to-track-your-media/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://www.blog.pythonlibrary.org/2011/12/09/ann-medialocker-%e2%80%93-a-wxpython-app-to-track-your-media/</feedburner:origLink></item>
	</channel>
</rss><!-- Dynamic Page Served (once) in 1.952 seconds --><!-- Cached page served by WP-Cache -->

