|
Davy Mitchell's Meandering Weblog Home - Angus - Christian - Energy - Fun - General - Internet - IronPython - MoodNews - NintendoDS - Personal - Photos - Podcast - Politics - Python - Scotland - Software Blog Statistics Tag Cloud RSS More Feeds Archives2007-02-032006-12-16 2006-12-09 2006-12-02 2006-11-25 2006-11-18 2006-11-11 2006-10-14 2006-10-07 2006-09-30 |
wxTayLayout Permalink More GUI-goodness, I have release an early version of TayLayout this time for wxPython (CPython). It implements most of the DotNet features just not all the helpers yet. You can get it here.
Posted by Davy Mitchell on
2007-02-15 22:29:41. Hello World - TayLayout Tutorial Permalink This tutorial shows how to use TayLayout, starting with Hello World. Tutorial1-1.pyimport clr
clr.AddReference('System.Windows.Forms') clr.AddReference('System.Drawing') from taylayout import * class MainForm(Form): def __init__(self): Form.__init__(self) # STEP 1 - Create Layout. self.ALayout = TayLayout() self.ALayout.parent = self # STEP 2 - Add Controls To The Form. self.label = self.ALayout.addLabel("Hello World",False) # STEP 3 - Finally set the size of the Form. self.ALayout.complete() self.Show() Application.EnableVisualStyles() form = MainForm() Application.Run(form) Running the above will produce a small form with 'Hello World :' displayed on it. For the next step we will add a second control. Tutorial1-2.pyimport clr
clr.AddReference('System.Windows.Forms') clr.AddReference('System.Drawing') from taylayout import * class MainForm(Form): def __init__(self): Form.__init__(self) # STEP 1 - Create Layout. self.ALayout = TayLayout() self.ALayout.parent = self # STEP 2 - Add Controls To The Form. self.label = self.ALayout.addLabel("Hello World",False) self.textbox = self.ALayout.addTextBox(" and his dog.", True) # STEP 3 - Finally set the size of the Form. self.ALayout.complete() self.Show() Application.EnableVisualStyles() form = MainForm() Application.Run(form) Running the above will produce a bigger form with a label and a textbox alongside it. This demos an important feature of TayLayout. The Form (or container) size is set when complete is called (STEP 3) based on the size of controls within it. The two controls have a second parameter. False means the next control will appear on the same line as the Label. The textbox passes True which means the next control to be added will be on a new row. The next example shows this happening. Tutorial1-3.pyimport clr
clr.AddReference('System.Windows.Forms') clr.AddReference('System.Drawing') from taylayout import * class MainForm(Form): def __init__(self): Form.__init__(self) # STEP 1 - Create Layout. self.ALayout = TayLayout() self.ALayout.parent = self # STEP 2 - Add Controls To The Form. self.label = self.ALayout.addLabel("Hello World",False) self.textbox = self.ALayout.addTextBox(" and his dog.") self.button1 = self.ALayout.addButton("Press Me") # STEP 3 - Finally set the size of the Form. self.ALayout.complete() self.Show() Application.EnableVisualStyles() form = MainForm() Application.Run(form) The button appears below the label. Note that the Form height has automatically been increased to make space for the button.
Posted by Davy Mitchell on
2007-02-13 12:50:13. TayLayout 00.00.16 Permalink This is a small release of TayLayout with a few new handy classes. LDForm, LDPrompt and LDDialog provide a few more helpers and the main layout code has an important tweak. Thought I would squeeze this one in whilst I am distracted by other things. Tonight I was reading the docs for Wax and found this interesting bit in the TODO file This has been suggested before: what about a way to add widgets to a container in one pass? E.g. b = mypanel.MakeComponent(Button, "text", event=something) This is exactly what Taylayout intends to do. Sadly Wax hasn't had a release for a while though it is tempting to do a few updates to stop import warnings coming up when running Firedrop!! Anyway working with wxPython again has been interesting and I am toying with the idea of a wxPython version of TayLayout. It should be fairly easy to convert the existing code but maintenance of both could be tedious without help (hint!).
Posted by Davy Mitchell on
2007-02-12 22:30:23. |
|