Sha256: 4001b97de7891936ba7fe1a015b9a01ad46c57b742852d9c9569b56248c6a19e

Contents?: true

Size: 855 Bytes

Versions: 3

Compression:

Stored size: 855 Bytes

Contents

module TkInspect
  module CanvasWindow
    class Base
      attr_accessor :tk_root
      attr_accessor :main_component

      delegate :canvas, to: :main_component

      def initialize
        @tk_root = nil
        @main_component = nil
      end

      def refresh
        @main_component.nil? ? create_root : @main_component.regenerate
        self
      end

      def create_root
        @tk_root = TkComponent::Window.new(title: "Canvas Window")
        @main_component = RootComponent.new
        @main_component.canvas_window = self
        @tk_root.place_root_component(@main_component)
      end

      def new_turtle
        TkComponent::Turtle.new(canvas: main_component.canvas)
      end
    end
  end

  module Console
    class Base
      def new_canvas_window
        TkInspect::CanvasWindow::Base.new.refresh
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
tk_inspect-0.2.1 lib/tk_inspect/canvas_window/base.rb
tk_inspect-0.2.0 lib/tk_inspect/canvas_window/base.rb
tk_inspect-0.1.0 lib/tk_inspect/canvas_window/base.rb