Документация Python неофициальный перевод

tk.md

114 строк · 12.2 КБ · обычная страница · сырой текст · скачать

1> **Источник:** https://python-all.ru/3.1/library/tk.html2>3> «Документация Python на русском» – неофициальный перевод официальной документации Python: версии от 2.6 до 3.16, полнотекстовый поиск, английский оригинал рядом с переводом. Эта Markdown-версия страницы предназначена для работы с LLM: вставьте её в ChatGPT, Claude или Cursor.45---67# 24. Графические интерфейсы пользователя с Tk89Tk/Tcl уже давно является неотъемлемой частью Python. Он предоставляет надежный и независимый от платформы набор инструментов для работы с окнами, доступный программистам Python через пакет [`tkinter`](https://python-all.ru/3.1/library/tkinter.html#module-tkinter) и его расширения – модули [`tkinter.tix`](https://python-all.ru/3.1/library/tkinter.tix.html#module-tkinter.tix) и [`tkinter.ttk`](https://python-all.ru/3.1/library/tkinter.ttk.html#module-tkinter.ttk).1011Пакет [`tkinter`](https://python-all.ru/3.1/library/tkinter.html#module-tkinter) представляет собой тонкий объектно-ориентированный слой поверх Tcl/Tk. Для использования [`tkinter`](https://python-all.ru/3.1/library/tkinter.html#module-tkinter) не требуется писать код на Tcl, но потребуется обращаться к документации Tk, а иногда и к документации Tcl. [`tkinter`](https://python-all.ru/3.1/library/tkinter.html#module-tkinter) – это набор обёрток, реализующих виджеты Tk в виде классов Python. Кроме того, внутренний модуль `_tkinter` предоставляет потокобезопасный механизм, позволяющий Python и Tcl взаимодействовать.1213Главные достоинства [`tkinter`](https://python-all.ru/3.1/library/tkinter.html#module-tkinter) – это его быстродействие и то, что он обычно поставляется вместе с Python. Хотя его стандартная документация слабая, существует хороший материал: справочники, учебники, книга и другое. [`tkinter`](https://python-all.ru/3.1/library/tkinter.html#module-tkinter) также известен своим устаревшим внешним видом, который был значительно улучшен в Tk 8.5. Тем не менее, существует множество других библиотек GUI, которые могут вас заинтересовать. Дополнительную информацию об альтернативах см. в разделе [*Другие пакеты графического интерфейса пользователя*](https://python-all.ru/3.1/library/othergui.html#other-gui-packages).1415- [24.1. `tkinter` – интерфейс Python к Tcl/Tk](https://python-all.ru/3.1/library/tkinter.html)1617  - [24.1.1. Модули Tkinter](https://python-all.ru/3.1/library/tkinter.html#tkinter-modules)18  - [24.1.2. Жизненный спасатель Tkinter](https://python-all.ru/3.1/library/tkinter.html#tkinter-life-preserver)1920    - [24.1.2.1. Как использовать этот раздел](https://python-all.ru/3.1/library/tkinter.html#how-to-use-this-section)21    - [24.1.2.2. Простая программа Hello World](https://python-all.ru/3.1/library/tkinter.html#a-simple-hello-world-program)22  - [24.1.3. Очень быстрый взгляд на Tcl/Tk](https://python-all.ru/3.1/library/tkinter.html#a-very-quick-look-at-tcl-tk)23  - [24.1.4. Отображение базового Tk в Tkinter](https://python-all.ru/3.1/library/tkinter.html#mapping-basic-tk-into-tkinter)24  - [24.1.5. Как связаны Tk и Tkinter](https://python-all.ru/3.1/library/tkinter.html#how-tk-and-tkinter-are-related)25  - [24.1.6. Удобный справочник](https://python-all.ru/3.1/library/tkinter.html#handy-reference)2627    - [24.1.6.1. Настройка параметров](https://python-all.ru/3.1/library/tkinter.html#setting-options)28    - [24.1.6.2. Упаковщик](https://python-all.ru/3.1/library/tkinter.html#the-packer)29    - [24.1.6.3. Параметры упаковщика](https://python-all.ru/3.1/library/tkinter.html#packer-options)30    - [24.1.6.4. Привязка переменных виджетов](https://python-all.ru/3.1/library/tkinter.html#coupling-widget-variables)31    - [24.1.6.5. Менеджер окон](https://python-all.ru/3.1/library/tkinter.html#the-window-manager)32    - [24.1.6.6. Типы данных параметров Tk](https://python-all.ru/3.1/library/tkinter.html#tk-option-data-types)33    - [24.1.6.7. Привязки и события](https://python-all.ru/3.1/library/tkinter.html#bindings-and-events)34    - [24.1.6.8. Параметр index](https://python-all.ru/3.1/library/tkinter.html#the-index-parameter)35    - [24.1.6.9. Изображения](https://python-all.ru/3.1/library/tkinter.html#images)36- [24.2. `tkinter.ttk` – тематические виджеты Tk](https://python-all.ru/3.1/library/tkinter.ttk.html)3738  - [24.2.1. Использование Ttk](https://python-all.ru/3.1/library/tkinter.ttk.html#using-ttk)39  - [24.2.2. Виджеты Ttk](https://python-all.ru/3.1/library/tkinter.ttk.html#ttk-widgets)40  - [24.2.3. Виджет](https://python-all.ru/3.1/library/tkinter.ttk.html#widget)4142    - [24.2.3.1. Стандартные параметры](https://python-all.ru/3.1/library/tkinter.ttk.html#standard-options)43    - [24.2.3.2. Параметры прокручиваемого виджета](https://python-all.ru/3.1/library/tkinter.ttk.html#scrollable-widget-options)44    - [24.2.3.3. Параметры метки](https://python-all.ru/3.1/library/tkinter.ttk.html#label-options)45    - [24.2.3.4. Параметры совместимости](https://python-all.ru/3.1/library/tkinter.ttk.html#compatibility-options)46    - [24.2.3.5. Состояния виджетов](https://python-all.ru/3.1/library/tkinter.ttk.html#widget-states)47    - [24.2.3.6. ttk.Widget](https://python-all.ru/3.1/library/tkinter.ttk.html#ttk-widget)48  - [24.2.4. Combobox](https://python-all.ru/3.1/library/tkinter.ttk.html#combobox)4950    - [24.2.4.1. Параметры](https://python-all.ru/3.1/library/tkinter.ttk.html#options)51    - [24.2.4.2. Виртуальные события](https://python-all.ru/3.1/library/tkinter.ttk.html#virtual-events)52    - [24.2.4.3. ttk.Combobox](https://python-all.ru/3.1/library/tkinter.ttk.html#ttk-combobox)53  - [24.2.5. Notebook](https://python-all.ru/3.1/library/tkinter.ttk.html#notebook)5455    - [24.2.5.1. Параметры](https://python-all.ru/3.1/library/tkinter.ttk.html#id1)56    - [24.2.5.2. Параметры вкладок](https://python-all.ru/3.1/library/tkinter.ttk.html#tab-options)57    - [24.2.5.3. Идентификаторы вкладок](https://python-all.ru/3.1/library/tkinter.ttk.html#tab-identifiers)58    - [24.2.5.4. Виртуальные события](https://python-all.ru/3.1/library/tkinter.ttk.html#id2)59    - [24.2.5.5. ttk.Notebook](https://python-all.ru/3.1/library/tkinter.ttk.html#ttk-notebook)60  - [24.2.6. Progressbar](https://python-all.ru/3.1/library/tkinter.ttk.html#progressbar)6162    - [24.2.6.1. Параметры](https://python-all.ru/3.1/library/tkinter.ttk.html#id3)63    - [24.2.6.2. ttk.Progressbar](https://python-all.ru/3.1/library/tkinter.ttk.html#ttk-progressbar)64  - [24.2.7. Separator](https://python-all.ru/3.1/library/tkinter.ttk.html#separator)6566    - [24.2.7.1. Параметры](https://python-all.ru/3.1/library/tkinter.ttk.html#id4)67  - [24.2.8. Sizegrip](https://python-all.ru/3.1/library/tkinter.ttk.html#sizegrip)6869    - [24.2.8.1. Примечания для конкретных платформ](https://python-all.ru/3.1/library/tkinter.ttk.html#platform-specific-notes)70    - [24.2.8.2. Ошибки](https://python-all.ru/3.1/library/tkinter.ttk.html#bugs)71  - [24.2.9. Treeview](https://python-all.ru/3.1/library/tkinter.ttk.html#treeview)7273    - [24.2.9.1. Параметры](https://python-all.ru/3.1/library/tkinter.ttk.html#id5)74    - [24.2.9.2. Параметры элементов](https://python-all.ru/3.1/library/tkinter.ttk.html#item-options)75    - [24.2.9.3. Параметры тегов](https://python-all.ru/3.1/library/tkinter.ttk.html#tag-options)76    - [24.2.9.4. Идентификаторы столбцов](https://python-all.ru/3.1/library/tkinter.ttk.html#column-identifiers)77    - [24.2.9.5. Виртуальные события](https://python-all.ru/3.1/library/tkinter.ttk.html#id6)78    - [24.2.9.6. ttk.Treeview](https://python-all.ru/3.1/library/tkinter.ttk.html#ttk-treeview)79  - [24.2.10. Стилизация Ttk](https://python-all.ru/3.1/library/tkinter.ttk.html#ttk-styling)8081    - [24.2.10.1. Макеты](https://python-all.ru/3.1/library/tkinter.ttk.html#layouts)82- [24.3. `tkinter.tix` – Расширяющие виджеты для Tk](https://python-all.ru/3.1/library/tkinter.tix.html)8384  - [24.3.1. Использование Tix](https://python-all.ru/3.1/library/tkinter.tix.html#using-tix)85  - [24.3.2. Виджеты Tix](https://python-all.ru/3.1/library/tkinter.tix.html#tix-widgets)8687    - [24.3.2.1. Базовые виджеты](https://python-all.ru/3.1/library/tkinter.tix.html#basic-widgets)88    - [24.3.2.2. Селекторы файлов](https://python-all.ru/3.1/library/tkinter.tix.html#file-selectors)89    - [24.3.2.3. Иерархический ListBox](https://python-all.ru/3.1/library/tkinter.tix.html#hierarchical-listbox)90    - [24.3.2.4. Табличный ListBox](https://python-all.ru/3.1/library/tkinter.tix.html#tabular-listbox)91    - [24.3.2.5. Виджеты-менеджеры](https://python-all.ru/3.1/library/tkinter.tix.html#manager-widgets)92    - [24.3.2.6. Типы изображений](https://python-all.ru/3.1/library/tkinter.tix.html#image-types)93    - [24.3.2.7. Прочие виджеты](https://python-all.ru/3.1/library/tkinter.tix.html#miscellaneous-widgets)94    - [24.3.2.8. Менеджер геометрии Form](https://python-all.ru/3.1/library/tkinter.tix.html#form-geometry-manager)95  - [24.3.3. Команды Tix](https://python-all.ru/3.1/library/tkinter.tix.html#tix-commands)96- [24.4. `tkinter.scrolledtext` – Виджет прокручиваемого текста](https://python-all.ru/3.1/library/tkinter.scrolledtext.html)97- [24.5. IDLE](https://python-all.ru/3.1/library/idle.html)9899  - [24.5.1. Меню](https://python-all.ru/3.1/library/idle.html#menus)100101    - [24.5.1.1. Меню «Файл»](https://python-all.ru/3.1/library/idle.html#file-menu)102    - [24.5.1.2. Меню «Правка»](https://python-all.ru/3.1/library/idle.html#edit-menu)103    - [24.5.1.3. Меню «Окна»](https://python-all.ru/3.1/library/idle.html#windows-menu)104    - [24.5.1.4. Меню отладки (только в окне Python Shell)](https://python-all.ru/3.1/library/idle.html#debug-menu-in-the-python-shell-window-only)105  - [24.5.2. Основы редактирования и навигации](https://python-all.ru/3.1/library/idle.html#basic-editing-and-navigation)106107    - [24.5.2.1. Автоматический отступ](https://python-all.ru/3.1/library/idle.html#automatic-indentation)108    - [24.5.2.2. Окно оболочки Python](https://python-all.ru/3.1/library/idle.html#python-shell-window)109  - [24.5.3. Цвета синтаксиса](https://python-all.ru/3.1/library/idle.html#syntax-colors)110  - [24.5.4. Запуск](https://python-all.ru/3.1/library/idle.html#startup)111112    - [24.5.4.1. Использование командной строки](https://python-all.ru/3.1/library/idle.html#command-line-usage)113- [24.6. Другие пакеты графического интерфейса пользователя](https://python-all.ru/3.1/library/othergui.html)114