Blob Blame History Raw
<?xml version="1.0" encoding="utf-8"?>
<page xmlns="http://projectmallard.org/1.0/" xmlns:its="http://www.w3.org/2005/11/its" xmlns:xi="http://www.w3.org/2001/XInclude" type="guide" style="task" id="grid.py" xml:lang="ko">
  <info>
    <title type="text">Grid(Python)</title>
    <link type="guide" xref="beginner.py#layout"/>
    <link type="seealso" xref="label.py"/>
    <link type="next" xref="separator.py"/>
    <revision version="0.2" date="2012-08-01" status="stub"/>

    <credit type="author copyright">
      <name>Tiffany Antopolski</name>
      <email its:translate="no">tiffany.antopolski@gmail.com</email>
      <years>2012</years>
    </credit>

    <credit type="author copyright">
      <name>Marta Maria Casetti</name>
      <email its:translate="no">mmcasetti@gmail.com</email>
      <years>2012</years>
    </credit>

    <desc>위젯을 행열 방향으로 감쌉니다</desc>
  
    <mal:credit xmlns:mal="http://projectmallard.org/1.0/" type="translator copyright">
      <mal:name>조성호</mal:name>
      <mal:email>shcho@gnome.org</mal:email>
      <mal:years>2017</mal:years>
    </mal:credit>
  </info>

  <title>Grid</title>

  <media type="image" mime="image/png" src="media/grid_simple.png"/>
  <p>그리드에 레이블 몇 개를 넣어봤습니다.</p>

  <links type="section"/>

  <section id="code">
    <title>예제 결과를 만드는 코드</title>
    <code mime="text/python" style="numbered">from gi.repository import Gtk
import sys


class MyWindow(Gtk.ApplicationWindow):

    def __init__(self, app):
        Gtk.Window.__init__(self, title="Grid Example", application=app)

        # three labels
        label_top_left = Gtk.Label(label="This is Top Left")
        label_top_right = Gtk.Label(label="This is Top Right")
        label_bottom = Gtk.Label(label="This is Bottom")

        # a grid
        grid = Gtk.Grid()

        # some space between the columns of the grid
        grid.set_column_spacing(20)

        # in the grid:
        # attach the first label in the top left corner
        grid.attach(label_top_left, 0, 0, 1, 1)
        # attach the second label
        grid.attach(label_top_right, 1, 0, 1, 1)
        # attach the third label below the first label
        grid.attach_next_to(
            label_bottom, label_top_left, Gtk.PositionType.BOTTOM, 2, 1)

        # add the grid to the window
        self.add(grid)


class MyApplication(Gtk.Application):

    def __init__(self):
        Gtk.Application.__init__(self)

    def do_activate(self):
        win = MyWindow(self)
        win.show_all()

app = MyApplication()
exit_status = app.run(sys.argv)
sys.exit(exit_status)
</code>
  </section>

  <section id="methods">
    <title>Grid 위젯에 쓸만한 메서드</title>

    <list>
      <item><p><code>width, height</code> 크기로 <code>left, top</code> 위치에 <code>child</code>  위젯을 붙이려면 <code>attach(child, top, left, width, height)</code> 함수를 사용하십시오, <code>sibling</code> 위젯을 이미 두었다면 <code>attach_next_to(child, sibling, side, width, height)</code> 함수를 사용할 수 있습니다. 여기서 <code>side</code> 값은 <code>Gtk.PositionType.LEFT, Gtk.PositionType.RIGHT, Gtk.PositionType.TOP, Gtk.PositionType.BOTTOM</code> 중 하나입니다.</p></item>
      <item><p><code>insert_row(position)</code> 함수와 <code>insert_column(position)</code> 함수는 주어진 이름대로 정확하게 동작합니다. 이 위치 옆에 붙은 하위 요소 또는 아래에 붙은 하위 요소를 한줄 아래로 내리며, 이 위치의 하위 요소는 (종,횡 방향으로) 새 줄을 확장합니다. <code>insert_next_to(sibling, side)</code>  함수는 지정 위치에 줄이나 행을 넣습니다. 즉, 이 함수는 새 줄 또는 행을 <code>sibling</code> 다음의 <code>side</code>에서 지정한 위치에 넣습니다. <code>side</code> 값이 <code>Gtk.PositionType.TOP</code> 또는 <code>Gtk.PositionType.BOTTOM</code>이면 새 줄을 넣고, <code>Gtk.PositionType.LEFT</code> 또는 <code>Gtk.PositionType.RIGHT</code>면 새 칸을 넣습니다.</p></item>
      <item><p><code>set_row_homogeneous(True)</code> 함수는 각각 모든 줄의 높이를 동일하게 설정하며 <code>set_column_homogeneous(True)</code> 함수는 모든 칸의 너비를 동일하게 설정합니다.</p></item>
      <item><p><code>set_row_spacing(spacing)</code>함수는 줄 간격을 강제로 설정하고 <code>set_column_spacing(spacing)</code> 함수는 칸 간격을 강제로 설정합니다. <code>spacing</code> 값은 기본값 <code>0</code>에서 <code>32767</code>값 사이입니다.</p></item>
    </list>

  </section>

  <section id="references">
    <title>API 참고서</title>
    <p>이 예제는 다음 참고자료가 필요합니다:</p>
    <list>
      <item><p><link href="http://developer.gnome.org/gtk3/unstable/GtkApplication.html">GtkApplication</link></p></item>
      <item><p><link href="http://developer.gnome.org/gtk3/unstable/GtkApplicationWindow.html">GtkApplicationWindow</link></p></item>
      <item><p><link href="http://developer.gnome.org/gtk3/unstable/GtkLabel.html">GtkLabel</link></p></item>
      <item><p><link href="http://developer.gnome.org/gtk3/unstable/GtkImage.html">GtkImage</link></p></item>
      <item><p><link href="http://developer.gnome.org/gtk3/unstable/GtkGrid.html">GtkGrid</link></p></item>
    </list>
  </section>
</page>