Hello, I'm just getting into Pharo, and am trying to
do the example 'tutorial' UI programs in chapter 2 of The Spec UI Framework book. I have a special interest in end user GUI interfaces for programs. I enter the first example code as written and the methods are all accepted without errors. And yes, I did generate the accessors. However , on attempting to execute the code at the bottom of page 6 from the latest Spec UI Framework book, | ui | ui := CustomerSatisfaction newopenWithSpec. ui close. this error message appears, no UI image appears of course. "SubclassResponsibility:CustomerSatisfaction class had the subclass responsibility to implement #defaultSpec" ====== Not only don't I understand the message, but it implies I have to write something called #defaultSpec !, which is not mentioned in the tutorial. Any help appreciated, Yours, -- Cheers, Brett |
On 21 March 2018 at 03:12, dragoncity <[hidden email]> wrote:
> Hello, I'm just getting into Pharo, and am trying to > do the example 'tutorial' UI programs in chapter 2 of The Spec UI Framework > book. I have a special interest in end user GUI interfaces for programs. I > enter the first example code as written and the methods are all accepted > without errors. And yes, I did generate the accessors. > > However , on attempting to execute the code at the bottom of page 6 from the > latest Spec UI Framework book, > > > | ui | > > ui := CustomerSatisfaction newopenWithSpec. > > ui close. > > > > this error message appears, no UI image appears of course. > > "SubclassResponsibility:CustomerSatisfaction class had the subclass > responsibility to implement #defaultSpec" > > ====== > > Not only don't I understand the message, but it implies I have to write > something called #defaultSpec !, which is not mentioned in the tutorial. CustomerSatisfaction is a subclass of ComposableModel (ComposablePresenter in Pharo 7). If you have a look at the implementation of #defaultSpec in ComposableModel or ComposablePresenter (depending on which version of Pharo you are using) it says that it is up to subclasses to implement the method (#subclassResponsibility). Since you haven't defined it (yet), the call to #defaultSpec uses the inherited definition from ComposableModel, which raises the error you are seeing. CustomerSatisfaction class>>defaultSpec is on page 6 of my version of the booklet, dated Feb 6, 2107. Cheers, Alistair |
In reply to this post by brett
at the end of the fifth page " The widgets have now been defined and configured, but their placement in the UI has not yet been specified. This is the role of the class side method defaultSpec . " CustomerSatisfaction class >> defaultSpec ^ SpecLayout composed newRow: [ :row | row add: #buttonHappy; add: #buttonNeutral; add: #buttonBad ] origin: 0 @ 0 corner: 1 @ 0.7; newRow: [ :row | row add: #screen ] origin: 0 @ 0.7 corner: 1 @ 1; yourself 2018-03-21 5:12 GMT+03:00 dragoncity <[hidden email]>: Hello, I'm just getting into Pharo, and am trying to |
In reply to this post by alistairgrant
I had already defined & accepted defaultSpec , as per page 6.
Attached is my CustomerSatisfaction.st file : I assume Pharo will suck it back in ! On 21/03/18 17:55, Alistair Grant wrote: > On 21 March 2018 at 03:12, dragoncity <[hidden email]> wrote: >> Hello, I'm just getting into Pharo, and am trying to >> do the example 'tutorial' UI programs in chapter 2 of The Spec UI Framework >> book. I have a special interest in end user GUI interfaces for programs. I >> enter the first example code as written and the methods are all accepted >> without errors. And yes, I did generate the accessors. >> >> However , on attempting to execute the code at the bottom of page 6 from the >> latest Spec UI Framework book, >> >> >> | ui | >> >> ui := CustomerSatisfaction newopenWithSpec. >> >> ui close. >> >> >> >> this error message appears, no UI image appears of course. >> >> "SubclassResponsibility:CustomerSatisfaction class had the subclass >> responsibility to implement #defaultSpec" >> >> ====== >> >> Not only don't I understand the message, but it implies I have to write >> something called #defaultSpec !, which is not mentioned in the tutorial. > CustomerSatisfaction is a subclass of ComposableModel > (ComposablePresenter in Pharo 7). If you have a look at the > implementation of #defaultSpec in ComposableModel or > ComposablePresenter (depending on which version of Pharo you are > using) it says that it is up to subclasses to implement the method > (#subclassResponsibility). Since you haven't defined it (yet), the > call to #defaultSpec uses the inherited definition from > ComposableModel, which raises the error you are seeing. > > CustomerSatisfaction class>>defaultSpec is on page 6 of my version of > the booklet, dated Feb 6, 2107. > > > Cheers, > Alistair > > Cheers, Brett CustomerSatisfaction.st (3K) Download Attachment |
On 21 March 2018 at 08:37, dragoncity <[hidden email]> wrote:
> I had already defined & accepted defaultSpec , as per page 6. > > Attached is my CustomerSatisfaction.st file : I assume Pharo will suck it > back in ! You've defined this as an instance method, not a class method. If what I've said doesn't make sense, let us know and we can point you to a description (which I don't have handy). One tip: Assuming you're using Pharo 6, in the System Browser, roughly in the middle is a "Class" button. Pressing that will show you the class methods. HTH, Alistair > On 21/03/18 17:55, Alistair Grant wrote: >> >> On 21 March 2018 at 03:12, dragoncity <[hidden email]> wrote: >>> >>> Hello, I'm just getting into Pharo, and am trying to >>> do the example 'tutorial' UI programs in chapter 2 of The Spec UI >>> Framework >>> book. I have a special interest in end user GUI interfaces for programs. >>> I >>> enter the first example code as written and the methods are all accepted >>> without errors. And yes, I did generate the accessors. >>> >>> However , on attempting to execute the code at the bottom of page 6 from >>> the >>> latest Spec UI Framework book, >>> >>> >>> | ui | >>> >>> ui := CustomerSatisfaction newopenWithSpec. >>> >>> ui close. >>> >>> >>> >>> this error message appears, no UI image appears of course. >>> >>> "SubclassResponsibility:CustomerSatisfaction class had the subclass >>> responsibility to implement #defaultSpec" >>> >>> ====== >>> >>> Not only don't I understand the message, but it implies I have to write >>> something called #defaultSpec !, which is not mentioned in the tutorial. >> >> CustomerSatisfaction is a subclass of ComposableModel >> (ComposablePresenter in Pharo 7). If you have a look at the >> implementation of #defaultSpec in ComposableModel or >> ComposablePresenter (depending on which version of Pharo you are >> using) it says that it is up to subclasses to implement the method >> (#subclassResponsibility). Since you haven't defined it (yet), the >> call to #defaultSpec uses the inherited definition from >> ComposableModel, which raises the error you are seeing. >> >> CustomerSatisfaction class>>defaultSpec is on page 6 of my version of >> the booklet, dated Feb 6, 2107. >> >> >> Cheers, >> Alistair >> >> > > -- > Cheers, > Brett > |
You've defined this as an instance method, not a class method Thanks for that observation! On closer read indeed I had missed the 'class' word in the defaultSpec text on page 6, it took a little fiddling to get a Class method defined. Its 'almost' working :-) When I run the |ui | ... etc.... from a Playground, I don't get a working UI Form, but I get a correctly defined static image layout of the form under 'Morph' IN the Playground. I expected the CustomerSatisfaction UI form to appear as a independent item on the Pharo 'world'. Now what am I doing wrong ? :-) On 21/03/18 19:02, Alistair Grant wrote: > On 21 March 2018 at 08:37, dragoncity <[hidden email]> wrote: >> I had already defined & accepted defaultSpec , as per page 6. >> >> Attached is my CustomerSatisfaction.st file : I assume Pharo will suck it >> back in ! > You've defined this as an instance method, not a class method. > > If what I've said doesn't make sense, let us know and we can point you > to a description (which I don't have handy). One tip: Assuming you're > using Pharo 6, in the System Browser, roughly in the middle is a > "Class" button. Pressing that will show you the class methods. > > HTH, > Alistair > > > >> On 21/03/18 17:55, Alistair Grant wrote: >>> On 21 March 2018 at 03:12, dragoncity <[hidden email]> wrote: >>>> Hello, I'm just getting into Pharo, and am trying to >>>> do the example 'tutorial' UI programs in chapter 2 of The Spec UI >>>> Framework >>>> book. I have a special interest in end user GUI interfaces for programs. >>>> I >>>> enter the first example code as written and the methods are all accepted >>>> without errors. And yes, I did generate the accessors. >>>> >>>> However , on attempting to execute the code at the bottom of page 6 from >>>> the >>>> latest Spec UI Framework book, >>>> >>>> >>>> | ui | >>>> >>>> ui := CustomerSatisfaction newopenWithSpec. >>>> >>>> ui close. >>>> >>>> >>>> >>>> this error message appears, no UI image appears of course. >>>> >>>> "SubclassResponsibility:CustomerSatisfaction class had the subclass >>>> responsibility to implement #defaultSpec" >>>> >>>> ====== >>>> >>>> Not only don't I understand the message, but it implies I have to write >>>> something called #defaultSpec !, which is not mentioned in the tutorial. >>> CustomerSatisfaction is a subclass of ComposableModel >>> (ComposablePresenter in Pharo 7). If you have a look at the >>> implementation of #defaultSpec in ComposableModel or >>> ComposablePresenter (depending on which version of Pharo you are >>> using) it says that it is up to subclasses to implement the method >>> (#subclassResponsibility). Since you haven't defined it (yet), the >>> call to #defaultSpec uses the inherited definition from >>> ComposableModel, which raises the error you are seeing. >>> >>> CustomerSatisfaction class>>defaultSpec is on page 6 of my version of >>> the booklet, dated Feb 6, 2107. >>> >>> >>> Cheers, >>> Alistair >>> >>> >> -- >> Cheers, >> Brett >> > -- Cheers, Brett |
Administrator
|
dragoncity-2 wrote
> When I run the > > |ui | ... etc.... from a Playground, I don't get a working UI Form, but > I get a correctly defined static image layout of the form under 'Morph' IN > the Playground. > > I expected the CustomerSatisfaction UI form to appear as a independent > item on the Pharo 'world'. > > Now what am I doing wrong ? :-) I think you want "Do It" instead of "Do It and Go" ----- Cheers, Sean -- Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html
Cheers,
Sean |
In reply to this post by brett
Have you left in that ui close statement that was in your first post? I tried
you code and it worked fine - but if you issue a close you'll have nothing to see! -- Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html |
Thank you -- of course ! I had that "ui close" in my code !!! , I'd expected
the form to take control until I exited the form itself and had not considered the code would 'fall straight through' to the 'ui close' The example form now displays on Pharo's World and is active as expected. From my experience with trying to get this example working, I think the chapter needs a bit of expansion & more explanation about some features used. The Class method creation verse the instance methods being an example. I guess the authors assume most people will have worked with Pharo without jumping straight to the GUI interfacing !! Thank you all for your help, getting this example running is a very important step to understanding Pharo's UI. -- Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html |
On Thu, Mar 22, 2018 at 1:41 AM, brett <[hidden email]> wrote:
> Thank you -- of course ! I had that "ui close" in my code !!! , I'd expected > the > form to take control until I exited the form itself and had not considered > the code would 'fall straight through' to the 'ui close' > > > The example form now displays on Pharo's World and is active as expected. > > From my experience with trying to get this example working, I think the > chapter needs a bit of expansion & more explanation > about some features used. The Class method creation verse the instance > methods being an example. I guess the authors assume most people will have > worked with Pharo without jumping straight to the GUI interfacing !! Indeed. We cannot add Pharo by example in all the books we write :) > > Thank you all for your help, getting this example running is a very > important step to understanding Pharo's UI. > > > > > > -- > Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html > |
Free forum by Nabble | Edit this page |