Skip to content

Instantly share code, notes, and snippets.

@estebanlm
Last active January 25, 2022 22:16
Show Gist options
  • Save estebanlm/bb165a259f436f18855a2fb194ccf45c to your computer and use it in GitHub Desktop.
Save estebanlm/bb165a259f436f18855a2fb194ccf45c to your computer and use it in GitHub Desktop.
Spec - applying styles to spec presenters (both Morphic and GTK3)
app := SpApplication new.
"If using Morphic"
app addStyleSheetFromString: '.application [
.red [ Draw { #color: #red } ],
.green [ Draw { #color: #green } ]
]'.
"If using GTK (you need to choose one, both options are not possible at the same time)"
app useBackend: #Gtk.
app addCSSProviderFromString: '
.red { background-color: red }
.green { background-color: green }
'.
presenter := SpPresenter new.
presenter application: app.
presenter layout: (SpBoxLayout newTopToBottom
add: (textPresenter := presenter newTextInput) expand: false;
addLast: (SpBoxLayout newLeftToRight
add: (presenter newButton
label: 'Red';
action: [ textPresenter removeStyle: 'green'; addStyle: 'red' ];
yourself);
add: (presenter newButton
label: 'Green';
action: [ textPresenter removeStyle: 'red'; addStyle: 'green' ];
yourself);
yourself)
expand: false;
yourself).
presenter asWindow
title: 'Example applying styles';
open
@estebanlm
Copy link
Author

and this is the result :

qa4-1
qa4-2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment