Created
October 17, 2015 09:46
-
-
Save mukolweke/c83af3e134a71a61266f to your computer and use it in GitHub Desktop.
Ruby Login with TK
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, "[email protected] | |
end | |
end | |
LogIn.new | |
Tk.mainloop |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment