lxn / walk

A Windows GUI toolkit for the Go Programming Language
Other
6.8k stars 885 forks source link

log fill to textedit, after a while, the textedit not to work #648

Closed thejosan closed 4 years ago

thejosan commented 4 years ago

var OutTE walk.TextEdit var Username,Password walk.LineEdit var Lab1 *walk.Label var CmdReader io.Reader

func main() { session, err := util.Connect("root", "123456", "192.168.2.137", 22) MainWindow{ Icon: Bind("'/img/logo.ico'"), Title: "K8S 沙雕日志监视器", MinSize: Size{400, 200}, Size: Size{1200, 800}, Layout: VBox{}, Children: []Widget{ Composite{ Layout: VBox{}, Children: []Widget{ //VSpacer{Size:100}, GroupBox{ StretchFactor: 1300, //Title: "登陆验证", Layout: Grid{Columns: 6}, Children: []Widget{ Label{ AssignTo: &Lab1, Text: "用户名:", }, LineEdit{ AssignTo: &Username, //MinSize: Size{60,30}, }, Label{ Text: "密码:", }, LineEdit{ AssignTo: &Password, //MinSize: Size{60,30}, PasswordMode: true, }, PushButton{ //MaxSize: Size{150, 25}, Text: "确认登陆", OnClicked: func() { //postValue := url.Values{"password":{password.Text()},"username":{username.Text()}} //Apirequest := util.Api_Post("http://192.168.1.197:8080/api/login",postValue) //outTE.AppendText(Apirequest+"\n") //session.Close() go func() {

                                    if err != nil {
                                        log.Fatal(err)
                                    }
                                    defer session.Close()
                                    session.Run("kubectl exec -it tomcat-vehicle-28080-f9c75c455-kmq5k -- tail -f logs/catalina.out")
                                    session.Wait()
                                }()
                                CmdReader, err = session.StdoutPipe()
                                if err != nil {
                                    log.Fatal(err)
                                }
                                reader := bufio.NewReader(CmdReader)

                                go func() {
                                    for {
                                        line, err2 := reader.ReadString('\n')
                                        if err2 != nil || io.EOF == err2 {
                                            break
                                        }
                                        OutTE.AppendText(line)
                                    }
                                }()
                            },
                        },
                        HSpacer{Size:600},
                    },
                },
                TextEdit{
                    AssignTo: &OutTE,
                    ReadOnly: true,
                    VScroll: true,
                },
            },
        },
    },
}.Run()

} 111

thejosan commented 4 years ago

i know how to do it,thanks