Gooey Documentation Release 1.0 Emily Johnston, Leah Cole, Kenny Suh, Mary McCreary, Evan Har February 16, 2015 Contents 1 About 1.1 What is Gooey? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.2 What are the Gooey Docs? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.3 About the Creators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 3 3 3 2 Getting Started 2.1 Language Basics . . 2.2 Make Commands . . 2.3 Set Commands . . . 2.4 Variable Names . . . 2.5 Attributes and Values 2.6 Syntax Example . . . . . . . . 5 5 5 6 6 6 7 3 Tutorials 3.1 Window, Text, and Button Tutorial . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.2 Image, TextBox, Checkbox, and Menu Tutorial . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 9 14 4 Actions and Functions 4.1 Actions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.2 Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 17 18 5 Make and Set Commands 19 6 Objects 6.1 Button . . . 6.2 Window . . . 6.3 Checkboxes . 6.4 RadioButtons 6.5 Dropdown . 6.6 Text . . . . . 6.7 TextBox . . 6.8 Menu . . . . 6.9 MenuItem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21 21 21 22 22 22 23 23 23 23 Test Objects 7.1 Window . . . 7.2 Button . . . 7.3 Checkboxes . 7.4 RadioButtons . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 25 26 26 27 7 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . i 7.5 7.6 7.7 7.8 7.9 7.10 7.11 7.12 8 ii DropDown . . Text . . . . . . FormattedText TextBox . . . Menu . . . . . MenuItem . . Search . . . . Image . . . . . Indices and tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27 28 28 28 29 29 29 30 31 Gooey Documentation, Release 1.0 Contents: Contents 1 Gooey Documentation, Release 1.0 2 Contents CHAPTER 1 About Hello and welcome to Gooey Docs! 1.1 What is Gooey? Gooey is a tool for quick and easy creation of Graphical User Interfaces (GUIs). A GUI is the layout of an application - the buttons, the menus, the style, and so on. GUIs are notoriously troublesome to make, even for experienced programmers. The language was designed for people who have very little experience coding, and so is designed to look more like an English sentence than long blocks of code. 1.2 What are the Gooey Docs? Gooey is meant to be easy and intuitive, but a tool is only as good as it’s documentation. The Gooey team worked tirelessly to create flawless* documentation so that their users could create the very best GUIs possible. Here users can find language basics, tutorials, and all the nity-gritty details of each object and attribute. * some restrictions may apply. 1.3 About the Creators Gooey was created as a comps project by a group of six senior Computer Science majors at Carleton College. They’re swell people with a passion for puns. 3 Gooey Documentation, Release 1.0 4 Chapter 1. About CHAPTER 2 Getting Started 2.1 Language Basics The Gooey GUI language was designed to be easy! Our goal was to make coding look less like code, and more like an English sentence. There are a few basic rules to follow, and then you’ll be on your way. Normally, each line starts with either make or set, which can be capital or lowercase. As Gooey attempts to simulate english, each line of Gooey ends with a period. When making a list of multiple attributes, lines are seperated by commas. Although Gooey is similar to Python, in Gooey white space does not matter. 2.2 Make Commands You can use the make command to create and add new elements to your GUI. make commands always have the same basic syntax. Typing: make Object name. will create a new object of the given type with its default values. Alternatively, the syntax: make OBJECT NAME with ATTRIBUTE value. will create the object with most of the defaults, with one attribute modification that you specify. You can add as many attributes as you want in the make command, by separating the attributes with commas. The syntax this time might look like: make OBJECT NAME with ATTRIBUTE VALUE, ATTRIBUTE VALUE, ATTRIBUTE VALUE. The command make is always followed by the type of object you want to make. Types of objects always start with capital letters and might include: • Window • Button 5 Gooey Documentation, Release 1.0 • Menu • Text • Checkbox And so on. 2.3 Set Commands If you choose to use the live Gooey editor, you might want to modify your objects after making them. set commands allow you to change any attributes for objects you have already created. The set command syntax is: set NAME ATTRIBUTE VALUE. You can also set multiple attributes of a single objects by using commas: set NAME ATTRIBUTE VALUE, ATTRIBUTE VALUE, ATTRIBUTE VALUE. 2.4 Variable Names After the object comes the variable name. Your object has to start with a lowercase letter, be only one word long, and contain only letters, numbers, or underscore _. Valid variable names include: • myvariable • myVariable2 • mINE • not_yours • o_o These variable names are NOT valid: • my variable • MyVariable • mINE! • \(^-^)/ 2.5 Attributes and Values Attributes are a variety of customizable components of your object. Common attributes include: • size • color • text • position 6 Chapter 2. Getting Started Gooey Documentation, Release 1.0 Some objects may have additional unique attributes. There are a lot of attributes where commonly desired values are preset for you, like the size attribute has default values of small, medium, and large. However, for your custom needs, you can also set your own size numerically. So, size large and size 455 are both legal ways to define the size. 2.6 Syntax Example In summary, to create a button, say: make Button mybutton. To create a button with the words “Yes” on it, type: make Button mybutton with text “Yes”. And to create a big button with the words “Yes”, type: make Button mybutton with text “Yes”, size large. Now you’re ready to start making your own Gooey GUI! 2.6. Syntax Example 7 Gooey Documentation, Release 1.0 8 Chapter 2. Getting Started CHAPTER 3 Tutorials These tutorials are here to show examples of basic Gooey GUIs. If you’re just starting to learn Gooey, you might want to go through some or all of the tutorials before you make your own GUI. 3.1 Window, Text, and Button Tutorial To start using Gooey, go to the terminal and navigate to the project folder. Type in the terminal: python3 gooey.py Your Gooey editor will appear. 9 Gooey Documentation, Release 1.0 You can now enter the Gooey language into the editor. To start, make an empty window. Type in the editor: make Window w. When you’re ready to run your GUI, hit the play button at the bottom right corner. 10 Chapter 3. Tutorials Gooey Documentation, Release 1.0 This is your live preview. Right now it’s a little boring. 3.1. Window, Text, and Button Tutorial 11 Gooey Documentation, Release 1.0 Make the window bigger or smaller with the set command. The set command allows you to modify one or more things at a time. Try adjusting the title of the window, which will appear in the bar across the top. Type: set w size 5 5, title "My First Gooey". An empty window is useless though. To add writing to your GUI, you’ll need to add a Text object. Type: make Text t with text "Welcome to Gooey!". INSERT PICTURE make sure punctuation works in text objects. Now you’re ready to add a button. Type: make Button b with text “Hello”. After you Run, your GUI should look like this 12 Chapter 3. Tutorials Gooey Documentation, Release 1.0 Now that you have a simple layout, you can modify your existing objects further by using the set function. Try: set w color green. 3.1. Window, Text, and Button Tutorial 13 Gooey Documentation, Release 1.0 Your button is currently useless. You can click it, but since we haven’t given it an action attribute, it won’t do anything. Try: set b text "Go", action windowColorChange green. Try clicking on the button, see what happens. Your window should have turned green. Gooey has a number of built in actions which you can find in the Actions section of the Gooey Docs. 3.2 Image, TextBox, Checkbox, and Menu Tutorial Now, let’s try making a slightly more complicated Gooey. Remember, always start by making a window: make Window w with title "Gooey Two", size 10 10, color blue. Make things more decorative by adding a picture. This will use the Image object, and will need a still picture in the .gif format. For example: make Image apple with source "apple.gif", position 0 1. There are times when you might want your users to write something out. A TextBox is perfect in this situation! Type: make TextBox comments with text "Write your thoughts here". make Button submit with text "Submit", position 1 0. But maybe instead of direct input, you merely want your users to choose between a few choices. A simple Checkbox looks like: make Checkboxes cb with options "Apple" "Peach" "Pumpkin Pie". 14 Chapter 3. Tutorials Gooey Documentation, Release 1.0 Each of the options you list will make another checkbox with that label. You can put a preface on your Checkboxes using the title attribute: set cb title "Choose from the following:". Now onto one of the most complex components of Gooey: Menus. The basic Menu object will keep track of the different menus you plan on having. For example: make Menu toplevel with options file edit. will create two different drop down menu lists. To populate these lists, you need MenuItem objects. They should look like this: make MenuItem file with title "File", options "Quit":quit make MenuItem edit with title "Edit", options "Change color":quit "Change size":quit. All of these actions will close your program. You can create your own object actions by making functions. A simple function to simply change the window color looks like this: function myFunction(win) does set win color green; return win. After making a function, there are two ways to use it. To run myFucntion on the Window w, either you can say: run myFunction(w). or you can turn your function into an action for Buttons and MenuItems make Button b with action myFunction(w). make MenuItem edit with title "Edit", options "Change color":myFunciton(w) "Change size":quit. Now you’ve gone through all the main components of Gooey. You’re ready to make your own now! 3.2. Image, TextBox, Checkbox, and Menu Tutorial 15 Gooey Documentation, Release 1.0 16 Chapter 3. Tutorials CHAPTER 4 Actions and Functions Actions and functions are extremely important elements of GUIs. Actions and functions make things happen. 4.1 Actions Actions are the attributes for ojbects like Buttons and MenuItems that make them do things. For example: make Button quit with title "Stop", action quit. will make a button that shuts down the program when clicked. quit is one of a handful of defualt actions Gooey has created for you. 4.1.1 Write The write action will print a string to the terminal. After declaring the write action, add a string in double quotation marks, as follows: make Button b with action write "I’m a print statement". 4.1.2 Quit The quit action closes the program. Example: make Button b with action quit. 4.1.3 windowColorChange The windowColorChange action changes the color of the window. After declaring the windowColorChange, add a color value. Example: make Button error with title "Error", action windowColorChange red. 17 Gooey Documentation, Release 1.0 4.1.4 windowSizeChange The windowSizeChange action changes the size of the window. After declairing the windowSizeChange action, add a size value. Example: make Button size with title "Full Screen", action windowSizeChange large. 4.1.5 findAction Please ask Jamica 4.1.6 findMenuAction Ask Jamaica about this too. 4.1.7 callAction What even is this make Window w. function myFunction(win) does set win color green; return win. run myFunction(w) make Button b with action myFunction(w). 4.2 Functions A function will let you create your own actions. The syntax for functions is as follows: function NAME(VARIABLE) does GOOEY_CODE; return VARIABLE. A real example would look like this: function myFunction(win) does set win color green; return win. This line of code means that the function named myFunction, which takes in an object win, will reset the window color to green. You need to return the object at the end for your changes to occur. There are two ways to run your function. You can use the run command to run the function yourself: make Window w. function myFunction(win) does set win color green; return win. run myFunction(w). Alternatively, you can set the function as a Button or MenuItem action.: make Window w. function myFunction(win) does set win color green; return win. make Button b with action myFunction(win). make Menu with options file make MenuItem file with title "File", options "Change":myFunction(win). 18 Chapter 4. Actions and Functions CHAPTER 5 Make and Set Commands Maybe this page is not needed beacuse Language Basics seems to cover it already? 19 Gooey Documentation, Release 1.0 20 Chapter 5. Make and Set Commands CHAPTER 6 Objects Objects are the builing blocks of your GUI. Each object has a differnet set of uses, attributes, and functions. 6.1 Button A button is a clickable object. Example syntax: make Button b. make Button b with text "Hello". make Button b with text "Hello", position (3,5). set b action close. 6.2 Window A window is the frame on which you create your GUI. The window is always the first object you make. Example syntax: make Window w with size (10,10), color green. set w title "My favorite GUI". Attributes: 21 Gooey Documentation, Release 1.0 Attribute title Description size color action hidden font fontSize textColor Possible Values Default Value A plaintext string | A FormattedText object “”“Untitled Window”“” medium A string description of the size (or keyword?); The (x y) dimensions separated by a space A string description of the color (or keyword?); An rgb value separated by spaces The name of a Python or Gooey function to call when the object is acted upon A boolean indicating whether the object is hidden (True | true | False | false) The string name of a font available in Gooey white False A number indicating the font size “”“Times New Roman”“” 12 A color (A string description or an rgb value) black 6.3 Checkboxes Checkboxes are square boxes the user can click on to select any number of options. If you create a Checkbox object without the options attribute, it will have three default checkboxes labeled “Option 1”, “Option 2”, and “Option 3”. Placing an asterisk before any of the attributes will mark that option to be selected by default. Example syntax: make Checkbox c with options "hello" "yellow" "fellow". set c position (2,2). 6.4 RadioButtons Radio Button are circular buttons a user can click to select one option out of many. If you create a RadioButton object without the options attribute, it will have three default buttons labeled “Option 1”, “Option 2”, and “Option 3”. Placing an asterisk before one of the attributes will make that option to be selected by default. Example syntax: make RadioButton r with options "hello" "mello" "jello". set r title "Choose one:". 6.5 Dropdown Dropdown Menus allow the user to choose one option from pop-down list. If you create a Dropdown object without the options attribute, it will have three default options in the list labeled “Option 1”, “Option 2”, and “Option 3”. Example syntax: make Dropdown with options "hello" "cello" "othello". set d position bottomleft. 22 Chapter 6. Objects Gooey Documentation, Release 1.0 6.6 Text Text is a simple text region the user cannot interact with. Example syntax: make Text t with text "Welcome to Gooey! Please leave your shoes at the door." set t color blue. 6.7 TextBox TextBox objects create a space where users can type. When you create a TextBox with a text attribute, the value entered will appear as defualt text within the text box. Example syntax: make TextBox tb with text "Write your answer here". set tb size large. 6.8 Menu Menus are a list of actions. Menu’s are created with Menu Items. When creating a Menu, the options attribute points to the MenuItems to be included in the Menu. A Menu must include MenuItems. Example syntax: make Menu m with options file edit. 6.9 MenuItem MenuItems are the terminal actions in a Menu. The variable name of the MenuItem must match the name of the correlating option listed in the Menu object. With the options attribute, MenuItems have two parts. First the text the user will select, then a colon, followed by the action. Example syntax: make MenuItem file with options "quit":close. 6.6. Text 23 Gooey Documentation, Release 1.0 24 Chapter 6. Objects CHAPTER 7 Test Objects 7.1 Window 7.1.1 Attributes Attribute title size color action hidden font fontSize textColor Description Possible Values Default Value A plaintext string | A FormattedText object “”“Untitled Window”“” medium A string description of the size (or keyword?); The (x y) dimensions separated by a space A string description of the color (or keyword?); An rgb value separated by spaces The name of a Python or Gooey function to call when the object is acted upon A boolean indicating whether the object is hidden (True | true | False | false) The string name of a font available in Gooey white False A number indicating the font size “”“Times New Roman”“” 12 A color (A string description or an rgb value) black 25 Gooey Documentation, Release 1.0 7.2 Button 7.2.1 Attributes Attribute title text Description Possible Values Default Value A plaintext string | A FormattedText object A plaintext string | A FormattedText object position size A string description of the position (or is this a keyword?); An (x y) coordinate separated by a space A string description of the size (or keyword?); The (x y) dimensions separated by a space The name of a Python or Gooey function to call when the object is acted upon A boolean indicating whether the object is hidden (True | true | False | false) action hidden “”“Untitled Button”“” center medium False 7.3 Checkboxes 7.3.1 Attributes AtDetribute scription title Possible Values Default Value A plaintext string | A FormattedText object options “A list separated by spaces containing (For Checkboxes etc) A string preceded by a * if default selected; (For Menu) A menuItem object; (For MenuItem) A menuItem object | a terminal in the format “”name””:action” A string description of the position (or is this a keyword?); An (x y) coordinate separated by a space “”“Untitled Checkboxes”“” “*”“Option 1”” “”Option 2”” “”Option 3”“” center position size hidden 26 A string description of the size (or keyword?); The (x y) dimensions separated by a space A boolean indicating whether the object is hidden (True | true | False | false) medium False Chapter 7. Test Objects Gooey Documentation, Release 1.0 7.4 RadioButtons 7.4.1 Attributes AtDetribute scription title Possible Values Default Value A plaintext string | A FormattedText object options “A list separated by spaces containing (For Checkboxes etc) A string preceded by a * if default selected; (For Menu) A menuItem object; (For MenuItem) A menuItem object | a terminal in the format “”name””:action” A string description of the position (or is this a keyword?); An (x y) coordinate separated by a space “”“Untitled Radio Buttons”“” “*”“Option 1”” “”Option 2”” “”Option 3”“” center position size hidden A string description of the size (or keyword?); The (x y) dimensions separated by a space A boolean indicating whether the object is hidden (True | true | False | false) medium False 7.5 DropDown 7.5.1 Attributes AtDetribute scription title Possible Values Default Value A plaintext string | A FormattedText object options “A list separated by spaces containing (For Checkboxes etc) A string preceded by a * if default selected; (For Menu) A menuItem object; (For MenuItem) A menuItem object | a terminal in the format “”name””:action” A string description of the position (or is this a keyword?); An (x y) coordinate separated by a space “”“Untitled Drop Down”“” “*”“Option 1”” “”Option 2”” “”Option 3”“” center position size hidden A string description of the size (or keyword?); The (x y) dimensions separated by a space A boolean indicating whether the object is hidden (True | true | False | false) 7.4. RadioButtons medium False 27 Gooey Documentation, Release 1.0 7.6 Text 7.6.1 Attributes Attribute text position size Description Possible Values A plaintext string | A FormattedText object A string description of the position (or is this a keyword?); An (x y) coordinate separated by a space A string description of the size (or keyword?); The (x y) dimensions separated by a space A string description of the color (or keyword?); An rgb value separated by spaces A boolean indicating whether the object is hidden (True | true | False | false) color hidden Default Value “”“Text”“” center medium white False 7.7 FormattedText 7.7.1 Attributes Attribute text font fontSize textColor Description Possible Values A plaintext string | A FormattedText object The string name of a font available in Gooey A number indicating the font size A color (A string description or an rgb value) Default Value “”“Formatted Text”“” “”“Times New Roman”“” 12 black 7.8 TextBox 7.8.1 Attributes Attribute title text position size hidden 28 Description Possible Values Default Value A plaintext string | A FormattedText object “”“Untitled Text Box”“” “”“Type here”“” center A plaintext string | A FormattedText object A string description of the position (or is this a keyword?); An (x y) coordinate separated by a space A string description of the size (or keyword?); The (x y) dimensions separated by a space A boolean indicating whether the object is hidden (True | true | False | false) medium False Chapter 7. Test Objects Gooey Documentation, Release 1.0 7.9 Menu 7.9.1 Attributes AtDetribute scription options position hidden Possible Values Default Value “A list separated by spaces containing (For Checkboxes etc) A string preceded by a * if default selected; (For Menu) A menuItem object; (For MenuItem) A menuItem object | a terminal in the format “”name””:action” A string description of the position (or is this a keyword?); An (x y) coordinate separated by a space menuItem1 menuItem2 menuItem3 menuBar A boolean indicating whether the object is hidden (True | true | False | false) False 7.10 MenuItem 7.10.1 Attributes AtDetribute scription title Possible Values Default Value A plaintext string | A FormattedText object options “A list separated by spaces containing (For Checkboxes etc) A string preceded by a * if default selected; (For Menu) A menuItem object; (For MenuItem) A menuItem object | a terminal in the format “”name””:action” A boolean indicating whether the object is hidden (True | true | False | false) “”“Untitled Menu Item”“” “”“Option 1”” “”Option 2”” “”Option 3”“” False hidden 7.11 Search 7.11.1 Attributes Attribute text position size hidden 7.9. Menu Description Possible Values A plaintext string | A FormattedText object A string description of the position (or is this a keyword?); An (x y) coordinate separated by a space A string description of the size (or keyword?); The (x y) dimensions separated by a space A boolean indicating whether the object is hidden (True | true | False | false) Default Value “”“Search”“” center medium False 29 Gooey Documentation, Release 1.0 7.12 Image 7.12.1 Attributes Attribute title text position size hidden source 30 Description Possible Values Default Value A plaintext string | A FormattedText object A plaintext string | A FormattedText object A string description of the position (or is this a keyword?); An (x y) coordinate separated by a space A string description of the size (or keyword?); The (x y) dimensions separated by a space A boolean indicating whether the object is hidden (True | true | False | false) A string containing a path/filename “”“Image Caption”“” center medium False defaultIcon Chapter 7. Test Objects CHAPTER 8 Indices and tables • genindex • modindex • search 31
© Copyright 2024