Why is there no a border on this GtkFrame?

gtk frame
gtk aspect frame
gtk_container_add border width
gtk3 gtk_widget
gtkbox css
gtk+ widget library
gtk widget width
gtk canvas

I'm reading tutorials on GtkFrame, I have compile some code examples, but unlike screnhoot of the tutorial, but my program using GtkFrame don't have a border.

The following code:

#include <gtk/gtk.h>

int main( int   argc,
          char *argv[] )
{
  /* GtkWidget is the storage type for widgets */
  GtkWidget *window;
  GtkWidget *frame;
  GtkWidget *button;
  GtkWidget *label;
  gint i;

  /* Initialise GTK */
  gtk_init(&argc, &argv);

  /* Create a new window */
  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_window_set_title(GTK_WINDOW(window), "Frame Example");

  /* Here we connect the "destroy" event to a signal handler */ 
  g_signal_connect (G_OBJECT (window), "destroy",
                      G_CALLBACK (gtk_main_quit), NULL);

  gtk_widget_set_size_request(window, 300, 300);
  /* Sets the border width of the window. */
  gtk_container_set_border_width (GTK_CONTAINER (window), 10);

  label = gtk_label_new("foo");

  /* Create a Frame */
  frame = gtk_frame_new(NULL);
  gtk_container_add(GTK_CONTAINER(frame), label);
  gtk_widget_set_size_request(frame, 30, 30);

  gtk_container_add(GTK_CONTAINER(window), frame);

  /* Set the frame's label */
  gtk_frame_set_label( GTK_FRAME(frame), "GTK Frame Widget" );

  /* Set the style of the frame */
  gtk_frame_set_shadow_type( GTK_FRAME(frame), GTK_SHADOW_ETCHED_OUT);

  gtk_widget_show(frame);

  /* Display the window */
  gtk_widget_show (window);

  /* Enter the event loop */
  gtk_main ();

  return(0);
}
/* example-end */

Generate the program:

What am I missing?


This is GTK bug 659926. However, it seems this is mostly due to the fact that the Adwaita theme (default GNOME 3 theme) ignores the frames, so maybe changing the theme (using gnome-tweak-tool, if you want to use a GUI) will do the trick. However I think frames are abused in many GUIs and often lead to ugly interfaces, as they add visual clutter. Less is better.

c - Why is there no a border on this GtkFrame?, #include <gtk/gtk.h> int main( int argc, char *argv[] ) { /* GtkWidget is the storage the "devhelp" looking for something like set border/gtk frame style, but no luck. void gtk_frame_set_shadow_type (GtkFrame *frame, GtkShadowType type); Sets the “shadow-type” for frame, i.e. whether it is drawn without (GTK_SHADOW_NONE) or with (other values) a visible border. Values other than GTK_SHADOW_NONE are treated identically by GtkFrame. The chosen type is applied by removing or adding the .flat class to the CSS node named border.


Have you tried setting the shadow type of the frame?

gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_TYPE_IN); 

GtkFrame: GTK+ 3 Reference Manual, The frame widget is a bin that surrounds its child with a decorative frame and an The GtkFrame implementation of the GtkBuildable interface supports placing a If label is not NULL , creates a new GtkLabel with that text and adds it as the  void gtk_frame_set_label_widget (GtkFrame *frame, GtkWidget *label_widget); Set the label widget for the frame. This is the widget that will appear embedded in the top edge of the frame as a title.


You have to use CSS.

CSS file example:

frame#LINMONI_Frame_Inactiv {
    color: grey;
    border-style:solid;
    border-width: 8px;
    border-color: grey;
    background-color: white;
}

and after create gtkwidgets:

    GtkCssProvider *provider;
    GdkScreen *screen;
    GdkDisplay *display;

    provider = gtk_css_provider_new();
    display = gdk_display_get_default();
    screen = gdk_display_get_default_screen(display);
    gtk_style_context_add_provider_for_screen(screen, GTK_STYLE_PROVIDER(provider),GTK_STYLE_PROVIDER_PRIORITY_USER);
    gsize bytes_read;
    gsize bytes_written;
    GError *error = NULL;
    if (!gtk_css_provider_load_from_path(provider,g_filename_to_utf8("yourcssfilename.css, csCompleteFileName.GetLength(),&bytes_read, &bytes_written, &error), NULL)){
        if (error){
            Trace_Error("gtk_css_provider_load_from_path=%s\n",error->message);
        }
    }
    g_object_unref(provider);

Pro PHP-GTK, The GtkFrame has a thin border and a label at the top. Most containers do not take up space or have any size without having children added first, but because  gtk_frame_set_label_widget () void gtk_frame_set_label_widget (GtkFrame *frame, GtkWidget *label_widget);. Sets the label widget for the frame. This is the widget that will appear embedded in the top edge of the frame as a t


GtkFrame: GTK+ 2 Reference Manual, frame. a GtkFrame. label. the text to use as the label of the frame. [ allow-none ] or NULL if there was no label widget or the lable widget was not a GtkLabel. GtkFrame as GtkBuildable. The GtkFrame implementation of the GtkBuildable interface supports placing a child in the label position by specifying "label" as the "type" attribute of a <child> element. A normal content child can be specified without specifying a <child> type attribute.


009. How to put a border around GtkLabel?, You can add a border to GtkLabel with GtkFrame. Note 1: this sets the color of the border. Note the use of modify_bg and not modify_fg . a GtkFrame: Returns : the text in the label, or NULL if there was no label widget or the lable widget was not a GtkLabel. This string is owned by GTK+ and must not be modified or freed.


GtkFrame - Guile-Gtk, The position of the label can be controlled with gtk-frame-set-label-align . label, or ' #f ' if there was no label widget or the lable widget was not a <gtk-label> . Where this now generally results in GtkFrame widgets > having no border whatsoever regardless the setting made by > gtk_frame_set_shadow_type() . It was semi-fixed a couple of years ago for the default Adwaita theme: "semi-fixed" because it only gives you an "etched in" frame.