Page 1 of 1

Using Gtk#

PostPosted: Wed Mar 05, 2008 1:00 pm
by Mirco
When I try to compile the Gtk# example below I get an internal compiler error. Because the members of the instantiated Gtk.Window class cannot be accessed directly, the only way to get it to work is to use the 'sharp' prefix:
"""
gtk-test.cobra - Gtk# example.

To compile:
cobra -v:2 -compile -lib:/usr/lib/mono/gtk-sharp-2.0/ -r:gtk-sharp.dll gtk-test.cobra

To run:
mono gtk-test.exe
"""

use Gtk

class Program

def main is shared
Gtk.Application.init

window = Gtk.Window('A Window')
window.show # FAILS
# sharp'window.Show()' # OK

Gtk.Application.run

Compiler message:
Code: Select all
Cobra Command Line 0.7.4
Copyright (C) 2003-2008 by Cobra Language LLC.

OS Version:   Unix 2.6.22.17
CLR Platform: Mono
CLR Version:  2.0.50727.42
...
error: COBRA INTERNAL ERROR / ArgumentException / An element with the same key already exists in the dictionary.An element with the same key already exists in the dictionary.An element with the same key already exists in the dictionary.An element with the same key already exists in the dictionary.
Compilation failed - 1 error, 0 warnings

What is the problem?

Re: Using Gtk#

PostPosted: Wed Mar 05, 2008 1:31 pm
by Charles
I don't know yet, but will take a look tonight. Thanks for the report.

Re: Using Gtk#

PostPosted: Wed Mar 05, 2008 8:24 pm
by Charles
Well I don't have GTK# and when I go to download it I'm told that I already have it. Or rather, I'm told that Mono 1.2.6 has it which is what I'm already running...

I've posted to gtk-sharp-list for help. Until then, can you run your program again and send me the output directly to contact -AT- cobralang -DOT- com? But with -reveal-internal-exceptions added to the command line.

Thanks.

Re: Using Gtk#

PostPosted: Mon Mar 17, 2008 10:47 am
by PixelPartner
How about using the same method name as in your C# code. Did you try "windows.Show" (with capital S) ?

window.show # FAILS
# sharp'window.Show()' # OK

Re: Using Gtk#

PostPosted: Mon Mar 17, 2008 11:05 am
by Charles
I forgot to update this thread. Some of the GTK# troubleshooting took place via direct email and fixes have all been checked in.

Using GTK# should work fine now if you're running from the source:
http://cobra-language.com/source/

See Cobra-Workspace/HowTo/390-GTK.cobra

If you have any further problems, let me know.