HaskellWiki

Haskell | Wiki community | Recent changes
Random page | Special pages

 

Not logged in
Log in | Help

WxHaskell/Tips and tricks

< WxHaskell

Contents

1 Getting Started

2 Text

3 Layout

4 Scroll Bars

5 Mac OS X (Darwin)

6 Other tips

6.1 Idle event

Use the idle event for automation.

6.2 Long computations

Scenario: you've got a looooooong computation and you want to update a progress bar or you want to have a 'STOP' button which aborts the computation

Solution:

FIXME: elaborate on this!

6.3 Managing multiple windows

Scenario: you have a main window MAIN with some information. You want to create a secondary window PARAMS in which the user edits some configuration stuff. When the user closes PARAMS, the window MAIN should be updated to reflect the new settings.

You have some code which looks like

set paramsButton [ on command := do createParamsWindow
                                    updateMainWindow ]

Problem: MAIN is not updated... at least, not until you call PARAMS a second time.

Observations:

Explanation: updateMainWindow tries to read the new configuration value, but it does not succeed, because no configuration values have changed. Why not? Simpler than it looks: all the createParamsWindow function does is creates a window with some widgets, assign some commands to said widgets, and return. There's nothing in the createParamsWindow code that says the function should only return when PARAMS has been closed.

Solution: Pass createParamsWindow a function which updates the MAIN window:

set paramsButton [ on command := do createParamsWindow updateMainWindow ]

When the user closes PARAMS, one of the final things it should do is call this update function

Retrieved from "http://www.haskell.org/haskellwiki/WxHaskell/Tips_and_tricks"

This page has been accessed 394 times. This page was last modified 18:30, 5 August 2008. Recent content is available under a simple permissive license.