How to resize a Gtk4 window? - gtk4

Here has a gtk4 window (ApplicationWindow) which contain a gtk Label. When I fill a long multi-line text in the label, the window auto become large width and height, this no problem. But I fill a short text in the label again, I want the window resize to smaller to fit the label size.
Gtk.Widget.width_request no effect on both label and window.

gtk4 Window.resizable
Gtk.Window:resizable
Type: gboolean
Description
If TRUE, users can resize the window.
Setter method
gtk_window_set_resizable
Getter method
gtk_window_get_resizable

Related

gtk3 scrolled window size, with gtkbox inside and buttons inside after resize

Hello i am having problems to set a fixed size of a scrolled windows.
Add the beginning the size of the scrolled windows is set
gtk_widget_set_size_request (scrolled_window, 150, 0);
Then i tried
gtk_widget_set_hexpand (scrolled_window,FALSE);
But when i resize the window the scrolled windows changes his width, with the buttons inside of her.
The packing of the buttons to the gbox i did it like this
gtk_box_pack_start(GTK_BOX(box_button), boton_527000_57888, FALSE, FALSE, 0);
I can figure out how to resolve it. i tried searching around the web but was not successfull
I solved the answer is here, i must use gtkgrid because gtkgrid doesn't expand the widgets.
https://developer.gnome.org/gtk3/stable/gtk-migrating-GtkGrid.html

GTK3 Set GtkButton size

I have a very simple code, wich create a GtkWindow and place in it a GtkButton.
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_widget_set_size_request(_window, 800, 450);
gtk_window_set_decorated(GTK_WINDOW (_window), FALSE);
gtk_window_set_position(GTK_WINDOW (_window),GTK_WIN_POS_CENTER_ALWAYS);
gtk_window_set_resizable(GTK_WINDOW (_window), FALSE);
_startbutton = gtk_button_new_with_label("myLabel");
gtk_container_add(GTK_CONTAINER(_window), _startbutton);
gtk_widget_show_all(_window);
Yet, this doesn't work as expected because the button fills the whole window.
I tried to find a way to change the button size, but all the methods that i found use some methods that are deprecated...
Can someone explain to me the way to do this ?
Because the GtkButton is the only control in the GtkWindow, it will be given the entire area of the GtkWindow to fill. If you want to do anything more complicated, you will need to use layout containers like GtkBox and GtkGrid to explicitly lay out the button, usually in relation to other controls that you will also have in the window.
Once you do lay out your controls, you can use expansion and alignment to control how the button makes use of its allotted space.

Why is my WinForms Label resized when the Form.Designer code Controls.Add(myLabel) is called?

Why is my WinForms Label resized when the Form.Designer code Controls.Add(myLabel) is called? The label is in side a top panel with a fixed height that never changes (Dock=Top). In the Visual Studio Form Editor, the width of the label is X. In the designer code, the width of the label is still X until the Control.Add() is called on the label. Then the label gets somewhat larger, and the font gets slightly stretched out. Why is that? I really do not want to stretch out the font on the label.

WPF control is on top of the window border, how do I stop that?

I have a WPF window and an Image in a grid in the window. I am animating the Image so it moves from out of view (beyond widow location) into the window.
The animation is nice and smooth and everything works but I notice the image is over top of the window border while it is moving. The image at the end of this question is what it looks like.
Why would the image be over top of the window border, and how do I get it to be "under" the border?
Thanks in advance!
Well after a lot of trial and error it seems the problem was the fact I was moving the image in a grid that had no defined width, so the width would expand over the border when moving the image thus extending the "client" area of the window and showing over the window area.
Once I defined a specific width of the grid, everything worked.

Animation for SizeToContent resizing

In WPF window, I have specified SizeToContent="WidthAndHeight".
I have a number of panels stacked up, of which I change the visibility (to Visible or Collapsed) as required. My window resizes itself according to the panel that I have set visible. No issues here.
My problem is with the resizing, that the window resizes with a jerk to the final size.
I want to animate this such that the resizing is smooth. And i want to do this in my XAML file.
Is there any solution for this???
P.S. - I have not set any Width or Height property in the window and I want to restrict myself from doing that.

Resources