How to create a standalone app with Glamorous Toolkit
Creating a standalone app based on Glamorous Toolkit is as simple as opening an application specific window and closing the existing GT window. This can be achieved in just a few steps.
Open a space with a scene
BlSpace
is responsible for displaying a scene in a separate window. Users can customise window's title or extent. To spawn a window send BlSpace>>#show
to an instance of the space.
| aContainer aSpace |
aContainer := BrVerticalPane new
matchParent;
alignCenter.
aContainer addChild: (BrLabel new
look: (BrGlamorousLabelLook new fontSize: 100; bold);
text: 'Hello world!').
aSpace := BlSpace new
addChild: aContainer;
extent: 800@600;
title: 'Hello World'.
aSpace show.
]
Clean up existing windows
Glamorous Toolkit comes with a GtWorld
opened by default. When creating a standalone app based on GT we should close that window, which can be done in two steps.
Disable shutdown-on-close listener
To shutdown the process when a window is closed, we add a BlSpaceShutdownOnCloseListener
as an event handler to a BlSpace
. It should be removed before we close such spaces.
GtWorld allInstances do: [ :eachWorld | eachWorld removeShutdownListener ]
]
Closing an existing GtWorld
To close an opened window, it is enough to just send BlSpace>>#close
to the associated space.
GtWorld allInstances do: [ :eachWorld | eachWorld close ]
]
Save the image
Once the intended application window is opened and there are no more GT windows we can save the image (without quitting):
Smalltalk snapshot: true andQuit: false
]