02.06.2025 19:46 Gtk4
Приклад використання віджету Button - Кнопка

dotnet new consoledotnet add package GirCore.Gtk-4.0dotnet runusing Gtk;
class Program
{
static void Main()
{
var app = Application.New("ua.org.accounting.test", Gio.ApplicationFlags.FlagsNone);
app.OnActivate += (sender, args) =>
{
FirstWindow firstWindow = new(app);
firstWindow.Show();
};
app.RunWithSynchronizationContext(null);
}
}
using Gtk;
using static Gtk.Orientation;
class FirstWindow : Window
{
public FirstWindow(Application app) : base()
{
Application = app;
Title = "Window";
SetDefaultSize(500, 300);
Box vBox = Box.New(Vertical, 0);
vBox.MarginTop = vBox.MarginBottom = vBox.MarginStart = vBox.MarginEnd = 10;
Child = vBox;
Button button = Button.NewWithLabel("Button");
button.OnClicked += (sender, arrg) => Console.WriteLine(1);
Button button2 = Button.NewFromIconName("application-exit");
button2.OnClicked += (sender, arrg) => Console.WriteLine(2);
Box hBox = Box.New(Horizontal, 10);
hBox.Append(button);
hBox.Append(button2);
vBox.Append(hBox);
}
}© accounting.org.ua - 2025