Module: ChemistryParadise::GUI::Gtk::CalculateMolecularWeightModule
- Includes:
- Gtk::BaseModule
- Included in:
- CalculateMolecularWeight
- Defined in:
- lib/chemistry_paradise/gui/shared_code/calculate_molecular_weight/calculate_molecular_weight_module.rb
Constant Summary collapse
- NAMESPACE =
#
NAMESPACE
#
inspect
- TITLE =
#
TITLE
#
'Calculate the molecular weight of a compound'
- WIDTH =
#
WIDTH
#
1200
- HEIGHT =
#
HEIGHT
#
500
- USE_THIS_FONT =
#
USE_THIS_FONT
#
:dejavu_condensed_21
Class Method Summary collapse
-
.run(i = ARGV) ⇒ Object
# === ChemistryParadise::GUI::Gtk::CalculateMolecularWeightModule.run ========================================================================= #.
Instance Method Summary collapse
-
#border_size? ⇒ Boolean
# === border_size? ========================================================================= #.
-
#connect_skeleton ⇒ Object
# === connect_skeleton (connect tag) ========================================================================= #.
-
#create_skeleton ⇒ Object
# === create_skeleton (create tag) ========================================================================= #.
-
#create_the_entry ⇒ Object
# === create_the_entry ========================================================================= #.
-
#initialize(commandline_arguments = ARGV, run_already = true) ⇒ Object
# === initialize ========================================================================= #.
-
#padding? ⇒ Boolean
# === padding? ========================================================================= #.
-
#reset ⇒ Object
# === reset (reset tag) ========================================================================= #.
-
#run ⇒ Object
# === run (run tag) ========================================================================= #.
Class Method Details
.run(i = ARGV) ⇒ Object
#
ChemistryParadise::GUI::Gtk::CalculateMolecularWeightModule.run
#
159 160 161 162 163 164 165 166 167 168 169 |
# File 'lib/chemistry_paradise/gui/shared_code/calculate_molecular_weight/calculate_molecular_weight_module.rb', line 159 def self.run( i = ARGV ) require 'gtk_paradise/run' _ = ::ChemistryParadise::GUI::Gtk::CalculateMolecularWeight.new(i) r = ::Gtk.run r << _ r.set_size_request(_.width?, _.height?) r.automatic_title r.top_left_then_run end |
Instance Method Details
#border_size? ⇒ Boolean
#
border_size?
#
99 100 101 |
# File 'lib/chemistry_paradise/gui/shared_code/calculate_molecular_weight/calculate_molecular_weight_module.rb', line 99 def border_size? 0 end |
#connect_skeleton ⇒ Object
#
connect_skeleton (connect tag)
#
141 142 143 144 145 146 147 |
# File 'lib/chemistry_paradise/gui/shared_code/calculate_molecular_weight/calculate_molecular_weight_module.rb', line 141 def connect_skeleton abort_on_exception @text_result = gtk_text minimal bold_text('Chemical formula:'), 3 minimal @entry_for_the_chemical_formula, 3 minimal @text_result, 3 end |
#create_skeleton ⇒ Object
#
create_skeleton (create tag)
#
134 135 136 |
# File 'lib/chemistry_paradise/gui/shared_code/calculate_molecular_weight/calculate_molecular_weight_module.rb', line 134 def create_skeleton create_the_entry end |
#create_the_entry ⇒ Object
#
create_the_entry
#
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 |
# File 'lib/chemistry_paradise/gui/shared_code/calculate_molecular_weight/calculate_molecular_weight_module.rb', line 106 def create_the_entry # ======================================================================= # # === @entry_for_the_chemical_formula # ======================================================================= # @entry_for_the_chemical_formula = gtk_entry @entry_for_the_chemical_formula.bblack1 @entry_for_the_chemical_formula.yellow_background @entry_for_the_chemical_formula.center @entry_for_the_chemical_formula.hint = 'Input the chemical formula here, '\ 'then press enter. The atomic mass will be shown.' @entry_for_the_chemical_formula.shadow_text = 'Input a chemical formula here.' @entry_for_the_chemical_formula.on_enter_key { _ = @entry_for_the_chemical_formula.text? result = ChemistryParadise::CalculateAtomicMass.new(_) {{ verbosity: :be_quiet, may_we_exit: false }}.result? @text_result.set_text( result.to_f.round(3).to_s+' ame' ) @text_result.make_bold } end |
#initialize(commandline_arguments = ARGV, run_already = true) ⇒ Object
#
initialize
#
51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/chemistry_paradise/gui/shared_code/calculate_molecular_weight/calculate_molecular_weight_module.rb', line 51 def initialize( commandline_arguments = ARGV, run_already = true ) super(:vertical) reset set_commandline_arguments( commandline_arguments ) run if run_already end |
#padding? ⇒ Boolean
#
padding?
#
92 93 94 |
# File 'lib/chemistry_paradise/gui/shared_code/calculate_molecular_weight/calculate_molecular_weight_module.rb', line 92 def padding? 2 end |
#reset ⇒ Object
#
reset (reset tag)
#
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/chemistry_paradise/gui/shared_code/calculate_molecular_weight/calculate_molecular_weight_module.rb', line 66 def reset reset_the_internal_variables # ======================================================================= # # === @configuration # ======================================================================= # @configuration = [true, __dir__, NAMESPACE] # ======================================================================= # # === @title # ======================================================================= # @title = TITLE # ======================================================================= # # === @width # ======================================================================= # set_width(WIDTH) # ======================================================================= # # === @height # ======================================================================= # set_height(HEIGHT) set_use_this_font(USE_THIS_FONT) use_gtk_paradise_project_css_file infer_the_size_automatically end |
#run ⇒ Object
#
run (run tag)
#
152 153 154 |
# File 'lib/chemistry_paradise/gui/shared_code/calculate_molecular_weight/calculate_molecular_weight_module.rb', line 152 def run create_skeleton_then_connect_skeleton end |