-
Notifications
You must be signed in to change notification settings - Fork 46
Learning from examples
Once you will have created your first gtk-fortran toy applications, you will need to use more widgets and GTK advanced features. Learning by reading and playing with gtk-fortran and GTK examples is a good way.
You can study the examples available in the examples/ and plplot/ directories, beginning by gtkzero_gapp.f90 (just creates an empty GTK window) and gtkhello.f90 (a window with two buttons). Those simple examples are heavily commented in order to help you learn the GTK basics.
Note that in GTK 4, the recommended way to write a GTK program is using GtkApplication like in the gtkzero_gapp.f90 example: in the gtk3 branch, it's the only example using GtkApplication. But if you use GTK 3, try to follow this example for your own programs in order to ease the porting to GTK 4.
If you want to draw progressively a picture pixel by pixel during a scientific computation, mandelbrot_pixbuf.f90 is a good starting point:
You can even simply create a PNG file without creating any GUI, by using the GdkPixbuf library: see pixbuf_without_gui.f90.
You may also be interested by the gtk-fortran-extra repository which offers more examples (under MIT license), especially demonstrating how you can obtain an application that can be built with or without its GUI.
You can also run the gtk4-demo command (gtk-4-examples package in Ubuntu) to launch each official GTK example and read directly its C source code.
- Installation
- My first gtk-fortran application
- Drawing an image in a PNG file (without GUI)
- A program also usable without GUI
- Using Glade3 and gtkf-sketcher (GTK 3)
- Using gtk-fortran as a fpm dependency
- Debugging with GtkInspector
- Learning from examples
- Video tutorials
- How to start my own project from a gtk-fortran example
- git basics
- CMake basics
- Alternatives to CMake
- How to migrate to GTK 4
- How to contribute to gtk-fortran
- How to hack the cfwrapper with other C libraries