标题:50分求助一个linux下的gtk+程序的困惑
取消只看楼主
宣_仲达
Rank: 2
来 自:广东工业大学
等 级:论坛游民
帖 子:46
专家分:51
注 册:2009-8-3
结帖率:100%
 问题点数:0 回复次数:0 
50分求助一个linux下的gtk+程序的困惑
问题描述:随便修改一个按钮长度的大小(gtk_table_attach函数里),都会引起整个界面布局的变化。
                 假定的修改,具体的问题写在代码注释里面,非常希望有人能帮我解答。
程序代码:
#include <gtk/gtk.h>
int main (int argc, char *argv[])
{
    GtkWidget *window;
    GtkWidget *label;
    GtkWidget *button1;
    GtkWidget *button2;
    GtkWidget *button3;
    GtkWidget *button4;
    GtkWidget *button5;
    GtkWidget *button6;
    GtkWidget *button7;
    GtkWidget *table;
  
    gtk_init (&argc, &argv);
  
    window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    gtk_window_set_title (GTK_WINDOW(window),"计算机学院");
    gtk_widget_set_usize (window, 305, 235);
    gtk_widget_set_uposition(window, 500, 100);
    table = gtk_table_new(2,15,1);
    button1 = gtk_button_new_with_label("记录学生成绩");
    button2 = gtk_button_new_with_label("删除学生成绩");
    button3 = gtk_button_new_with_label("修改学生成绩");
    button4 = gtk_button_new_with_label("查询学生成绩");
    button5 = gtk_button_new_with_label("保存文件");
    button6 = gtk_button_new_with_label("导出文件");
    button7 = gtk_button_new_with_label("退出");
    label = gtk_label_new("成绩管理系统");
  
    gtk_container_add(GTK_CONTAINER(window), table);
    gtk_table_attach (GTK_TABLE(table), button1, 1, 15, 1, 2, (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0);
    gtk_table_attach (GTK_TABLE(table), button2, 1, 15, 2, 3, (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0);
    gtk_table_attach (GTK_TABLE(table), button3, 1, 15, 3, 4, (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0);
    gtk_table_attach (GTK_TABLE(table), button4, 1, 15, 4, 5, (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0);//为什么这里6不能设成15?设成15之后整个界面都变了
    gtk_table_attach (GTK_TABLE(table), button5, 1, 15, 5, 6, (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0);
    gtk_table_attach (GTK_TABLE(table), button6, 1, 15, 6, 7, (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0);
    gtk_table_attach (GTK_TABLE(table), button7, 1, 15, 7, 8, (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0);
    gtk_table_attach (GTK_TABLE(table), label, 0, 16, 0, 1, (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0);  
    //上面这部分,按钮的长度只要发生变化,都会引起整个界面发生变化,为什么阿?我只想改变一个按钮长度而已。
    gtk_widget_show (window);
    gtk_widget_show (table);
    gtk_widget_show (button1);
    gtk_widget_show (button2);
    gtk_widget_show (button3);
    gtk_widget_show (button4);
    gtk_widget_show (button5);
    gtk_widget_show (button6);
    gtk_widget_show (button7);
    gtk_widget_show (label);
  
    gtk_main();
    return 0;
}

搜索更多相关主题的帖子: gtk linux 困惑 
2009-09-10 09:16



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-285282-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.292392 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved