Class: Bioroebe::GUI::UniversalWidgets::ThreeToOne
- Inherits:
-
UniversalWidgets::Base
- Object
- UniversalWidgets::Base
- Bioroebe::GUI::UniversalWidgets::ThreeToOne
show all
- Includes:
- CommandlineArguments
- Defined in:
- lib/bioroebe/gui/universal_widgets/three_to_one/three_to_one.rb
Overview
Constant Summary
collapse
- TITLE =
'Three aminoacids to one aminoacid converter'
- WIDTH =
'45% or minimum 660px'
- HEIGHT =
'30% or minimum 280px'
- USE_THIS_FONT =
:dejavu_condensed_20
- LARGER_FONT =
:dejavu_condensed_24
- SMALLER_FONT =
#
SMALLER_FONT
This one should be matched onto the larger font defined above.
#
:dejavu_condensed_14
- SMALLEST_FONT =
:dejavu_condensed_12
- HASH_DESIGNATED_KEY_COMBINATIONS =
#
HASH_DESIGNATED_KEY_COMBINATIONS
#
{
'strg+s': 'save_the_buffer',
'alt+y': 'activate_the_third_textview'
}
ColoursForBase::ARRAY_HTML_COLOURS_IN_USE
Class Method Summary
collapse
Instance Method Summary
collapse
#commandline_arguments?, #commandline_arguments_that_are_files?, #e, #first?, #first_non_hyphen_argument?, #remove_hyphens_from_the_commandline_arguments, #return_commandline_arguments_as_string, #return_commandline_arguments_that_are_not_files, #return_entries_without_two_leading_hyphens, #select_commandline_arguments, #select_entries_starting_with_two_hyphens, #set_commandline_arguments
#colourize_this_aminoacid_sequence_for_the_commandline, #colourize_this_nucleotide_sequence, #disable_colours, #ecomment, #efancy, #egold, #enable_colours, #eorange, #eparse, #erev, #red, #remove_trailing_escape_part, #return_colour_for_nucleotides, #rev, #sdir, #set_will_we_use_colours, #sfancy, #sfile, #simp, #swarn, #use_colours?, #use_colours_within_the_bioroebe_namespace?
Constructor Details
#initialize(commandline_arguments = nil, run_already = true) ⇒ ThreeToOne
81
82
83
84
85
86
87
88
89
90
91
|
# File 'lib/bioroebe/gui/universal_widgets/three_to_one/three_to_one.rb', line 81
def initialize(
commandline_arguments = nil,
run_already = true
)
determine_the_GUI_to_be_used(commandline_arguments)
reset
set_commandline_arguments(
commandline_arguments
)
run if run_already
end
|
Class Method Details
.[](i = ARGV) ⇒ Object
322
323
324
|
# File 'lib/bioroebe/gui/universal_widgets/three_to_one/three_to_one.rb', line 322
def self.[](i = ARGV)
new(i)
end
|
.run(i = ARGV) ⇒ Object
#
Bioroebe::GUI::Gtk::ThreeToOne.run
#
329
330
331
332
333
334
335
|
# File 'lib/bioroebe/gui/universal_widgets/three_to_one/three_to_one.rb', line 329
def self.run(
i = ARGV
)
::Gtk.gtk_runner_factory(
::Bioroebe::GUI::Gtk::ThreeToOne.new(i)
)
end
|
Instance Method Details
#border_size? ⇒ Boolean
132
133
134
|
# File 'lib/bioroebe/gui/universal_widgets/three_to_one/three_to_one.rb', line 132
def border_size?
4
end
|
189
190
191
|
# File 'lib/bioroebe/gui/universal_widgets/three_to_one/three_to_one.rb', line 189
def button_convert?
@button_convert
end
|
#connect_the_skeleton ⇒ Object
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
|
# File 'lib/bioroebe/gui/universal_widgets/three_to_one/three_to_one.rb', line 282
def connect_the_skeleton
abort_on_exception
vbox = create_vbox
_ = text('Input sequence:')
_.hint = 'Input your three-letter-aminoacid sequence below.'
vbox.minimal(_, 2)
@entry1.on_enter_key_pressed {
do_trigger_the_conversion(@entry1.text?)
}
vbox.minimal(@entry1, 4)
vbox.minimal(@entry2, 4)
hbox = create_hbox
if use_libui?
hbox.maximal(button_convert?, 2)
else
hbox.maximal(
button_box(button_convert?) { :spread }, 2
)
end
hbox.minimal(return_the_checkbox_widget, 2)
vbox.minimal(hbox, 4)
vbox.set_size_request(width?, height?)
window = runner_widget(nil, width?, height?, title?)
window << vbox
::UniversalWidgets.set_main_window(window)
upon_delete_event_quit_the_application
window.use_this_font = larger_font?
window.show_all
window.set_size_request(width?, height?)
window.set_default_size(width?, height?)
window.top_left
run_main
end
|
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
|
# File 'lib/bioroebe/gui/universal_widgets/three_to_one/three_to_one.rb', line 196
def create_the_buttons
@button_convert = bold_button('_Convert', self, :use_mnemonics) {
:do_trigger_the_conversion
}
@button_convert.hint =
'Click this button in order to <b>convert the '\
'three amino acids code to a one amino acid '\
'letter code</b>. This is the <b>default</b>.'\
'If you need to convert from the one-letter code '\
'to the three-letter code then you need to use the '\
'check button on the right side.'
@button_convert.disallow_resizing
@button_convert.set_size_request(350, 40)
@button_convert.clear_background
@button_convert.on_hover(:lightblue)
@button_convert.set_name('button1')
end
|
#create_the_checkboxes ⇒ Object
#
create_the_checkboxes
#
155
156
157
158
159
|
# File 'lib/bioroebe/gui/universal_widgets/three_to_one/three_to_one.rb', line 155
def create_the_checkboxes
@checkbox1 = create_checkbox
@checkbox1.is_active
@checkbox2 = create_checkbox
end
|
#create_the_entries ⇒ Object
#
create_the_entries (entries tag)
#
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
|
# File 'lib/bioroebe/gui/universal_widgets/three_to_one/three_to_one.rb', line 164
def create_the_entries
@entry1 = create_entry
@entry1.hint = 'This entry should contain the three-letter code '\
'for the input sequence, such as "Asp-Lys-Gln", without '\
'the quotes. Use the <b>enter key</b> to trigger the '\
'conversion, or use the button below.'
@entry1.on_enter { do_the_conversion }
@entry2 = create_entry
@entry2.the_user_may_not_modify_this_entry
@entry2.hint = 'This input field will display the result of the '\
'conversion. The user can not modify it.'
@entry2.css_class('tomato')
@entry2.make_bold
end
|
#create_the_skeleton ⇒ Object
#
create_the_skeleton (create tag, skeleton tag)
#
146
147
148
149
150
|
# File 'lib/bioroebe/gui/universal_widgets/three_to_one/three_to_one.rb', line 146
def create_the_skeleton
create_the_checkboxes
create_the_entries
create_the_buttons
end
|
#do_trigger_the_conversion(i = @entry1.text?, checkbox1 = @checkbox1) ⇒ Object
Also known as:
do_the_conversion
#
do_trigger_the_conversion (conversion tag)
This method is the one that will convert from the three-letter to the one-letter and vice versa.
#
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
|
# File 'lib/bioroebe/gui/universal_widgets/three_to_one/three_to_one.rb', line 223
def do_trigger_the_conversion(
i = @entry1.text?,
checkbox1 = @checkbox1
)
i = i.to_s.dup.delete(' ')
if checkbox1.active?
new_result = Bioroebe.three_to_one(i).to_s
else
new_result = Bioroebe.one_to_three(i).to_s
end
if new_result and !new_result.empty?
@entry2.set_text(new_result)
@entry2.make_bold
end
end
|
#handle_CSS_rules ⇒ Object
Also known as:
handle_CSS
#
handle_CSS_rules (CSS tag)
#
116
117
118
119
120
|
# File 'lib/bioroebe/gui/universal_widgets/three_to_one/three_to_one.rb', line 116
def handle_CSS_rules
use_gtk_paradise_project_css_file
append_project_css_file
apply_the_CSS_rules
end
|
#padding? ⇒ Boolean
125
126
127
|
# File 'lib/bioroebe/gui/universal_widgets/three_to_one/three_to_one.rb', line 125
def padding?
8
end
|
#reset ⇒ Object
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
|
# File 'lib/bioroebe/gui/universal_widgets/three_to_one/three_to_one.rb', line 96
def reset
super() if respond_to?(:super)
reset_the_internal_variables
reset_the_base_module infer_the_namespace
@configuration = [true, __dir__, namespace?]
@internal_hash[:larger_font] = LARGER_FONT
title_width_height_font(TITLE, WIDTH, HEIGHT, LARGER_FONT)
handle_CSS if use_gtk3?
end
|
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
|
# File 'lib/bioroebe/gui/universal_widgets/three_to_one/three_to_one.rb', line 242
def return_the_checkbox_widget
smaller_font = smaller_font?
grid = default_grid
text1 = text('3-to-1 conversion')
text1.use_this_font(smaller_font)
text1.hint = 'Convert the three letter code to the one letter code.'
grid.left(text1)
grid.right(@checkbox1)
text2 = text('1-to-3 conversion')
text2.use_this_font(smaller_font)
text2.hint = 'Convert the one letter code to the three letter code.'
grid.left(text2)
grid.right(@checkbox2)
@checkbox1.on_toggled {
if @checkbox1.active? == false
@checkbox2.is_now_active
else
@checkbox2.is_now_inactive
end
}
@checkbox2.on_toggled {
if @checkbox2.active? == false
@checkbox1.is_now_active
else
@checkbox1.is_now_inactive
end
}
return grid
end
|
#run ⇒ Object
275
276
277
|
# File 'lib/bioroebe/gui/universal_widgets/three_to_one/three_to_one.rb', line 275
def run
run_super
end
|
#smaller_font? ⇒ Boolean
139
140
141
|
# File 'lib/bioroebe/gui/universal_widgets/three_to_one/three_to_one.rb', line 139
def smaller_font?
SMALLER_FONT
end
|