Forums

Using Gtk#

General discussion about Cobra. Releases and general news will also be posted here.
Feel free to ask questions or just say "Hello".

Using Gtk#

Postby Mirco » Wed Mar 05, 2008 1:00 pm

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?
Mirco
 
Posts: 2

Re: Using Gtk#

Postby Charles » Wed Mar 05, 2008 1:31 pm

I don't know yet, but will take a look tonight. Thanks for the report.
Charles
 
Posts: 2515
Location: Los Angeles, CA

Re: Using Gtk#

Postby Charles » Wed Mar 05, 2008 8:24 pm

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.
Charles
 
Posts: 2515
Location: Los Angeles, CA

Re: Using Gtk#

Postby PixelPartner » Mon Mar 17, 2008 10:47 am

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
PixelPartner
 
Posts: 5
Location: Berlin/Germany

Re: Using Gtk#

Postby Charles » Mon Mar 17, 2008 11:05 am

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.
Charles
 
Posts: 2515
Location: Los Angeles, CA


Return to Discussion

Who is online

Users browsing this forum: No registered users and 29 guests