How can I show text with different language direction in GTK+?

倖福魔咒の 提交于 2019-12-24 08:06:09

问题


I need to show some text in Arabic (which is right-to-left) and some other text in English (which is left-to-right) in the same GTK+ windows. Is there any way to set the language to the GktLabel instead of the application?


回答1:


Yes, with gtk_widget_set_direction:

label = gtk_label_new ("Hello World");
gtk_widget_set_halign (label, GTK_ALIGN_START);
gtk_container_add (GTK_CONTAINER (box), label);

label = gtk_label_new ("برنامج أهلا بالعالم");
gtk_widget_set_halign (label, GTK_ALIGN_START);
gtk_widget_set_direction (label, GTK_TEXT_DIR_RTL);
gtk_container_add (GTK_CONTAINER (box), label);



来源:https://stackoverflow.com/questions/47978848/how-can-i-show-text-with-different-language-direction-in-gtk

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!