[Ada] CONSTRAINT_ERROR trying to read a GtkEntry



I get a CONSTRAINT_ERROR always I try to read a GtkEntry, as an example,
the folowing program ends with

raised CONSTRAINT_ERROR : test.adb:24

Piece of code:

with Glib; use Glib;
with Gtk.Widget; use Gtk.Widget;
with Gtk.Window; use Gtk.Window;
with Gtk.Box; use Gtk.Box;
with Gtk.GEntry; use Gtk.GEntry;
with Gtk.Button; use Gtk.Button;
with Gtk.Handlers; use Gtk.Handlers;
with Gtk.Main;

procedure Test is
	
    Window1 : Gtk_Window;
    Vbox1 : Gtk_Vbox;
    Entry1 : Gtk_Entry;
    Button1 : Gtk_Button;
	
	package Button_Callback is new
		Gtk.Handlers.Callback (Gtk_Button_Record);
	procedure Read
     (Object : access Gtk_Button_Record'Class)
   is
		Str : string(1..30);
   begin

		Str := Get_Text(Entry1); -- LINE 24

   end Read;

begin

   Gtk.Main.Set_Locale;
   Gtk.Main.Init;
   
   Gtk_New(Window1);
   Gtk_New_Vbox (Vbox1, False, 0);
   Add (Window1, Vbox1);

   Gtk_New (Entry1);
   Set_Max_Length (Entry1, 30);
   Pack_Start (Vbox1, Entry1, False, False, 0);
   
   Gtk_New (Button1,"Read");
   Button_Callback.Connect
     (Button1, "clicked",
      Button_Callback.To_Marshaller (Read'Access));
   Pack_Start (Vbox1,Button1, False, False, 0);
   
   Show(Entry1);
   Show(Button1);
   Show(VBox1);
   Show(Window1);
   
   Gtk.Main.Main;
end Test;


-- 
The chains are broken and the door is open wide
Our eyes adjusting to the light that was denied
And bring a sense of wonder

	http://www.es.debian.org/intro/about.es.html




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]