Class: Bioroebe::GUI::Tk::LevenstheinDistance
- Inherits:
-
Tk::Base
- Object
- Tk::Base
- Bioroebe::GUI::Tk::LevenstheinDistance
- Includes:
- Tk
- Defined in:
- lib/bioroebe/gui/tk/levensthein_distance/levensthein_distance.rb
Overview
Bioroebe::GUI::Tk::LevenstheinDistance
Constant Summary collapse
- NAMESPACE =
#
NAMESPACE
#
inspect
- TITLE =
#
TITLE
#
'Levensthein distance'
- MAIN_FONT =
#
MAIN_FONT
#
TkFont.new(family: 'Helvetica', size: 20, weight: 'bold')
- SMALLER_FONT =
#
SMALLER_FONT
#
TkFont.new(family: 'Helvetica', size: 16, weight: 'bold')
- USE_THIS_BACKGROUND_COLOUR =
#
USE_THIS_BACKGROUND_COLOUR
#
'mintcream'
- MONOSPACED_FONT =
#
MONOSPACED_FONT
#
TkFont.new(family: 'Hack', size: 22, weight: 'bold')
- PADDING_TO_USE =
#
PADDING_TO_USE
#
{ padx: 10, pady: 10 }
Class Method Summary collapse
-
.[](i = '') ⇒ Object
# === Bioroebe::GUI::Tk::LevenstheinDistance[] ========================================================================= #.
Instance Method Summary collapse
-
#compare_the_two_sequences ⇒ Object
(also: #do_compare, #do_calculate_the_differences)
# === compare_the_two_sequences.
-
#initialize(commandline_arguments = nil, run_already = true) ⇒ LevenstheinDistance
constructor
# === initialize ========================================================================= #.
-
#reset ⇒ Object
# === reset (reset tag) ========================================================================= #.
-
#run ⇒ Object
# === run (run tag) ========================================================================= #.
-
#seq1? ⇒ Boolean
# === seq1? ========================================================================= #.
-
#seq2? ⇒ Boolean
# === seq2? ========================================================================= #.
Constructor Details
#initialize(commandline_arguments = nil, run_already = true) ⇒ LevenstheinDistance
#
initialize
#
74 75 76 77 78 79 80 81 82 83 |
# File 'lib/bioroebe/gui/tk/levensthein_distance/levensthein_distance.rb', line 74 def initialize( commandline_arguments = nil, run_already = true ) reset set_commandline_arguments( commandline_arguments ) run if run_already end |
Class Method Details
.[](i = '') ⇒ Object
#
Bioroebe::GUI::Tk::LevenstheinDistance[]
#
235 236 237 |
# File 'lib/bioroebe/gui/tk/levensthein_distance/levensthein_distance.rb', line 235 def self.[](i = '') new(i) end |
Instance Method Details
#compare_the_two_sequences ⇒ Object Also known as: do_compare, do_calculate_the_differences
#
compare_the_two_sequences
This is the method that will compare the two sequences.
#
225 226 227 228 229 |
# File 'lib/bioroebe/gui/tk/levensthein_distance/levensthein_distance.rb', line 225 def compare_the_two_sequences levensthein_distance_object = ::Bioroebe::LevenstheinDistance.new("#{seq1?} #{seq2?}") { :be_quiet } _ = levensthein_distance_object.n_differences?.to_s @entry_n_differences.insert(0, _) end |
#reset ⇒ Object
#
reset (reset tag)
#
88 89 90 |
# File 'lib/bioroebe/gui/tk/levensthein_distance/levensthein_distance.rb', line 88 def reset super() end |
#run ⇒ Object
#
run (run tag)
#
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 |
# File 'lib/bioroebe/gui/tk/levensthein_distance/levensthein_distance.rb', line 95 def run root = TkRoot.new { title TITLE background USE_THIS_BACKGROUND_COLOUR } root.geometry('700x400+0+0') root.minsize(400, 200) # ======================================================================= # # Add a frame for the whole application. # ======================================================================= # outermost_frame = TkFrame.new(root) { background USE_THIS_BACKGROUND_COLOUR } label = ::TkLabel.new(outermost_frame) { font(MAIN_FONT) text TITLE pack(side: 'top', padx: 10, pady: 10) background USE_THIS_BACKGROUND_COLOUR } ::TkLabel.new(outermost_frame) { font SMALLER_FONT text "The Levensthein distance - a number - measures "\ "the number of\npositions at which two strings "\ "of equal length are different." pack(side: 'top', padx: 5, pady: 5) background USE_THIS_BACKGROUND_COLOUR } @text1 = TkVariable.new(::Bioroebe::GUI::Gtk::LevenstheinDistanceModule::DEFAULT_TEXT_FOR_ENTRY1) # ======================================================================= # # === @entry1 # ======================================================================= # @entry1 = TkEntry.new(outermost_frame, textvariable: @text1) { font(MONOSPACED_FONT) background 'lightsteelblue' } @entry1.pack(outermost_frame) @entry1.configure(width: 35) @text2 = TkVariable.new(::Bioroebe::GUI::Gtk::LevenstheinDistanceModule::DEFAULT_TEXT_FOR_ENTRY2) # ======================================================================= # # === @entry2 # ======================================================================= # @entry2 = TkEntry.new(outermost_frame, textvariable: @text2) { font(MONOSPACED_FONT) background 'lightsteelblue' } @entry2.pack(outermost_frame) @entry2.configure(width: 35) callback_do_compare = proc { do_compare } # ======================================================================= # # === The convert-button with its special frame # ======================================================================= # = TkFrame.new( outermost_frame, highlightbackground: 'black', highlightthickness: 2, bd: 0, borderwidth: 2 ) .pack = TkButton.new() { text 'Compare the two sequences' font(MAIN_FONT) relief :flat command callback_do_compare pack borderwidth 5 } @text3 = tk_variable # ======================================================================= # # === @entry_n_differences # # This is the third (and last) entry. # ======================================================================= # @entry_n_differences = TkEntry.new(outermost_frame, textvariable: @text3) { font(MAIN_FONT) background 'yellow' } @entry_n_differences.pack(outermost_frame) @entry_n_differences.configure(width: 25) # ======================================================================= # # === The quit-button and its special frame # ======================================================================= # = TkFrame.new( outermost_frame, highlightbackground: 'black', highlightthickness: 2, bd: 0, borderwidth: 2 ) .pack = ::TkButton.new(, text: 'Quit') { font(MAIN_FONT) relief :flat command proc { exit } pack borderwidth 5 } ::Tk.run end |
#seq1? ⇒ Boolean
#
seq1?
#
216 217 218 |
# File 'lib/bioroebe/gui/tk/levensthein_distance/levensthein_distance.rb', line 216 def seq1? @text1 end |
#seq2? ⇒ Boolean
#
seq2?
#
209 210 211 |
# File 'lib/bioroebe/gui/tk/levensthein_distance/levensthein_distance.rb', line 209 def seq2? @text2 end |