<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Toes to the Edge &#187; wxPython</title>
	<atom:link href="http://powertwenty.com/kpd/blog/index.php/category/python/wxpython/feed" rel="self" type="application/rss+xml" />
	<link>http://powertwenty.com/kpd/blog</link>
	<description>Rowing, Python, and experiences of a Micro-ISV</description>
	<lastBuildDate>Wed, 14 Jul 2010 01:57:37 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>wxPython Font by Pixel Height</title>
		<link>http://powertwenty.com/kpd/blog/index.php/python/wxpython_font_by_pixel_height</link>
		<comments>http://powertwenty.com/kpd/blog/index.php/python/wxpython_font_by_pixel_height#comments</comments>
		<pubDate>Wed, 11 Nov 2009 11:42:44 +0000</pubDate>
		<dc:creator>kpd</dc:creator>
				<category><![CDATA[Python]]></category>
		<category><![CDATA[wxPython]]></category>

		<guid isPermaLink="false">http://powertwenty.com/kpd/blog/?p=98</guid>
		<description><![CDATA[<br/>I&#8217;ve been looking to find a way to resize a font when the window&#8217;s size changes.  Here is code that will create a font that is close as possible to a given height in pixels without specifying anything about the font width.   Osku Salerma posted some code in GitHub that did the [...]]]></description>
			<content:encoded><![CDATA[<br/><p>I&#8217;ve been looking to find a way to resize a font when the window&#8217;s size changes.  Here is code that will create a font that is close as possible to a given height in pixels without specifying anything about the font width.   <a href="http://github.com/oskusalerma">Osku Salerma</a> posted <a href="http://github.com/oskusalerma/blyte/blob/master/util.py">some code in GitHub</a> that did the trick.   </p>
<p>I changed it a bit to make it self-contained.   Here&#8217;s my modified version of his code to create a wxPython font given a height in pixels:</p>
<p><pre><code>
&lt;pre&gt;
&nbsp;&nbsp;&nbsp;&nbsp;def createFontFromHeightInPixels(self, heightInPixels, family, style, weight):
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;# return a font that&#039;s as close to &#039;heightInPixels&#039; as possible without being larger
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;# modified from code at http://github.com/oskusalerma/blyte/blob/master/util.py&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;fontSizeToTest = 6
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;bestFontSoFar = wx.Font(fontSizeToTest, family, style, weight, encoding = wx.FONTENCODING_ISO8859_1)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;closestDiffInPixelsSoFar = 1000
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;testDc = wx.MemoryDC()
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;testDc.SelectObject(wx.EmptyBitmap(512, 32)) 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;while 1:
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;testedFont = wx.Font(fontSizeToTest, family, style, weight, encoding = wx.FONTENCODING_ISO8859_1)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;testDc.SetFont(testedFont)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;heightOfTestedFont = testDc.GetTextExtent(&quot;_\xC5&quot;)[1]
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;diff = heightInPixels-heightOfTestedFont
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if diff &gt;= 0:
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if diff &lt; closestDiffInPixelsSoFar:
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;closestDiffInPixelsSoFar = diff
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;bestFontSoFar = testedFont
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else:
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;break
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;fontSizeToTest += 2
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return bestFontSoFar 
&lt;/pre&gt;
</code></pre></p>
<p>It would be used like this assuming the above function is in the window class or one of its superclasses:</p>
<p><pre><code>
&lt;pre&gt;
def __init__(self, *args, **kwds):
&nbsp;&nbsp;&nbsp;&nbsp;.
&nbsp;&nbsp;&nbsp;&nbsp;.
&nbsp;&nbsp;&nbsp;&nbsp;.
&nbsp;&nbsp;&nbsp;&nbsp;self.Bind(wx.EVT_SIZE, self.OnSize)&nbsp;&nbsp;&nbsp;&nbsp; 

def OnSize(self, event):
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;size = event.GetSize()
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;currentFont = self.GetFont()
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;newFont = self.createFontFromHeightInPixels( (size.height*0.8), 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;currentFont.GetFamily(), currentFont.GetStyle(), currentFont.GetWeight())
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;self.label_1.SetFont(newFont)
 &lt;/pre&gt;
</code></pre></p>
]]></content:encoded>
			<wfw:commentRss>http://powertwenty.com/kpd/blog/index.php/python/wxpython_font_by_pixel_height/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Update to TimeSpin Control for wxGlade</title>
		<link>http://powertwenty.com/kpd/blog/index.php/python/update_to_timespin_control_for_wxglade</link>
		<comments>http://powertwenty.com/kpd/blog/index.php/python/update_to_timespin_control_for_wxglade#comments</comments>
		<pubDate>Sat, 08 Mar 2008 20:17:52 +0000</pubDate>
		<dc:creator>kpd</dc:creator>
				<category><![CDATA[Python]]></category>
		<category><![CDATA[wxPython]]></category>

		<guid isPermaLink="false">http://powertwenty.com/kpd/blog/index.php/python/wxpython/update_to_timespin_control_for_wxglade</guid>
		<description><![CDATA[<br/>TimeSpin has a bug in that it reports the same width for GetBestSize  when AM/PM is shown and when it is not (24 hour format).  This causes an empty space to appear after the control when it is set to display time in 24 hours.  I&#8217;m not able to fix the bug [...]]]></description>
			<content:encoded><![CDATA[<br/><p>TimeSpin has a bug in that it reports the same width for <em>GetBestSize </em> when AM/PM is shown and when it is not (24 hour format).  This causes an empty space to appear after the control when it is set to display time in 24 hours.  I&#8217;m not able to fix the bug at this point, but I was able to add a workaround that adjusts the width as needed.</p>
<p><a href="http://powertwenty.com/kpd/downloads/time_spin_and_control_1.4.tar.gz">Version 1.4 of the time_spin_and_control distrubution</a> contains the workaround.</p>
]]></content:encoded>
			<wfw:commentRss>http://powertwenty.com/kpd/blog/index.php/python/update_to_timespin_control_for_wxglade/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Update to TimeCtrl/TimeSpin wxGlade extension</title>
		<link>http://powertwenty.com/kpd/blog/index.php/python/update_to_timectrl2ftimespin_wxglade_extension_</link>
		<comments>http://powertwenty.com/kpd/blog/index.php/python/update_to_timectrl2ftimespin_wxglade_extension_#comments</comments>
		<pubDate>Wed, 13 Feb 2008 12:21:29 +0000</pubDate>
		<dc:creator>kpd</dc:creator>
				<category><![CDATA[Python]]></category>
		<category><![CDATA[wxPython]]></category>

		<guid isPermaLink="false">http://powertwenty.com/kpd/blog/index.php/python/update_to_timectrl2ftimespin_wxglade_extension_</guid>
		<description><![CDATA[<br/>I added a workaround for a problem with timectrl.  
You&#8217;ll want to upgrade to the 1.4 version of the time_spin_and_control distribution if you use limited, min, max, or value parameters in Glade when specifying the control.
Edit &#8211; 3/8 &#8211; updated to version 1.4
]]></description>
			<content:encoded><![CDATA[<br/><p>I added a workaround for a <a href="http://sourceforge.net/tracker/index.php?func=detail&#038;aid=1892666&#038;group_id=9863&#038;atid=109863">problem</a> with timectrl.  </p>
<p>You&#8217;ll want to upgrade to the <a href="http://powertwenty.com/kpd/downloads/time_spin_and_control_1.4.tar.gz">1.4 version of the time_spin_and_control distribution</a> if you use limited, min, max, or value parameters in Glade when specifying the control.</p>
<p>Edit &#8211; 3/8 &#8211; updated to version 1.4</p>
]]></content:encoded>
			<wfw:commentRss>http://powertwenty.com/kpd/blog/index.php/python/update_to_timectrl2ftimespin_wxglade_extension_/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Adding a TimeCtrl Widget to wxGlade</title>
		<link>http://powertwenty.com/kpd/blog/index.php/python/adding_a_timectrl_widget_to_wxglade</link>
		<comments>http://powertwenty.com/kpd/blog/index.php/python/adding_a_timectrl_widget_to_wxglade#comments</comments>
		<pubDate>Mon, 11 Feb 2008 12:17:46 +0000</pubDate>
		<dc:creator>kpd</dc:creator>
				<category><![CDATA[Python]]></category>
		<category><![CDATA[wxPython]]></category>

		<guid isPermaLink="false">http://powertwenty.com/kpd/blog/index.php/python/adding_a_timectrl_widget_to_wxglade</guid>
		<description><![CDATA[<br/>The program I&#8217;m working on (ErgMate) requires entry of hours/mins/seconds durations.  I just defined input as total number of seconds for the initial prototypes, but the time has come to make it more usable.   I was able to create the bridge code necessary to add the wx.lib.masked.TimeCtrl to the wxGlade widget palette [...]]]></description>
			<content:encoded><![CDATA[<br/><p>The program I&#8217;m working on (<a href="http://www.powertwenty.com/ergmate/index.html">ErgMate</a>) requires entry of hours/mins/seconds durations.  I just defined input as total number of seconds for the initial prototypes, but the time has come to make it more usable.   I was able to create the bridge code necessary to add the wx.lib.masked.TimeCtrl to the wxGlade widget palette by following examples from Alberto Griggio .   </p>
<p>The normal TimeCtrl can bind to an external scroll button.   The package also includes a new control called TimeSpin.  It is based on Andrea Gavana&#8217;s FloatSpin control, and provides both a TimeCtrl and scroll button in one control.  TimeSpin does not accept the <em>format </em>nor the <em>scrollBar </em>parameters, otherwise it should be a drop-in replacement for TimeCtrl.  Let me know if I missed something important in the interface.</p>
<p><a href="http://powertwenty.com/kpd/blog/wp-content/uploads/TimeSpinInGlade.png"><img src="http://powertwenty.com/kpd/blog/wp-content/uploads/_TimeSpinInGlade.png" width="231" height="250" alt="" title=""  /></a></p>
<p>There is (at least!) one minor problem with TimeSpin: It seems to report too large a width &#8211; its bounding box is actually wider than the displayed control.   I&#8217;d appreciate anyone with more knowledge of wxPython than I looking into it and sending a patch.  For now it&#8217;s good enough to get started using.</p>
<p>Both time widgets are added to wxGlade by untarring the <a href="http://powertwenty.com/kpd/downloads/time_spin_and_control_1.4.tar.gz">time_spin_and_control distribution</a> from within your .wxglade directory. The included README contains more details.</p>
<p>Edit:<br />
1.1 &#8211; fixed codegen problem w/value<br />
1.2 &#8211; fixed loading problem when presetting a value<br />
1.3 &#8211; added workaround for bug in timectrl when using min/max/limited settings</p>
]]></content:encoded>
			<wfw:commentRss>http://powertwenty.com/kpd/blog/index.php/python/adding_a_timectrl_widget_to_wxglade/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Exception when Generating Code from wxGlade &#8211; and how to fix it</title>
		<link>http://powertwenty.com/kpd/blog/index.php/python/wxpython/exception_when_generating_code_from_wxglade_-_and_how_to_fix_it</link>
		<comments>http://powertwenty.com/kpd/blog/index.php/python/wxpython/exception_when_generating_code_from_wxglade_-_and_how_to_fix_it#comments</comments>
		<pubDate>Sat, 02 Feb 2008 13:18:19 +0000</pubDate>
		<dc:creator>kpd</dc:creator>
				<category><![CDATA[wxPython]]></category>

		<guid isPermaLink="false">http://powertwenty.com/kpd/blog/index.php/python/wxpython/exception_when_generating_code_from_wxglade_-_and_how_to_fix_it</guid>
		<description><![CDATA[<br/>This morning I started getting the following exception when generating code from wxGlade:

&#60;pre&#62;
Traceback (most recent call last):
&#160;&#160;File &#34;c:\temp\wxGlade\application.py&#34;, line 394, in generate_code
&#160;&#160;&#160;&#160;class_names=class_names)
&#160;&#160;File &#34;c:\temp\wxGlade\xml_parse.py&#34;, line 503, in __init__
&#160;&#160; .
&#160;&#160; .
&#160;&#160; .
&#160;&#160;File &#34;c:\temp\wxGlade\xml_parse.py&#34;, line 593, in endElement
&#160;&#160;&#160;&#160;self.code_writer.add_class(obj)
&#160;&#160;File &#34;c:\temp\wxGlade\codegen\py_codegen.py&#34;, line 640, in add_class
&#160;&#160;&#160;&#160;indentation = prev_src.spaces[code_obj.klass]
KeyError: &#039;FancyListControl&#039;
&#60;/pre&#62;

There was only one mention of a similar problem on the wxGlade mailing [...]]]></description>
			<content:encoded><![CDATA[<br/><p>This morning I started getting the following exception when generating code from wxGlade:</p>
<p><pre><code>
&lt;pre&gt;
Traceback (most recent call last):
&nbsp;&nbsp;File &quot;c:\temp\wxGlade\application.py&quot;, line 394, in generate_code
&nbsp;&nbsp;&nbsp;&nbsp;class_names=class_names)
&nbsp;&nbsp;File &quot;c:\temp\wxGlade\xml_parse.py&quot;, line 503, in __init__
&nbsp;&nbsp; .
&nbsp;&nbsp; .
&nbsp;&nbsp; .
&nbsp;&nbsp;File &quot;c:\temp\wxGlade\xml_parse.py&quot;, line 593, in endElement
&nbsp;&nbsp;&nbsp;&nbsp;self.code_writer.add_class(obj)
&nbsp;&nbsp;File &quot;c:\temp\wxGlade\codegen\py_codegen.py&quot;, line 640, in add_class
&nbsp;&nbsp;&nbsp;&nbsp;indentation = prev_src.spaces[code_obj.klass]
KeyError: &#039;FancyListControl&#039;
&lt;/pre&gt;
</code></pre></p>
<p>There was only one mention of a <a href="http://sourceforge.net/mailarchive/forum.php?thread_name=ccee3d7d0709061349j2dd1870el2744bcd51bee6f57%40mail.gmail.com&#038;forum_name=wxglade-general">similar problem</a> on the wxGlade mailing list.  The solution posted there was to start a new project &#8211; not really an option at this stage of development.</p>
<p>So after a little digging, I found a different solution.</p>
<p>The item causing the problem is a fancy subclass of ListControl defined in another module.  I had placed a wx.Panel in the sizer slot, and had then changed the class to my fancy ListControl.   Is the problem now obvious?  This fancy list control is not equivalent to a wx.Panel from wxGlade&#8217;s perspective.  Removing the panel and instead adding a ListControl with my fancy control as the class name fixed everything up. </p>
<p>So, in summary, use the closest matching wxGlade class (ListControl instead of Panel) when using your own classes.  </p>
<p>Doh.</p>
]]></content:encoded>
			<wfw:commentRss>http://powertwenty.com/kpd/blog/index.php/python/wxpython/exception_when_generating_code_from_wxglade_-_and_how_to_fix_it/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Watch out for wxGlade&#8217;s Overwrite Sources!</title>
		<link>http://powertwenty.com/kpd/blog/index.php/python/wxpython/watch_out_for_wxglade5c27s_overwrite_sources21</link>
		<comments>http://powertwenty.com/kpd/blog/index.php/python/wxpython/watch_out_for_wxglade5c27s_overwrite_sources21#comments</comments>
		<pubDate>Thu, 15 Feb 2007 13:02:23 +0000</pubDate>
		<dc:creator>kpd</dc:creator>
				<category><![CDATA[wxPython]]></category>

		<guid isPermaLink="false">http://powertwenty.com/kpd/blog/index.php/python/wxpython/watch_out_for_wxglade5c27s_overwrite_sources21</guid>
		<description><![CDATA[<br/>wxGlade has an option for &#8216;overwrite sources&#8217; in the application dialog:

I normally have it off, but when doing some exploratory testing I enabled it.    This morning I was working on my main application and regenerated the code.  Guess what?  Yes, it overwrote every gui class.   Three things led [...]]]></description>
			<content:encoded><![CDATA[<br/><p>wxGlade has an option for &#8216;overwrite sources&#8217; in the application dialog:</p>
<p><img src="http://powertwenty.com/kpd/blog/wp-content/uploads/overwriteexistingsources.jpg" width="250" height="54" alt="" title="" /></p>
<p>I normally have it off, but when doing some exploratory testing I enabled it.    This morning I was working on my main application and regenerated the code.  Guess what?  Yes, it overwrote every gui class.   Three things led to this:</p>
<p>1. I had assumed the overwrite setting was stored in the .wxg file (it is part of the configuration for a given application.)<br />
2. My main wxsGlade window is sized so that option is not normally visible.<br />
3. The value for &#8216;overwrite sources&#8217; is actually a global configuration.</p>
<p>So BE CAREFUL with this option.   Fortunately, a <em>svn update</em> brought the code back to where it was just a few minutes earlier minus a minor gui change.</p>
]]></content:encoded>
			<wfw:commentRss>http://powertwenty.com/kpd/blog/index.php/python/wxpython/watch_out_for_wxglade5c27s_overwrite_sources21/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Py2Exe Changing wxPython Look and Feel</title>
		<link>http://powertwenty.com/kpd/blog/index.php/python/wxpython/py2exe_changing_wxpython_look_and_feel</link>
		<comments>http://powertwenty.com/kpd/blog/index.php/python/wxpython/py2exe_changing_wxpython_look_and_feel#comments</comments>
		<pubDate>Sun, 11 Feb 2007 05:53:09 +0000</pubDate>
		<dc:creator>kpd</dc:creator>
				<category><![CDATA[wxPython]]></category>

		<guid isPermaLink="false">http://powertwenty.com/kpd/blog/index.php/python/wxpython/py2exe_changing_wxpython_look_and_feel</guid>
		<description><![CDATA[<br/>I just noticed that my wxPython application looks different after creation of an exe with Py2Exe.   The image on the left is the application running under the normal python interpreter.  The one on the right is the same application after creation of an exe with Py2exe.   

Notice:
1. The dark gray [...]]]></description>
			<content:encoded><![CDATA[<br/><p>I just noticed that my wxPython application looks different after creation of an exe with Py2Exe.   The image on the left is the application running under the normal python interpreter.  The one on the right is the same application after creation of an exe with Py2exe.   </p>
<p><img src="http://powertwenty.com/kpd/blog/wp-content/uploads/WxInterpVsPy2Exe.png" width="404" height="219" alt="" title="" /></p>
<p>Notice:<br />
1. The dark gray below the Music label instead of white.<br />
2. The area around Music is inset in the exe version.<br />
3. The splash handle separator is different, it looks more 3D in the Py2EXE version.</p>
<p>This is with wxPython 2.8.1.1.</p>
<p>I&#8217;d guess there is a simple solution, but I&#8217;m not finding it.  Any ideas?</p>
<p>Edit:<br />
Solution is at: <a href="http://wiki.wxpython.org/index.cgi/DistributingYourApplication">http://wiki.wxpython.org/index.cgi/DistributingYourApplication</a></p>
]]></content:encoded>
			<wfw:commentRss>http://powertwenty.com/kpd/blog/index.php/python/wxpython/py2exe_changing_wxpython_look_and_feel/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Adding Custom Widgets to wxGlade</title>
		<link>http://powertwenty.com/kpd/blog/index.php/python/adding-custom-widgets-to-wxglade</link>
		<comments>http://powertwenty.com/kpd/blog/index.php/python/adding-custom-widgets-to-wxglade#comments</comments>
		<pubDate>Thu, 16 Nov 2006 10:29:45 +0000</pubDate>
		<dc:creator>kpd</dc:creator>
				<category><![CDATA[Python]]></category>
		<category><![CDATA[wxPython]]></category>

		<guid isPermaLink="false">http://powertwenty.com/kpd/blog/?p=51</guid>
		<description><![CDATA[<br/>wxGlade has the ability to integrate custom or 3rd party widgets into its pallette.  This feature is not documented very well.  By using some sample code from Alberto Griggio and digging through the core-widgets source code, I was able to create bridge code that adds Andrea Gavana&#8217;s FloatSpin control to the pallette.  [...]]]></description>
			<content:encoded><![CDATA[<br/><p><a href="http://wxglade.sourceforge.net/">wxGlade </a>has the ability to integrate custom or 3rd party widgets into its pallette.  This feature is not documented very well.  By using some sample code from Alberto Griggio and digging through the core-widgets source code, I was able to create <a href="http://powertwenty.com/kpd/downloads/float_spin_1.1.tar.gz">bridge code</a> that adds <a href="http://wiki.wxpython.org/index.cgi/FloatSpin">Andrea Gavana&#8217;s FloatSpin control</a> to the pallette.  For those that follow, I suggest starting with the a similar class from the core pallette and the code for html_window.  The only real gotcha for this integration was that the widget container was not seeing KILL FOCUS events from the FloatSpin controls and therefore changed data was not saved.  This was fixed by trapping EV_FLOATSPIN events and calling the update.  </p>
<p><a href="http://powertwenty.com/kpd/blog/wp-content/uploads/float_spin.jpg"><img src="http://powertwenty.com/kpd/blog/wp-content/uploads/_float_spin.jpg" width="250" height="170" alt="wxGlade Pallette with Float Spin" title="wxGlade Pallette with Float Spin"  /></a></p>
<p>The <a href="http://powertwenty.com/kpd/downloads/float_spin_1.1.tar.gz">FloatSpin bridge code</a> is installed by untarring from within your .wxglade directory.  The included README contains more details.</p>
<p>Edits:<br />
11/16/2006 &#8211; uploaded version 1.1.  Adds event handlers and support for digits=0.</p>
]]></content:encoded>
			<wfw:commentRss>http://powertwenty.com/kpd/blog/index.php/python/adding-custom-widgets-to-wxglade/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Cleaning up panel resources when a parent frame is closed</title>
		<link>http://powertwenty.com/kpd/blog/index.php/python/cleaning-up-panel-resources-when-a-parent-frame-is-closed</link>
		<comments>http://powertwenty.com/kpd/blog/index.php/python/cleaning-up-panel-resources-when-a-parent-frame-is-closed#comments</comments>
		<pubDate>Wed, 15 Nov 2006 11:07:46 +0000</pubDate>
		<dc:creator>kpd</dc:creator>
				<category><![CDATA[Python]]></category>
		<category><![CDATA[wxPython]]></category>

		<guid isPermaLink="false">http://powertwenty.com/kpd/blog/?p=50</guid>
		<description><![CDATA[<br/>I try to create reusable windows as subclases of wx.Panel and then insert them into frames as needed.   This morning I had a panel that needed to perform some cleanup.  The problem was that the close event happens on the frame, not the panel.  Overriding the obvious methods, Destroy, Close, etc [...]]]></description>
			<content:encoded><![CDATA[<br/><p>I try to create reusable windows as subclases of wx.Panel and then insert them into frames as needed.   This morning I had a panel that needed to perform some cleanup.  The problem was that the close event happens on the frame, not the panel.  Overriding the obvious methods, <em>Destroy</em>, <em>Close</em>, etc did not work as expected.  I found the answer from Robin Dunn <a href="http://lists.wxwidgets.org/archive/wxPython-users/msg12464.html">deep in the wxPython mailing list</a>:</p>
<p><pre><code>
&lt;pre&gt;
&nbsp;&nbsp;&nbsp;&nbsp; # __init__ method of wx.Panel subclass
&nbsp;&nbsp;&nbsp;&nbsp; self.Bind(wx.EVT_WINDOW_DESTROY, self.OnDestroy)

&nbsp;&nbsp;&nbsp;&nbsp;def OnDestroy(self, event):
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;## clean up resources as needed here
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;event.Skip()
&lt;/pre&gt;
</code></pre><br />
Seems obvious now.   Another step forward in learning the wxPython/wxWidgets philosophy.</p>
]]></content:encoded>
			<wfw:commentRss>http://powertwenty.com/kpd/blog/index.php/python/cleaning-up-panel-resources-when-a-parent-frame-is-closed/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Adding / Removing Controls from a wxPython Frame</title>
		<link>http://powertwenty.com/kpd/blog/index.php/python/adding-removing-controls-from-a-wxpython-frame</link>
		<comments>http://powertwenty.com/kpd/blog/index.php/python/adding-removing-controls-from-a-wxpython-frame#comments</comments>
		<pubDate>Wed, 15 Nov 2006 03:07:35 +0000</pubDate>
		<dc:creator>kpd</dc:creator>
				<category><![CDATA[Python]]></category>
		<category><![CDATA[wxPython]]></category>

		<guid isPermaLink="false">http://powertwenty.com/kpd/blog/?p=49</guid>
		<description><![CDATA[<br/>I have  a mini-Frame whose child controls change based on a user selection.  It took awhile to get the resizing and layout working as controls are added and removed from the panel.  This is the final code that works.   The event handler calls selectedXXX, where XXX is one of the [...]]]></description>
			<content:encoded><![CDATA[<br/><p>I have  a mini-Frame whose child controls change based on a user selection.  It took awhile to get the resizing and layout working as controls are added and removed from the panel.  This is the final code that works.   The event handler calls <em>selectedXXX</em>, where XXX is one of the options.   Each set of controls that are shown or hiddern reside in their own sizer, although if it were just one control you can show or hide it directly.</p>
<p><code></code></p>
]]></content:encoded>
			<wfw:commentRss>http://powertwenty.com/kpd/blog/index.php/python/adding-removing-controls-from-a-wxpython-frame/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
