Yes the problem is the toplevel. Basically the toplevel runs a winforms event loop by default so you can use winforms controls no problem (this has been observed to work correctly under mono too).

The F# level offers the possibility to replace the event loop, the samples, now on code gallery [1], show to replace the winforms event loop with WPF event loop. In theroy it should be possible to write a GTK replacement event loop, but as far as I know no-one has ever done this, possibly because the interface you need to implement isn't too well document.

Cheers,

Rob

[1] [link:code.msdn.microsoft.com]

By on 11/19/2008 12:21 AM ()

The real problem here was quite simple. During copying of the code I have missed the last line (Application.Run()). With this line everything works fine.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#light

open System
open Gtk

Application.Init()

let window = new Gtk.Window(”F# Gtk”)
let vBox = new Gtk.VBox()
let closeButton = new Gtk.Button()
let label = new Gtk.Label(”Hello World!”)

window.WindowPosition < - Gtk.WindowPosition.Center
window.SetDefaultSize(160, 40)
window.Destroyed.Add(fun _ -> Application.Quit() )
closeButton.Label < - “Close”
closeButton.Clicked.Add(fun _ -> Application.Quit() )

vBox.BorderWidth < - (uint32) 6
vBox.PackStart(label, false, false, (uint32) 6)
vBox.PackStart(closeButton, false, false, (uint32) 6)

window.Add(vBox)
window.ShowAll()

Application.Run()
By on 11/21/2008 12:34 PM ()
IntelliFactory Offices Copyright (c) 2011-2012 IntelliFactory. All rights reserved.
Home | Products | Consulting | Trainings | Blogs | Jobs | Contact Us | Terms of Use | Privacy Policy | Cookie Policy
Built with WebSharper