Ruby, Gtk+ and Txt's

Well, I create a script in Ruby that you write a thing in the Text Box and you can read it in a txt file. Look ate the image and scripts:


#!/usr/bin/env ruby
# Escrito por Carlos Junior Félix Rodrigues; Licença: GPL v2
require 'gtk2'
window = Gtk::Window.new
window.title = "Text Box"
button = Gtk::Button.new("Salvar")
text = Gtk::Entry.new
hbox = Gtk::HBox.new(false, 10)
hbox.pack_start(text)
hbox.pack_start(button)
window.add(hbox)
window.signal_connect("destroy"){Gtk.main_quit}
button.signal_connect("clicked"){
arquivo = File.new("arquivo.txt", "a")
arquivo.puts "#{text.text}"
arquivo.close
}
window.show_all
Gtk.main

See you latter

0 comentários: