Class: Bioroebe::GUI::Gtk::ThreeToOne
- Inherits:
-
Gtk::Box
- Object
- Gtk::Box
- Bioroebe::GUI::Gtk::ThreeToOne
show all
- Includes:
- ThreeToOneModule, Gtk::BaseModule
- Defined in:
- lib/bioroebe/gui/gtk3/three_to_one/three_to_one.rb
Overview
Bioroebe::GUI::Gtk::ThreeToOne
Constant Summary
collapse
- NAMESPACE =
inspect
- WIDTH =
'30% or minimum 300px'
- HEIGHT =
'25%'
- USE_THIS_FONT =
:dejavu_condensed_20
- SMALLER_FONT =
:dejavu_condensed_14
Bioroebe::GUI::Gtk::ThreeToOneModule::TITLE
Class Method Summary
collapse
-
.run(i = ARGV) ⇒ Object
# === Bioroebe::GUI::Gtk::ThreeToOne.run ========================================================================= #.
Instance Method Summary
collapse
Constructor Details
#initialize(commandline_arguments = ARGV, run_already = true) ⇒ ThreeToOne
59
60
61
62
63
64
65
66
67
68
69
|
# File 'lib/bioroebe/gui/gtk3/three_to_one/three_to_one.rb', line 59
def initialize(
commandline_arguments = ARGV,
run_already = true
)
super(:vertical)
reset
set_commandline_arguments(
commandline_arguments
)
run if run_already
end
|
Class Method Details
.run(i = ARGV) ⇒ Object
#
Bioroebe::GUI::Gtk::ThreeToOne.run
#
217
218
219
220
221
222
223
224
225
226
|
# File 'lib/bioroebe/gui/gtk3/three_to_one/three_to_one.rb', line 217
def self.run(
i = ARGV
)
require 'gtk_paradise/run'
_ = ::Bioroebe::GUI::Gtk::ThreeToOne.new(i)
r = ::Gtk.run
r << _
r.automatic_size_then_automatic_title
r.top_left_then_run
end
|
Instance Method Details
#border_size? ⇒ Boolean
104
105
106
|
# File 'lib/bioroebe/gui/gtk3/three_to_one/three_to_one.rb', line 104
def border_size?
4
end
|
#connect_skeleton ⇒ Object
#
connect_skeleton (connect tag)
#
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
|
# File 'lib/bioroebe/gui/gtk3/three_to_one/three_to_one.rb', line 194
def connect_skeleton
abort_on_exception
_ = text('Input sequence:')
_.hint = 'Input your three-letter-aminoacid sequence below.'
minimal(_, 2)
@entry1.on_enter_key_pressed {
do_trigger_the_conversion(@entry1.text?)
}
minimal(@entry1, 4)
minimal(@entry2, 4)
hbox = gtk_hbox
hbox.maximal(
gtk_button_box(@button_convert) { :spread }, 2
)
hbox.minimal(
return_the_checkbox_widget, 2
)
minimal(hbox, 4)
end
|
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
|
# File 'lib/bioroebe/gui/gtk3/three_to_one/three_to_one.rb', line 163
def create_button
@button_convert = gtk_button('_Convert')
@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.on_clicked {
do_trigger_the_conversion
}
@button_convert.clear_background
@button_convert.on_hover(:lightblue)
@button_convert.set_name('button1')
end
|
#create_entries ⇒ Object
#
create_entries (entries tag)
#
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
|
# File 'lib/bioroebe/gui/gtk3/three_to_one/three_to_one.rb', line 253
def create_entries
@entry1 = gtk_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 = gtk_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_skeleton ⇒ Object
#
create_skeleton (create tag)
#
155
156
157
158
|
# File 'lib/bioroebe/gui/gtk3/three_to_one/three_to_one.rb', line 155
def create_skeleton
create_entries
create_button
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.
#
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
|
# File 'lib/bioroebe/gui/gtk3/three_to_one/three_to_one.rb', line 234
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
88
89
90
91
92
|
# File 'lib/bioroebe/gui/gtk3/three_to_one/three_to_one.rb', line 88
def handle_CSS_rules
use_gtk_paradise_project_css_file
append_project_css_file
apply_the_CSS_rules
end
|
#padding? ⇒ Boolean
97
98
99
|
# File 'lib/bioroebe/gui/gtk3/three_to_one/three_to_one.rb', line 97
def padding?
8
end
|
#reset ⇒ Object
74
75
76
77
78
79
80
81
82
83
|
# File 'lib/bioroebe/gui/gtk3/three_to_one/three_to_one.rb', line 74
def reset
reset_the_internal_variables
@configuration = [true, __dir__, NAMESPACE]
title_width_height_font(TITLE, WIDTH, HEIGHT, USE_THIS_FONT)
handle_CSS_rules
infer_the_size_automatically
end
|
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
|
# File 'lib/bioroebe/gui/gtk3/three_to_one/three_to_one.rb', line 118
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)
@checkbox1 = gtk_check_box
@checkbox1.is_active
grid.right(@checkbox1)
grid.new_row
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)
@checkbox2 = gtk_check_box
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
187
188
189
|
# File 'lib/bioroebe/gui/gtk3/three_to_one/three_to_one.rb', line 187
def run
create_skeleton_then_connect_skeleton
end
|
#smaller_font? ⇒ Boolean
111
112
113
|
# File 'lib/bioroebe/gui/gtk3/three_to_one/three_to_one.rb', line 111
def smaller_font?
SMALLER_FONT
end
|