Hello all,
I've been interested to read about some of the activities of the Documentation team, as I've recently been trying to work out how to build a GUI application in Squeak.
To that end, I've built a sample image viewer application, heavily annotated, to keep a record of my understanding of the following areas: - Morphic layout - Use of Models and Pluggable Morphs - Interacting with the filesystem - Launching and managing background processes
The code is attached, and can also be found at http://www.squeaksource.com/SampleImageViewer.html
I'd appreciate it if anyone could spare some time to have a look at this sample and see if I'm making any obvious mistakes (especially my termination of processes, which I suspect isn't very robust), or if the 'squeakiness' of the code could be improved.
If anyone from the Documentation team is building a repository of sample code for beginners, I'd be happy to incorporate this application into such a repository.
Thanks in advance for any comments, Michael
Thanks for writing some commented SAMPLE CODE for us Squeak newbies. Very NEEDED and appreciated!
I've been at this for about two weeks, and it's a little tough to make the transition between making a car go in circles to writing something useful.
I know enough to open a Morphic project, get your file list, and open it with the zip viewer. This is as close to the "file in" as I can seem to get, as the "load file" command will not show your file. I can load your code from there, but now what do I do with the blank screen? I'm obviously not loading or running it properly.
Hi Dave, I know that feeling well! Having programmed in many environments over the years, I recognise that Squeak has lots of great stuff under the covers, but it takes a lot of work to find your way around at first.
Here's how to load and run the application from scratch:
Start in a Morphic Project (the project you're in when you launch Squeak is actually morphic, so there's no need to open one specially except for tidyness).
Click on the background. This will bring up the World menu. Choose "open..." then "file list", which will bring up a file browser.
Navigate to the file and click on it. You will see that the buttons will change to include a "file in" button. Click that button!
The code is then "filed-in" - you can look at it using the Browser (World menu>open>browser or cmd-B (Mac) / Alt-B (PC)).
To run it, open a Workspace (World menu>open>workspace, cmd-K) and type "SampleImageViewerMorph new" (without the quotes), and press cmd-D/alt-D at the end of the line - the application should then launch.
Press the dir button to select a directory, then press enter in the directory text box, and enjoy the pictures!
I hope this helps.
Michael
ps the other way to load the code is using the Monticello Browser against the squeaksource.com code. This is really useful once you work out how to do it, especially for code that is likely to change. I'm sure I remember seeing an email that explained how to use it in great detail, but here's one from Avi Bryant that gives enough to get started: http://lists.squeakfoundation.org/pipermail/squeak-dev/2004-July/079958.html (change http://www.squeaksource.com/Graphhttp://www.squeaksource.com/Graph%27 to http://www.squeaksource.com/SampleImageViewerhttp://www.squeaksource.com/Graph%27in this case).
On 10/16/06, Another Dave dooright101@yahoo.com wrote:
Thanks for writing some commented SAMPLE CODE for us Squeak newbies. Very NEEDED and appreciated!
I've been at this for about two weeks, and it's a little tough to make the transition between making a car go in circles to writing something useful.
I know enough to open a Morphic project, get your file list, and open it with the zip viewer. This is as close to the "file in" as I can seem to get, as the "load file" command will not show your file. I can load your code from there, but now what do I do with the blank screen? I'm obviously not loading or running it properly.
-- View this message in context: http://www.nabble.com/Some-sample-code-to-help-understand-Morphic-applicatio... Sent from the Squeak - Beginners mailing list archive at Nabble.com.
Beginners mailing list Beginners@lists.squeakfoundation.org http://lists.squeakfoundation.org/mailman/listinfo/beginners
Neither Squeak 3.8 nor 3.9 will give me that "file in" button, but now that I know the .mcz extension means Monticello I can make my incoming directory a repository and open it. From there I can load the image.
Starting things off with "SampleImageViewerMorph new" in a workspace is really basic, but it is something that us new guys just don't get until we've done a few examples. I gather that the final class in the listing will generally be the one that you start the program with--bottom-up programming, as in Forth?
System browser, rt click on class category, then select printOut is another command that isn't talked about much, and I guess you have to "just know" that the .html output listing is not really HTML, but now I have a printed listing with lots of comments, and a running program with buttons and graphics.
Nice! Thanks!
On 10/18/06, Another Dave dooright101@yahoo.com wrote:
Neither Squeak 3.8 nor 3.9 will give me that "file in" button, but now that I know the .mcz extension means Monticello I can make my incoming directory a repository and open it. From there I can load the image.
Sorry, I assumed it was the .st file you were having problems with.
Starting things off with "SampleImageViewerMorph new" in a workspace is
really basic, but it is something that us new guys just don't get until we've done a few examples.
That's been my experience too - once you understand the 'shape' of the solution you're trying to build, it's easier to use the browsers to find relevant code to learn from
I gather that the final class in the listing will
generally be the one that you start the program with--bottom-up programming, as in Forth?
If I understand you right, then the answer's 'no' - everything's listed alphabetically in the browser - it's just a co-incidence that this reflects the "level" of the classes in this case.
System browser, rt click on class category, then select printOut is another
command that isn't talked about much, and I guess you have to "just know" that the .html output listing is not really HTML, but now I have a printed listing with lots of comments, and a running program with buttons and graphics.
Nice! Thanks!
No problem, Michael
On Mon, Oct 16, 2006 at 01:49:20PM +0100, Michael Davies wrote:
Hello all,
I've been interested to read about some of the activities of the Documentation team, as I've recently been trying to work out how to build a GUI application in Squeak.
To that end, I've built a sample image viewer application, heavily annotated, to keep a record of my understanding of the following areas:
- Morphic layout
- Use of Models and Pluggable Morphs
- Interacting with the filesystem
- Launching and managing background processes
Cool. That heavily commented SampleImageViewerMorph>>initialize is especially useful
The code is attached, and can also be found at http://www.squeaksource.com/SampleImageViewer.html
I'd appreciate it if anyone could spare some time to have a look at this sample and see if I'm making any obvious mistakes (especially my termination of processes, which I suspect isn't very robust), or if the 'squeakiness' of the code could be improved.
I am not sure, but every time I hit enter in the dir box, or click the main panel, I get a debug window. What Squeak version is this made for? I am using 3.8. A quick question: is the correct way to run this program: SampleImageViewerMorph new openInWorld
If anyone from the Documentation team is building a repository of sample code for beginners, I'd be happy to incorporate this application into such a repository.
We have not considered a code repository, but this morph is quite simple, and may be useful in a tutorial. I might incorporate it into my beginner's tutorial: http://minnow.cc.gatech.edu/squeak/5869
beginners@lists.squeakfoundation.org