#include <gtk/gtk.h>
#include <string.h>
#include <stdlib.h>
#include <string.h>
static GtkWidget *window;
static GtkWidget *txt;
static GtkWidget *table;
static GtkWidget *button[4];
static GtkWidget *label;
static GtkWidget *entry[2];
char *reg_mesg()
{
char userinfo[40];
memset(userinfo , 0 , sizeof(userinfo));
strcat(userinfo , "REGIST");
strcat(userinfo , ":");
strcat(userinfo , gtk_entry_get_text(GTK_ENTRY(entry[0])));
strcat(userinfo , ":");
strcat(userinfo , gtk_entry_get_text(GTK_ENTRY(entry[1]) ));
printf("%s", userinfo);
gtk_main_quit();
exit(0);
}
char *log_mesg()
{
char userinfo[40];
memset(userinfo , 0 , sizeof(userinfo));
strcat(userinfo , "LOGIN");
strcat(userinfo , ":");
strcat(userinfo , gtk_entry_get_text(GTK_ENTRY(entry[0])));
strcat(userinfo , ":");
strcat(userinfo , gtk_entry_get_text(GTK_ENTRY(entry[1]) ));
printf("%s", userinfo);
gtk_main_quit();
exit(0);
}
int main(int argc, char *argv[] )
{
gtk_init(&argc, &argv);
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
table = gtk_table_new (4 ,3 ,TRUE);
button[0] = gtk_button_new_with_label ("Number");
button[1] = gtk_button_new_with_label ("passwd");
button[2] = gtk_button_new_with_label ("regist");
button[3] = gtk_button_new_with_label ("denglu");
label = gtk_label_new ("this is a label");
entry[0] =gtk_entry_new();
entry[1] =gtk_entry_new();
gtk_entry_set_text(GTK_ENTRY(entry[0]), "please input you QQnum");
gtk_entry_set_text(GTK_ENTRY(entry[1]), "please input you passwd");
gtk_window_set_title (GTK_WINDOW(window), "table button");
gtk_widget_set_usize (window , 600, 400);
gtk_container_add(GTK_CONTAINER(window), table);
gtk_signal_connect(GTK_OBJECT(button[2]), "clicked", GTK_SIGNAL_FUNC(reg_mesg), NULL);
gtk_signal_connect(GTK_OBJECT(button[3]), "clicked", GTK_SIGNAL_FUNC(log_mesg), NULL);
gtk_table_attach (GTK_TABLE(table), button[0], 0, 1, 0, 1,
(GtkAttachOptions) (GTK_FILL),
(GtkAttachOptions) (0), 0, 0);
gtk_table_attach (GTK_TABLE(table), button[1], 0, 1, 1, 2,
(GtkAttachOptions) (GTK_FILL),
(GtkAttachOptions) (0), 0, 0);
gtk_table_attach (GTK_TABLE(table), button[2], 1, 2, 2, 3,
(GtkAttachOptions) (GTK_FILL),
(GtkAttachOptions) (0), 0, 0);
gtk_table_attach (GTK_TABLE(table), button[3], 2, 3, 2, 3,
(GtkAttachOptions) (GTK_FILL),
(GtkAttachOptions) (0), 0, 0);
gtk_table_attach (GTK_TABLE(table), entry[0], 1, 3, 0, 1,
(GtkAttachOptions) (GTK_FILL),
(GtkAttachOptions) (0), 0, 0);
gtk_table_attach (GTK_TABLE(table), entry[1], 1, 3, 1, 2,
(GtkAttachOptions) (GTK_FILL),
(GtkAttachOptions) (0), 0, 0);
gtk_widget_show (window);
gtk_widget_show (table);
gtk_widget_show (button[0]);
gtk_widget_show (button[1]);
gtk_widget_show (button[2]);
gtk_widget_show (button[3]);
gtk_widget_show (entry[0]);
gtk_widget_show (entry[1]);
gtk_main( );
}
denglu.c.tar.gz_gtk
版权申诉
147 浏览量
2022-09-24
04:01:22
上传
评论
收藏 894B GZ 举报
APei
- 粉丝: 63
- 资源: 1万+
最新资源
- C语言基础-C语言编程基础之Leetcode编程题解之第39题组合总和.zip
- C语言基础-C语言编程基础之Leetcode编程题解之第38题外观数列.zip
- C语言基础-C语言编程基础之Leetcode编程题解之第37题解数独.zip
- C语言基础-C语言编程基础之Leetcode编程题解之第36题有效的数独.zip
- C语言基础-C语言编程基础之Leetcode编程题解之第35题搜索插入位置.zip
- index.wxml
- C语言基础-C语言编程基础之Leetcode编程题解之第33题搜索旋转排序数组.zip
- 基于Python实现的手写数字识别系统源码.zip
- 从网页提取禁止转载的文字
- C语言基础-C语言编程基础之Leetcode编程题解之第32题最长有效括号.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈