Interactive GUI programming

GUI libraries are usually very large and therefore it is as time consuming to learn a new language as it is to learn a new GUI library. The F# interactive can be very helpful in exploring the Winforms GUI toolkit through its auto-completion feature.

> open System;;
> open System.Windows.Forms;;
> let form = new Form();;

val form : Form = System.Windows.Forms.Form, Text: 

> form.Visible <- true;;

Now, try to explore the content of this forms object through auto-completion invoked by typing the TAB-key after entering the object name following a dot. On each TAB key-press a possible auto-completion should appear. You may move backwards by pressing Shift-TAB.

> form.

Move forward until you reach the element ‘Text’ and enter ‘<- “Hello”‘ to assign a text to the window.

> form.Text <- "Hello";;                 
val it : unit = ()

You  may also enter partially completed text and ask the interactive to check for possible completions.

> form.Clo

// first completion after TAB
> form.Closing

// second completion after TAB
> form.Close

// third completion after TAB
> form.Closed

I always keep an interactive F# session open while coding to explore the API directly.

This entry was posted in GUI. Bookmark the permalink.

2 Responses to Interactive GUI programming

  1. Hi,

    thank you for putting these turorials together. I am also in the process of learning F# and I appreciate your easy to follow examples.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s