From: <ch...@dt...> - 2004-06-16 23:37:54
|
Daan Leijen wrote: > Hi Anders, > > On Wed, 16 Jun 2004 15:06:21 +0200, Anders H=F6ckersten=20 > <ch...@dt...> wrote: > >> Hi! I've been toying around a bit with wxHaskell lately and have run=20 >> into a problem. My application needs to be able to add elements to a=20 >> Choice control. The elements are read from a HaskellDB-based database=20 >> as a list. >> >> My question is this: When clicking my "add" button, how do I tell the=20 >> Choice control to re-read >> its list from source? I'm assuming I need to send it some event, but=20 >> which one? > > > I think you can just use the "items" attribute to set the form of the=20 > choice > control. Something like: > > c <- choice ... > ... > set c [items :=3D ["hi", "there"]] > > > Furthermore, I think you need to use the "dynamic" attribute on the > layout of the choice control. > > set f [layout :=3D .... dynamic (widget c) ... ] > > > I hope this helps, > All the best, > Daan. That worked great! Thank you. Now, on to my next question, which is more=20 generally design oriented, but still touches the previous one. I have a=20 parent window, where you can open a child window to add some new data (a=20 customer in this case). When the new data has been saved, the Choice=20 control in the parent window has to be updated. However, the child window has no specific knowledge of the Choice=20 control in the parent window, it only knows about the parent window, and=20 giving knowledge of the Choice control to the child window would break=20 encapsulation. Is there any "recommended" way of solving these kinds of problems? Would=20 creating a new custom event, "updateParent" or similar be a good solution= ? Actually, after having toyed with wxHaskell for a few days now how to=20 structure my code is my main problem. wxWidgets seems to force sort of=20 an object-oriented approach onto my Haskell program, which I am having=20 trouble adapting to. :) Still, I like wxHaskell. It works well and=20 produces nice results. Regards, Anders |