Advertisement
cardel

Untitled

Sep 24th, 2017
627
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 1.77 KB | None | 0 0
  1. # Autor: Carlos Andres Delgado <carlos.andres.delgado@correounivalle.edu.co>
  2. # Descripción: Primera interfaz gráfica.
  3. # Fecha: 24 de Septiembre de 2017
  4.  
  5. #Nota importante: No se puede trabajar con tildes ni ñ debido a problemas de codificación de la librería
  6.  
  7. require 'Qt'
  8.  
  9. class QtApp < Qt::MainWindow
  10.  
  11.     #Declaramos los conectores
  12.     slots 'accionBotonPresioname()'
  13.    
  14.     def initialize
  15.         super
  16.        
  17.         setWindowTitle "Venta prueba"
  18.        
  19.         interfaz
  20.        
  21.         resize 250, 450
  22.         move 300, 300
  23.  
  24.         show
  25.     end
  26.    
  27.     def interfaz    
  28.         #Creamos el boton
  29.         botonQuitar = Qt::PushButton.new 'Salir', self
  30.         #Le damos un tamaño
  31.         botonQuitar.resize 80, 30
  32.         #Lo colocamos en la interfaz (pixeles)
  33.         botonQuitar.move 50, 50
  34.        
  35.         #Lo conectamos a alguna función quit() ya existe por defecto y ciera la ventana
  36.         connect botonQuitar, SIGNAL('clicked()'), $qApp, SLOT('quit()')
  37.        
  38.         botonPresioname = Qt::PushButton.new "Presioname", self
  39.         botonPresioname.resize 80, 30
  40.         botonPresioname.move 150, 50
  41.         connect botonPresioname, SIGNAL('clicked()'), SLOT('accionBotonPresioname()')
  42.        
  43.         #Creamos un mensaje
  44.         $mensajeHola = Qt::Label.new "Soy un mensaje", self
  45.         $mensajeHola.move 50, 100  
  46.        
  47.        
  48.         $campoTexto = Qt::TextEdit.new self
  49.         #Esto es para no editarlo
  50.         $campoTexto.setEnabled false    
  51.         $campoTexto.resize 200, 150
  52.         $campoTexto.move 28, 200
  53.     end
  54.    
  55.     def accionBotonPresioname()
  56.         mensaje = $campoTexto.plainText
  57.         $campoTexto.plainText=mensaje+"\nTexto de prueba"
  58.     end
  59.    
  60. end
  61.  
  62. app = Qt::Application.new ARGV
  63. QtApp.new
  64. app.exec
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement