Quantcast

Re: Beginners Digest, Vol 123, Issue 3

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Beginners Digest, Vol 123, Issue 3

Tim Cuthbertson
Please allow me to simplify my question. I need a basic answer.

One of the articles on Morphic says you can create composite morphs either programatically, using addMorph, or using drag and drop from the Objects menu of the morphic World. I have done the latter, because it is easier to design my layout that way. Once that has been done, how do I address the submorph from a browser? If I inspect my button submorph, for example, all it will tell me about it is "a ScriptableButton<Button>(1364754)". I have no idea how to access that object in order to do anything with it. This is the crux of my questions.

Thank you

Tim Cuthbertson

On Wed, Feb 22, 2017 at 10:03 AM, <[hidden email]> wrote:
Send Beginners mailing list submissions to
        [hidden email]

To subscribe or unsubscribe via the World Wide Web, visit
        http://lists.squeakfoundation.org/mailman/listinfo/beginners
or, via email, send a message with subject or body 'help' to
        [hidden email]

You can reach the person managing the list at
        [hidden email]

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Beginners digest..."


Today's Topics:

   1. Re: Using squeak with a script? (H. Hirzel)
   2. Re: Beginner Morphic Question (Tim Cuthbertson)
   3. Re: Beginner Morphic Question (H. Hirzel)


----------------------------------------------------------------------

Message: 1
Date: Wed, 22 Feb 2017 15:49:35 +0100
From: "H. Hirzel" <[hidden email]>
To: "A friendly place to get answers to even the most basic questions
        about Squeak." <[hidden email]>
Subject: Re: [Newbies] Using squeak with a script?
Message-ID:
        <CAGQxfVh_a3V8qotwfQn=BMF4Rbq098hG=BZjHjs=[hidden email]>
Content-Type: text/plain; charset=UTF-8

Maybe

      ExternalCommandShell

     http://wiki.squeak.org/squeak/6023

this is of some help?

--Hannes

On 2/22/17, Göran Krampe <[hidden email]> wrote:
> On 21/02/17 20:51, Jacques Harmand wrote:
>> Hi list,
>> I try to use squeak to execute the following basic Smalltalk script (in
>> a file "hello.st <http://hello.st>")
>> "Transcript show: 'Hello world'; cr."
>> from the command line with Squeak.  This works as expected with both GNU
>> Smalltalk and Pharo, but with Squeak nothing happens: Squeak seems to
>> wait forever.  If I add
>> "Smalltalk snapshot: false andQuit: true."
>> after the above line, the execution of the script terminates, but
>> without printing anything.
>
> I haven't looked closely at latest Squeak (perhaps Pharo has coupled
> Transcript to stdout for headless mode?), but Transcript is not the same
> thing as stdout - so you wouldn't see anything on stdout.
>
> regards, Göran
> _______________________________________________
> Beginners mailing list
> [hidden email]
> http://lists.squeakfoundation.org/mailman/listinfo/beginners
>


------------------------------

Message: 2
Date: Wed, 22 Feb 2017 09:18:16 -0600
From: Tim Cuthbertson <[hidden email]>
To: [hidden email]
Subject: Re: [Newbies] Beginner Morphic Question
Message-ID:
        <CAAKzf7nSsRE=[hidden email]>
Content-Type: text/plain; charset="utf-8"

Date: Tue, 21 Feb 2017 22:41:36 +0100
From: "H. Hirzel" <[hidden email]>
To: "A friendly place to get answers to even the most basic questions
        about Squeak." <[hidden email]>
Subject: Re: [Newbies] Beginner Morphic Question
Message-ID:
        <[hidden email]>
Content-Type: text/plain; charset=UTF-8

Have you seen this example

http://wiki.squeak.org/squeak/526

?

Code

http://wiki.squeak.org/squeak/uploads/MorphicGUIDemo.2.cs.gz

Could you please explain in more details what you would like to build?

--Hannes

On 2/21/17, Tim Cuthbertson <[hidden email]> wrote:
> I am trying to start a Morphic application. I have read a lot of
tutorials,
> but I can't figure out how to program my submorphs.
>
> I have created my top level as a subclass of PasteUpMorph, opened it, and
> embedded a ScriptableButton and, separately, a RoundRect into which I have
> embedded a TextMorph. (eventually, I plan to have five siblings of each of
> these submorphs, but I'm trying to start the project, simply).
>
> I think I am supposed to start programming these submorphs from my
> PasteUpMorph, in which they are all directly or indirectly embedded. If I
> inspect the PasteUpMorph subclass, I can see the others as submorphs of
it,
> but if I browse it, I don't see any objects into which to put any code. I
> just see an empty PasteUpMorph.
>
> How do I access and code the submorphs within subclasses (I think) of my
> top level morph?
>
> Tim Cuthbertson
>

No, I had not come across that example of "How to work with multiple text
morphs". I will study it and your other link.

I am starting a project (just as an example to learn Squeak) to come up
with a Yahtzee game clone. My text morphs will simply display a number that
represents a randomly rolled die. The button morphs will allow the user to
select whether a particular die is to be held from being rerolled. There
will be an additional button to allow the user to re-roll unheld dice.

I have this model working in a text-based model, but I decided to try to
re-implement it in a morphic GUI framework.

Thank you for the tips.

Tim Cuthbertson
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/beginners/attachments/20170222/7126e970/attachment-0001.html>

------------------------------

Message: 3
Date: Wed, 22 Feb 2017 17:03:08 +0100
From: "H. Hirzel" <[hidden email]>
To: "A friendly place to get answers to even the most basic questions
        about Squeak." <[hidden email]>
Subject: Re: [Newbies] Beginner Morphic Question
Message-ID:
        <[hidden email]>
Content-Type: text/plain; charset="utf-8"

On 2/22/17, Tim Cuthbertson <[hidden email]> wrote:
> Date: Tue, 21 Feb 2017 22:41:36 +0100
> From: "H. Hirzel" <[hidden email]>
> To: "A friendly place to get answers to even the most basic questions
>         about Squeak." <[hidden email]>
> Subject: Re: [Newbies] Beginner Morphic Question
> Message-ID:
>
> <[hidden email]>
> Content-Type: text/plain; charset=UTF-8
>
> Have you seen this example
>
> http://wiki.squeak.org/squeak/526
>
> ?
>
> Code
>
> http://wiki.squeak.org/squeak/uploads/MorphicGUIDemo.2.cs.gz
>
> Could you please explain in more details what you would like to build?
>
> --Hannes
>
> On 2/21/17, Tim Cuthbertson <[hidden email]> wrote:
>> I am trying to start a Morphic application. I have read a lot of
> tutorials,
>> but I can't figure out how to program my submorphs.
>>
>> I have created my top level as a subclass of PasteUpMorph, opened it, and
>> embedded a ScriptableButton and, separately, a RoundRect into which I
>> have
>> embedded a TextMorph. (eventually, I plan to have five siblings of each
>> of
>> these submorphs, but I'm trying to start the project, simply).
>>
>> I think I am supposed to start programming these submorphs from my
>> PasteUpMorph, in which they are all directly or indirectly embedded. If I
>> inspect the PasteUpMorph subclass, I can see the others as submorphs of
> it,
>> but if I browse it, I don't see any objects into which to put any code. I
>> just see an empty PasteUpMorph.
>>
>> How do I access and code the submorphs within subclasses (I think) of my
>> top level morph?
>>
>> Tim Cuthbertson
>>
>
> No, I had not come across that example of "How to work with multiple text
> morphs". I will study it and your other link.
>
> I am starting a project (just as an example to learn Squeak) to come up
> with a Yahtzee game clone. My text morphs will simply display a number that
> represents a randomly rolled die. The button morphs will allow the user to
> select whether a particular die is to be held from being rerolled.

Then I suggest that you focus first on programming a DieMorph

http://pharo.gforge.inria.fr/PBE1/PBE1ch12.html

Remember: 'Where Morphic stands out'
http://wiki.squeak.org/squeak/6528

<citation>
The (Morphjic) framework is fully in Smalltalk; there are no
"primitive" widgets or hidden functionality. This means that there are
no restrictions to how a morph will appear and react. There are morphs
that behave like the widgets usually found, and therefore conventional
interfaces can be built. But there are more interesting visual
metaphors like CurveMorph, FishEyeMorph, EnvelopeEditorMorph, or
SpectrumAnalyzerMorph (see the next section with a Squeak at hand to
know them). And the framework is open end extensible. It s not
difficult to make new visual metaphors for our own objects, which are
perfectly integrated in the system.
</citation>

And
    'Method for making Morphs'
    http://wiki.squeak.org/squeak/70


> There
> will be an additional button to allow the user to re-roll unheld dice.
>
> I have this model working in a text-based model, but I decided to try to
> re-implement it in a morphic GUI framework.
>
> Thank you for the tips.
>
> Tim Cuthbertson
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: die.png
Type: image/png
Size: 6879 bytes
Desc: not available
URL: <http://lists.squeakfoundation.org/pipermail/beginners/attachments/20170222/c579d022/attachment.png>

------------------------------

Subject: Digest Footer

_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners


------------------------------

End of Beginners Digest, Vol 123, Issue 3
*****************************************


_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Beginners Digest, Vol 123, Issue 3

Jecel Assumpcao Jr
Tim,

> One of the articles on Morphic says you can create composite morphs either programatically,
> using addMorph, or using drag and drop from the Objects menu of the morphic World. I have
> done the latter, because it is easier to design my layout that way. Once that has been done,
> how do I address the submorph from a browser? If I inspect my button submorph, for example
>, all it will tell me about it is "a ScriptableButton<Button>(1364754)". I have no idea how to
> access that object in order to do anything with it. This is the crux of my questions.

This is, in my opinion, the most significant limitation of Morphic for
interactive GUI creation. In the original Morphic in Self the way to
handle this was to simply search through all your submorphs for the one
you were interested in, usually by comparing the morphType string. In
Squeak we can add properties to Morphs very easily so that would be one
way to tag it. Something like:

| stopButton |
stopButton := nil.
self submorphsDo: [ :m | (m hasProperty: #stopButton) ifTrue: [
                               stopButton := m ] ].
stopButton ifNotNilDo: [ :b | b ... ].

Code like this will work even if there are no stopButtons at all and if
you add more than one the code will just use the last one and ignore the
others.

After creating the button you have to get its halo and use the red
button (menu) with the debug->inspect morph option to set the
#stopButton property.

An alternative to using specially created properties is to depend on the
morph's name. In your case it is "a ScriptableButton<Button>(1364754)"..
So:

self subMorphsDo: [ :m | (m name includesSubString: 'Button') ifTrue:
...

should work for you as long as there is only one button.

-- Jecel
_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
cbc
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Beginners Digest, Vol 123, Issue 3

cbc
In reply to this post by Tim Cuthbertson
Hi.

On Wed, Feb 22, 2017 at 10:52 AM, Tim Cuthbertson <[hidden email]> wrote:
Please allow me to simplify my question. I need a basic answer.

One of the articles on Morphic says you can create composite morphs either programatically, using addMorph, or using drag and drop from the Objects menu of the morphic World. I have done the latter, because it is easier to design my layout that way. Once that has been done, how do I address the submorph from a browser? If I inspect my button submorph, for example, all it will tell me about it is "a ScriptableButton<Button>(1364754)". I have no idea how to access that object in order to do anything with it. This is the crux of my questions.

Thank you

Tim Cuthbertson

Hi, having been through this recently myself, let me share what I do.

First, expore the new morph, and name the morph, such as:
   self name: 'NameString'
Then, when you need to find the morph later use #externalName, roughly like what Jecel suggests:
 
| stopButton |
stopButton := nil.
self allMorphsDo: [ :m | (m externalName = 'NameString') ifTrue: [
                               stopButton := m ] ].
stopButton ifNotNilDo: [ :b | b ... ].

In my code, I store all of the submorphs I want in local variables for later use.

(note that I use #allMorphsDo: - this check morphs embedded in other morphs in your main morph, which I did a lot of!).

-cbc

_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Loading...