Thanks for all the testing and reporting. If the executable lbc_fruit.exe works without a problem, then I am thinking that the discrepancy lies with either Python 2.7, as opposed to 2.5, or with wxPython 2.9, as opposed to 2.8. I forget if you indicated what wxPython version you are using. My guess is that a different wxPython version is more likely to be the explanation than a different Python version in this case.
I know it involves installing various software, but if you happen to be able to test with wxPython 2.8X, that could help us figure this out. If no difference there, then perhaps try Python 2.5. I'd love to get to the bottom of this.
Jamal On Fri, 17 Jun 2011, Alex Hall wrote:
Date: Fri, 17 Jun 2011 10:16:17 -0400 From: Alex Hall <mehgcap@xxxxxxxxx> Reply-To: programmingblind@xxxxxxxxxxxxx To: programmingblind@xxxxxxxxxxxxx Subject: Re: Improved Layout by Code module for Python Interesting... When set to 10010, the fruitbasket program works normally, but when set to 10008, it does not work (except for the prompt on exiting). In either case, the test program in the zip file exits when I press enter on the first button, or tab to move to another button, with no traceback being printed - it just closes. More intriguing, my mother has 32-bit Vista and I just installed python27, pywin, and wx on her laptop. When we ran the program I am writing (which also works on my 64-bit system with 10010 but not 10008), it did not work. She has to leave, but I strongly suspect that if I changed the value to 10008 instead of 10010 on her computer, it would function normally. Unfortunately, I cannot test this for a few hours until she gets back, but it makes me wonder if the 32 vs 64 bit thing is throwing off the codes somehow. Oh, my version of Python is 32-bit on 64-bit Windows (I heard that I might have trouble with 64-bit Python, so I have so far stayed away from it). On 6/17/11, Jamal Mazrui <empower@xxxxxxxxx> wrote:Thanks. Do you have a 64-bit version of Python associated with .py files? If so, then that could explain my different results, because lbc_fruit.exe is a 32-bit executable. With that code change, can you confirm that running test_lbc.py seems to work properly? Jamal On 6/17/2011 7:56 AM, Alex Hall wrote:The only change is in the IsClickEvent function; either change 10008 to 10010, or add 10010 to the if statement: def IsClickEvent(event): iID = event.GetId() iType = event.GetEventType() if iType == 10010: return True else: return False That works for me. It may also work to say if iType==10010 or iType==10008:... but I have not tried that. This is python 2.7, if that matters. On 6/17/11, Jamal Mazrui<empower@xxxxxxxxx> wrote:I just tried running lbc_fruit.py from the zip archive (I unzipped the archive from the web site into a new directory rather than using my development directory). The program ran as expected (I was able to add or delete fruit.etc.). This is puzzling, especially since you say the lbc_fruit.exe version works, which was built from the same code. Perhaps 64-bit has something to do with our different results, or the fact that I am using Python 2.5. Not sure. Can you post a code snippet that changes lbc.py in a way that resolves the problem? Jamal On 6/17/2011 7:33 AM, Alex Hall wrote:It was; I was using IsClickEvent(). Again, though, the fruit basket python file failed to run with the new lbc. It opened, but the buttons were inoperative, and I had not changed anything in that file. I am not sure why this is so, but as soon as I changed the trigger to 10010 in lbc.py, things worked as expected. See if the fruit basket python file (not the executable) runs on your computer from the zip file you posted; it may be something to do with 64-bit vs 32-bit, or some other oddity. On 6/17/11, Jamal Mazrui<empower@xxxxxxxxx> wrote:The new Layout by Code automatically passes more events to the default event handler, which processes them before the custom event handler that you define. The focus event is one of those passed, so yu have to make sure your code is reacting specifically to the click event, not just to an event on the control of interest. If a problem remains, please post or send me a sample script, and I will try to resolve this. Jamal On 6/17/2011 6:36 AM, Alex Hall wrote:Okay, more pressing problem! I tried to use your "IsClickEvent" method since the alert dialog I have set to trigger on a button was happening when I tabbed to the button, not when I activated it. However, the dialog will not appear. Your method returns true if the EventType==10008. However, when I printed out the EventType in my event handler, I saw that I got 10010 when I pressed space or enter on the button. I am tempted to just change the condition for returning in your function, but I am not sure if that will cause problems later on. Your fruit basket executable works as expected, so I am not sure how that works and this does not. Interestingly, the fruit basket python file does not work, I suspect due to the same problem I am having. It confirms exiting with the y/n dialog, but clicking any button does nothing. On 6/17/11, Alex Hall<mehgcap@xxxxxxxxx> wrote:Thanks for the update, I am going to try it to see if I can get things working better. My only question for now is about the ini file. In the sample, you have a [Fruit Basket] section. How did you decide on that section name? Does it have to match the title of the dialog with which it is associated? On 6/16/11, Jamal Mazrui<empower@xxxxxxxxx> wrote:From the archive at http://EmpowermentZone.com/pyLbc.zip Layout by Code for Python Version 1.3 June 16, 2011 Copyright 2009 - 2011 by Jamal Mazrui GNU Lesser General Public License (LGPL) I have updated a Python module called Layout by Code (lbc), which simplifies design of dialogs with the WxWidgets GUI library. It is another implementation of the Layout by Code approach that I originally developed for the AutoIt language, available at http://EmpowermentZone.com/lbc.zip I also developed a version for .NET languages, such as C# and Visual Basic, which is distributed as part of HomerApp, the Homer Application Framework, available at http://EmpowermentZone.com/appsetup.exe 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 versions 2.4 through 2.7. It depends on the following 3rd-party Python modules: wxPython http://wxpython.org py2exe http://py2exe.org Python for Windows extensions http://sourceforge.net/projects/pywin32/ odict -- an ordered dictionary http://www.voidspace.org.uk/python/odict.html The py2exe module is only needed if one wants to create a Windows executable like lbc_fruit.exe. The batch file run_setup_lbc_fruit.bat does this, using setup_lbc_fruit.py to specify how the executable is built. 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 Complete 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 an ordered dictionary 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. By default, a status bar is added as the last control of a dialog. It may be used for help messages to the user. For example, each control can trigger a help message when it receives focus. These messages may be defined in a .ini file that accompanies the main script file (with the same name except for the extension). The fruit basket sample script illustrates this feature in the file lbc_fruit.ini. A screen reader user can press a hotkey to read the status bar. 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. For convenient reference, the code in test_lbc.py and then lbc_fruit.py follows afterward. Jamal ---------- lbc convenience dialogs DialogBrowseForFolder(title='', 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(title='Open', 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(title='Save', value='', wildcard='All files (*.*)|*.*') -- Specify a file to save DialogShow(title='Show', message='') -- Show a message ---------- Content of test_lbc.py import lbc labels = 'Label1 Label2 Label3'.split() names = 'Name1 Name2 Name3'.split() values = 'Value1 Value2 Value3'.split() result = lbc.DialogChoose(title='Choose a Button', message='My message', names=['Button1', 'Button2', 'Button3']) lbc.DialogShow(title='result', message=result) result = lbc.DialogConfirm(title='Confirm an Action', message='my question', value='Y') lbc.DialogShow(title='result', message=result) result=lbc.DialogInput(title='Input a Value', label='My Label', value='My Value') lbc.DialogShow(title='result', message=result) result = lbc.DialogMemo(title='Input Multiple Lines', label='', value='line1\nline2\nline3') lbc.DialogShow(title='result', message=result) result = lbc.DialogMultiInput(title='Input Multiple Values', labels=labels, values=values) lbc.DialogShow(title='result', message=result) result = lbc.DialogPick(title='Pick an Item', names=names, values=values, sort=True) lbc.DialogShow(title='result', message=result) result=lbc.DialogMultiPick(title='Pick Multiple Items', names=names, values=values) lbc.DialogShow(title='result', message=result) result = lbc.DialogOpenFile(value=r'c:\temp\test.txt') lbc.DialogShow(title='result', message=result) result = lbc.DialogSaveFile(value=r'c:\temp\test.txt') lbc.DialogShow(title='result', message=result) result = lbc.DialogBrowseForFolder(value=r'c:\temp') lbc.DialogShow(title='result', message=result) ---------- Content of lbc_fruit.py import wx, lbc # Custom event handler def OnEvent(dlg, event, name): if lbc.IsCloseEvent(event): if lbc.DialogConfirm(title='Confirm', message='Exit program?', value='Y') == 'Y': return event.Skip() else: return event.Veto() txt = dlg.Controls['TextCtrl_Fruit'] lst = dlg.Controls['ListBox_Basket'] if not lbc.IsClickEvent(event): pass elif name == '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 name == '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.Complete(buttons=['Add', 'Delete'], handler=OnEvent) app.Exit() __________ 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-- 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