Jump to content

GUI component interaction: Difference between revisions

m
Minor changes.
m (Minor changes.)
Line 2,257:
===Gtk3 (gintro)===
{{libheader|gintro}}
This is a translation of the GTk2Gtk2 version to Gtk3 using the higher level "gintro" bindings. The higher level is not really obvious in this small example, but, for instance, we are able to transmit to signal handlers a pure Nim Context“Context” object (managed by the GC). With the Gtk2 bindings, it would require to use unsafe addresses.
<lang Nim>import random, strutils
import gintro/[glib, gobject, gtk, gio]
Line 2,282:
#---------------------------------------------------------------------------------------------------
 
proc onQuit(button: Button; winwindow: ApplicationWindow) =
winwindow.destroy()
 
#---------------------------------------------------------------------------------------------------
Line 2,311:
## Activate the application.
 
let winwindow = app.newApplicationWindow()
winwindow.setTitle("Component interaction")
 
let content = newBox(Orientation.vertical, 10)
Line 2,336:
content.packStart(btnQuit, true, true, 0)
 
winwindow.setBorderWidth(5)
winwindow.add(content)
 
let context = Context(value: 0, entry: entry)
 
discard btnQuit.connect("clicked", onQuit, winwindow)
discard btnIncr.connect("clicked", onIncr, context)
discard btnRand.connect("clicked", onRand, context)
discard entry.connect("changed", onEntryChange, context)
 
winwindow.showAll()
 
#———————————————————————————————————————————————————————————————————————————————————————————————————
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.