Description:
Hetch is Graphical User interface to fetch a Regex pattern from a text file and display the result in a text window in the same GUI.
The Gui is called by a simpified call to the Tcl/Tk Syntax built in a gui class in a separate "gui.rb"file.
The "gui.rb"demonstrates the way to call various widgets including a Help menu on the Menubar which includes the instruction on use of "gui.rb". The Help text is included in a separate "guide.rb" file.
Classes:
- class Gui
- class H # Hetch file to fetch string matching a pattern
- class Guide # to "view" the help instructions
Files:
- gui.rb
- hetch.rb # contains a method to run the Gui from irb prompt
- guide.rb
- hetch_tk # file containing the main script to call GUI
USAGE:
At the irb command prompt type:
require 'hetch' ; H.run
Type the name of the text file in the first entry field and the Regex pattern in the second entry field. You can enter the full path of the file, e.g. c:\test without extension.
Using the 'gui.rb' file:
the Gui class may be used for building other Gui's by calling the class name followed by the method with its parameters. x, y are the row number (x) and column number (y) in grid geometry
- Gui.root: no parameters
- Gui.entry($var1, x, y) : $var1 is the variable that contains entry text. Gui.entry($var2, x, y) : $var2 is the variable that contains entry
- Gui.textfield(h, w, c1, c2, x, y) : The parameters are h=height, w=width, c1=background color, c2=foreground color
- Gui.button(tx1, m, x, y) : tx1= text on button, m= method triggered by button.
- Gui.label(tx2, x, y): tx2 = text on label
- Gui.show :Tk.mainloop
Sample Method:
The method should be written in the active script before the end Gui.show command. e.g. This simple method just add the two variables and get result into the text window.
def m
z = $var1+ $var2
$textfield.delete(1.0, 'end')
$textfield.insert(1.0, '#{z}')
end
Sample Script:
------------------
require_relative 'gui'
Gui.root
Gui.menu
Gui.label("Enter Number", 0, 0)
Gui.entry($var1, 0, 1)
Gui.label("Enter Number", 1, 0)
Gui.entry($var2, 1, 1)
Gui.textfield(15, 1, "black", "white", 2, 1)
Gui.button("OK", "m" , 2, 0)
def m
$z = $var1 + $var2
$textfield.insert('end', "#$z")
end
Gui.show