0

如果文件不存在,我想创建一个显示错误消息的网格:

/* size */
s = get_file_size(recording->filename);
if (s > 0) {
    size = g_format_size_full(s, G_FORMAT_SIZE_LONG_FORMAT);
    gtk_label_set_text(GTK_LABEL(size_lbl), size);
    gtk_widget_hide(error)
    g_free(size);
} else {
    size = g_strdup(_("Import Errors"));
    gtk_widget_show(error)
}

在 gtk 网格中,无法设置“错误”元素的类型以显示屏幕截图中的消息:

grid = gtk_grid_new();
gtk_grid_set_row_spacing(GTK_GRID(grid), 6);
gtk_grid_set_column_spacing(GTK_GRID(grid), 15);
gtk_container_set_border_width(GTK_CONTAINER(grid), 6);

s_lbl = gtk_label_new(Size:);
size_lbl = gtk_label_new("");
error = ?
error_pixmap = gtk_image_new_from_stock(GTK_STOCK_DIALOG_ERROR, GTK_ICON_SIZE_SMALL_TOOLBAR);
gtk_container_add(GTK_CONTAINER(error), error_pixmap);

gtk_grid_attach(GTK_GRID(grid), s_lbl, 0, 0, 1, 1);
gtk_grid_attach(GTK_GRID(grid), error, 1, 0, 1, 1);
gtk_grid_attach(GTK_GRID(grid), size_lbl, 2, 0, 1, 1);

任何帮助,谢谢。

截屏:

[尺寸]:在此处输入图像描述

4

1 回答 1

0

使用GtkBox带有GTK_ORIENTATION_HORIZONTAL的 或 中的相邻单元格GtkGrid

于 2012-07-03T06:18:25.583 回答