GUI basics in Smalltalk
Asked Answered
R

1

8

I'm quite new to Smalltalk and I've been searching a whole day how I could write a GUI. I've found loads of information on how to work with Morphs and what Halos are, but I don't seem to be able to find what I need (It's only a table with the entries from a Dictionary).

Next to Morphs, I also found quite something on how smalltalk introduced the MVC-principle. I even found the ST-80 Views Category, containing everything I would need, but again I am not sure on how to use it correctly and somehow I don't seem to find the right sources to get me started.

Therefore my question(s): Where to start to build a simple GUI? How should I choose from the billion Morphs available and how do I combine them to a solid interface? Should MVC only be used when it gets more complex or are they also useful for simple GUIs? Is there any general overview on what to use in which cases?

To illustrate what I would like to do, I added some pseudo-code of how I would have it in mind:

d := Dictionary new.
"add data to the dictionary..."

view := DictionaryView new.
view addDictionary: d.

button := SimpleButtonMorph new.
"e.g. change label to sum of values"
button target: [button label: d sum.].

window := SystemWindow labelled: test.
window addMorph: view.
window addMorph: button.

Any help to get me started with this is highly appreciated.


Update:

I recently found a chapter from a book that helped me understand morphic better with some nice explanation and example code and for people who want to know more, there is a whole list of free books too. Also useful were the tutorials from the squeak wiki. Especially the one on Pluggable Morphs helped me to understand this concept better. Note that this tutorial is hidden in the list of unreviewed tutorials (possibly because there is a little error in the project that can be downloaded).

Rickart answered 22/12, 2015 at 19:58 Comment(0)
C
8

In Squeak (I presume you use Squeak, because you speak of Morphs and ST80), there are several ways to build GUIs.

Plain Morphs

You can just put together Morphs. Typically, you need some Widget, like a SimpleHierarchicalListMorph. But this process gets tedious fast.

ToolBuilder

If you're creating an application that somehow resembles a tool, of whatever kind, the ToolBuilder might be your friend. Tools like the System Browser, the Debugger, or more recently, the FontImporter are built with ToolBuilder. It requires a Model with the #buildWith: message. Search for implementers of this message to get an idea how to use ToolBuilder.

But probably the easiest way:

Morphic Designer

The Morphic Designer lets you put together your Application UI graphically. You can re-use the design and do not need too many code to hook you program up to the UI. Examples included.


Note: You also found the MVC implementation. It has come out of fashion in Squeak, but it still should be usable. However, you must create a new Project to use MVC. It is, by the way, possible to create tools that can run in both Morphic and MVC projects when you use ToolBuilder.

Callen answered 22/12, 2015 at 21:28 Comment(1)
Sorry for the late reply. I tried installing the morphic designer, but apparently there are some compatibility issues with squeak 5 (actually with seaside for as far as I understood it...). I tried looking at classes that implement buildWith, but they all seem to use buildWindowWith which I don't seem to find (can one find methods by name in the system browser?). Concerning the Plain morphs: Does this mean that the outer layer should always be a widget containing morphs for everything I would like to be shown in a single window?Rickart

© 2022 - 2024 — McMap. All rights reserved.