Hi,
Thanks for your reply. Looked at dabo and it seems nice, but to big
for my needs, and not modular enough to keep things simple. I'm only
getting started with wxPython so I want to learn to use the basics and
build from there. The TransferFromWindow and data-aware controls
related info in the wiki seem a bit heavy as well. I'm coming from a
Borland Delphi world of point-and-click and in wxpython it's a bit
more hardcode, DIY. But that's ok. I'll look more into validators and
the data-aware docs, but I wish there were a few more basics,
explanatory examples, not just a bunch of code. It's harder to grasp
the concepts when there's that much code to just explain a few
concepts ( my impression after looking at the data-aware link you
sent. )
Anyway, thanks for your input. There's obviously alot more to learn in
the wxPython-world :-). Thanks again!!
Thomas
···
On 12/21/06, Werner F. Bruhin <werner.bruhin@free.fr> wrote:
Hi Thomas,
Before going further you might want to consider looking at:
- validators
- TransferDataFromWindow
- TransferDataToWindowAnd don't forget to check also the wiki:
http://wiki.wxpython.org/index.cgi/Data-aware_Controls_with_Validators%2C_Note_1?highlight=(validator)You might also want to look at Dabo - http://dabodev.com/
Werner
Thomas Weholt wrote:
> Hi all,
>
> I normally work with alot with database-related stuff in my day-job
> and the first thing that struck me when I started working with
> wxPython ( not long ago ) was how much code I had to write to set/get
> values on input-fields/controls, especially in situation where data
> was stored in a RDBMS. This is where wxFieldConnector comes into play.
> It's really simple; whenever I create a control I also add it to the
> wxFieldConnector along with a name for that control. The I can set and
> get the values of all added controls using one method call. Future
> versions will include some code showing how to get data from
> SQLObject-instances and further use of SQL-data as datasource.
>
> Another feature I'm looking into is generating a basic
> label+field-grid/form using the added controls in a wxFieldConnector,
> no defining a gridsizer, adding a label, the the control, another
> label, then the second control etc. to create the grid of labels and
> controls. Of course, this won't fit the bill in every case, but
> perhaps in alot of them, saving us some time. This is demonstrated in
> autogenerate_test.py in the download below. It would be nice if the
> generated panel containing the controls and labels was scrollable, but
> I didn't get that to work. Comments or tips on this would be highly
> appreciated.
>
> The code is very basic and brutal in its approach to setting and
> getting values so this is where I need advise and comments from you.
> See example code below and feel free to download the source, including
> some basic tests and example code.
>
> Download here : http://www.mrmuffin.net/code/wxFieldConnector.zip
>
> Code example. Press the set, get and clear buttons to see what happens.
>
> import wx
> import wx.lib.masked as masked
> from wxFieldConnector import wxFieldConnector
>
> import wx.lib.scrolledpanel as scrolled
>
> sampleList = ['zero', 'one', 'two', 'three', 'four', 'five',
> 'six', 'seven', 'eight', 'nine', 'ten', 'eleven',
> 'twelve', 'thirteen', 'fourteen']
> data = {
> 'name': 'Thomas Weholt',
> 'level': ['one', 'five', 'seven'],
> 'age': 32,
> 'newsletter': False
> }
>
> class TestPanel(scrolled.ScrolledPanel):
>
> def onGet(self, evt):
> import pprint
> pprint.pprint(self.wxfc.getValues())
>
> def onSet(self, evt):
> self.wxfc.setValues(data)
>
> def onClear(self, evt):
> self.wxfc.clear()
>
> def __init__(self, parent):
> scrolled.ScrolledPanel.__init__(self, parent, -1)
> self.panel = self
> self.wxfc = wxFieldConnector()
> self.mainSizer = wx.BoxSizer(wx.VERTICAL)
>
> getBtn = wx.Button(self, -1, "Get")
> setBtn = wx.Button(self, -1, "Set")
> clearBtn = wx.Button(self, -1, "Clear")
>
> btnSizer = wx.BoxSizer(wx.HORIZONTAL)
> btnSizer.Add((20,20), 1)
> btnSizer.Add(setBtn)
> btnSizer.Add((20,20), 1)
> btnSizer.Add(getBtn)
> btnSizer.Add((20,20), 1)
> btnSizer.Add(clearBtn)
> btnSizer.Add((20,20), 1)
> self.mainSizer.Add(btnSizer, 0, wx.EXPAND|wx.BOTTOM, 10)
>
> self.Bind(wx.EVT_BUTTON, self.onSet, setBtn)
> self.Bind(wx.EVT_BUTTON, self.onGet, getBtn)
> self.Bind(wx.EVT_BUTTON, self.onClear, clearBtn)
>
> name = wx.TextCtrl(self.panel, -1, "")
> self.mainSizer.Add(name, 0, wx.ALIGN_TOP)
> self.wxfc.bindControl('name', name)
>
> age = masked.NumCtrl(self.panel, value=10, integerWidth=2,
> allowNegative=False)
> self.mainSizer.Add(age, 0, wx.ALIGN_TOP)
> self.wxfc.bindControl('age', age)
>
> newsletter = wx.CheckBox(self.panel, -1, "Newsletter")
> self.mainSizer.Add(newsletter, 0, wx.ALIGN_TOP)
> self.wxfc.bindControl('newsletter', newsletter)
>
> level = wx.CheckListBox(self.panel, -1, (80, 50),
> wx.DefaultSize, sampleList)
> self.mainSizer.Add(level, 0, wx.ALIGN_TOP)
> self.wxfc.bindControl('level', level)
>
> self.panel.SetSizer(self.mainSizer)
> self.SetupScrolling()
>
> class TestFrame1(wx.Frame):
> def __init__(self):
> wx.Frame.__init__(self, None, -1, "Real World Test")
> self.panel = TestPanel(self)
>
> if __name__ == '__main__':
> app = wx.PySimpleApp()
> TestFrame1().Show()
> app.MainLoop()
>---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org
--
Mvh/Best regards,
Thomas Weholt
http://www.weholt.org