-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added getting started information and hello world example, reorganize…
…d and added to screenshots
- Loading branch information
Showing
6 changed files
with
91 additions
and
259 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,41 @@ | ||
--- | ||
title: Getting Started | ||
description: What does your user need to know to try your project? | ||
categories: [Examples, Placeholders] | ||
tags: [test, docs] | ||
weight: 2 | ||
description: Set up prerequisites, install Gi, and run the Widgets example. | ||
weight: 1 | ||
--- | ||
|
||
{{% pageinfo %}} | ||
This is a placeholder page that shows you how to use this template site. | ||
{{% /pageinfo %}} | ||
## Prerequisites | ||
|
||
Information in this section helps your user try your project themselves. | ||
On all platforms, you must download and install Go from [the Go website](https://go.dev/doc/install) if you do not already have Go 1.18+ installed. | ||
|
||
* What do your users need to do to start using your project? This could include downloading/installation instructions, including any prerequisites or system requirements. | ||
### MacOS | ||
|
||
* Introductory “Hello World” example, if appropriate. More complex tutorials should live in the Tutorials section. | ||
1. Install the xcode command-line tools if you don't already have them by running `xcode-select --install` | ||
2. If you don't already have the Vulkan SDK installed, install it by doing the following: | ||
* Run `curl -O https://sdk.lunarg.com/sdk/download/latest/mac/vulkan_sdk.dmg` | ||
* Run `open vulkan_sdk.dmg` | ||
* Double click `InstallVulkan.app` | ||
* Follow the installation prompts and ignore all warnings about the Vulkan Portability Enumeration extension | ||
|
||
Consider using the headings below for your getting started page. You can delete any that are not applicable to your project. | ||
### Windows | ||
|
||
## Prerequisites | ||
1. Download and install Git for Windows from the [git website](https://git-scm.com/download/win) if you don't already have it. You should install Git Bash as part of this process and use it for development. | ||
2. Download and install TDM-GCC from [this website](https://jmeubank.github.io/tdm-gcc/) | ||
3. Open Windows Command Prompt and run `cd C:\TDM-GCC-64` | ||
4. Then, run `mingwvars.bat` | ||
|
||
Are there any system requirements for using your project? What languages are supported (if any)? Do users need to already have any software or tools installed? | ||
### Linux | ||
|
||
## Installation | ||
* If you are on Ubuntu or Debian, run `sudo apt-get install libgl1-mesa-dev xorg-dev` | ||
* If you are on CentOS or Fedora, run `sudo dnf install libX11-devel libXcursor-devel libXrandr-devel libXinerama-devel mesa-libGL-devel libXi-devel libXxf86vm-devel` | ||
|
||
Where can your user find your project code? How can they install it (binaries, installable package, build from source)? Are there multiple options/versions they can install and how should they choose the right one for them? | ||
|
||
## Setup | ||
## Installation | ||
|
||
Is there any initial setup users need to do after installation to try your project? | ||
Clone the Gi repository by running `git clone https://github.com/goki/gi` | ||
|
||
## Try it out! | ||
|
||
Can your users test their installation, for example by running a command or deploying a Hello World example? | ||
4. Navigate to the widgets example by running `cd gi/examples/widgets` | ||
5. Build the widgets example by running `go build` | ||
6. Run the widgets example by running `./widgets` if you are on MacOS or Linux and `./widgets.exe` if you are on Windows. This should create a window with a variety of widgets, similar to the screenshot below: | ||
![Screenshot of Widgets Demo](/screenshots/widgets.png) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
--- | ||
title: Hello World | ||
description: Create a simple Hello World example app with Gi. | ||
categories: [Examples] | ||
--- | ||
|
||
## Create a new Go project | ||
|
||
1. Navigate back to your home directory by running `cd` | ||
2. Create a new directory called myapp by running `mkdir myapp` | ||
3. Navigate to your newly created directory by running `cd myapp` | ||
4. Create a new Go module by running `go mod init myapp` | ||
5. Create a new Go file by running `touch main.go` | ||
6. Open main.go using an editor of your choice | ||
|
||
## Make a simple app | ||
|
||
1. Add the following code to your editor: | ||
|
||
```go | ||
package main | ||
|
||
import ( | ||
"github.com/goki/gi/gi" | ||
"github.com/goki/gi/gimain" | ||
) | ||
|
||
func main() { | ||
// Run the window event loop function as the main function | ||
gimain.Main(func() { | ||
mainrun() | ||
}) | ||
} | ||
|
||
func mainrun() { | ||
// Create a window called My App Window with width 1024 and height 768 | ||
win := gi.NewMainWindow("myapp", "My App Window", 1024, 768) | ||
// Get the viewport within the window | ||
vp := win.WinViewport2D() | ||
// Start a protect update on the viewport | ||
updt := vp.UpdateStart() | ||
// Create a standard frame within the window and make it the main widget | ||
mfr := win.SetMainFrame() | ||
|
||
// Add a label to the main frame with the text "Hello, World!" | ||
label := gi.AddNewLabel(mfr, "label", "Hello, World!") | ||
// Make the font size of the label large | ||
label.SetProp("font-size", "large") | ||
|
||
// End the protected update on the viewport without a signal. | ||
// Update signals cause things to be redrawn, which is unnecessary at the start | ||
// because it is already drawing everything new. | ||
vp.UpdateEndNoSig(updt) | ||
// Start the event loop that keeps the window rendering. | ||
// This is a blocking call, and it will not return until | ||
// the user quits the app or gi.Quit() is called | ||
win.StartEventLoop() | ||
} | ||
|
||
``` | ||
|
||
2. Update your dependencies by running `go mod tidy` | ||
3. Build the code by running `go build` | ||
4. Run the app by running `./myapp` if you are on MacOS or Linux and `./myapp.exe` if you are on Windows. This should create a window with text that says "Hello, World," similar to the screenshot below: | ||
![Screenshot of Hello World App](/screenshots/helloworld.png) | ||
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.