Skip to content

Instantly share code, notes, and snippets.

@arthurschreiber
Forked from anonymous/gist:5840
Created August 17, 2008 22:42
Show Gist options
  • Save arthurschreiber/5860 to your computer and use it in GitHub Desktop.
Save arthurschreiber/5860 to your computer and use it in GitHub Desktop.
require 'tk'
class BMI
def run
@window.mainloop
end
def initialize
@window = TkRoot.new(:title => 'BMI', 'height' => 304, 'width' => 258) do
root.geometry('+40+50')
end
TkLabel.new do
text 'Geben sie bitte hier ihr Gewicht ein:'
place 'x' => 50, 'y' => 10
end
@gewicht = TkText.new('height' => 2, 'width' => 9 ) do
place 'x' => 50, 'y' => 40
end
TkLabel.new do
text 'Geben sie bitte hier ihre Groese ein:'
place 'x' => 50, 'y' => 80
end
@groesse = TkText.new('height' => 2, 'width' => 9 ) do
place 'x' => 50, 'y' => 120
end
TkLabel.new do
text 'Dies ist ihr BMI'
place 'x' => 50, 'y' => 160
end
@ergebnis = TkText.new do
place 'x' => 50, 'y' => 200
end
@button = TkButton.new('height' => 2, 'width' => 10) do
text "BMI Berechnen"
place 'x' => 50, 'y' => 150
end
@button.bind('ButtonRelease-1') do
gewicht = @gewicht.text.to_f
groesse = @groesse.text.to_f
@ergebnis.text = "#{gewicht / (groesse **2)}"
end
end
end
lol = BMI.new
lol.run
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment