=begin
https://www.tutorialspoint.com/ruby/ruby_tk_guide.htm
=end
require 'tk'
$mili = TkVariable.new
$pulgadas = TkVariable.new
v = TkRoot.new {title "Conversor"}
v.geometry('640x480')
v.minsize(600,380)
e1 = TkLabel.new(v) {
text 'Conversión de pulgadas a milÃmetros'
font TkFont.new('times 20 bold')
foreground "red"
place('relx'=>0.1,'rely'=>0.1)
}
e2 = TkLabel.new(v) {
text 'Escribe la cantidad de pulgadas: '
font TkFont.new('times 15')
foreground "blue"
place('relx'=>0.1,'rely'=>0.25)
}
e3 = TkEntry.new(v){
textvariable $pulgadas
place('relx'=>0.55,'rely'=>0.25)
}
TkLabel.new(v) {
text ' Equivale a: '
font TkFont.new('times 15')
place('relx'=>0.35,'rely'=>0.50)
}
TkLabel.new(v) {
textvariable $mili
foreground "red"
font TkFont.new('times 20')
place('relx'=>0.51,'rely'=>0.49)
}
TkButton.new(v) {
text 'Calcular'
command {cal}
place('relx'=>0.6,'rely'=>0.38)
}
e4 = TkLabel.new(v) {
text 'Una pulgada equivale a 25,4 mm. '
font TkFont.new('times 15')
place('relx'=>0.3,'rely'=>0.65)
}
TkLabel.new(v) {
text " milÃmetros"
font TkFont.new('times 15')
place('relx'=>0.70,'rely'=>0.50)
}
salir = TkButton.new(v) {
text 'Salir'
command 'exit'
place('relx'=>0.9,'rely'=>0.9)
}
foto = TkPhotoImage.new
foto.file = "buena1.gif"
label = TkLabel.new(v)
label.image = foto
label.place('height' => foto.height, 'width' => foto.width, 'x' => 80, 'y' => 250)
def cal
begin
$mili.value = (25.4*$pulgadas)
rescue
$mili.value = ''
end
end
Tk.mainloop
Ruby es un lenguaje es un universo, donde todo parte de un mismo objeto "main" y desde ahí se diferencian los demás. Es realmente fácil de ir comprendiendo y nos va a permitir ir plasmando la idea que generó la necesidad de hacer ese programa pero muy humanamente.
6 nov 2018
Teoría - TK7
ejercicio TK -1
#!/usr/bin/ruby #https://sandbox.mc.edu/~bennet/ruby/code/tk2_rb.html # Import the library. require 'tk' # Root window. root = TkRo...
-
#!/usr/bin/ruby #https://sandbox.mc.edu/~bennet/ruby/code/tk2_rb.html # Import the library. require 'tk' # Root window. root = TkRo...
-
Primero has de tener instalado Ruby Después, instala la gema ocra así: gem install ocra Como da problemas si tan sólo llamamos a la gema oc...
-
https://sourceforge.net/projects/redsky-ruby/files/RedSky%20Stable%20Setup/RedSky%20Ruby%20v2019.1%20SETUP.exe/download