Class: MittensUi::Label
Overview
A simple wrapper around a GTK4::Label for use with MittensUi::Core.
This class ensures the provided text is non-empty and initializes a GTK4 label widget, then delegates common setup to MittensUi::Core.
Examples:
label = MittensUi::Label.new("Hello")
label = MittensUi::Label.new(nil) # => uses "Label"
Instance Attribute Summary
Attributes inherited from Core
Instance Method Summary collapse
-
#initialize(text, options = {}) ⇒ MittensUi::Label
constructor
Create a new Label wrapper.
-
#text ⇒ String
Returns the current label text.
- #text=(value) ⇒ Object
Methods inherited from Core
#hidden?, #hide, #keyboard_shortcut, #remove, #remove_keyboard_shortcut, #render, #shortcuts, #show
Methods included from Helpers
#icon_map, #list_system_icons, #set_margin_from_opts_for
Constructor Details
#initialize(text, options = {}) ⇒ MittensUi::Label
Create a new Label wrapper.
29 30 31 32 33 34 |
# File 'lib/mittens_ui/label.rb', line 29 def initialize(text, = {}) text = 'Label' if text.nil? || text.to_s.strip.empty? gtk_label = Gtk::Label.new(text) super(gtk_label, ) end |
Instance Method Details
#text ⇒ String
Returns the current label text.
37 38 39 |
# File 'lib/mittens_ui/label.rb', line 37 def text @core_widget.label end |
#text=(value) ⇒ Object
42 43 44 |
# File 'lib/mittens_ui/label.rb', line 42 def text=(value) @core_widget.set_label(value.to_s) end |