Search code examples
scriptingcygwingui-designer

What language would people recommend as simple GUI that can be used as input to a script runing on Cygwin?


I need a simple window with three input boxes and three labels (login name, password, and server node) and a button to execute the script. I do not want any third party programs that need to be installed on Windows. If it can be installed on Cygwin that would be great.


Solution

  • You might want to look at Tcl/Tk and the notion of starkits and starpacks. With the latter you can create a single-file windows executable so your end users wouldn't have to install anything other than this program.

    By using tk 8.5 you'll also get the benefit of native windows widgets so the GUI can look very professional.

    The code would look something like this:

    package require Tk 8.5
    proc main {} {
        ttk::frame .f
        ttk::label .l1 -text "Username:" -anchor e
        ttk::label .l2 -text "Password:" -anchor e
        ttk::label .l3 -text "Server:" -anchor e
        ttk::entry .e1 -textvariable data(username)
        ttk::entry .e2 -textvariable data(password) -show *
        ttk::entry .e3 -textvariable data(server)
        ttk::button .b1 -text "Submit" -command run
    
        grid .l1 .e1 -sticky ew -in .f -padx 4
        grid .l2 .e2 -sticky ew -in .f -padx 4
        grid .l3 .e3 -sticky ew -in .f -padx 4
        grid x   .b1 -sticky e -row 4 -in .f -padx 4 -pady 4
    
        grid rowconfigure .f 3 -weight 1
        grid columnconfigure .f 1 -weight 1
    
        pack .f -side top -fill both -expand true
    
        focus .e1
    }
    
    proc run {} {
        global data
        puts "username: $data(username)"
        puts "password: $data(password)"
        puts "server: $data(server)"
    }
    
    main