Re: making GUI with WXPython

  • From: Alex Hall <mehgcap@xxxxxxxxx>
  • To: programmingblind@xxxxxxxxxxxxx
  • Date: Wed, 10 Mar 2010 15:31:51 -0500

Looks promising. I can do notebooks and panels, right?

On 3/10/10, Jamal Mazrui <empower@xxxxxxxxx> wrote:
> Below is the text of my original post about Layout by Code for Python.
> Examples of its use are also included in the source code for McTwit
> http://EmpowermentZone.com/mtsetup.exe
>
> or .zip
>
> Sizers can definately be used to create accessible GUIs.
>
> Hope this helps,
> Jamal
>
> From the archive at
> http://EmpowermentZone.com/pyLbc.zip
>
> I have developed a Python module called Layout by Code (lbc), which
> simplifies design of dialogs with the wxPython package available from
> http://wxPython.org
>
> This is another implementation of the Layout by Code approach that I
> originally developed for the AutoIt language,
> http://EmpowermentZone.com/lbc.zip
>
> Although the Python version is not as flexible, it is still intended to
> support most dialogs one might need (based on years of experience with
> various applications and languages).  It should work with Python 2.4,
> 2.5, or 2.6.
>
> After instantiating an lbc dialog object, any of the following controls
> may be added with a line of code:  Button, CheckBox, ListBox,
> RadioButton, RichEdit, StaticText, or TextCtrl.  The control is added to
> a horizontal band of controls, with layout automatically managed by
> wxSizer containers.  Adding a new band is analagous to pressing carriage
> return at the end of a line.
>
> The lbc ShowModal method adds a band of buttons at the bottom of the
> dialog before invoking it.  The method returns the ID of the button that
> ended the dialog.  At that point, the dialog object has a list attribute
> called Controls, containing the names of controls that were added to the
> dialog before it was invoked.  A control name is its class and label, if
> any, seperated by an underscore, e.g., Button_OK.  The dialog also has a
> dictionary attribute called Results, containing the control names and
> values when the dialog ended.
>
> Over ten convenience dialogs have been defined using lbc, illustrated
> with the program test_lbc.py.  Also, a fruit basket program is in
> lbc_fruit.py.
>
> Below is a summary of lbc functions, followed by the fruit basket
> example.
>
> Jamal
>
> DialogBrowseForFolder(message='', value='') -- Select a folder
>
> DialogChoose(title='Choose', message = '', names=[]) -- Choose a button
>
> DialogConfirm(title='Confirm', message='', value='Y') -- Choose from a
> Yes/No/Cancel message box
>
> DialogInput(title='Input', label='', value='', ) -- Input with a
> single-line edit box
>
> DialogMemo(title='Memo', label='', value='', readonly=False) -- Input or
> read text with a multiple-line edit box
>
> DialogMultiInput(title='MultiInput', labels=[], values=[], options=[])
> -- Input with multiple edit boxes
>
> DialogMultiPick(title='Multi Pick', message='', names=[], values=[],
> sort=False, index=0) -- Pick from a multiple-selection listbox
>
> DialogOpenFile(message='', value='', wildcard='All files (*.*)|*.*') --
> Specify a file to open
>
> DialogPick(title='Pick', message='', names=[], values=[], sort=False,
> index=0) -- Pick from a single-selection listbox
>
> DialogSaveFile(message='', value='', wildcard='All files (*.*)|*.*') --
> Specify a file to save
>
> DialogShow(title='Show', message='') -- Show a message
>
>
>
> AddBand(self)
>
> AddButtonBand(buttons=[], handler=None)
>
> AddButton(label='', pos=wx.DefaultPosition, size=wx.DefaultSize,
> style=DEFAULT_STYLE, name='')
>
> AddCheckBox(label='', value=False, pos=wx.DefaultPosition,
> size=wx.DefaultSize, style=DEFAULT_STYLE, name='')
>
> AddListBox(label='', names=[], values=[], sort=False,
> pos=wx.DefaultPosition, size=wx.DefaultSize, style=DEFAULT_STYLE,
> name='')
>
> AddRadioButton(label='', value=False, pos=wx.DefaultPosition,
> size=wx.DefaultSize, style=DEFAULT_STYLE, name='')
>
> AddRichEdit(label='', value='', readonly=False, pos=wx.DefaultPosition,
> size=wx.DefaultSize, style= wx.TE_MULTILINE | wx.TE_PROCESS_ENTER |
> wx.TE_RICH2, name='')
>
> AddStaticText(label='', pos=wx.DefaultPosition, size=wx.DefaultSize,
> style=DEFAULT_STYLE, name='')
>
> AddTextCtrl(label='', value='', pos=wx.DefaultPosition,
> size=wx.DefaultSize, style=DEFAULT_STYLE, name='')
>
> ShowModal(buttons = ['OK', 'Cancel'], handler=None)
>
> """
> Fruit basket program in Python with lbc
> Public domain by Jamal Mazrui
> """
>
> import wx, lbc
>
> # Custom event handler
> def OnEvent(dlg, event):
>       if event.GetEventType() in wx.EVT_CLOSE.evtType:
>               if lbc.DialogConfirm(title='Confirm', message='Exit
> program?', value='Y') == 'Y': return event.Skip()
>               else: return event.Veto()
>
>       wgt = event.GetEventObject()
>       txt = dlg.FindWindowByName('TextCtrl_Fruit')
>       lst = dlg.FindWindowByName('ListBox_Basket')
>       if wgt.GetName() == 'Button_Add':
>               fruit = txt.GetValue()
>               if len(fruit) == 0: return lbc.DialogShow(title='Alert',
> message='No fruit to add!')
>               lst.Append(fruit)
>               index = lst.GetCount() - 1
>               lst.SetSelection(index)
>               txt.Clear()
>       elif wgt.GetName() == 'Button_Delete':
>               index = lst.GetSelection()
>               if index == -1: return lbc.DialogShow(title='Alert',
> message='No fruit to delete!')
>               lst.Delete(index)
>               if index == lst.GetCount(): index -= 1
>               if index >= 0: lst.SetSelection(index)
>
> # Main program
> app = lbc.App()
> dlg = lbc.Dialog(title='Fruit Basket')
> dlg.AddTextCtrl(label='Fruit:')
> dlg.AddListBox(label='Basket:')
> dlg.ShowModal(buttons=['Add', 'Delete'], handler=OnEvent)
> app.Exit()
>
> On Wed, 10 Mar
> 2010,
> Alex Hall wrote:
>
>> Date: Wed, 10 Mar 2010 12:07:56 -0500
>> From: Alex Hall <mehgcap@xxxxxxxxx>
>> Reply-To: programmingblind@xxxxxxxxxxxxx
>> To: programmingblind <programmingblind@xxxxxxxxxxxxx>
>> Subject: making GUI with WXPython
>>
>> Hi all,
>> I am working on an options dialog for a program written in Python2.6.
>> I am using WXPython and XRC (created with the XRCed editor). I am
>> getting lost in all the position and size numbers, though. I seem to
>> remember Jamal had something about "layout by code" and I wondered if
>> that would be useable here? Or, if I use wx.sizers, can they position
>> the elements for me? Also, if I use sizers, will screen readers be
>> able to read the label in one sizer as the prompt for the text box in
>> another sizer? I remember someone on here telling me that screen
>> readers read labels for text boxes if the label and text box touch by
>> one or more pixels, and I am not sure how I would use a sizer to
>> overlap these widgets like that. Suggestions? Thanks!
>>
>> --
>> Have a great day,
>> Alex (msg sent from GMail website)
>> mehgcap@xxxxxxxxx; http://www.facebook.com/mehgcap
>> __________
>> View the list's information and change your settings at
>> //www.freelists.org/list/programmingblind
>>
> __________
> View the list's information and change your settings at
> //www.freelists.org/list/programmingblind
>
>


-- 
Have a great day,
Alex (msg sent from GMail website)
mehgcap@xxxxxxxxx; http://www.facebook.com/mehgcap
__________
View the list's information and change your settings at 
//www.freelists.org/list/programmingblind

Other related posts: