Skip to content

Instantly share code, notes, and snippets.

@mukolweke
Created October 17, 2015 09:46
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mukolweke/c83af3e134a71a61266f to your computer and use it in GitHub Desktop.
Save mukolweke/c83af3e134a71a61266f to your computer and use it in GitHub Desktop.
Ruby Login with TK
require 'tk'
class LogIn
def initialize
ph ={'padx'=>50,'pady'=>30}
p=proc{hello}
@text =TkVariable.new
root=TkRoot.new{title "Hello, Name"}
top=TkFrame.new(root)
TkLabel.new(top) {text 'name?'; pack(ph)}
@entry=TkEntry.new(top, 'textvariable'=>@text)
@entry.pack(ph)
TkButton.new(top) { text 'Say Hello'; command p; pack ph}
TkButton.new(top) { text 'Exit' ; command {proc exit}; pack ph}
top.pack('fill'=>'both', 'side'=>'top')
end
def hello
@text.value="Hello, "+@text.value
end
end
LogIn.new
Tk.mainloop
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment