tkinter.ttk — Tk 테마 위젯¶
소스 코드: Lib/tkinter/ttk.py
The tkinter.ttk module provides access to the Tk themed widget set,
introduced in Tk 8.5. It provides additional benefits including anti-aliased font
rendering under X11 and window transparency (requiring a composition
window manager on X11).
The basic idea for tkinter.ttk is to separate, to the extent possible,
the code implementing a widget’s behavior from the code implementing its
appearance.
Added in version 3.1.
더 보기
- Tk 위젯 스타일링 지원
Tk의 테마 지원을 소개하는 문서
Ttk 사용하기¶
Ttk를 사용하려면, 모듈을 임포트 하십시오:
from tkinter import ttk
기본 Tk 위젯을 재정의하려면, 임포트는 Tk 임포트 뒤에 와야 합니다:
from tkinter import *
from tkinter.ttk import *
That code causes several tkinter.ttk widgets (Button,
Checkbutton, Entry, Frame, Label,
LabelFrame, Menubutton, PanedWindow,
Radiobutton, Scale and Scrollbar) to
automatically replace the Tk widgets.
This has the direct benefit of using the new widgets which gives a better look
and feel across platforms; however, the replacement widgets are not completely
compatible.
The main difference is that widget options such as “fg”, “bg” and others
related to widget styling are no longer present in Ttk widgets.
Instead, use the ttk.Style class for improved styling effects.
더 보기
- Tile 위젯을 사용하도록 기존 응용 프로그램을 변환하기
새 위젯을 사용하도록 응용 프로그램을 바꿀 때 일반적으로 발생하는 차이점에 대한 모노그래프 (Tcl 용어로).
Ttk widgets¶
Ttk에는 18개의 위젯이 있으며, 그중 12개는 tkinter에 이미 존재합니다: Button, Checkbutton, Entry, Frame, Label, LabelFrame, Menubutton, PanedWindow, Radiobutton, Scale, Scrollbar 및 Spinbox. 다른 6개는 Combobox, Notebook, Progressbar, Separator, Sizegrip 및 Treeview입니다. 그리고 이들은 모두 Widget의 서브 클래스입니다.
Ttk 위젯을 사용하면 응용 프로그램의 모양과 느낌이 개선됩니다. 위에서 설명한 것처럼, 스타일을 코딩하는 방법에는 차이가 있습니다.
Tk 코드:
l1 = tkinter.Label(text="Test", fg="black", bg="white")
l2 = tkinter.Label(text="Test", fg="black", bg="white")
Ttk 코드:
style = ttk.Style()
style.configure("BW.TLabel", foreground="black", background="white")
l1 = ttk.Label(text="Test", style="BW.TLabel")
l2 = ttk.Label(text="Test", style="BW.TLabel")
Widget¶
ttk.Widget defines standard options and methods supported by
Tk themed widgets and is not supposed to be directly instantiated.
Standard options¶
All the ttk Widgets accept the following options:
옵션 |
설명 |
|---|---|
class |
윈도우 클래스를 지정합니다. 이 클래스는 창의 다른 옵션에 대한 옵션 데이터베이스를 조회하고, 창의 기본 바인딩 태그를 결정하고, 위젯의 기본 레이아웃과 스타일을 선택하는 데 사용됩니다. 이 옵션은 읽기 전용이며, 창을 만들 때만 지정할 수 있습니다. |
cursor |
Specifies the mouse cursor to be used for the widget. If set to the empty string (the default), the cursor is inherited from the parent widget. |
takefocus |
키보드 순회 중 창에서 포커스를 받아들일지를 결정합니다. 0, 1 또는 빈 문자열이 반환됩니다. 0이 반환되면, 키보드 순회 중에 창을 완전히 건너뛰어야 한다는 의미입니다. 1이면, 창은 볼 수 있는 한 입력 포커스를 받아야 함을 의미합니다. 빈 문자열은 순회 스크립트가 창에 포커스를 맞출지를 결정함을 의미합니다. |
style |
사용자 정의 위젯 스타일을 지정하는 데 사용될 수 있습니다. |
Scrollable widget options¶
다음 옵션은 스크롤 막대로 제어되는 위젯에서 지원됩니다.
옵션 |
설명 |
|---|---|
xscrollcommand |
가로 스크롤 막대와 통신하는 데 사용됩니다. When the view in the widget’s window changes, the widget calls the xscrollcommand callback. Usually this option consists of the method
|
yscrollcommand |
세로 스크롤 막대와 통신하는 데 사용됩니다. 자세한 내용은 위를 참조하십시오. |
Label options¶
다음 옵션은 레이블, 버튼 및 기타 버튼류 위젯에서 지원됩니다.
옵션 |
설명 |
|---|---|
text |
위젯 안에 표시할 텍스트 문자열을 지정합니다. |
textvariable |
text 옵션 자원 대신 그 값이 사용될 이름을 지정합니다. |
underline |
설정되면, 텍스트 문자열에서 밑줄 그을 문자의 인덱스(0에서 시작)를 지정합니다. 밑줄 있는 문자는 니모닉 활성화(mnemonic activation)에 사용됩니다. |
image |
표시할 이미지를 지정합니다. 이것은 하나 이상의 요소로 구성된 리스트입니다. 첫 번째 요소는 기본 이미지 이름입니다. 리스트의 나머지가 |
compound |
텍스트와 이미지 옵션이 모두 있을 때, 텍스트를 기준으로 이미지를 표시하는 방법을 지정합니다. 유효한 값은 다음과 같습니다:
|
width |
0보다 크면, 문자 너비 단위로, 텍스트 레이블에 할당할 공간의 크기를 지정합니다, 0보다 작으면, 최소 너비를 지정합니다. 0으로 지정하거나 지정하지 않으면, 텍스트 레이블의 자연 너비가 사용됩니다. |
Compatibility options¶
옵션 |
설명 |
|---|---|
state |
“disabled” 상태 비트를 제어하기 위해 “normal”이나 “disabled”로 설정될 수 있습니다. 이것은 쓰기 전용 옵션입니다: 이를 설정하면 위젯 상태가 변경되지만, |
Widget states¶
위젯 상태는 독립 상태 플래그의 비트 맵입니다.
플래그 |
설명 |
|---|---|
active |
마우스 커서가 위젯 위에 있으며 마우스 버튼을 누르면 어떤 동작을 일으킵니다 |
disabled |
프로그램 제어 하에 위젯이 비활성화되었습니다 |
focus |
위젯에 키보드 포커스가 있습니다 |
pressed |
위젯을 누르고 있습니다 |
selected |
체크 버튼과 라디오 버튼과 같은 항목의 경우 “On”, “true” 또는 “current” |
background |
윈도우와 맥에는 “활성(active)”이나 전경(foreground) 창이라는 개념이 있습니다. background 상태는 배경 창의 위젯에 대해 설정되고, 전경 창의 위젯에서는 지워집니다. |
readonly |
위젯이 사용자 수정을 허용하지 않습니다 |
alternate |
위젯 별 대체 디스플레이 포맷 |
invalid |
위젯 값이 유효하지 않습니다 |
상태 명세는 상태 이름의 시퀀스이며, 선택적으로 비트가 꺼져 있음을 나타내는 느낌표가 접두어로 붙습니다.
ttk.Widget¶
Besides the methods described below, the ttk.Widget supports
the methods tkinter.Widget.cget and
tkinter.Widget.configure.
- class tkinter.ttk.Widget¶
- identify(x, y)¶
위치 x y에 있는 요소의 이름을 반환하거나, 점이 요소 내에 없으면 빈 문자열을 반환합니다.
x 와 y는 위젯에 상대적인 픽셀 좌표입니다.
- instate(statespec, callback=None, *args, **kw)¶
위젯 상태를 테스트합니다. 콜백을 지정하지 않으면, 위젯 상태가 statespec과 일치하면
True를, 그렇지 않으면False를 반환합니다. 콜백이 지정되면 위젯 상태가 statespec과 일치하면 args로 호출됩니다.
- state(statespec=None)¶
위젯 상태를 수정하거나 요청합니다. statespec이 지정되면, 그에 따라 위젯 상태를 설정하고 변경된 플래그를 나타내는 새 statespec을 반환합니다. statespec을 지정하지 않으면, 현재 활성화된 상태 플래그를 반환합니다.
Not to be confused with
Wm.state.
statespec은 일반적으로 리스트나 튜플입니다.
Combobox¶
The ttk.Combobox widget combines a text field with a
pop-down list of values.
This widget is a subclass of Entry.
Besides the methods inherited from Widget: cget(),
configure(), identify(),
instate() and state(), and the following inherited
from Entry: bbox(), delete(),
icursor(), index(),
insert(),
selection*,
xview*, it has some other methods, described at
ttk.Combobox.
옵션¶
이 위젯은 다음과 같은 특정 옵션을 받아들입니다:
옵션 |
설명 |
|---|---|
exportselection |
Boolean value. If set, the widget selection is linked to the X selection (which can be returned by invoking Misc.selection_get, for example). |
justify |
위젯 내에서 텍스트가 정렬되는 방식을 지정합니다. “left”, “center” 또는 “right” 중 하나입니다. |
height |
팝-다운 목록 상자의 높이를 행 단위로 지정합니다. |
postcommand |
값을 표시하기 직전에 호출되는 (Misc.register로 등록할 수 있는) 스크립트. 표시할 값을 지정할 수 있습니다. |
state |
One of “normal”, “readonly”, or “disabled”. In the “readonly” state, the value may not be edited directly, and the user can only select one of the values from the dropdown list. In the “normal” state, the text field is directly editable. In the “disabled” state, no interaction is possible. |
textvariable |
값이 위젯 값에 연결된 이름을 지정합니다. 해당 이름과 관련된 값이 변경될 때마다, 위젯 값이 갱신되고, 그 반대도 마찬가지입니다. |
values |
드롭-다운 목록 상자에 표시할 값의 리스트를 지정합니다. |
width |
원하는 입력 창의 너비를 나타내는 정숫값을 위젯 글꼴의 평균 크기 문자 단위로 지정합니다. |
참고
Tk 9.1 added the locale option, which selects the locale used to determine
word and character boundaries within the text ("C" by default).
가상 이벤트¶
콤보 박스 위젯은 사용자가 값 목록에서 요소를 선택할 때 <<ComboboxSelected>> 가상 이벤트를 생성합니다.
ttk.Combobox¶
Spinbox¶
The ttk.Spinbox widget is a ttk.Entry
enhanced with increment and decrement arrows.
It can be used for numbers or lists of string values.
This widget is a subclass of Entry.
Besides the methods inherited from Widget: cget(),
configure(), identify(),
instate() and state(), and the following inherited
from Entry: bbox(), delete(),
icursor(), index(),
insert(), xview*, it has
some other methods, described at ttk.Spinbox.
옵션¶
이 위젯은 다음과 같은 특정 옵션을 받아들입니다:
옵션 |
설명 |
|---|---|
from |
부동 소수점 값. 설정하면, 감소 버튼이 감소할 최솟값입니다. |
to |
부동 소수점 값. 설정되면, 증가 버튼이 증가할 최댓값입니다. |
increment |
부동 소수점 값. 증가/감소 버튼이 값을 변경할 양을 지정합니다. 기본값은 1.0입니다. |
values |
문자열이나 부동 소수점 값의 시퀀스. 지정되면, 증가/감소 버튼은 숫자를 늘리거나 줄이는 것이 아니라, 이 시퀀스에서 항목을 순환합니다. |
wrap |
불리언 값. |
format |
문자열 값. 증가/감소 버튼으로 설정된 숫자의 포맷을 지정합니다. “%W.Pf” 형식이어야 합니다, 여기서 W는 값의 패딩 된 너비, P는 정밀도, 그리고 ‘%’와 ‘f’는 리터럴 입니다. |
command |
파이썬 콜러블. 증가나 감소 버튼 중 하나를 누를 때마다 인자 없이 호출됩니다. |
가상 이벤트¶
스핀 박스 위젯은 사용자가 <Up>을 누를 때 <<Increment>> 가상 이벤트를, 사용자가 <Down>을 누를 때 <<Decrement>> 가상 이벤트를 생성합니다.
ttk.Spinbox¶
Notebook¶
Ttk Notebook 위젯은 창 모음을 관리하고 한 번에 하나의 창을 표시합니다. 각 자식 창은 사용자가 현재 표시된 창을 변경하도록 선택할 수 있는 탭과 연결되어 있습니다.
옵션¶
이 위젯은 다음과 같은 특정 옵션을 받아들입니다:
옵션 |
설명 |
|---|---|
height |
존재하고 0보다 크면, 팬 영역(pane area)의 원하는 높이를 지정합니다 (내부 패딩이나 탭을 포함하지 않습니다). 그렇지 않으면, 모든 팬의 최대 높이가 사용됩니다. |
padding |
노트북 외부에 추가할 여분의 공간을 지정합니다. 패딩은 좌(left) 상(top) 우(right) 하(bottom) 최대 4개의 길이 명세 리스트입니다. 4개보다 적은 요소가 지정되면, bottom의 기본값은 top, right의 기본값은 left, top의 기본값은 left입니다. |
width |
존재하고 0보다 크면, 원하는 팬 영역 너비를 지정합니다 (내부 패딩을 포함하지 않습니다). 그렇지 않으면, 모든 팬의 최대 너비가 사용됩니다. |
Tab options¶
탭에 대한 특정 옵션도 있습니다:
옵션 |
설명 |
|---|---|
state |
“normal”, “disabled” 또는 “hidden”. “disabled” 이면, 탭을 선택할 수 없습니다. “hidden” 이면, 탭이 표시되지 않습니다. |
sticky |
Specifies how the child window is positioned within the pane
area. Value is a string containing zero or more of the
characters “n”, “s”, “e” or “w”. Each letter refers to a
side (north, south, east or west) that the child window will
stick to, as per the |
padding |
노트북과 이 팬 사이에 추가할 여분의 공간을 지정합니다. 문법은 이 위젯에서 사용하는 옵션 padding과 같습니다. |
text |
탭에 표시할 텍스트를 지정합니다. |
image |
탭에 표시할 이미지를 지정합니다. |
compound |
옵션 text와 image가 모두 있을 때, 텍스트에 상대적으로 이미지를 표시하는 방법을 지정합니다. 유효한 값은 레이블 옵션을 참조하십시오. |
underline |
텍스트 문자열에서 밑줄 그을 문자의 인덱스(0에서 시작)를 지정합니다. |
Tab identifiers¶
The tab_id present in several methods of ttk.Notebook may
take any of the following forms:
0과 탭 수 사이의 정수
자식 창의 이름
탭을 식별하는 “@x,y” 형식의 위치 명세
현재 선택된 탭을 식별하는 리터럴 문자열 “current”
탭 수를 반환하는 리터럴 문자열 “end” (
Notebook.index()에만 유효합니다)
가상 이벤트¶
이 위젯은 새 탭을 선택한 후 <<NotebookTabChanged>> 가상 이벤트를 생성합니다.
ttk.Notebook¶
- class tkinter.ttk.Notebook¶
- add(child, **kw)¶
노트북에 새 탭을 추가합니다.
창이 현재 노트북으로 관리되지만 숨겨져 있으면, 창은 이전 위치로 복원됩니다.
사용 가능한 옵션 목록은 탭 옵션을 참조하십시오.
- forget(tab_id)¶
tab_id로 지정된 탭을 제거하고, 연관된 창을 매핑 취소하고 관리 취소합니다.
This shadows the inherited geometry-manager
forget(); usepack_forget(),grid_forget()orplace_forget()to remove the widget itself from its manager.
- hide(tab_id)¶
tab_id로 지정된 탭을 숨깁니다.
탭은 표시되지 않지만, 관련 창은 노트북에 의해 계속 관리되고 구성이 기억됩니다. 숨겨진 탭은
add()명령으로 복원될 수 있습니다.
- identify(x, y)¶
위치 x, y의 탭 요소 이름을 반환하거나, 없으면 비어있는 문자열을 반환합니다.
- index(tab_id)¶
tab_id로 지정된 탭의 숫자 인덱스를 반환하거나, tab_id가 문자열 “end”이면 총 탭 수를 반환합니다.
- insert(pos, child, **kw)¶
지정된 위치에 팬(pane)을 삽입합니다.
pos는 문자열 “end”, 정수 인덱스 또는 관리되는 자식의 이름입니다. 노트북에서 child를 이미 관리하고 있으면, 지정된 위치로 옮깁니다.
사용 가능한 옵션 목록은 탭 옵션을 참조하십시오.
- select(tab_id=None)¶
지정된 tab_id를 선택합니다.
연결된 자식 창이 표시되고, 이전에 선택한 창이 (다르다면) 매핑이 취소됩니다. tab_id가 생략되면, 현재 선택된 팬의 위젯 이름을 반환합니다.
- tab(tab_id, option=None, **kw)¶
특정 tab_id의 옵션을 조회하거나 수정합니다.
kw가 제공되지 않으면, 탭 옵션값의 딕셔너리를 반환합니다. option이 지정되면, 해당 option의 값을 반환합니다. 그렇지 않으면, 옵션을 해당 값으로 설정합니다.
- tabs()¶
Returns a tuple of windows managed by the notebook.
- enable_traversal()¶
이 노트북이 포함된 최상위 창의 키보드 순회를 활성화합니다.
이것은 노트북을 포함하는 최상위 창에 대한 바인딩을 다음과 같이 확장합니다:
Control-Tab: 현재 선택된 탭 다음에 있는 탭을 선택합니다.
Shift-Control-Tab: 현재 선택된 탭 앞에 있는 탭을 선택합니다.
Alt-K: 여기서 K는 탭의 니모닉 (밑줄이 그어진) 문자이며, 해당 탭을 선택합니다.
Multiple notebooks in a single toplevel may be enabled for traversal, including nested notebooks. However, notebook traversal only works properly if all panes are direct children of the notebook.
Progressbar¶
The ttk.Progressbar widget shows the status of a
long-running operation.
It can operate in two modes: 1) the determinate mode which shows the amount
completed relative to the total amount of work to be done and 2) the
indeterminate mode which provides an animated display to let the user know that
work is progressing.
옵션¶
이 위젯은 다음과 같은 특정 옵션을 받아들입니다:
옵션 |
설명 |
|---|---|
orient |
“horizontal” 또는 “vertical” 중 하나입니다. 진행 막대의 방향을 지정합니다. |
length |
진행 막대의 긴 축의 길이를 지정합니다 (가로면 너비, 세로면 높이). |
mode |
“determinate” 또는 “indeterminate” 중 하나. |
maximum |
최댓값을 지정하는 숫자. 기본값은 100입니다. |
value |
진행 막대의 현재 값. “determinate” (확정적) 모드에서는, 완료된 작업량을 나타냅니다. “indeterminate” (불확정적) 모드에서는, 모듈로 maximum으로 해석됩니다; 즉, 진행 막대의 값이 maximum 증가하면 하나의 “사이클”이 완료됩니다. |
variable |
옵션값에 연결된 이름. 지정되면, 진행 막대의 값은 이 이름의 값이 수정될 때마다 이 이름의 값으로 자동 설정됩니다. |
phase |
읽기 전용 옵션. 위젯은 값이 0보다 크고 확정적 모드에서 최댓값보다 작을 때마다 이 옵션의 값을 주기적으로 증가시킵니다. 이 옵션은 현재 테마에서 추가 애니메이션 효과를 제공하는 데 사용할 수 있습니다. |
ttk.Progressbar¶
- class tkinter.ttk.Progressbar¶
- start(interval=None)¶
자동 증가 모드를 시작합니다: interval 밀리초마다
Progressbar.step()을 호출하는 반복 타이머 이벤트를 예약합니다. 생략하면, interval의 기본값은 50밀리초입니다.
- step(amount=None)¶
진행 막대의 값을 amount만큼 증가시킵니다.
생략하면 amount의 기본값은 1.0입니다.
- stop()¶
자동 증가 모드를 중지합니다: 이 진행 막대에 대한
Progressbar.start()로 시작된 반복 타이머 이벤트를 취소합니다.
Separator¶
The ttk.Separator widget displays a horizontal or vertical
separator bar.
It has no other methods besides the ones inherited from
ttk.Widget.
옵션¶
이 위젯은 다음과 같은 특정 옵션을 받아들입니다:
옵션 |
설명 |
|---|---|
orient |
“horizontal”(가로)이나 “vertical”(세로) 중 하나입니다. 구분 막대의 방향을 지정합니다. |
Sizegrip¶
The ttk.Sizegrip widget (also known as a grow box) allows
the user to resize the containing toplevel window by pressing and dragging the
grip.
This widget has neither specific options nor specific methods, besides the
ones inherited from ttk.Widget.
플랫폼별 노트¶
맥 OS에서, 최상위 창에는 기본적으로 내장 크기 그립이 자동으로 포함됩니다. 내장 그립이 위젯을 가리기 때문에
Sizegrip을 추가하는 것은 무해합니다.
버그¶
If the containing toplevel’s position was specified relative to the right or bottom of the screen (for example, ….), the
Sizegripwidget will not resize the window.이 위젯은 “동남쪽” 크기 조정만 지원합니다.
Treeview¶
The ttk.Treeview widget displays a hierarchical collection
of items.
Each item has a textual label, an optional image, and an optional list of data
values.
The data values are displayed in successive columns after the tree label.
위젯 옵션 displaycolumns를 설정하여 데이터값이 표시되는 순서를 제어할 수 있습니다. 트리 위젯은 열 제목을 표시할 수도 있습니다. 위젯 옵션 열에 나열된 숫자나 기호 이름으로 열에 액세스 할 수 있습니다. 열 식별자를 참조하십시오.
각 항목은 고유한 이름으로 식별됩니다. 호출자가 제공하지 않으면 위젯은 항목 ID를 생성합니다. {}라고 이름 붙은, 구별되는 루트 항목이 있습니다. 루트 항목 자체는 표시되지 않습니다; 이것의 자식들이 계층 구조의 최상위 수준에 나타납니다.
각 항목에는 이벤트 바인딩을 개별 항목과 연관시키고 항목의 모양을 제어하는 데 사용할 수 있는 태그 목록이 있습니다.
Treeview 위젯은 스크롤 가능한 위젯 옵션에 설명된 옵션과 Treeview.xview()와 Treeview.yview() 메서드에 따라 가로와 세로 스크롤을 지원합니다.
옵션¶
이 위젯은 다음과 같은 특정 옵션을 받아들입니다:
옵션 |
설명 |
|---|---|
columns |
열 수와 이름을 지정하는, 열 식별자 리스트. |
displaycolumns |
표시할 데이터 열과 표시되는 순서를 지정하는 열 식별자 (기호나 정수 인덱스) 리스트, 또는 문자열 “#all”. |
height |
보여야 하는 행 수를 지정합니다. 참고: 요청된 너비는 열 너비의 합계로 결정됩니다. |
padding |
위젯의 내부 패딩을 지정합니다. 패딩은 최대 4개의 길이 명세 리스트입니다. |
selectmode |
내장 클래스 바인딩이 선택을 관리하는 방법을 제어합니다. “extended”, “browse” 또는 “none” 중 하나입니다. “extended”(기본값)로 설정하면, 여러 항목을 선택할 수 있습니다. “browse”이면, 한 번에 하나의 항목 만 선택됩니다. “none”이면 선택이 변경되지 않습니다. 이 옵션의 값과 관계없이, 응용 프로그램 코드와 태그 바인딩은 원하는 대로 선택을 설정할 수 있음에 유의하십시오. |
show |
표시할 트리의 요소를 지정하는, 다음 값 중 0개 이상을 포함하는 리스트.
The default is “tree headings”, that is, show all elements. 참고: show=”tree” 가 지정되지 않은 경우에도, #0 열은 항상 트리 열을 나타냅니다. |
참고
Tk 9.0 added several Treeview features.
The selectmode option gained the values "single" and "multiple";
the new widget options selecttype ("item" or "cell" selection),
striped (zebra-striped rows), and titlecolumns / titleitems (columns
or rows frozen against scrolling) were introduced; and items gained a
hidden option.
Tk 9.1 added the rowheight and headingheight options.
Item options¶
insert와 item 위젯 명령에서 항목에 대해 다음 항목 옵션을 지정할 수 있습니다.
옵션 |
설명 |
|---|---|
text |
항목에 표시할 텍스트 레이블. |
image |
레이블 왼쪽에 표시되는, Tk 이미지. |
values |
항목과 관련된 값의 리스트. 각 항목은 위젯 옵션 열과 같은 수의 값을 가져야 합니다. 열보다 적은 값이 있으면, 나머지 값은 비어 있다고 가정합니다. 열보다 많은 값이 있으면, 추가 값은 무시됩니다. |
open |
항목의 자식을 표시할지를 나타내는 |
tags |
이 항목과 관련된 태그의 리스트. |
Tag options¶
태그에 다음 옵션을 지정할 수 있습니다:
옵션 |
설명 |
|---|---|
foreground |
텍스트 전경색을 지정합니다. |
background |
셀이나 항목 배경색을 지정합니다. |
font |
텍스트를 그릴 때 사용할 글꼴을 지정합니다. |
image |
항목의 image 옵션이 비어있는 경우, 항목 이미지를 지정합니다. |
Column identifiers¶
열 식별자는 다음 형식 중 하나를 취합니다:
열 옵션 목록에 있는 기호 이름.
n번째 데이터 열을 지정하는, 정수 n.
#n 형식의 문자열, 여기서 n은 정수이며 n번째 표시 열을 지정합니다.
노트:
항목의 옵션 값은 저장된 순서와 다른 순서로 표시될 수 있습니다.
show=”tree”가 지정되지 않은 경우에도, #0 열은 항상 트리 열을 나타냅니다.
데이터 열 번호는 항목의 옵션 값 리스트에 대한 인덱스입니다; 표시 열 번호는 값이 표시되는 트리의 열 번호입니다. 트리 레이블은 열 #0 에 표시됩니다. displaycolumns 옵션을 설정하지 않으면, 데이터 열 n이 열 #n+1 에 표시됩니다. 다시, #0 열은 항상 트리 열을 나타냅니다.
가상 이벤트¶
Treeview 위젯은 다음과 같은 가상 이벤트를 생성합니다.
이벤트 |
설명 |
|---|---|
<<TreeviewSelect>> |
선택이 변경될 때마다 생성됩니다. |
<<TreeviewOpen>> |
포커스 항목을 open=True 로 설정하기 직전에 생성됩니다. |
<<TreeviewClose>> |
포커스 항목을 open=False 로 설정한 직후 생성됩니다. |
Treeview.focus()와 Treeview.selection() 메서드를 사용하여 영향을 받는 항목이나 항목들을 결정할 수 있습니다.
ttk.Treeview¶
- class tkinter.ttk.Treeview¶
- bbox(item, column=None)¶
지정된 item의 경계 상자(트리 뷰 위젯의 창에 상대적인)를 (x, y, 너비, 높이) 형식으로 반환합니다.
If column is specified, returns the bounding box of that cell. If the item is not visible (that is, if it is a descendant of a closed item or is scrolled offscreen), returns an empty string.
This shadows the inherited
Misc.bbox(); usegrid_bbox()for the grid bounding box.
- get_children(item=None)¶
Returns a tuple of children belonging to item.
item이 지정되지 않으면, 루트 자식을 반환합니다.
- set_children(item, *newchildren)¶
Replaces item’s children with newchildren.
item에 있지만 newchildren에 없는 자식은 트리에서 분리됩니다. newchildren의 어떤 항목도 item의 조상이 될 수 없습니다. newchildren을 지정하지 않으면 item의 자식이 분리됨에 유의하십시오.
- column(column, option=None, **kw)¶
지정된 column에 대한 옵션을 조회하거나 수정합니다.
kw가 제공되지 않으면, 열 옵션 값의 딕셔너리를 반환합니다. option이 지정되면 해당 option의 값이 반환됩니다. 그렇지 않으면, 옵션을 해당 값으로 설정합니다.
유효한 옵션/값은 다음과 같습니다:
- id
열 이름을 반환합니다. 이것은 읽기 전용 옵션입니다.
- anchor: 표준 Tk 앵커값 중 하나.
이 열의 텍스트가 셀을 기준으로 정렬되는 방법을 지정합니다.
- minwidth: 너비
열의 픽셀 단위의 최소 너비. 위젯의 크기가 조정되거나 사용자가 열을 드래그할 때 트리 뷰 위젯은 이 옵션으로 지정된 것보다 작게 열을 만들지 않습니다.
- stretch:
True/False 위젯 크기를 조정할 때 열 너비를 조정할지를 지정합니다.
- width: 너비
열의 픽셀 단위 너비.
트리 열을 구성하려면, column = “#0” 으로 호출하십시오.
- delete(*items)¶
지정된 items와 그들의 모든 자손을 삭제합니다.
루트 항목은 삭제되지 않을 수 있습니다.
- detach(*items)¶
지정된 items를 모두 트리에서 연결 해제합니다.
항목과 그들의 모든 자손은 여전히 존재하며, 트리의 다른 지점에 다시 삽입될 수 있지만, 표시되지는 않습니다.
루트 아이템은 분리되지 않을 수 있습니다.
- exists(item)¶
Returns
Trueif the specified item is present in the tree,Falseotherwise.
- focus(item=None)¶
item이 지정되면, 포커스 항목을 item으로 설정합니다. 그렇지 않으면, 현재 포커스 항목을 반환하거나, 없으면 ‘’ 을 반환합니다.
This shadows the inherited
Misc.focus(); usefocus_set()to focus the widget itself.
- heading(column, option=None, **kw)¶
지정된 column에 대한 제목(heading) 옵션을 조회하거나 수정합니다.
kw가 제공되지 않으면, 제목 옵션값의 딕셔너리를 반환합니다. option이 지정되면 해당 option의 값이 반환됩니다. 그렇지 않으면, 옵션을 해당 값으로 설정합니다.
유효한 옵션/값은 다음과 같습니다:
- text: 텍스트
열 제목에 표시할 텍스트.
- image: 이미지 이름
열 제목의 오른쪽에 표시할 이미지를 지정합니다.
- anchor: 앵커
제목 텍스트를 정렬하는 방법을 지정합니다. 표준 Tk 앵커값 중 하나입니다.
- command: 콜백
제목 레이블을 누를 때 호출되는 콜백.
트리 열 제목을 구성하려면, column = “#0” 으로 호출하십시오.
- identify(component, x, y)¶
x 와 y로 주어진 점 밑에 있는 지정된 component에 대한 설명을 반환하거나, 해당 component가 해당 위치에 없으면 빈 문자열을 반환합니다.
- identify_row(y)¶
y 위치에 있는 항목의 항목 ID를 반환합니다.
- identify_column(x)¶
Returns the display column identifier of the cell at position x.
트리 열의 ID는 #0 입니다.
- identify_region(x, y)¶
다음 중 하나를 반환합니다:
영역(region)
의미
heading
트리 제목 영역.
separator
두 열 제목 사이의 공간.
tree
트리 영역.
cell
데이터 셀.
가용성: Tk 8.6.
- identify_element(x, y)¶
위치 x, y에 있는 요소를 반환합니다.
가용성: Tk 8.6.
- index(item)¶
부모의 자식 리스트에서 item의 정수 인덱스를 반환합니다.
- insert(parent, index, iid=None, **kw)¶
새 항목을 만들고 새로 만들어진 항목의 항목 ID를 반환합니다.
parent는 부모 항목의 항목 ID이거나, 새 최상위 항목을 만들려면 빈 문자열입니다. index는 정수이거나, “end” 값으로, 부모의 자식 리스트에서 새 항목을 삽입할 위치를 지정합니다. index가 0보다 작거나 같으면, 새 노드가 처음에 삽입됩니다; index가 현재 자식 수보다 크거나 같으면, 끝에 삽입됩니다. iid가 지정되면, 항목 식별자로 사용됩니다; iid는 아직 트리에 존재하지 않아야 합니다. 그렇지 않으면, 새로운 고유 식별자가 생성됩니다.
사용 가능한 옵션 목록은 Item Options을 참조하십시오.
- item(item, option=None, **kw)¶
지정된 item에 대한 옵션을 조회하거나 수정합니다.
옵션이 제공되지 않으면 항목에 대한 옵션/값이 포함된 딕셔너리가 반환됩니다. option이 지정되면 해당 옵션의 값이 반환됩니다. 그렇지 않으면, 옵션을 kw에서 제공한 해당 값으로 설정합니다.
- move(item, parent, index)¶
item을 parent의 자식 리스트에서 index 위치로 이동합니다.
항목을 그 자신의 자손 항목 중 하나 밑으로 이동하는 것은 불법입니다. index가 0보다 작거나 같으면, item이 처음으로 이동합니다; 자식 수보다 크거나 같으면, 끝으로 이동합니다. item이 분리되었으면 다시 연결됩니다.
reattach()is an alias ofmove().
- next(item)¶
item의 다음 형제의 식별자를 반환하거나, item이 부모의 마지막 자식이면 ‘’ 을 반환합니다.
- parent(item)¶
item의 부모 ID를 반환하거나, item이 계층의 최상위에 있으면 ‘’ 을 반환합니다.
- prev(item)¶
item의 이전 형제의 식별자를 반환하거나, item이 부모의 첫 번째 자식이면 ‘’ 을 반환합니다.
- see(item)¶
item이 보이도록 합니다.
item의 모든 조상의 open 옵션을
True로 설정하고, 필요하면 위젯을 스크롤 하여 item이 트리의 보이는 부분 내에 있도록 합니다.
- selection()¶
선택한 항목의 튜플을 반환합니다.
버전 3.8에서 변경:
selection()은 더는 인자를 취하지 않습니다. 선택 상태를 변경하려면 다음 선택 메서드를 사용하십시오.
- selection_set(*items)¶
items가 새로운 선택이 됩니다.
버전 3.6에서 변경: items는 단일 튜플이 아닌 별도의 인자로 전달될 수 있습니다.
- selection_add(*items)¶
선택에 items를 추가합니다.
버전 3.6에서 변경: items는 단일 튜플이 아닌 별도의 인자로 전달될 수 있습니다.
- selection_remove(*items)¶
선택에서 items를 제거합니다.
버전 3.6에서 변경: items는 단일 튜플이 아닌 별도의 인자로 전달될 수 있습니다.
- selection_toggle(*items)¶
items에 있는 각 항목의 선택 상태를 토글 합니다.
버전 3.6에서 변경: items는 단일 튜플이 아닌 별도의 인자로 전달될 수 있습니다.
- set(item, column=None, value=None)¶
하나의 인자로는, 지정된 item에 대한 열/값 쌍 딕셔너리를 반환합니다. 두 개의 인자를 사용하면, 지정된 column의 현재 값을 반환합니다. 세 개의 인자를 사용하면, 지정된 item의 지정된 column의 값을, 지정된 value로 설정합니다.
- tag_bind(tagname, sequence=None, callback=None)¶
주어진 이벤트 sequence에 대한 콜백을 태그 tagname에 바인딩합니다. 이벤트가 항목에 전달되면, 각 항목의 태그 옵션에 대한 콜백이 호출됩니다.
- tag_configure(tagname, option=None, **kw)¶
지정된 tagname에 대한 옵션을 조회하거나 수정합니다.
kw가 제공되지 않으면, tagname에 대한 옵션 설정의 딕셔너리를 반환합니다. option이 지정되면, 지정된 tagname에 대한 해당 option의 값을 반환합니다. 그렇지 않으면, 옵션을 주어진 tagname에 대해 해당하는 값으로 설정합니다.
- tag_has(tagname, item=None)¶
If item is specified, returns
Trueif the specified item has the given tagname andFalseotherwise. Otherwise, returns a tuple of all items that have the specified tag.가용성: Tk 8.6
- xview(*args)¶
트리 뷰의 가로 위치를 조회하거나 수정합니다.
- yview(*args)¶
트리 뷰의 수직 위치를 조회하거나 수정합니다.
Ttk styling¶
Each widget in ttk is assigned a style, which specifies the set of
elements making up the widget and how they are arranged, along with dynamic and
default settings for element options.
By default the style name is the same as the widget’s class name, but it may be
overridden by the widget’s style option.
If you don’t know the class name of a widget, use the method
Misc.winfo_class (somewidget.winfo_class()).
더 보기
- Tcl’2004 conference presentation
이 문서는 테마 엔진의 작동 방식을 설명합니다
- class tkinter.ttk.Style¶
이 클래스는 스타일 데이터베이스를 조작하는 데 사용됩니다.
- configure(style, query_opt=None, **kw)¶
style에서 지정된 옵션의 기본값을 조회하거나 설정합니다.
kw의 각 키는 옵션이며 각 값은 해당 옵션의 값을 식별하는 문자열입니다.
예를 들어, 모든 기본 버튼을 패딩이 있고 배경색이 다른 평평한 버튼으로 바꾸려면:
from tkinter import ttk import tkinter root = tkinter.Tk() ttk.Style().configure("TButton", padding=6, relief="flat", background="#ccc") btn = ttk.Button(text="Sample") btn.pack() root.mainloop()
- map(style, query_opt=None, **kw)¶
style에서 지정된 옵션의 동적 값을 조회하거나 설정합니다.
kw의 각 키는 옵션이며 각 값은 (일반적으로) 튜플, 리스트 또는 다른 선호하는 것에 그룹화된 상태 명세(statespecs)를 포함하는 리스트나 튜플이어야 합니다. 상태 명세(statespec)는 하나 이상의 상태와 그다음에 값이 오는 복합체입니다.
예를 들면 더 이해하기 쉽습니다:
import tkinter from tkinter import ttk root = tkinter.Tk() style = ttk.Style() style.map("C.TButton", foreground=[('pressed', 'red'), ('active', 'blue')], background=[('pressed', '!disabled', 'black'), ('active', 'white')] ) colored_btn = ttk.Button(text="Test", style="C.TButton").pack() root.mainloop()
옵션의 (상태들, 값) 시퀀스의 순서는 중요함에 유의하십시오. 예를 들어, foreground 옵션에서 순서가
[('active', 'blue'), ('pressed', 'red')]로 변경되면, 예를 들어, 위젯이 active 나 pressed 상태일 때 결과는 파란색 전경이 됩니다.When called to query the map (without specifying values to set), it returns a dictionary mapping each option to its list of statespecs.
버전 3.10에서 변경: The value returned when querying the map was corrected.
- lookup(style, option, state=None, default=None)¶
style에서 option에 지정된 값을 반환합니다.
state가 지정되면, 하나 이상의 상태 시퀀스일 것으로 기대됩니다. default 인자가 설정되면, 옵션에 대한 명세가 없을 때 폴 백값으로 사용됩니다.
Button이 기본적으로 사용하는 글꼴을 확인하려면:
from tkinter import ttk print(ttk.Style().lookup("TButton", "font"))
- layout(style, layoutspec=None)¶
주어진 style에 대한 위젯 레이아웃을 정의합니다. layoutspec이 생략되면, 지정된 스타일의 레이아웃 명세를 반환합니다.
지정되면, layoutspec은 리스트나 다른 시퀀스 형(문자열 제외)이어야 합니다. 여기서 각 항목은 튜플이어야 하고 첫 번째 항목은 레이아웃 이름이고 두 번째 항목은 레이아웃에 설명된 형식이어야 합니다.
형식을 이해하려면, 다음 예제를 참조하십시오 (유용한 것은 아닙니다):
from tkinter import ttk import tkinter root = tkinter.Tk() style = ttk.Style() style.layout("TMenubutton", [ ("Menubutton.background", None), ("Menubutton.button", {"children": [("Menubutton.focus", {"children": [("Menubutton.padding", {"children": [("Menubutton.label", {"side": "left", "expand": 1})] })] })] }), ]) mbtn = ttk.Menubutton(text='Text') mbtn.pack() root.mainloop()
- element_create(elementname, etype, *args, **kw)¶
현재 테마에서 주어진 etype의 새 요소를 만듭니다. etype은 “image”, “from” 또는 “vsapi”일 것으로 기대됩니다. 마지막 것은 윈도우 용 Tk 8.6에서만 사용할 수 있습니다.
“image”를 사용하면, args는 기본 이미지 이름과 그 뒤에 오는 statespec/value 쌍 (이것이 이미지 명세(imagespec)입니다)을 포함해야 하며, kw에는 다음 옵션이 올 수 있습니다:
- border=padding
패딩은 각각 좌(left), 상(top), 우(right), 하(bottom) 테두리를 지정하는 최대 4개의 정수 리스트입니다.
- height=height
요소의 최소 높이를 지정합니다. 0보다 작으면, 기본 이미지의 높이가 기본값으로 사용됩니다.
- padding=padding
요소의 내부 패딩을 지정합니다. 지정하지 않으면 기본값은 border의 값입니다.
- sticky=spec
최종 파슬(parcel) 내에 이미지를 배치하는 방법을 지정합니다. 명세에는 0개 이상의 문자 “n”, “s”, “w” 또는 “e” 가 포함됩니다.
- width=width
요소의 최소 너비를 지정합니다. 0보다 작으면, 기본 이미지의 너비가 기본값으로 사용됩니다.
예제:
img1 = tkinter.PhotoImage(master=root, file='button.png') img1 = tkinter.PhotoImage(master=root, file='button-pressed.png') img1 = tkinter.PhotoImage(master=root, file='button-active.png') style = ttk.Style(root) style.element_create('Button.button', 'image', img1, ('pressed', img2), ('active', img3), border=(2, 4), sticky='we')
“from”이 etype의 값으로 사용되면,
element_create()는 기존 요소를 복제합니다. args는 요소를 복제할 테마 이름(themename)과, 선택적으로 요소를 복제할 요소를 포함할 것으로 기대됩니다. 복제할 요소를 지정하지 않으면, 빈 요소가 사용됩니다. kw는 폐기됩니다.예제:
style = ttk.Style(root) style.element_create('plain.background', 'from', 'default')
If “vsapi” is used as the value of etype,
element_create()will create a new element in the current theme whose visual appearance is drawn using the Microsoft Visual Styles API which is responsible for the themed styles on Windows XP and Vista. args is expected to contain the Visual Styles class and part as given in the Microsoft documentation followed by an optional sequence of tuples of ttk states and the corresponding Visual Styles API state value. kw may have the following options:- padding=padding
Specify the element’s interior padding. padding is a list of up to four integers specifying the left, top, right and bottom padding quantities respectively. If fewer than four elements are specified, bottom defaults to top, right defaults to left, and top defaults to left. In other words, a list of three numbers specify the left, vertical, and right padding; a list of two numbers specify the horizontal and the vertical padding; a single number specifies the same padding all the way around the widget. This option may not be mixed with any other options.
- margins=padding
요소 외부 패딩을 지정합니다. padding은 각각 좌(left), 상(top), 우(right), 하(bottom) 패딩량을 지정하는 최대 4개의 정수 리스트입니다. 이 옵션은 다른 옵션과 함께 사용할 수 없습니다.
- width=width
Specifies the width for the element. If this option is set then the Visual Styles API will not be queried for the recommended size or the part. If this option is set then height should also be set. The width and height options cannot be mixed with the padding or margins options.
- height=height
Specifies the height of the element. See the comments for width.
예제:
style = ttk.Style(root) style.element_create('pin', 'vsapi', 'EXPLORERBAR', 3, [ ('pressed', '!selected', 3), ('active', '!selected', 2), ('pressed', 'selected', 6), ('active', 'selected', 5), ('selected', 4), ('', 1)]) style.layout('Explorer.Pin', [('Explorer.Pin.pin', {'sticky': 'news'})]) pin = ttk.Checkbutton(style='Explorer.Pin') pin.pack(expand=True, fill='both')
버전 3.13에서 변경: Added support of the “vsapi” element factory.
- element_names()¶
Returns a tuple of elements defined in the current theme.
- element_options(elementname)¶
Returns a tuple of elementname’s options.
- theme_create(themename, parent=None, settings=None)¶
새로운 테마를 만듭니다.
themename이 이미 존재하면 에러입니다. parent가 지정되면, 새 테마는 부모 테마에서 스타일, 요소 및 레이아웃을 상속합니다. settings가 있으면,
theme_settings()에 사용되는 것과 같은 문법일 것으로 기대됩니다.
- theme_settings(themename, settings)¶
현재 테마를 themename으로 임시 설정하고, 지정된 settings를 적용한 다음 이전 테마를 복원합니다.
settings의 각 키는 스타일이며 각 값에는 ‘configure’, ‘map’, ‘layout’ 및 ‘element create’ 키가 포함될 수 있으며 각각
Style.configure(),Style.map(),Style.layout()및Style.element_create()가 지정한 것과 같은 형식을 갖습니다.예를 들어, 기본 테마의 Combobox를 약간 변경해 봅시다:
from tkinter import ttk import tkinter root = tkinter.Tk() style = ttk.Style() style.theme_settings("default", { "TCombobox": { "configure": {"padding": 5}, "map": { "background": [("active", "green2"), ("!disabled", "green4")], "fieldbackground": [("!disabled", "green3")], "foreground": [("focus", "OliveDrab1"), ("!disabled", "OliveDrab2")] } } }) combo = ttk.Combobox().pack() root.mainloop()
- theme_names()¶
Returns a tuple of all known themes.
- theme_use(themename=None)¶
themename이 제공되지 않으면, 사용 중인 테마를 반환합니다. 그렇지 않으면, 현재 테마를 themename으로 설정하고, 모든 위젯을 새로 고치고 <<ThemeChanged>> 이벤트를 방출합니다.
레이아웃¶
레이아웃은 옵션을 취하지 않으면 None일 수 있습니다, 또는 요소를 정렬하는 방법을 지정하는 옵션의 딕셔너리입니다. 레이아웃 메커니즘은 pack 지오메트리 관리자의 단순화 된 버전을 사용합니다: 초기 캐비티(cavity)가 주어지면, 각 요소에는 파슬(parcel)이 할당됩니다.
유효한 옵션/값은 다음과 같습니다:
- side: whichside
요소를 배치할 캐비티(cavity)의 변을 지정합니다; 상(top), 우(right), 하(bottom) 또는 좌(left) 중 하나입니다. 생략하면, 요소가 전체 캐비티를 차지합니다.
- sticky: nswe
할당된 파슬(parcel)에서 요소가 배치되는 위치를 지정합니다.
- unit: 0 또는 1
1로 설정하면,
Widget.identify()등의 목적으로 요소와 그것의 모든 자손이 단일 요소로 처리됩니다. 그립이 있는 스크롤 막대 썸(thumbs)과 같은 것들에 사용됩니다.- children: [sublayout… ]
요소 안에 배치할 요소 리스트를 지정합니다. 각 요소는 첫 번째 항목이 레이아웃 이름이고, 다른 하나는 레이아웃인 튜플(또는 다른 시퀀스 형)입니다.
Additional widgets¶
The following themed widgets complete the tkinter.ttk widget set.
Each is the themed counterpart of the like-named classic tkinter widget
and inherits the common methods of Widget.
- class tkinter.ttk.Button(master=None, **kw)¶
Ttk
Buttonwidget, displays a textual label and/or image, and evaluates a command when pressed. It is the themed counterpart oftkinter.Buttonand inherits the common widget methods fromWidget.- invoke()¶
Invoke the command associated with the button and return its result.
- class tkinter.ttk.Checkbutton(master=None, **kw)¶
Ttk
Checkbuttonwidget, used to control a boolean variable that is toggled on and off. It is the themed counterpart oftkinter.Checkbuttonand inherits the common widget methods fromWidget.- invoke()¶
Toggle the button between its selected and deselected states, invoke the command associated with the button, and return its result.
- class tkinter.ttk.Entry(master=None, widget=None, **kw)¶
Ttk
Entrywidget, displays a one-line text string and allows the user to edit it. It is the themed counterpart oftkinter.Entryand inherits the common widget methods fromWidgetas well as the editing methods fromtkinter.Entry.- bbox(index)¶
Return a tuple
(x, y, width, height)giving the bounding box of the character at the given index.This shadows the inherited
Misc.bbox(); usegrid_bbox()for the grid bounding box.
- identify(x, y)¶
Return the name of the element under the point given by x and y, or the empty string if no element is present at that location.
- validate()¶
Force validation of the entry and return
Trueif validation succeeded, andFalseotherwise.
- class tkinter.ttk.Frame(master=None, **kw)¶
Ttk
Framewidget, a container used to group and lay out other widgets. It is the themed counterpart oftkinter.Frameand inherits the common widget methods fromWidget.
- class tkinter.ttk.Label(master=None, **kw)¶
Ttk
Labelwidget, displays a textual label and/or image. It is the themed counterpart oftkinter.Labeland inherits the common widget methods fromWidget.
- class tkinter.ttk.Labelframe(master=None, **kw)¶
Ttk
Labelframewidget, a container that draws a border and a title label around its contents. It is the themed counterpart oftkinter.LabelFrameand inherits the common widget methods fromWidget.
- class tkinter.ttk.Menubutton(master=None, **kw)¶
Ttk
Menubuttonwidget, displays a textual label and/or image, and pops up a menu when pressed. It is the themed counterpart oftkinter.Menubuttonand inherits the common widget methods fromWidget.
- class tkinter.ttk.OptionMenu(master, variable, default=None, *values, **kwargs)¶
Ttk
OptionMenuwidget, aMenubuttonthat pops up a menu of mutually exclusive choices. variable is the variable that tracks the currently selected value, default is the value to set initially, and values are the entries to display in the menu. A command keyword argument may be given to specify a callable that is invoked with the selected value whenever the selection changes; the style keyword argument sets the style used by the underlying menubutton; and the name keyword argument sets the Tk widget name.Replace the entries of the menu with values. If default is given, also set it as the current value of the variable.
- destroy()¶
Destroy this widget and its associated menu.
버전 3.14에서 변경: Added support for the name keyword argument.
- class tkinter.ttk.Panedwindow(master=None, **kw)¶
Ttk
Panedwindowwidget, displays a number of subwindows stacked either vertically or horizontally. The user may adjust the relative sizes of the subwindows by dragging the sash between panes. It is the themed counterpart oftkinter.PanedWindowand inherits the common widget methods fromWidget, as well as theadd()andpanes()methods fromtkinter.PanedWindow.- insert(pos, child, **kw)¶
Insert a pane containing child at the position pos. pos is either the string
'end', an integer index, or the name of a managed subwindow. If child is already managed by the paned window, move it to the specified position. Any keyword arguments set pane options.
- forget(child)¶
Remove child, which may be either an integer index or the name of a managed subwindow, from the panes.
This shadows the inherited geometry-manager
forget(); usepack_forget(),grid_forget()orplace_forget()to remove the widget itself from its manager.
- pane(pane, option=None, **kw)¶
Query or modify the options of the specified pane, where pane is either an integer index or the name of a managed subwindow. If no arguments are given, return a dictionary of the pane option values. If option is specified, return the value of that option. Otherwise, set the options given as keyword arguments to their corresponding values.
- sashpos(index, newpos=None)¶
If newpos is specified, set the position of sash number index and return its new position. This may adjust the positions of adjacent sashes to ensure that positions are monotonically increasing; positions are also constrained to be between 0 and the total size of the widget. If newpos is omitted, return the current position of the sash.
- class tkinter.ttk.Radiobutton(master=None, **kw)¶
Ttk
Radiobuttonwidget, used as part of a group to control a single shared variable by selecting one of several mutually exclusive values. It is the themed counterpart oftkinter.Radiobuttonand inherits the common widget methods fromWidget.- invoke()¶
Set the option variable to the button’s value, select the button, invoke the command associated with the button, and return its result.
- class tkinter.ttk.Scale(master=None, **kw)¶
Ttk
Scalewidget, displays a slider that lets the user select a numeric value from a range by moving the slider along a trough. It is the themed counterpart oftkinter.Scaleand inherits the common widget methods fromWidget.- configure(cnf=None, **kw)¶
Modify or query the widget options, like
Widget.configure. In addition, this method clips thefromandtovalues so that the current value stays within the range defined by them.버전 3.9에서 변경: Now returns the configuration value, like
Widget.configure.
- get(x=None, y=None)¶
Return the current value of the scale. If x and y are given, return the value corresponding to the pixel coordinate x, y instead.
- class tkinter.ttk.Scrollbar(master=None, **kw)¶
Ttk
Scrollbarwidget, controls the viewport of an associated scrollable widget such as aTreeview,Entryortkinter.Text. It is the themed counterpart oftkinter.Scrollbarand inherits the common widget methods fromWidget, as well as theset()andget()methods fromtkinter.Scrollbar.
- class tkinter.ttk.Separator(master=None, **kw)¶
Ttk
Separatorwidget, displays a horizontal or vertical separator line. It has no direct counterpart intkinterand inherits the common widget methods fromWidget.
- class tkinter.ttk.Sizegrip(master=None, **kw)¶
Ttk
Sizegripwidget, displays a grip that allows the user to resize the containing toplevel window by pressing and dragging the grip, typically placed in the bottom-right corner. It has no direct counterpart intkinterand inherits the common widget methods fromWidget.
- class tkinter.ttk.LabeledScale(master=None, variable=None, from_=0, to=10, **kw)¶
A
Framecontaining aScaleand aLabelthat shows the scale’s current value. variable is theIntVartracked by the scale (one is created if it is not given), and from_ and to define the range of the scale.- destroy()¶
Destroy this widget and remove the trace callback registered on the associated variable.
- class tkinter.ttk.LabelFrame(master=None, **kw)¶
Alias of
Labelframe, kept for naming compatibility withtkinter.LabelFrame.
- class tkinter.ttk.PanedWindow(master=None, **kw)¶
Alias of
Panedwindow, kept for naming compatibility withtkinter.PanedWindow.