User interfaces | getting started

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

User interfaces | getting started

Darren White
Hello,
This is my first post here. I have been exploring the squeak environment and smalltalk syntax for a few weeks now. Usually when learning a new programming language I create a small programs such as a contacts list. First I may do it with a console front end then play around with a GUI and widgets.

I have got to the stage with squeak where I want to do that but I can't see how to proceed. For a console type program how do I proceed and for a GUI program what is the main form/frame/window to hold the components. So the main thing I'm stuck with is the user interface, I have read enough to know how to create classes and their method bodies (though my code may be bad at this stage :-) ).
Any advice would be most welcome, I can't wait to get stuck in!

Darren

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

RE: User interfaces | getting started

Ron Teitelbaum
Hi Darren,

Welcome to the list.  I'm glad you have been reading about classes and
methods that should help.  There is no console type application for Squeak.
The closest thing we have to a console app is the Transcript, but the
Transcript does not accept input.  We also have inspectors, browsers and a
workspace with act much like the input side but they too are not really like
the console you may be expecting.

I agree with your path though, you want to get into the logic and flow of
the program without having to worry about GUI itself.  Here is how you might
do that.

You create classes that represent your domain.  For a contact list you might
create a contact and a contactBook.  

Something simple like

Object subclass: #Contact
        instanceVariableNames: 'name email phoneNumber'

Object subclass: #LittleBlackBook
        instanceVariableNames: 'contacts'

You should create accessors and mutators for the instanceVariables on
Contact and LittleBlackBook.

LittleBlackBook >> initialize
        contacts := OrderedCollection new.

Now what you need is a way to add contacts.

LittleBlackBook >> addContactNamed: aName email: anEmail phoneNumber:
aPhoneNumber
        "create a contact and add it to the list of contacts"
        self contacts add: (Contact name: aName email: anEmail phoneNumber:
aPhoneNumber).

Contact class >> name: aName email: anEmail phoneNumber: aPhoneNumber
        "Return to the sender a new instance of contact with this
information"
        ^self new
                name: aName;
                email: anEmail;
                phoneNumber: aPhoneNumber;
                yourself.

Ok so very simply you can create instances of your book by starting from the
workspace and then using the inspectors for modifying your instance and
getting feedback.  This feedback is different from a console but it does
give you a good feeling for objects.

>From a workspace you would do:

LittleBlackBook new

Now highlight that, right click -> inspect it.

What you get back is an inspector.  This is an instance of your class
LittleBlackBook.  Notice that you can click on the ivars and see their
contents.  #contacts is currently empty.  

On the inspector of LittelBlackBook you can now type: self.  #self refers to
the instance itself.  If you type self, highlight it and inspect it you get
the same instance back again.  It's not a copy it's the same instance, what
ever you do to one will be reflected in the other since they are the same
instance.  

The method we wrote can be called by using #self.  Try this by typing this
in the inspector window of your instance of LittleBlackBook.  (you can close
the second inspector).

self addContactNamed: 'Darren White' email: '[hidden email]'
phoneNumber: nil.

You can just highlight it and do it.  Now check out the contacts ivar.  It
now has a contact in it.  If you inspect the contact you will see that you
have a collection and if you inspect the first item in the collection you
will see that you have an instance of Contact, with your info in it.  

It's not a console but there is nothing that a console can do that you can
not reproduce by adding new methods to your instance.

Happy Coding!

Ron Teitelbaum
President / Principal Software Engineer
US Medical Record Specialists

________________________________________
From: Darren White

Hello,
This is my first post here. I have been exploring the squeak environment and
smalltalk syntax for a few weeks now. Usually when learning a new
programming language I create a small programs such as a contacts list.
First I may do it with a console front end then play around with a GUI and
widgets.

I have got to the stage with squeak where I want to do that but I can't see
how to proceed. For a console type program how do I proceed and for a GUI
program what is the main form/frame/window to hold the components. So the
main thing I'm stuck with is the user interface, I have read enough to know
how to create classes and their method bodies (though my code may be bad at
this stage :-) ).
Any advice would be most welcome, I can't wait to get stuck in!

Darren

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

Re: User interfaces | getting started

Giuseppe Luigi Punzi-2
In reply to this post by Darren White
Hi Darren.

The "Main Form" is where you develop.

This is a little confusing to new's (i'm new, and happened to me at first). The Squeak Environment (Smalltalk Environment) where you develop is the end user app.

About the GUI's, you can use MORPHIC: http://wiki.squeak.org/squeak/30 for example, or Tweak: http://tweakproject.org/ for example

Web interface is a good alternative (if you like it), Seaside is a great framework for this: http://seaside.st/

Ask all you need, and be patiente, squeak/smalltalk is all diferent to "normal" develop.

Cheers.



El 20/05/2007, a las 22:55, Darren White escribió:

Hello,
This is my first post here. I have been exploring the squeak environment and smalltalk syntax for a few weeks now. Usually when learning a new programming language I create a small programs such as a contacts list. First I may do it with a console front end then play around with a GUI and widgets.

I have got to the stage with squeak where I want to do that but I can't see how to proceed. For a console type program how do I proceed and for a GUI program what is the main form/frame/window to hold the components. So the main thing I'm stuck with is the user interface, I have read enough to know how to create classes and their method bodies (though my code may be bad at this stage :-) ).
Any advice would be most welcome, I can't wait to get stuck in!

Darren
_______________________________________________
Beginners mailing list

| Giuseppe Luigi Punzi Ruiz |




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

Re: User interfaces | getting started

Herbert König
In reply to this post by Darren White
Hello Darren,

DW> This is my first post here. I have been  exploring the squeak

Welcome here!

DW> I have got to the stage with squeak where I want to do that
DW> but I can't see how to proceed. For a console type program how do
DW> I proceed and for a GUI program what is the main form/frame/window
DW> to hold the components. So the main thing I'm stuck with is the
DW> user interface, I have read enough to know how to create classes
DW> and their method bodies (though my code may be bad at this stage
DW> :-) ).
uh yeah errm...

Well this is where squeak differs most from the rest of the world and
even from the rest of Smalltalk. You hit on a big topic so feel free
to ask more if the following only confuses you.

The keyword is morpic. You might want to search the swiki for the
article "why morpic is way cool" for an introduction into the inner
workings of morpic later.

What you want to do, is put your UI elements into a SystemWindow.
(I dislike this so the attached example just uses morphs)

As for the UI elements you may look into the pluggable...Morphs, esp.
PluggableListMorph and PluggableButtonMorph. Also google for
PluggableMorphsDemo.pr (or mail me about it). This is a well explained
demo project for using the pluggable morphs. I've tried this from 3.6
to 3.8, don't know about later Squeak versions.

To layout your UI elements in the SystemWindow add a LayoutPolicy to
it. Don't get confused, TableLayout is not a grid layout but either a
vertical or a horizontal layout.

To build the attached UI file in the attached class (take a fresh 3.8
image) and follow buildGUI.

This UI is used to click into one element of the list to move this
element into the other list (like selecting recipients for an email)
and on accept return the list.

I had special reasons for using accept and cancel buttons which are
just an underlined text.

This is how it's invoked (won't work directly, just an example):

addAdmins
        "add ore remove process admins from all possible Gjallar admins"

        | selector possible |
        self prepareAllAdmins.
        possible := allAdmins.
        possible removeAllFoundIn: processAdmins.
        selector := Q2DualSelectionListMorph new.
        selector
                selected: processAdmins copy;
                unselected: possible;
                buildGui;
                target: self;
                headLineText: 'Select or remove administrators for the new process';
                leftLabelText: 'Possible admins';
                rightLabelText: 'Selected admins';
                resultSelector: #changeAdminsTo:unselected:


If you want to use this UI inside a SystemWindow just add it to a
SystemWindow using spaceFill layout.


Cheers

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

Q2DualSelectionListMorph.st (11K) Download Attachment
Q2DualSelectionList.png (4K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: User interfaces | getting started

K. K. Subramaniam
In reply to this post by Darren White
On Monday 21 May 2007 2:25 am, Darren White wrote:
> Hello,
> This is my first post here.... how do I proceed and for a GUI
> program what is the main form/frame/window to hold the components. So the
> main thing I'm stuck with is the user interface, I have read enough to know
> how to create classes and their method bodies (though my code may be bad at
> this stage :-) ).
Welcome! Squeak is not just a programming environment. It is like
a 'construction kit'. In real life, one learns to build stuff by taking
things apart to see how it was all put together (and perhaps repair it before
Dad comes home! ;-). At some point, you learn enough to build one yourself.

You could take the same tack in Squeak. For instance, open a Workspace and
drill down using halos till you get to the smallest part. Drag it to a
different place. Repeat for all the parts. Then 'inspect/explore/browse' each
part to see how it was put together. You could also try tracing code
execution using "debug it" to pick up programming idioms. Use 'explain' to
find out more about new words/terms. Debug through ClickExerciser object to
see how it handles mouse clicks.

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

Re: User interfaces | getting started

Michael Davies-2
In reply to this post by Darren White
On 20/05/07, Darren White <[hidden email]> wrote:
> Hello,
> This is my first post here. I have been exploring the squeak environment and
> smalltalk syntax for a few weeks now. Usually when learning a new
> programming language I create a small programs such as a contacts list.
> First I may do it with a console front end then play around with a GUI and
> widgets.
>

Hi Darren, I produced a bit of code to help me understand how to build
a GUI using Morphic. It's heavily (excessively!) commented, so may be
of some use to you - have a look at
http://www.squeaksource.com/SampleImageViewer.html

Cheers,
Michael
_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: User interfaces | getting started

David Mitchell-10
In reply to this post by Darren White
For console apps on Unix, see OSProcess:
http://wiki.squeak.org/squeak/708

Some support in Windows.

Darren White wrote:

> Hello,
> This is my first post here. I have been exploring the squeak
> environment and smalltalk syntax for a few weeks now. Usually when
> learning a new programming language I create a small programs such as
> a contacts list. First I may do it with a console front end then play
> around with a GUI and widgets.
>
> I have got to the stage with squeak where I want to do that but I
> can't see how to proceed. For a console type program how do I proceed
> and for a GUI program what is the main form/frame/window to hold the
> components. So the main thing I'm stuck with is the user interface, I
> have read enough to know how to create classes and their method bodies
> (though my code may be bad at this stage :-) ).
> Any advice would be most welcome, I can't wait to get stuck in!
>
> Darren
>
>------------------------------------------------------------------------
>
>_______________________________________________
>Beginners mailing list
>[hidden email]
>http://lists.squeakfoundation.org/mailman/listinfo/beginners
>  
>
_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners