package main import ( "fmt" "os" "github.com/gotk3/gotk3/gtk" ) type Applicant struct { FirstName string LastName string Age int Sex Sex Education []Education } type Education struct { SchoolName string YearOfPassing int PassPercentage float32 } type Sex int var ui *gtk.Builder const ( Male Sex = 1 Female = 2 Other = 3 ) /* func SaveToJson(a *Applicant) { b, err := json.Marshal(a) if err != nil { fmt.Println(err.Error()) os.Exit(2) } err = ioutil.WriteFile("test.json", b, 0644) if err != nil { fmt.Println(err.Error()) os.Exit(3) } } */ func getBasicDetails() (*Applicant, error) { obj, err := ui.GetObject("FirstName") if err != nil { return nil, err } fsname, ok := obj.(*gtk.Entry) if !ok { return nil, err } firstname, err := fsname.GetText() if err != nil { return nil, err } obj, err = ui.GetObject("LastName") if err != nil { return nil, err } lsname, ok := obj.(*gtk.Entry) if !ok { return nil, err } lastname, err := lsname.GetText() if err != nil { return nil, err } var applicant = new(Applicant) applicant.FirstName = firstname applicant.LastName = lastname return applicant, nil } func getWindow() (*gtk.Window, error) { obj, err := ui.GetObject("MainWindow") if err != nil { fmt.Println(err.Error()) return nil, err } wnd, ok := obj.(*gtk.Window) if !ok { return nil, err } return wnd, nil } func getSaveButton() (*gtk.Button, error) { btnobj, err := ui.GetObject("SaveButton") if err != nil { fmt.Println(err.Error()) return nil, err } btn, ok := btnobj.(*gtk.Button) if !ok { return nil, err } return btn, nil } func LoadMain() { gtk.Init(nil) var err error ui, err = gtk.BuilderNewFromFile("resumebuilder.glade") if err != nil { fmt.Println(err.Error()) os.Exit(1) } wnd, err := getWindow() if err != nil { os.Exit(1) } btn, err := getSaveButton() if err != nil { os.Exit(1) } btn.Connect("clicked", SaveButtonClicked) wnd.SetTitle("Resume Builder") wnd.ShowAll() wnd.Connect("destroy", func() { gtk.MainQuit() }) gtk.Main() } func SaveButtonClicked() { a, err := getBasicDetails() if err != nil { fmt.Println(err.Error()) os.Exit(1) } fmt.Println(*a) } func main() { LoadMain() }