Guest User

Untitled

a guest
Aug 17th, 2019
61
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package main
  2.  
  3. import (
  4. "log"
  5. "strconv"
  6. "time"
  7. )
  8.  
  9. import (
  10. "github.com/lxn/walk"
  11. . "github.com/lxn/walk/declarative"
  12. "strings"
  13. )
  14.  
  15. type MyMainWindow struct {
  16. *walk.MainWindow
  17.  
  18. outTE *walk.TextEdit
  19. inTE *walk.TextEdit
  20. }
  21.  
  22. type Structure struct {
  23. Index int
  24. }
  25.  
  26. func main() {
  27. mw := new(MyMainWindow)
  28.  
  29. if _, err := (MainWindow{
  30. AssignTo: &mw.MainWindow,
  31. Title: "SCREAMO",
  32. MinSize: Size{600, 400},
  33. Layout: VBox{},
  34. Children: []Widget{
  35. HSplitter{
  36. Children: []Widget{
  37. TextEdit{AssignTo: &mw.inTE},
  38. TextEdit{AssignTo: &mw.outTE, ReadOnly: true},
  39. },
  40. },
  41. PushButton{
  42. Text: "SCREAM",
  43. OnClicked: func() {
  44. mw.mainProcess()
  45. },
  46. },
  47. },
  48. }.Run()); err != nil {
  49. log.Fatal(err)
  50. }
  51. }
  52.  
  53. func delaySecond(n time.Duration) {
  54. time.Sleep(n * time.Second)
  55. }
  56.  
  57. func (mw *MyMainWindow) mainProcess() {
  58. tmp := make([]Structure, 200)
  59. for i, item := range tmp {
  60. item.Index = i
  61. delaySecond(15)
  62. mw.outTE.SetText(strconv.Itoa(i) +" " + strings.ToUpper(mw.inTE.Text()))
  63. }
  64. }
RAW Paste Data