-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
48 lines (41 loc) · 1002 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package main
import (
"fmt"
"log"
"math/rand"
"time"
. "github.com/lxn/walk/declarative"
)
func main() {
rand.Seed(time.Now().UnixNano())
var app AppMainWindow
app.Generator = &PasswordGeneratorValidator{}
app.Validator = &PasswordGeneratorValidator{}
if _, err := (MainWindow{
AssignTo: &app.MainWindow,
Title: "Password Generator",
Size: Size{Width: 300, Height: 150},
Layout: VBox{},
Children: []Widget{
LineEdit{
AssignTo: &app.PasswordLineEdit,
ReadOnly: true,
},
PushButton{
Text: "Generate Password",
OnClicked: app.GeneratePasswordClicked,
},
},
}).Run(); err != nil {
log.Fatalf("Error al ejecutar la ventana principal: %v", err)
}
}
func (app *AppMainWindow) GeneratePasswordClicked() {
length := 12
password := app.Generator.Generate(length)
if app.Validator.Validate(password) {
app.PasswordLineEdit.SetText(password)
return
}
fmt.Println("The generated password does not meet the length requirements.")
}