Class: Cosmos::TextItemChooser

Inherits:
Qt::Widget show all
Defined in:
lib/cosmos/tools/tlm_extractor/text_item_chooser.rb

Overview

Allow entry of a column name and some text

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(parent) ⇒ TextItemChooser



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/cosmos/tools/tlm_extractor/text_item_chooser.rb', line 23

def initialize(parent)

  super(parent)
  @overall_frame = Qt::HBoxLayout.new(self)
  @overall_frame.setContentsMargins(0,0,0,0)

  # Column Name
  @column_name_layout = Qt::HBoxLayout.new
  @column_name_label = Qt::Label.new('Column Name:')
  @column_name_label.setSizePolicy(Qt::SizePolicy::Fixed, Qt::SizePolicy::Fixed)
  @column_name_layout.addWidget(@column_name_label)
  @column_name = Qt::LineEdit.new('')
  @column_name_layout.addWidget(@column_name)
  @overall_frame.addLayout(@column_name_layout)

  # Text
  @text_layout = Qt::HBoxLayout.new
  @text_label = Qt::Label.new('Text:')
  @text_label.setSizePolicy(Qt::SizePolicy::Fixed, Qt::SizePolicy::Fixed)
  @text_layout.addWidget(@text_label)
  @text = Qt::LineEdit.new('')
  @text_layout.addWidget(@text)
  @overall_frame.addLayout(@text_layout)

  # Button
  @button = Qt::PushButton.new('Add Text')
  @button.connect(SIGNAL('clicked()')) do
    @button_callback.call(@column_name.text, @text.text) if @button_callback
  end
  @overall_frame.addWidget(@button)

  # Initialize instance variables
  @button_callback = nil
end

Instance Attribute Details

#button_callbackObject

Callback called when the button is pressed - call(column_name, text)



20
21
22
# File 'lib/cosmos/tools/tlm_extractor/text_item_chooser.rb', line 20

def button_callback
  @button_callback
end