Skip to content

Instantly share code, notes, and snippets.

Created August 17, 2008 22:03
Show Gist options
  • Save anonymous/5840 to your computer and use it in GitHub Desktop.
Save anonymous/5840 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
@lol = 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
@lol1 = 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
TkText.new do
place 'x' => 50, 'y' => 200
text "#{hallo.to_i / (hallo1.to_f **2)}"
end
button
end
def button
TkButton.new('height' => 2, 'width' => 10) do
text "BMI Berechnen"
place 'x' => 50, 'y' => 150
end
button.bind('ButtonRelease-1') do
hallo = @lol.text
hallo1 = @lol1.text
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