[Haskell-cafe] wxHaskell: getting a checkbox state
Arthur Baars
arthurb at cs.uu.nl
Wed Sep 14 11:54:10 EDT 2005
Hi,
A "Checkbox" is instance of the class Checkable:
http://wxhaskell.sourceforge.net/doc/
Graphics.UI.WX.Classes.html#t%3ACheckable
This means you can "get" and "set" the "checked" property for
checkboxes.
for example:
c <- get cbEdit checked
set cbEdit [checked := not c ]
The following code makes the checkbox print its state every time it is
checked or unchecked:
cbEdit <- checkBox f [text := "Edit Mode" ]
set cbEdit [ on command := do v <- get cbEdit checked
print v
]
Arthur
PS: there is a mailinglist for wxhaskell-related questions:
http://lists.sourceforge.net/lists/listinfo/wxhaskell-users
On 14-sep-05, at 17:15, Mark Carter wrote:
> I'm a complete n00b to Haskell, and I am trying to write an
> experimental app using wxHaskell. I'm getting on suprisingly well,
> given that I have practially no idea what I'm doing.
>
> In my main loop I have
> cbEdit <- checkBox p1 [text := "Edit Mode", on command := onCbEdit
> textlog ]
> where p1 is a panel, and textlog is a textCtrl that I want to write
> output to. In my where clause I have defined:
>
> onCbEdit textlog = do
> appendText textlog "onCbEdit\n"
>
> So far, this works. The thing that's got me totally stumped is this:
> suppose I want onCbEdit to do something dependent on the state of the
> checkbox (i.e. whether it is checked or unchecked). I've tried a
> variety of things, but I can't get anything to work.
>
> To put things into a wider context, here's the message I posted to
> fa.haskell yesterday:
>
> I'm the rawest of n00bs to Haskell. I was interested in evaluating it,
> and I've seen some GUI stuff that looked pretty impressive.
>
> I wanted to write a protoype for a commercial application to do
> hydrocarbon accounting. Which is to say, you've a number of so-called
> "streams" - think of them as graph nodes - feeding into each other in a
> directed fashion (assume the graph is acyclic). Then there's a bunch of
> business logic which determines how the values of one stream are
> affected by the values in another. An example of a stream might be a
> platform. Another one might be a well. Each stream would display on the
> window as some funky symbol, with its name underneath.
>
> It would be nice if the application had an edit mode, where you could
> add, move, delete, and join streams in a window; and a data mode, where
> you could click on the stream you were interested in and examine its
> properties.
>
> Is there a Haskell GUI toolkit which is particularly suitable for this?
>
> Other requirements of the toolkit would be:
> * Works on Windows (XP)
> * commercial-friendly licence: GPL is out, and even LGPL is a bit
> fiddly
> * free
> * bonus points for being easy to use, and well-documented
>
>
> ___________________________________________________________ To help
> you stay safe and secure online, we've developed the all new Yahoo!
> Security Centre. http://uk.security.yahoo.com
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
More information about the Haskell-Cafe
mailing list