From: Dean H. <her...@mi...> - 2008-05-09 04:09:27
|
I'm using wxhaskell 0.10.3 with ghc 6.8.2 on Windows XP Pro. I'm trying to figure out how to change the content of a frame dynamically. The program shown below has several problems: * The initial text is garbled (a combination of "Screen 1" and "Screen 2"). * The button label doesn't change when first clicked. * Nothing changes on subsequent button presses. Any ideas? > module Main where > > import Graphics.UI.WX > > main = start gui > > gui = do > f <- frame [text := "Test 1"] > p <- panel f [] > t1 <- staticText p [text := "Screen 1"] > b1 <- button p [text := "switch to 2"] > t2 <- staticText p [text := "Screen 2"] > b2 <- button p [text := "switch to 1"] > set b1 [on command := switch f p t2 b2] > set b2 [on command := switch f p t1 b1] > switch f p t1 b1 > > switch f p t b = set f [layout := fill $ container p $ margin 10 $ >column 5 [widget t, widget b]] |
From: Dean H. <her...@mi...> - 2008-05-15 05:11:09
|
Is anyone out there??? I reread Daan's original paper and found a hint that layouts need to mention each widget exactly once (though I can't find anything definitive in documentation for either wxhaskell or wxwidgets). Obeying that "rule" avoids the garbling, but I'm still not able successfully to change the layout repeatedly. Even if I could, how then would I show different subsets of widgets at different times? Is there any hope of getting a decent description of wxhaskell's (intended) semantics? I'm getting exasperated. At 12:08 AM -0400 5/9/08, Dean Herington wrote: >I'm using wxhaskell 0.10.3 with ghc 6.8.2 on Windows XP Pro. I'm >trying to figure out how to change the content of a frame >dynamically. The program shown below has several problems: > * The initial text is garbled (a combination of "Screen 1" and "Screen 2"). > * The button label doesn't change when first clicked. > * Nothing changes on subsequent button presses. >Any ideas? > >> module Main where >> >> import Graphics.UI.WX >> >> main = start gui >> >> gui = do >> f <- frame [text := "Test 1"] >> p <- panel f [] >> t1 <- staticText p [text := "Screen 1"] >> b1 <- button p [text := "switch to 2"] >> t2 <- staticText p [text := "Screen 2"] >> b2 <- button p [text := "switch to 1"] >> set b1 [on command := switch f p t2 b2] >> set b2 [on command := switch f p t1 b1] >> switch f p t1 b1 >> >> switch f p t b = set f [layout := fill $ container p $ margin 10 $ > >column 5 [widget t, widget b]] |
From: Eric Y. K. <eri...@gm...> - 2008-05-15 08:13:22
Attachments:
Dynamically.hs
|
Hi Dean, I'm very sorry nobody got back to you. Personally, I filed your message away in my pending queue and marked it 'reread'. By the way, it might help to attach your examples in an easy compile-and-run format, as I have hopefully done. It just smooths out these discussions a little bit! :-) On Thu, May 15, 2008 at 01:10:58 -0400, Dean Herington wrote: > I reread Daan's original paper and found a hint that layouts need to > mention each widget exactly once (though I can't find anything > definitive in documentation for either wxhaskell or wxwidgets). > Obeying that "rule" avoids the garbling, but I'm still not able > successfully to change the layout repeatedly. Could you attach your modified code? My experience with wxhaskell is that once you create a widget, it's going to be displayed, so you might as well lay it out somewhere. > Even if I could, how > then would I show different subsets of widgets at different times? You could set the visible attribute. See attachment. I do not claim that this is the right way to go about things. Maybe somebody like Mads or Shelarcy would have a better idea. -- Eric Kow <http://www.nltg.brighton.ac.uk/home/Eric.Kow> PGP Key ID: 08AC04F9 |
From: Dean H. <her...@mi...> - 2008-05-20 04:54:08
|
Hi, Eric, (I wish I could have replied earlier, but this past weekend was very busy.) Thanks to replies from you and Mads I'm back in business. At 9:13 AM +0100 5/15/08, Eric Y. Kow wrote: >Hi Dean, > >I'm very sorry nobody got back to you. Personally, I filed your message >away in my pending queue and marked it 'reread'. > >By the way, it might help to attach your examples in an easy >compile-and-run format, as I have hopefully done. It just smooths >out these discussions a little bit! :-) Good idea. Will do next time. > >On Thu, May 15, 2008 at 01:10:58 -0400, Dean Herington wrote: >> I reread Daan's original paper and found a hint that layouts need to >> mention each widget exactly once (though I can't find anything >> definitive in documentation for either wxhaskell or wxwidgets). >> Obeying that "rule" avoids the garbling, but I'm still not able >> successfully to change the layout repeatedly. > >Could you attach your modified code? My experience with wxhaskell is >that once you create a widget, it's going to be displayed, so you might >as well lay it out somewhere. Yes, you and Mads helped me figure that out. I believe I now understand all the anomalies I saw. > >> Even if I could, how >> then would I show different subsets of widgets at different times? > >You could set the visible attribute. >See attachment. Ah, thanks for the tip. > >I do not claim that this is the right way to go about things. Maybe >somebody like Mads or Shelarcy would have a better idea. In fact, Mads's suggestion does work better for my application. (See my upcoming reply to him.) > >Eric Kow <http://www.nltg.brighton.ac.uk/home/Eric.Kow> Thanks again. And sorry I overreacted at my earlier frustration. Dean |
From: Mads L. <mad...@ya...> - 2008-05-15 14:37:50
|
Hi Dean Dean Herington wrote: > Is anyone out there??? Yes. > > I reread Daan's original paper and found a hint that layouts need to > mention each widget exactly once (though I can't find anything > definitive in documentation for either wxhaskell or wxwidgets). > Obeying that "rule" avoids the garbling, but I'm still not able > successfully to change the layout repeatedly. Even if I could, how > then would I show different subsets of widgets at different times? Every widget which is created must be used once and only once. That is the rule. In your action (the "on command := do" -stuff) to change the panel content do: 1) delete your old widgets like: get p children >>= mapM_ objectDelete 2) create new widgets 3) do "set p [ layout := ... ]. 4) finally it might be good to do "refit p". Also have a look at dynamic http://wxhaskell.sourceforge.net/doc/Graphics-UI-WXCore-Layout.html#v% 3Adynamic . I am no quite sure when it is necessary to use this function. Greetings, Mads > > Is there any hope of getting a decent description of wxhaskell's > (intended) semantics? I'm getting exasperated. > > At 12:08 AM -0400 5/9/08, Dean Herington wrote: > >I'm using wxhaskell 0.10.3 with ghc 6.8.2 on Windows XP Pro. I'm > >trying to figure out how to change the content of a frame > >dynamically. The program shown below has several problems: > > * The initial text is garbled (a combination of "Screen 1" and "Screen 2"). > > * The button label doesn't change when first clicked. > > * Nothing changes on subsequent button presses. > >Any ideas? > > > >> module Main where > >> > >> import Graphics.UI.WX > >> > >> main = start gui > >> > >> gui = do > >> f <- frame [text := "Test 1"] > >> p <- panel f [] > >> t1 <- staticText p [text := "Screen 1"] > >> b1 <- button p [text := "switch to 2"] > >> t2 <- staticText p [text := "Screen 2"] > >> b2 <- button p [text := "switch to 1"] > >> set b1 [on command := switch f p t2 b2] > >> set b2 [on command := switch f p t1 b1] > >> switch f p t1 b1 > >> > >> switch f p t b = set f [layout := fill $ container p $ margin 10 $ > > >column 5 [widget t, widget b]] > > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Microsoft > Defy all challenges. Microsoft(R) Visual Studio 2008. > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ > _______________________________________________ > wxhaskell-users mailing list > wxh...@li... > https://lists.sourceforge.net/lists/listinfo/wxhaskell-users |
From: Dean H. <her...@mi...> - 2008-05-20 04:54:08
|
Hi, Mads, Thanks for your very helpful reply. I'm back in business. At 4:33 PM +0200 5/15/08, Mads Lindstrøm wrote: >Hi Dean > >Dean Herington wrote: >> Is anyone out there??? >Yes. > >> >> I reread Daan's original paper and found a hint that layouts need to >> mention each widget exactly once (though I can't find anything >> definitive in documentation for either wxhaskell or wxwidgets). >> Obeying that "rule" avoids the garbling, but I'm still not able >> successfully to change the layout repeatedly. Even if I could, how >> then would I show different subsets of widgets at different times? >Every widget which is created must be used once and only once. That is >the rule. Does the documentation for either wxHaskell or wxWidgets explain this rule? I couldn't find it. > >In your action (the "on command := do" -stuff) to change the panel >content do: > >1) delete your old widgets like: > >get p children >>= mapM_ objectDelete > >2) create new widgets > >3) do "set p [ layout := ... ]. > >4) finally it might be good to do "refit p". The above approach works for me. Thanks a lot for the explanation! Dean > >Also have a look at dynamic >http://wxhaskell.sourceforge.net/doc/Graphics-UI-WXCore-Layout.html#v% >3Adynamic . I am no quite sure when it is necessary to use this >function. > > >Greetings, > >Mads > >> >> Is there any hope of getting a decent description of wxhaskell's >> (intended) semantics? I'm getting exasperated. >> >> At 12:08 AM -0400 5/9/08, Dean Herington wrote: >> >I'm using wxhaskell 0.10.3 with ghc 6.8.2 on Windows XP Pro. I'm >> >trying to figure out how to change the content of a frame >> >dynamically. The program shown below has several problems: >> > * The initial text is garbled (a >>combination of "Screen 1" and "Screen 2"). >> > * The button label doesn't change when first clicked. >> > * Nothing changes on subsequent button presses. >> >Any ideas? >> > >> >> module Main where >> >> >> >> import Graphics.UI.WX >> >> >> >> main = start gui >> >> >> >> gui = do >> >> f <- frame [text := "Test 1"] >> >> p <- panel f [] >> >> t1 <- staticText p [text := "Screen 1"] >> >> b1 <- button p [text := "switch to 2"] >> >> t2 <- staticText p [text := "Screen 2"] >> >> b2 <- button p [text := "switch to 1"] >> >> set b1 [on command := switch f p t2 b2] >> >> set b2 [on command := switch f p t1 b1] >> >> switch f p t1 b1 >> >> >> >> switch f p t b = set f [layout := fill $ container p $ margin 10 $ > > > >column 5 [widget t, widget b]] |
From: Mads L. <mad...@ya...> - 2008-05-20 15:05:40
|
Hi, Dean Herington wrote: > >> I reread Daan's original paper and found a hint that layouts need to > >> mention each widget exactly once (though I can't find anything > >> definitive in documentation for either wxhaskell or wxwidgets). > >> Obeying that "rule" avoids the garbling, but I'm still not able > >> successfully to change the layout repeatedly. Even if I could, how > >> then would I show different subsets of widgets at different times? > >Every widget which is created must be used once and only once. That is > >the rule. > > Does the documentation for either wxHaskell or > wxWidgets explain this rule? I couldn't find it. I looked a bit and could not find the rule except in the paper "wxHaskell – A portable and concise GUI library for Haskell" (see http://legacy.cs.uu.nl/daan/pubs.html#wxhaskell ), which I guess is the one you refers to. It would be good if we added the use-only-once rule somewhere. Do you have a suggestion? Can you name a place where would you would have found it? Greetings, Mads Lindstrøm |