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="scrolledwindow.py" xml:lang="ko">
  <info>
    <title type="text">ScrolledWindow (Python)</title>
    <link type="guide" xref="beginner.py#scrolling"/>
    <link type="next" xref="paned.py"/>
    <revision version="0.1" date="2012-05-26" status="draft"/>

    <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>ScrolledWindow</title>
  <media type="image" mime="image/png" src="media/scrolledwindow.png"/>
  <p>스크롤 창에 이미지를 나타냅니다.</p>

  <links type="section"/>

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


class MyWindow(Gtk.ApplicationWindow):

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

        # the scrolledwindow
        scrolled_window = Gtk.ScrolledWindow()
        scrolled_window.set_border_width(10)
        # there is always the scrollbar (otherwise: AUTOMATIC - only if needed
        # - or NEVER)
        scrolled_window.set_policy(
            Gtk.PolicyType.ALWAYS, Gtk.PolicyType.ALWAYS)

        # an image - slightly larger than the window...
        image = Gtk.Image()
        image.set_from_file("gnome-image.png")

        # add the image to the scrolledwindow
        scrolled_window.add_with_viewport(image)

        # add the scrolledwindow to the window
        self.add(scrolled_window)


class MyApplication(Gtk.Application):

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

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

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

app = MyApplication()
exit_status = app.run(sys.argv)
sys.exit(exit_status)
</code>
  </section>
  <section id="methods">
    <title>ScrolledWindow 위젯에 쓸만한 메서드</title>
    <list>
      <item><p><code>set_policy(hscrollbar_policy, vscrollbar_policy)</code> 함수에서 각 인자에는 수평 수직 방향으로 스크롤 표시줄을 나타낼지 여부를 정규화 한 <code>Gtk.Policy.AUTOMATIC, Gtk.Policy.ALWAYS, Gtk.Policy.NEVER</code> 값 중 하나가 들어갑니다. <code>AUTOMATIC</code> 값을 넣으면 필요할 경우 나타내며, <code>ALWAYS</code>, <code>NEVER</code>는 값에서 설명하는 의미와 같습니다.</p></item>
      <item><p><code>add_with_viewport(widget)</code> 함수는 창에 자체 스크롤 기능을 넣지 않고 Gtk.Widget <code>widget</code>을 추가하는데 사용합니다.</p></item>
      <item><p><code>set_placement(window_placement)</code> 함수는 스크롤 창에서 스크롤 표시줄을 나타낼 컨텐트 위치를 설정합니다. 인자 옵션은 <code>Gtk.CornerType.TOP_LEFT</code> (기본값: 스크롤 표시줄을 창 하단과 우측에 나타냄), <code>Gtk.CornerType.TOP_RIGHT, Gtk.CornerType.BOTTOM_LEFT, Gtk.CornerType.BOTTOM_RIGHT</code>가 있습니다.</p></item>
      <item><p><code>set_hadjustment(adjustment)</code> 함수와 <code>set_vadjustment(adjustment)</code> 함수는 각각 Gtk.Adjustment <code>adjustment</code>를 설정합니다. 상한 값, 하한 값, 단계/페이지 증가 값, 페이지 크기를 나타내며, <code>Gtk.Adjustment(value, lower, upper, step_increment, page_increment, page_size)</code>로 만듭니다. 여기서 각 필드 값은 <code>float</code> 형식입니다. (참고로 지금 같은 경우는 <code>step_increment</code>를 사용하지 않으므로 <code>0</code> 값으로 설정합니다).</p></item>
    </list>
  </section>
  <section id="references">
    <title>API 참고서</title>
    <p>이 예제는 다음 참고자료가 필요합니다:</p>
    <list>
      <item><p><link href="http://developer.gnome.org/gtk3/unstable/GtkScrolledWindow.html">GtkScrolledWindow</link></p></item>
      <item><p><link href="http://developer.gnome.org/gtk3/unstable/gtk3-Standard-Enumerations.html">표준 서수형 값 목록</link></p></item>
      <item><p><link href="http://developer.gnome.org/gtk3/unstable/GtkImage.html">GtkImage</link></p></item>
    </list>
  </section>
</page>