我想创建一个Toplevel窗口并在其中使用此功能。
在任何地方都没有例子......
此处有/usr/share/ada/adainclude/gtkada/gtk-gentry.ads
function Get_Text (The_Entry : access Gtk_Entry_Record) return UTF8_String;
-- Modify the text in the entry.
-- The text is cut at the maximum length that was set when the entry was
-- created.
-- The text replaces the current contents.
对于Debian和亲属操作系统,您可以访问以下目录:sudo apt-get install libgtkada2.24.1-dev
答案 0 :(得分:1)
我想出了如何将Get_text函数与Entry一起使用。
manuBriot& andlabs =
当用户按_Enter时,我还在条目包中找到了信号。
最后,现在一切正常。
我的课程做什么? =它是一个窗口,看起来完全像这样:http://pix.toile-libre.org/?img=1450777307.png
然后,在您编写内容并在图形条目中按_Enter后,结果将在command_line中打印。
简单而有用的GTK语言开始。
WITH Gtk.Main ; USE Gtk.Main ;
WITH Gtk.Window ; USE Gtk.Window ;
WITH Gtk.Enums ; USE Gtk.Enums ;
WITH Gtk.Button ; USE Gtk.Button ;
WITH Gtk.Alignment ; USE Gtk.Alignment ;
WITH Gtk.Box ; USE Gtk.Box ;
WITH Gtk.Gentry; USE Gtk.Gentry;
WITH Ada.text_io; USE Ada.text_io;
WITH Gtk.Widget ; USE Gtk.Widget ;
with Gtk.Handlers;
PROCEDURE prototype IS
-----------------------
-- VARIABLES -- |
----------------------------------------------------------
win : Gtk_window ;
Btn1, Btn2 ,Btn3 : Gtk_Button ;
alignG, alignM ,alignD : Gtk_Alignment ;
Boite : Gtk_VBox ;
Boutons : Gtk_HBox ;
saisie : Gtk_Entry ;
----------------------------------------------------------
--Instanciation package(s) for connexion
----------------------------------------------------------
PACKAGE P_Callback IS NEW Gtk.Handlers.Callback(Gtk_Widget_Record);
USE P_Callback ;
----------------------------------------------------------
-- Handlers (or callbacks) |
----------------------------------------------------------
procedure Stop_Program(Emetteur : access Gtk_Widget_Record'class)
is
PRAGMA Unreferenced (Emetteur);
begin
Main_Quit;
end Stop_Program ;
procedure Handler_text(Ent : access Gtk_Widget_Record'class)
is begin
put_line(get_text(saisie));
end Handler_text ;
-------------------------------------------------
BEGIN
Init ;
----------------
-- NEW -- |
-------------------------------------------------
Gtk_New(win);
Gtk_New(saisie);
Gtk_New(Btn1, "Bouton 1") ;
Gtk_New(Btn2, "Bouton 2") ;
Gtk_New(Btn3, "Bouton 3") ;
Gtk_New(alignG,0.0,1.0,1.0,1.0);
Gtk_New(alignM,0.5,1.0,1.0,1.0);
Gtk_New(alignD,1.0,1.0,1.0,1.0);
Gtk_New_VBox
(Boite, homogeneous => false, Spacing => 0) ;
Gtk_New_HBox
(Boutons, homogeneous => false, Spacing => 0) ;
---------------------------------
-- Add |
---------------------------------
alignG.add(Btn1) ;
alignM.add(Btn2) ;
alignD.add(Btn3) ;
win.Add(Boite);
------------------------------------------
-- Connect |
------------------------------------------
Connect(Widget => win ,
Name => "destroy" ,
Cb => Stop_Program'access);
Connect(Widget => saisie ,
Name => "activate" ,
Cb => Handler_text'access);
------------------------------------------
-- Design Window |
------------------------------------------
Boite.Pack_Start(saisie);
Boite.Pack_Start(Boutons);
Boutons.Pack_Start(alignG);
Boutons.Pack_Start(alignM);
Boutons.Pack_Start(alignD);
win.Set_Default_Size(500,500) ;
win.set_position(Win_Pos_Mouse) ;
-- win.set_opacity(0.7) ;
win.Show_all ;
Main ;
END prototype ;
答案 1 :(得分:0)
WITH Gtk.Main ; USE Gtk.Main ;
WITH Gtk.Window ; USE Gtk.Window ;
WITH Gtk.Gentry; USE Gtk.Gentry;
WITH Gtk.Box ; USE Gtk.Box ;
WITH Gtk.Enums ; USE Gtk.Enums ;
Procedure gtkada_get_a_entry is
win : Gtk_window ;
space : Gtk_Entry ;
the_box : Gtk_VBox ;
-- function Get_Text (The_Entry : access Gtk_Entry_Record) return UTF8_String;
-- How to use the function ???
begin
Init ;
Gtk_New(win);
Gtk_New(space);
Gtk_New_VBox
(the_box, homogeneous => false, Spacing => 0) ;
the_box.Pack_Start(space);
win.Add(the_box);
win.Set_Default_Size(300,200) ;
win.set_position(Win_Pos_Center) ;
win.Show_all ;
Main ;
end gtkada_get_a_entry;
我想要做的就是使用包中描述的Get_text
函数。
我发布的代码是最小的:在屏幕上打印文本条目,但是如果我不能使用该功能那么它就没用了。