Module: TkComponent::Builder::Scrollable
Constant Summary collapse
- ROOT_FRAME_OPTIONS =
%i|width height relief borderwidth padx pady padding| + TkComponent::Builder::LAYOUT_OPTIONS
Instance Method Summary collapse
- #initialize(parent_item, name, options = {}, grid = {}, event_handlers = []) ⇒ Object
-
#remove ⇒ Object
We need to remove the parent native item, as it’s the container we put in place initially.
Instance Method Details
#initialize(parent_item, name, options = {}, grid = {}, event_handlers = []) ⇒ Object
190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 |
# File 'lib/tk_component/builder/tk_item.rb', line 190 def initialize(parent_item, name, = {}, grid = {}, event_handlers = []) return super unless ( = .delete(:scrollers)) && .present? && != 'none' frame_item = TK_CLASSES[:frame].new(parent_item.native_item) # Containing frame real_native_item = create_native_item(frame_item, name, , grid, event_handlers) = .extract!(*ROOT_FRAME_OPTIONS) (, frame_item) # Apply the applicable options to the enclosing frame @native_item = real_native_item (, real_native_item) set_grid(grid, frame_item) real_native_item.grid( :column => 0, :row => 0, :sticky => 'nwes') if .include?('x') = TK_CLASSES[:hscroll_bar].new(frame_item) .orient('horizontal') .command proc { |*args| real_native_item.xview(*args) } real_native_item['xscrollcommand'] = proc { |*args| .set(*args) } .grid( :column => 0, :row => 1, :sticky => 'wes') end if .include?('y') = TK_CLASSES[:vscroll_bar].new(frame_item) .orient('vertical') .command proc { |*args| real_native_item.yview(*args) } real_native_item['yscrollcommand'] = proc { |*args| .set(*args) } .grid( :column => 1, :row => 0, :sticky => 'nse') end TkGrid.columnconfigure(frame_item, 0, :weight => 1) TkGrid.columnconfigure(frame_item, 1, :weight => 0) if .present? TkGrid.rowconfigure(frame_item, 0, :weight => 1) TkGrid.rowconfigure(frame_item, 1, :weight => 0) if .present? @native_item = real_native_item set_event_handlers(event_handlers) end |
#remove ⇒ Object
We need to remove the parent native item, as it’s the container we put in place initially
223 224 225 |
# File 'lib/tk_component/builder/tk_item.rb', line 223 def remove @native_item.winfo_parent.destroy end |