2012-09-19 4 views
1

누구나 GTKAda에서 버튼 레이블의 특성을 수정하는 방법을 알고 있습니다.GTKAda에서 버튼 레이블의 글꼴 크기 및 색상 수정

Pango의 패키지와 스타일 패키지를 위젯의 패키지로 사용해 보았는데 속성을 변경하지 않았습니다.

코드는 다음과 같은 것입니다 :

Gtk_New (Button_Select, "Select"); 
Modify_Font (Button_Select, From_String("Helvetica 16")); 
Pack_Start (Control_Box, Button_Select, False, False, 1); 

하지만 라벨의 특성은 변경되지 않습니다 "선택".

어떤 아이디어 나 힌트가 있습니까?

내 질문을 읽고 주셔서 감사합니다.

답변

1

PHP의 코드에서 솔루션을 찾았지만 명령을 ada로 전송했지만 질문을 남기고 대답하는 것이 유용하다고 생각합니다.

단추를 만들면 레이블 개체도 만들어지고 단추에 추가됩니다. 그것은 얻을 수있는 레이블 개체 - Get_Child-- 기능을 누른 다음 정상적인 레이블로 레이블 개체를 사용합니다. 다음과 같이

명령은 다음과 같습니다

Set_Markup(GTk_Label(Get_Child (Button_S)), "<span weight=""bold"" color=""blue"" size=""xx-large"">It Works!!</span>"); 

전체 코드는 다음과 같습니다

with GLib;   use GLib; 
    with Gtk.Window; use Gtk.Window; 
    with Gtk.Frame;  use Gtk.Frame; 
    with Gtk.Button; use Gtk.Button; 
    with Gtk.Widget; use Gtk.Widget; 
    with Gtk.Label;  use Gtk.Label; 
    with Pango.Font; use Pango.Font; 
    with Gtk.Handlers; 
    with Gtk.Main; 

    procedure button_label_test is 
     Window   : Gtk_Window; 
     Frame   : Gtk_Frame; 
     Button_S  : Gtk_Button; 

     package Handlers is new Gtk.Handlers.Callback (Gtk_Widget_Record); 
     package Return_Handlers is 
      new Gtk.Handlers.Return_Callback (Gtk_Widget_Record, Boolean); 

     function Delete_Event (Widget : access Gtk_Widget_Record'Class) 
      return Boolean is 
     begin 
      return False; 
     end Delete_Event; 

     procedure Destroy (Widget : access Gtk_Widget_Record'Class) is 
     begin 
      Gtk.Main.Main_Quit; 
     end Destroy; 

     -- This is the function to modify the characteristics of the label of the button 
     procedure Clicked (Widget : access Gtk_Widget_Record'Class) is 
     begin 
      Set_Markup(GTk_Label(Get_Child (Button_S)), "<span weight=""bold"" color=""blue"" size=""xx-large"">It Works!!</span>"); 
     end Clicked; 


    begin 
     Gtk.Main.Init; 
     Gtk.Window.Gtk_New (Window); 
     Set_Default_Size (Window, 200, 200); 
     Gtk.Window.Set_Title (Window, "Button Label test"); 
     Gtk_New (Frame); 
     Gtk_New (Button_S, "Try"); 
     Add (Frame, Button_S); 
     Add (Window, Frame); 

     Return_Handlers.Connect 
     ( Window, 
      "delete_event", 
      Return_Handlers.To_Marshaller (Delete_Event'Access) 
     ); 
     Handlers.Connect 
     ( Window, 
      "destroy", 
      Handlers.To_Marshaller (Destroy'Access) 
     ); 
     Handlers.Connect 
     ( Button_S, 
      "clicked", 
      Handlers.To_Marshaller (Clicked'Access) 
     ); 

     Show_All (Window); 
     Show (Window); 

     Gtk.Main.Main; 

    end button_label_test; 

내가 그것을 누군가에 유용 할 것이라 생각합니다.