En tant que débutant dans Pharo 5, je ne peux pas trouver comment afficher une horloge numérique comme "12:25:05" dans le monde et/ou une fenêtre. Il n'y a pas ClockMorph dans Pharo?Comment afficher une horloge numérique dans Pharo? et Cuis?
Je reçois ce que je veux! Il est grand:
pour une horloge dans le monde:
|morph| morph := StringMorph new. morph font: (LogicalFont familyName: 'Source Sans Pro' pointSize: 20). morph color: Color gray. morph openInWorld; bounds: ((World bounds corner x)[email protected] extent: [email protected]). [ [ true ] whileTrue: [ morph contents: Time now print24. 1 second wait ] ] fork.
pour une horloge dans une fenêtre avec morphique:
|morph myWindow| myWindow := StandardWindow labelled: 'CLOCK'. myWindow addMorph:(morph := StringMorph new) frame: ([email protected](-0.2) corner: [email protected]). myWindow beUnresizeable ; removeCloseBox ; removeCollapseBox ; removeExpandBox ; removeMenuBox. "meta-click to activate the ""morphic halo"" and close window" morph font: (LogicalFont familyName: 'Source Sans Pro' pointSize: 20). morph color: Color white. myWindow openInWorld; bounds: ((World bounds corner x)[email protected] extent: [email protected]). [ [ true ] whileTrue: [ morph contents: Time now print24. 1 second wait ] ] fork.
pour une horloge dans une fenêtre avec Spec:
| view labelClock layout | " Configure the Spec models " view := DynamicComposableModel new instantiateModels: #(labelClock ButtonModel); extent: [email protected]; title: 'CLOCK' yourself. " Configure the Spec layout " layout := SpecLayout composed newColumn: [ : r | r add: #labelClock]; yourself. " Set up the widgets " view labelClock font: (LogicalFont familyName: 'Source Sans Pro' pointSize: 20). [ [ true ] whileTrue: [ view labelClock label: Time now print24. 1 second wait ] ] fork. " Open the Window " (view openWithSpecLayout: layout) centered; modalRelativeTo: World.
Merci à tout le monde @Peter, @Bert, @aka.
pour une horloge dans un Morph Cuis:
|morph string| morph := LayoutMorph newRow. morph morphPosition:(Display width -160)@10 extent:[email protected]; color:Color skyBlue; padding:#center. string := StringMorph new. string font: (AbstractFont familyName: 'DejaVu' pointSize: 22). [ [ true ] whileTrue: [ string contents: Time now print24. (Delay forSeconds:1) wait ] ] fork. morph addMorph: string. morph openInWorld.
Mais il y a un Morph appelé "UpdatingStringMorph" dans la rubrique "Nouveau Morph ..." dans le menu mondial qui affiche l'heure à Cuis!
Merci beaucoup @Stephan. Pomodoro a l'air bien. –