Bonjour comme l'indique le titre j'ai un souci lors de la compilation de mon code etant donne qu'il ne trouve pas le module dans les libs de ocaml/lablgtk2.
le XML test.glade :
Le loader basique pris sur l'exemple de SpiceGuid:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182 <?xml version="1.0"?> <glade-interface> <!-- interface-requires gtk+ 2.16 --> <!-- interface-naming-policy project-wide --> <widget class="GtkWindow" id="window1"> <child> <widget class="GtkHPaned" id="hpaned1"> <property name="visible">True</property> <property name="can_focus">True</property> <child> <widget class="GtkVPaned" id="vpaned1"> <property name="visible">True</property> <property name="can_focus">True</property> <property name="orientation">vertical</property> <child> <widget class="GtkMenuBar" id="menubar1"> <property name="visible">True</property> <child> <widget class="GtkMenuItem" id="menuitem1"> <property name="visible">True</property> <property name="label" translatable="yes">_File</property> <property name="use_underline">True</property> <child> <widget class="GtkMenu" id="menu1"> <property name="visible">True</property> <child> <widget class="GtkImageMenuItem" id="imagemenuitem1"> <property name="label">gtk-new</property> <property name="visible">True</property> <property name="use_underline">True</property> <property name="use_stock">True</property> </widget> </child> <child> <widget class="GtkImageMenuItem" id="imagemenuitem2"> <property name="label">gtk-open</property> <property name="visible">True</property> <property name="use_underline">True</property> <property name="use_stock">True</property> </widget> </child> <child> <widget class="GtkImageMenuItem" id="imagemenuitem3"> <property name="label">gtk-save</property> <property name="visible">True</property> <property name="use_underline">True</property> <property name="use_stock">True</property> </widget> </child> <child> <widget class="GtkImageMenuItem" id="imagemenuitem4"> <property name="label">gtk-save-as</property> <property name="visible">True</property> <property name="use_underline">True</property> <property name="use_stock">True</property> </widget> </child> <child> <widget class="GtkSeparatorMenuItem" id="separatormenuitem1"> <property name="visible">True</property> </widget> </child> <child> <widget class="GtkImageMenuItem" id="imagemenuitem5"> <property name="label">gtk-quit</property> <property name="visible">True</property> <property name="use_underline">True</property> <property name="use_stock">True</property> </widget> </child> </widget> </child> </widget> </child> <child> <widget class="GtkMenuItem" id="menuitem2"> <property name="visible">True</property> <property name="label" translatable="yes">_Edit</property> <property name="use_underline">True</property> <child> <widget class="GtkMenu" id="menu2"> <property name="visible">True</property> <child> <widget class="GtkImageMenuItem" id="imagemenuitem6"> <property name="label">gtk-cut</property> <property name="visible">True</property> <property name="use_underline">True</property> <property name="use_stock">True</property> </widget> </child> <child> <widget class="GtkImageMenuItem" id="imagemenuitem7"> <property name="label">gtk-copy</property> <property name="visible">True</property> <property name="use_underline">True</property> <property name="use_stock">True</property> </widget> </child> <child> <widget class="GtkImageMenuItem" id="imagemenuitem8"> <property name="label">gtk-paste</property> <property name="visible">True</property> <property name="use_underline">True</property> <property name="use_stock">True</property> </widget> </child> <child> <widget class="GtkImageMenuItem" id="imagemenuitem9"> <property name="label">gtk-delete</property> <property name="visible">True</property> <property name="use_underline">True</property> <property name="use_stock">True</property> </widget> </child> </widget> </child> </widget> </child> <child> <widget class="GtkMenuItem" id="menuitem3"> <property name="visible">True</property> <property name="label" translatable="yes">_View</property> <property name="use_underline">True</property> </widget> </child> <child> <widget class="GtkMenuItem" id="menuitem4"> <property name="visible">True</property> <property name="label" translatable="yes">_Help</property> <property name="use_underline">True</property> <child> <widget class="GtkMenu" id="menu3"> <property name="visible">True</property> <child> <widget class="GtkImageMenuItem" id="imagemenuitem10"> <property name="label">gtk-about</property> <property name="visible">True</property> <property name="use_underline">True</property> <property name="use_stock">True</property> </widget> </child> </widget> </child> </widget> </child> </widget> <packing> <property name="resize">False</property> <property name="shrink">True</property> </packing> </child> <child> <widget class="GtkDrawingArea" id="drawingarea1"> <property name="visible">True</property> </widget> <packing> <property name="resize">False</property> <property name="shrink">True</property> </packing> </child> </widget> <packing> <property name="resize">False</property> <property name="shrink">True</property> </packing> </child> <child> <widget class="GtkButton" id="Quit"> <property name="label" translatable="yes">button</property> <property name="visible">True</property> <property name="can_focus">False</property> <property name="receives_default">False</property> </widget> <packing> <property name="resize">True</property> <property name="shrink">True</property> </packing> </child> </widget> </child> </widget> </glade-interface>
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 (*Gladeconverter.ml*) let load_xml () = let xml = Glade.create ~file:"test.glade" () in let window = new GWindow.window (GtkBaseProps.Window.cast(Glade.get_widget xml "window1")) in let button = new GButton.button (GtkButtonProps.Button.cast(Glade.get_widget xml "Quit")) in button#connect#clicked ~callback: (fun () -> print_endline "Bye"; window#destroy (); GMain.Main.quit ()); window#show (); GMain.Main.main () let main () = load_xml () let _ = main ()
La ligne de compile que j'utilise (biensur il manque le gtkBaseProps que je trouve pas dans les libs):
ocamlopt -o test -I +lablgtk2 lablgtk.cmxa gtkInit.cmx glade.cmx lablglade.cmxa gtkBase.cmx gladeconverter.ml
File "gladeconverter.ml", line 6, characters 4-28:
Error: Unbound value GtkBaseProps.Window.cast
Partager