Ruby-tk-grid

提供:Dev Guides
移動先:案内検索

Ruby/TK-グリッドジオメトリマネージャー

説明

グリッドジオメトリマネージャは、最も柔軟で使いやすいジオメトリマネージャです。 親ウィンドウまたはウィジェットを2次元テーブルの行と列に論理的に分割します。

その後、それぞれ_row_オプションと_column_オプションを使用して、適切な行と列の形式でウィジェットを配置できます。 行と列のオプションの使用を理解するために、次の例を検討してください。

構文

グリッドウィジェットを作成する簡単な構文を次に示します-

grid('row'=>x, 'column'=>y)

以下は、グリッドジオメトリマネージャーを使用してラベルとエントリウィジェットを表示するコードです-

require 'tk'

top = TkRoot.new {title "Label and Entry Widget"}

#code to add a label widget
lb1 = TkLabel.new(top){
   text 'Hello World'
   background "yellow"
   foreground "blue"
   grid('row'=>0, 'column'=>0)
}

#code to add a entry widget
e1 = TkEntry.new(top){
   background "red"
   foreground "blue"
   grid('row'=>0, 'column'=>1)
}

Tk.mainloop

これは、次の結果を生成します-

Ruby/Tk Grid