GTK+中文社区(gtk.awaysoft.com)

 找回密码
 马上加入

QQ登录

只需一步,快速开始

查看: 2566|回复: 1

button and box

[复制链接]

该用户从未签到

发表于 2012-12-5 12:22:06 | 显示全部楼层 |阅读模式
#include <gtk/gtk.h>
#include <stdio.h>
void button_start_func (GtkWidget *window, gpointer data)
{
    printf ("start\n");
}
void button_end_func (GtkWidget *window, gpointer data)
{
    printf ("end\n");
}
int main (int argc, char *argv[])
{
    GtkWidget *window;
    GtkWidget *entry;
    GtkWidget *button_start;
    GtkWidget *button_end;
    GtkWidget *entry_num;
    GtkWidget *entry_val;
    GtkWidget *hbox;
    GtkWidget *vbox;
    gtk_init (&argc, &argv);
    window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
    entry = gtk_entry_new ();
    button_start = gtk_button_new_with_label ("start");
    button_end = gtk_button_new_with_label ("end");
    entry_num = gtk_entry_new ();
    entry_val = gtk_entry_new ();
    hbox = gtk_hbox_new (FALSE, 4);
    vbox = gtk_vbox_new (TRUE, 4);
    g_signal_connect (GTK_OBJECT (button_start), "clicked", GTK_SIGNAL_FUNC ( button_start_func ), NULL);
    g_signal_connect (GTK_OBJECT (button_end), "clicked", GTK_SIGNAL_FUNC ( button_end_func ), NULL);
    gtk_box_pack_start (GTK_BOX (hbox), entry, TRUE, TRUE, 2);
    gtk_box_pack_start (GTK_BOX (hbox), entry_num, TRUE, TRUE, 2);
    gtk_box_pack_start (GTK_BOX (hbox), button_start, FALSE, TRUE, 2);
    gtk_box_pack_start (GTK_BOX (hbox), button_end, FALSE, TRUE, 2);
    gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 2);
    gtk_box_pack_start (GTK_BOX (vbox), entry_val, TRUE, TRUE, 2);
    gtk_container_add (GTK_CONTAINER (window), vbox);
    gtk_widget_show_all (window);
    gtk_main ();
    return 0;
}

  • TA的每日心情
    奋斗
    2015-10-16 12:17
  • 签到天数: 401 天

    连续签到: 1 天

    [LV.9]以坛为家II

    发表于 2012-12-5 22:10:33 | 显示全部楼层
    在label里面显示出来多好啊  dos太难看了
    *滑块验证:
    您需要登录后才可以回帖 登录 | 马上加入

    本版积分规则

    申请友链|Archiver|小黑屋|手机版|GTK+中文社区 ( 粤ICP备13080851号 )

    我要啦免费统计

    GMT+8, 2024-11-21 18:31 , Processed in 0.027169 second(s), 9 queries , Redis On.

    Powered by Discuz! X3.4

    Copyright © 2001-2021, Tencent Cloud.

    快速回复 返回顶部 返回列表