2023-01-23 01:51 AM
Hi!
I am using STM32MP157C-DK2 board to create an application on the screen (using GTK library). My idea is to create a window with the following image inside:
Created code:
#include <gtk/gtk.h>
int main(int argc, char **argv)
{
GtkWidget *window;
GtkWidget *layout;
GtkWidget *image;
GtkWidget *button;
gtk_init(&argc, &argv);
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_default_size (GTK_WINDOW (window), 800, 480);
gtk_window_set_title (GTK_WINDOW (window), "Info window");
// gtk_window_fullscreen(GTK_WINDOW(window));
gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
layout = gtk_layout_new(NULL, NULL);
gtk_container_add(GTK_CONTAINER (window), layout);
gtk_widget_show(layout);
image = gtk_image_new_from_file("linux.png");
gtk_layout_put(GTK_LAYOUT(layout), image, 600, 50);
button = gtk_button_new_with_label("PREVIOUS");
gtk_layout_put(GTK_LAYOUT(layout), button, 150, 300);
gtk_widget_set_size_request(button, 200, 50);
g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(gtk_window_close), window);
button = gtk_button_new_with_label("NEXT");
gtk_layout_put(GTK_LAYOUT(layout), button, 450, 300);
gtk_widget_set_size_request(button, 200, 50);
g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(gtk_window_close), window);
gtk_widget_show_all(window);
gtk_main();
return 0;
}
Then I have created executable using STM32CubeIDE and uploaded it with the image file (.png) in the following location:
Finally, I have run the GTK application with the following command:
Board $> su -l weston -c "/usr/local/custom_GTK"
Obtained result:Does anyone know how I can display the image?
Thanks!
Solved! Go to Solution.
2023-01-23 04:48 AM
Hello @TArre.1,
This kind of problem with GTK really let me think about a wrong path of your image. Try to mention the absolute path of the image (e.g. /usr/local/myimages/linux.png), or be careful to respect the right relative path of it.
Kind regards,
Erwan
In order to give better visibility on the answered topics, please click on 'Select as Best' on the reply which solved your issue or answered your question. See also 'Best Answers'
2023-01-23 04:48 AM
Hello @TArre.1,
This kind of problem with GTK really let me think about a wrong path of your image. Try to mention the absolute path of the image (e.g. /usr/local/myimages/linux.png), or be careful to respect the right relative path of it.
Kind regards,
Erwan
In order to give better visibility on the answered topics, please click on 'Select as Best' on the reply which solved your issue or answered your question. See also 'Best Answers'
2023-01-23 07:34 AM
Thank you @Erwan SZYMANSKI , with absolute path is working! :beaming_face_with_smiling_eyes: