LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 12-29-2021, 03:13 AM   #1
web8
LQ Newbie
 
Registered: Jun 2021
Posts: 6

Rep: Reputation: Disabled
How can I add black borders to widget on grid (gtk4 linux xfce)?


Quote:
I have xubuntu 21.10. gtk4..g++ ...next source codes:
.......
GtkWidget *label;
........
label = gtk_label_new("dgdfgdfg");
gtk_widget_set_size_request(label, 20, 60);
.........
gtk_grid_attach (GTK_GRID (grid), label,200, 3, 50, 50);
.........
gtk_widget_show (win);
.........

How can I add black borders to this "label" (widget) on form (gtk4 form with grid)?
Attached Thumbnails
Click image for larger version

Name:	2222222.jpg
Views:	21
Size:	168.8 KB
ID:	37942  
 
Old 12-29-2021, 07:59 AM   #2
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
Wouldn't that be part of the theme's CSS, ideally?
Or hardcode some style attributes?

The actual style would just be
Code:
border: 1px solid black
or some such.
 
Old 12-29-2021, 09:09 AM   #3
web8
LQ Newbie
 
Registered: Jun 2021
Posts: 6

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by ondoho View Post
Wouldn't that be part of the theme's CSS, ideally?
Or hardcode some style attributes?

The actual style would just be
Code:
border: 1px solid black
or some such.
How can I add css style to GtkWidget:
Quote:
GtkWidget *btn1;
GtkWidget *btn2;
GtkWidget *label;
?
 
Old 12-29-2021, 09:31 AM   #4
shruggy
Senior Member
 
Registered: Mar 2020
Posts: 3,678

Rep: Reputation: Disabled
Ahem.
gtk_label_set_markup
gtk_button_set_has_frame

Last edited by shruggy; 12-29-2021 at 09:32 AM.
 
Old 12-29-2021, 10:03 AM   #5
web8
LQ Newbie
 
Registered: Jun 2021
Posts: 6

Original Poster
Rep: Reputation: Disabled
I writed as:
Quote:
const char *format = "<span style="color:blue">\%s</span>";
char *markup;

markup = g_markup_printf_escaped (format, str);
gtk_label_set_markup (GTK_LABEL (label), markup);
g_free (markup);
this code is not working.
I writed as:
Quote:
const char *format = "<span style="italic">\%s</span>";
char *markup;

markup = g_markup_printf_escaped (format, str);
gtk_label_set_markup (GTK_LABEL (label), markup);
g_free (markup);
this code is working.

How can I change color of this text on "gtk4 widget on grid form"?
 
Old 12-29-2021, 12:04 PM   #6
EdGr
Senior Member
 
Registered: Dec 2010
Location: California, USA
Distribution: I run my own OS
Posts: 1,003

Rep: Reputation: 474Reputation: 474Reputation: 474Reputation: 474Reputation: 474
Quote:
Originally Posted by web8 View Post
How can I change color of this text on "gtk4 widget on grid form"?
Use a GtkDrawingArea and draw the text yourself.

In general, an application program should not try to change the appearance of pre-defined widgets because that is controlled by the theme. Custom drawing is done with the GtkDrawingArea.
Ed
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] easyeffects/gtk4 rasp Slackware 2 08-07-2021 03:12 PM
LXer: Material Shell Gets GNOME Shell 40 Support, New Overview And Gtk4 Settings Alternative Tiling GNOME Shell UI LXer Syndicated Linux News 0 05-26-2021 08:33 PM
LXer: Shortwave Internet Radio Player 2.0 Released With UI Rewritten In GTK4, New Mini Player Mode LXer Syndicated Linux News 0 04-15-2021 10:42 PM
LXer: Ubuntu 21.04 Hirsute Hippo Scraps GNOME 40 and GTK4 LXer Syndicated Linux News 0 01-22-2021 11:46 PM
Showing a widget above a widget in GTK aarontwc Programming 4 11-26-2008 11:40 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:45 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration