-
Notifications
You must be signed in to change notification settings - Fork 45
Tutorial 4
This how-to is for GTK 3 only, Glade being not yet ported to GTK 4 and our gtkf-sketcher being not (yet?) fully ported to GTK 4.
You have three solutions to create a GUI with gtk-fortran:
- hard-coding the GUI in Fortran, inspiring yourself with the gtk-fortran examples. In my opinion, it's better to first learn this way, in order to understand the GTK concepts.
- Using Glade to create a
.ui
XML file and use the GtkBuilder API, - or write yourself your
.ui
file and use the GtkBuilder API
Using GtkBuilder maybe be useful if you use many widgets in your API.
gtkf-sketcher
aims to be a tool for rapid application development (RAD) and is inspired by the Freebasic code sketcher GTKtobac2. It can be used to generate/update Fortran source code for an existing Glade3 GUI-XML file via gtk-fortran to implement cross-platform GUI widgets.
The design of the GUI can be completely accomplished using the UI Designer Glade3, where the GUI is saved as an GktBuilder XML-file. gtkf-sketcher can load and analyze this file and generates cross platform Fortran source code to show and handle the GUI-widgets.
This is a very basic manual for gtkf-sketcher:
- go into the
gtk-fortran/build/sketcher/
directory and run./gtkf-sketcher
- From its File>Open menu, load the
example.glade
file available in the same directory (do not choose thegtkf-sketcher.glade
which is the file used to build the GUI of gtkf-sketcher itself!). - In the Info tab, the content of the
example.glade
file is analyzed. - Keep the default options available in the Options tab and go directly to the Output tab.
- Click on the Write Files button.
- In the terminal, go inside the
gtk-fortran/build/sketcher/example
directory where gtkf-sketcher has generated the Fortran files of the example application. - Compile and execute the example application:
$ gfortran example.f90 -o example $(pkg-config --cflags --libs gtk-3-fortran)
$ ./example
You can then add code to manage each event of your GUI into the specified files.
- 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