作为 Pharo 5 的初学者,我找不到如何在世界或/和窗口中将数字时钟显示为“12:25:05”。 Pharo 中没有 ClockMorph 吗?
我得到了我想要的!太棒了:
世界上的时钟:
|morph| morph := StringMorph new. morph font: (LogicalFont familyName: 'Source Sans Pro' pointSize: 20). morph color: Color gray. morph openInWorld; bounds: ((World bounds corner x)-100@0 extent: 100@20). [ [ true ] whileTrue: [ morph contents: Time now print24. 1 second wait ] ] fork.
对于带有 Morphic 的窗口中的时钟:
|morph myWindow| myWindow := StandardWindow labelled: 'CLOCK'. myWindow addMorph:(morph := StringMorph new) frame: (0.1@(-0.2) corner: <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="dbebf5e29bebf5e2" rel="noreferrer noopener nofollow">[email protected]</a>). 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)-140@10 extent: <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="172624275720223927" rel="noreferrer noopener nofollow">[email protected]</a>). [ [ true ] whileTrue: [ morph contents: Time now print24. 1 second wait ] ] fork.
对于窗口中的时钟,其规范为:
| view labelClock layout | " Configure the Spec models " view := DynamicComposableModel new instantiateModels: #(labelClock ButtonModel); extent: 128@18; 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.
感谢大家@Peter、@Bert、@aka。
对于 Cuis 中 Morph 中的时钟:
|morph string| morph := LayoutMorph newRow. morph morphPosition:(Display width -160)@10 extent:150@33; 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.
但是在世界菜单的“New morph...”项中有一个名为“UpdatingStringMorph”的 Morph,它显示 Cuis 中的时间!
最佳答案
您可以通过从目录中加载番茄工作法项目来找到答案。 其中包含一个从 25 分钟开始倒计时的时钟,您应该能够替换它。或者从 Squeak 导入 ClockMorph,假设图像中有一个。
关于smalltalk - 如何在 Pharo 中显示数字时钟?还有崔斯?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39954483/