Last active
January 25, 2022 22:16
-
-
Save estebanlm/bb165a259f436f18855a2fb194ccf45c to your computer and use it in GitHub Desktop.
Spec - applying styles to spec presenters (both Morphic and GTK3)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
and this is the result :