GTK进度条高度
Gtk Progress bar height
我正在开发C 中的GTK应用程序。(GTK 3.0(。我的问题是我无法更改进度键的高度!(https://developer.gnome.org/gtk3/stable/gtkprogressbar.html(
下图将显示我的需求。总的来说,我想在我的代码中设置进度栏的高度。
我正在使用以下命令来编译我的示例:
gcc progress.cpp `pkg-config --cflags gtk+-3.0` `pkg-config --libs gtk+-3.0
这是我的代码的示例:
#include <gtk/gtk.h>
static gboolean
fill (gpointer user_data)
{
GtkWidget *progress_bar = user_data;
/*Get the current progress*/
gdouble fraction;
fraction = gtk_progress_bar_get_fraction (GTK_PROGRESS_BAR (progress_bar));
/*Increase the bar by 10% each time this function is called*/
fraction += 0.1;
/*Fill in the bar with the new fraction*/
gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (progress_bar), fraction);
/*Ensures that the fraction stays below 1.0*/
if (fraction < 1.0)
return TRUE;
return FALSE;
}
static void
activate (GtkApplication *app,
gpointer user_data)
{
GtkWidget *window;
GtkWidget *progress_bar;
gdouble fraction = 0.0;
/*Create a window with a title, and a default size*/
window = gtk_application_window_new (app);
gtk_window_set_title (GTK_WINDOW (window), "ProgressBar Example");
gtk_window_set_default_size (GTK_WINDOW (window), 220, 20);
/*Create a progressbar and add it to the window*/
progress_bar = gtk_progress_bar_new ();
gtk_container_add (GTK_CONTAINER (window), progress_bar);
/*Fill in the given fraction of the bar. Has to be between 0.0-1.0 inclusive*/
gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (progress_bar), fraction);
/*Use the created fill function every 500 milliseconds*/
g_timeout_add (500, fill, GTK_PROGRESS_BAR (progress_bar));
gtk_widget_show_all (window);
}
int
main (int argc, char **argv)
{
GtkApplication *app;
int status;
app = gtk_application_new ("org.gtk.example", G_APPLICATION_FLAGS_NONE);
g_signal_connect (app, "activate", G_CALLBACK (activate), NULL);
status = g_application_run (G_APPLICATION (app), argc, argv);
g_object_unref (app);
return status;
}
对于GTK 3.20和更新,在定义CSS时,似乎必须使用progress
和trough
类,而不是使用progressbar
类。这对我有用:
progress, trough {
min-height: 30px;
}
相关文章:
- 如何在运行中期切换GTK CSS style_context
- 如何在GTK程序运行时禁用屏幕保护程序/电源管理/屏幕消隐
- 如何使用 GTK 3 正确设置默认文本
- Gtkmm 会不断检查 Gtk::日历上的所选日期是否发生变化
- 使用 Gtkmm 以编程方式选择 Gtk::TextView 中的文本
- C++:如何根据地形高度更新玩家身高?
- 如何更改QComboBox项目的高度大小?
- 是否可以编译 Gtk+ 应用程序以同时在 Gtk 2 和 3 上运行
- 更改高度贴图,使其在 4x4 网格上显示 16 个 hieghtmap
- 我试图用这段代码找到二叉树的高度,但它一直返回 0,有人可以告诉我为什么吗?
- GTK 最大化表单 C++
- GTK:完全摆脱系统主题/CSS
- C++:如何计算二叉树中其值模块高度小于 2 的节点数?
- GTK C++:找不到信号处理程序 您是否使用 -rdynamic 进行了编译?
- 如何使用 C++ gdal 库将栅格地理从 EGM96 转换为 WGS84 椭球体高度基准面
- 如何从 Gtk::窗口调用派生对象的析构函数
- 从具有父指针和左子树和右子树高度的树中删除
- 程序输入名称和高度并显示它。我不知道如何显示列表中最高人的姓名和身高
- Gtk::带有set_icon_name的窗口图标集在 wayland 上不起作用
- GTK进度条高度