=begin
https://www.tutorialspoint.com/ruby/ruby_tk_guide.htm
http://www.es.w3eacademy.com/ruby/ruby_tk_place.htm
=end
require 'tk'
top = TkRoot.new {title "Etiqueta, entrada de texto y botón salir"}
top.geometry('640x480')
top.minsize(400,400)
#code to add a label widget
lb0=TkLabel.new(top){
text 'Esto es una prueba de colocación de etiquetas, campos y botones en una ventana'
background "yellow"
foreground "blue"
place('relx'=>0.0,'rely'=>0.0)
}
lb1=TkLabel.new(top){
text '0123456789 '
background "yellow"
foreground "blue"
place('relx'=>0.08,'rely'=>0.08)
}
lb2=TkLabel.new(top){
text 'Aquà puedes escribir:'
background "green"
foreground "black"
place('relx'=>0.05,'rely'=>0.15)
}
text = TkText.new(top) do
width 60
height 15
borderwidth 1
font TkFont.new('times 12 bold')
place('relx'=>0.1,'rely'=>0.2)
end
vbar = TkScrollbar.new {
orient 'vert'
pack(:side => :right, :fill => :y)
}
text.yscrollbar(vbar)
text.insert 'end', "Hola!\n\ntext widget example"
=begin
relx y rely son las posiciones relativas respecto de la ventana
en %, por eso es un número decimal
relx y en rely el decimal es la posición x ó y respe
=end
#code to add a entry widget
e1 = TkEntry.new(top){
background "red"
foreground "blue"
place('relx'=>0.2,'rely'=>0.08)
}
sal = TkButton.new(top) {
text 'Salir'
command 'exit'
place('relx'=>0.9,'rely'=>0.9)
}
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 - TK6
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