首页 > 解决方案 > 用于滚动 H 的 GTK 应用程序

问题描述

我是一名 Linux 内核开发人员,我们有一块运行 Yocto Image 的开发板,需要显示“全黑屏,滚动 H ”以进行 CISPR 测试。我正在为此使用 GTK 库,编写了一个示例代码,它使整个屏幕空白并在中心写上“Hello World”。

#include <gtk/gtk.h>
int main (int argc, char *argv[])
{
    GtkWidget *window;// GtkWidget is the storage type for widgets
    GtkWidget *label;
    gtk_init (&argc, &argv);// This is called in all GTK applications. Arguments are parsed
                        //from the command line and are returned to the application.
    window=gtk_window_new(GTK_WINDOW_TOPLEVEL); //creating a new window.
    label = gtk_label_new("Hello World");
    gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT);
    gtk_container_add(GTK_CONTAINER(window), label);
    gtk_window_set_decorated(GTK_WINDOW(window), FALSE);
    GdkCursor* Cursor = gdk_cursor_new(GDK_BLANK_CURSOR);
    GdkWindow* win = gtk_widget_get_window((window));
    gdk_window_set_cursor((win),Cursor);
    gtk_widget_show_all(window); //The final step is to display this newly created widget.
   gtk_main (); //All GTK applications must have a gtk_main(). Control ends here
                       //and waits for an event to occur (like a key press or mouse event).
   return 0;
}

由于我是 GUI 的新手,任何人都可以指导我应该使用哪些小部件来获得滚动 H。

https://www.youtube.com/watch?v=PWkuqyC3AWk

标签: clinuxuser-interfacetestinggtk

解决方案


推荐阅读