-
Notifications
You must be signed in to change notification settings - Fork 46
Tutorials
Having built and installed gtk-fortran following the wiki instructions, you now need tutorials and how-to to learn programming with gtk-fortran.
Most tutorials are for GTK 4, but with the GTK 3 modifications given when possible.
- Installation: everything needed to install gtk-fortran on your machine (branches, dependencies) with detailed instructions for Linux, Windows, macOS and FreeBSD.
- My first gtk-fortran application - My first gtk-fortran application. You will create a GtkApplication with a window, some widgets and how to draw a bitmap image in Fortran.
- Drawing an image in a PNG file (without GUI) - Drawing an image in a PNG file (without GUI). You will draw in a PNG file using only the GdkPixbuf library: only 45 lines of Fortran code to draw a beautiful coloured Sierpinski Triangle!
- How to write a program also usable without GUI - How to write a gtk-fortran application that can be build with or without its GUI, in order to be executable on a machine where gtk-fortran is not installed.
- How-to use Glade3 and gtkf-sketcher to build more easily a complicated GUI (GTK 3 only).
- How to use gtk-fortran as a fpm dependency.
- How to start my own project from a gtk-fortran example?.
- Debugging with GtkInspector: inspect and edit your GUI on the fly.
You can begin by studying the examples available in the examples/
directory, 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.
- Programming in Modern Fortran - A HyperText-based introduction to programming in Fortran 2003, 2008, and 2018 on Unix. In the "User Interfaces, Graphics, and Plotting" chapter, you will find gtk-fortran.
- How to use GTK-Fortran with Code::Blocks IDE.
Some good blogs to learn GTK:
- The awesome Michael B. YouTube channel offers more than two hundreds video tutorials on GTK 3, and now GTK 4 (C language) !
- Gtk4 Tutorial for beginners: using C language.
- GTK4 for Graphical User Interfaces, with the Nim Programming Language: a "book" about GTK 4 (around ~67 printed pages).
- GtkDcoding - Musings of a GtkD Coder
- GTK Glade C Programming Tutorial
You can also launch gtk4-demo
to run the official GTK examples and read their source code.
Books about GTK are rare. There is especially the Andrew Krause's book: the first one is about GTK 2 (excellent but now obsolete, oriented toward the C language), the second one is the GTK 3 edition but for Python:
- Andrew Krause, Foundations of GTK+ Development, Apress, 2007, ISBN-13: 978-1-59059-793-4, 630pp, $36.99 (eBook). You can download the C examples here. And you can have a look at the book on Google Books.
- David Ashley, Andrew Krause, Foundations of PyGTK Development - GUI Creation with Python, Apress, 2019, ISBN-13: 978-1-4842-4178-3, 563pp, $34.31. You can download the Python examples here. And you can have a look at the book on Google Books.
- GTK 4 documentation:
- All GTK libraries
- GTK 4 itself
- The Widget Gallery, to visually choose a widget.
- In a terminal you can also launch the
gtk4-widget-factory
application to see and try all the GTK widgets, in three tabs.
- Drawing with GTK:
- GTK 3 documentation
- The official GTK Discourse Forum, to get help about GTK.
- The GTK official blog.
- The GTK Project
- Concerning designing a GUI, see GNOME Human Interface Guidelines.
- Cambalache, the new RAD tool for GTK 4 is under active development.
- Forum GTK de developpez.com
- Forum Fortran de developpez.com
- Cours d'interfaces graphiques d'Edouard Thiel (Université d'Aix-Marseille)
- Introduction au fortran 90/95/2003/2008 : polycopié de Master de Jacques Lefrère, Université Pierre et Marie Curie Sorbonne Université, 13 novembre 2019.
- 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