Skip to content

Commit

Permalink
Fix code examples in README
Browse files Browse the repository at this point in the history
  • Loading branch information
lxn committed Oct 3, 2012
1 parent e79d5dd commit ab9c088
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions README.mdown
Original file line number Diff line number Diff line change
Expand Up @@ -21,29 +21,32 @@ There are three ways to create GUIs with Walk:
1. Imperative code
==================

import "github.com/lxn/walk"

func runMainWindow() error {
import (
"log"
"github.com/lxn/walk"
)

func main() {
mw, err := walk.NewMainWindow()
if err != nil {
return err
log.Fatal(err)
}
if err := mw.SetTitle("My Cool App"); err != nil {
return err
log.Fatal(err)
}
if err := mw.SetLayout(walk.NewVBoxLayout()); err != nil {
return err
log.Fatal(err)
}
pb, err := walk.NewPushButton(mw)
if err != nil {
return err
log.Fatal(err)
}

if err := pb.SetText("Don't Click Me!"); err != nil {
return err
log.Fatal(err)
}
pb.Clicked().Attach(func(){
Expand All @@ -61,24 +64,25 @@ it is hard to see the hierarchical structure of the GUI.
===================

import (
"log"
"github.com/lxn/walk"
. "github.com/lxn/walk/declarative"
)

func runMainWindow() error {
func main() {
var mw *walk.MainWindow

if err := (MainWindow{
AssignTo: &mw,
Title: "My Cool App",
Layout: VBox{},
Children: []Widget{
PushButton{Text: "Don't Click Me!", OnClicked: func() { panic("Ouch!") }}
PushButton{Text: "Don't Click Me!", OnClicked: func() { panic("Ouch!") }},
},
}.Create(nil)); err != nil {
return err
log.Fatal(err)
}

mw.Show()
mw.Run()
}
Expand Down

0 comments on commit ab9c088

Please sign in to comment.