Email this Page | | Feedback

Labs

Change Location

Leopard Lesson Plan #1
Beginner - Day at the Beach
Lesson Files - Download

Introduction

Whether it's summer or not, many of us wish that we could be at the beach on a regular basis, but even though that may not be a possibility, the following lesson plan will show you how to build an application in Leopard that monitors the conditions at Panama City Beach.

Creating a Window

Open Leopard. Now you are ready to begin.

First download all files that are needed for lessons Plan #1. Right click to save the file, then drag and drop into Leopard.

ocean.mp3
leppanamacity.lep

To get started, the first thing that you need to do is specify the type of window that you want to use, which for this example is a regular window.

Enter:

window

Drop down two lines. Always leave a space between the previous command (set of directions) and the next.

Now you enter the text that you want to appear in the title bar of the window:

Enter:

window title
Sunburn Central

The only thing that's left to do is customize the size of the window:

Enter:

window size
563
295

The first number is the width of the window, and the second number is the height. These numbers are declared in pixels.

That's all there is to it! You now have a basic window template to work from. Before showing you how to conclude and execute your program, let's first add all of the other components to our project.

Adding Controls

I want to add a live image of the beach to my program so that I can actually see what the current conditions are like, and thanks to WeatherBug's network of weather cameras, this isn't a problem:

Enter:

weatherbug camera
PSMCT
10
10

The “PSMCT” reference is the name of the camera that I want to use, and you can find these camera names on the images from the WeatherBug InstaCam Web site (http://www.instancam.com). The two numbers represent the x and y coordinates where the image is to be placed on the window.

Now that the camera image is a part of my window, I also want to add a button:

Enter:

button
SE Radar
350
10
183
50

SE Radar is the text that I want to appear on the button. The first two numbers stand for the x and y coordinates of the button, and the last two numbers represent the width and height of the button itself.

To complete the look of the window, I also want to add a WeatherBug control which will tell us what the current temperature and wind speed and direction is:

Enter:

weatherbug
32403
180x150
350
95

32403 is the zip code that I want to retrieve the weather data for, and 180x150 is one of the predetermined sizes that I can use for this control. The final two numbers relate to the x and y coordinates of its location on the window.

Creating an Onclick Event

Since we've added a button to our window, we need to specify what that button does when it's clicked, and this is done by using an onclick event. Let's use this one:

Enter:

button onclick
weatherbug radar
SE Radar
SE

That onclick command is now associated with the name of the control that's referenced (in this case, button), and it'll open up a WeatherBug radar map for us to examine. The title of the window that displays the map will be SE Radar, and the SE part of the code tells Leopard that we want to open the radar map for the southeast in order to see if there's any precipitation headed towards Panama City Beach.

Playing Audio

Before we finish working on our project, let's add a fun extra feature to the program that'll help you feel like you're close to the beach even if you aren't. You can have an MP3 file that contain ocean sounds play when the program is first opened, and to do this, use this code:

Enter:

play mp3
ocean.mp3

Of course, you'll have to have a file called “ocean.mp3” in your Leopard directory in order for this to work.

Wrapping Things Up

The only thing that's left to do in terms of putting the finishing touches on the program is to issue the end command, which needs to be placed at the end of every Leopard program:

Enter:

end

Piece of cake, right? Included below is the entire program from start to finish. Notice how there's always at least one line of white space between each command set. This helps Leopard to understand your code, and it also makes your code more readable. Be sure to follow this method.

window

window title
Sunburn Central

window size
563
295

weatherbug camera
PSMCT
10
10

button
SE Radar
350
10
183
50

weatherbug
32403
180x150
350
95

button onclick
weatherbug radar
SE Radar
SE

play mp3
ocean.mp3

end

Additional Student Activities

  1. Take this template and modify it to work for a sunny destination other than Panama City Beach.
  2. Change the button onclick command to load a temperature map, the storm tracker, or the forecast for the week.
  3. Instead of using an MP3 file that contains ocean sounds, record your own personalized beach forecast as an MP3 file that plays when the program is first opened.

reviewed by TRUST e site privacy statement
Read our Terms of Use. By clicking to download WeatherBug, you agree to these terms.