Skip to main content

为 tkinter 提供常用字符串常量和增强功能

Project description

🧩 TkinterTabMore —— 为 Tkinter 提供常用常量和更多功能

✨ 简介 / Introduction

TkinterTabMore 是一个为 Python 的 tkinter 模块提供常用字符串常量和增强功能的辅助模块,旨在提升开发效率并减少拼写错误。

TkinterTabMore is a helper module that provides commonly used string constants and enhanced features for the Python tkinter module, aiming to improve development efficiency and reduce typos.


📦 安装 / Installation

pip install TkinterTabMore

📚 使用示例 / Usage Example

from tkinter import *
from TkinterTabMore import WM_DELETE_WINDOW, CURSOR_HAND, RELIEF_RAISED

root = Tk()
root.protocol(WM_DELETE_WINDOW, root.destroy)

btn = Button(root, text="点击 / Click", cursor=CURSOR_HAND, relief=RELIEF_RAISED)
btn.pack()

root.mainloop()

📄 第 2 段:窗口管理器协议 + 拖放支持(Xdnd)


📋 支持的常量列表 / Supported Constants

1. 🔧 窗口管理器协议 / Window Manager Protocols

  • WM_DELETE_WINDOW = "WM_DELETE_WINDOW"
    窗口关闭协议 / Window close protocol
  • WM_PROTOCOL_MESSAGE = "WM_PROTOCOL_MESSAGE"
    窗口管理器通信消息 / Window manager communication message

2. 🖱️ 拖放支持(Xdnd) / Drag and Drop (Xdnd)

  • XdndEnter = "XdndEnter"
    拖放进入窗口事件 / Drag enters the window
  • XdndPosition = "XdndPosition"
    拖放位置更新事件 / Drag position update event
  • XdndDrop = "XdndDrop"
    拖放释放事件 / Drop event
  • XdndStatus = "XdndStatus"
    拖放状态反馈事件 / Drag status feedback event
  • XdndLeave = "XdndLeave"
    拖放离开窗口事件 / Drag leaves the window
  • XdndFinished = "XdndFinished"
    拖放结束事件 / Drag finished event
  • XdndSelection = "XdndSelection"
    拖放数据请求事件 / Drag data request event
  • XdndActionCopy = "XdndActionCopy"
    拖放复制操作 / Copy action in drag and drop
  • XdndActionMove = "XdndActionMove"
    拖放移动操作 / Move action in drag and drop
  • XdndActionLink = "XdndActionLink"
    拖放链接操作 / Link action in drag and drop
  • XdndActionAsk = "XdndActionAsk"
    拖放询问用户操作 / Ask user action in drag and drop

3. 📋 剪贴板 / Clipboard

  • CLIPBOARD = "CLIPBOARD"
    系统剪贴板名称 / System clipboard name
  • PRIMARY = "PRIMARY"
    主选剪贴板名称(X11) / Primary selection clipboard (X11)
  • TARGETS = "TARGETS"
    剪贴板数据类型列表 / Clipboard data type list

4. 🎯 虚拟事件 / Virtual Events

  • VIRTUAL_EVENT_PREFIX = "<<"
    虚拟事件前缀 / Prefix for virtual events
  • VIRTUAL_EVENT_SUFFIX = ">>"
    虚拟事件后缀 / Suffix for virtual events

5. 📦 Tk 版本 / Tk Versions

  • TK_VERSION = "tk_version"
    Tk 当前版本号字符串 / Current Tk version string
  • TK_PATCHLEVEL = "tk_patchLevel"
    Tk 补丁级别 / Tk patch level

6. 📁 文件类型 / File Types

  • FILE_TYPES_ALL = "*.*"
    所有文件类型 / All file types
  • FILE_TYPES_TEXT = "*.txt"
    文本文件 / Text file type (*.txt)
  • FILE_TYPES_PYTHON = "*.py"
    Python 源代码文件 / Python source files (*.py)
  • FILE_TYPES_IMAGE = "*.png *.jpg *.jpeg *.gif *.bmp"
    图像文件 / Image files (*.png, *.jpg, etc.)
  • FILE_TYPES_JSON = "*.json"
    JSON 数据文件 / JSON data files (*.json)
  • FILE_TYPES_CSV = "*.csv"
    CSV 表格文件 / CSV table files (*.csv)

7. 🖱️ 鼠标光标 / Mouse Cursors

  • CURSOR_ARROW = "arrow"
    箭头光标 / Arrow cursor
  • CURSOR_HAND = "hand2"
    手型光标 / Hand cursor
  • CURSOR_XTERM = "xterm"
    文本输入光标 / Text input cursor
  • CURSOR_CROSSHAIR = "crosshair"
    十字光标 / Crosshair cursor
  • CURSOR_WAIT = "watch"
    等待光标 / Wait cursor
  • CURSOR_SIZE_NW_SE = "size_nw_se"
    西北-东南调整光标 / NW-SE resize cursor
  • CURSOR_SIZE_NE_SW = "size_ne_sw"
    东北-西南调整光标 / NE-SW resize cursor
  • CURSOR_SIZE_HOR = "sb_h_double_arrow"
    水平调整光标 / Horizontal resize cursor
  • CURSOR_SIZE_VER = "sb_v_double_arrow"
    垂直调整光标 / Vertical resize cursor

8. ⚙️ 控件状态 / Widget States

  • STATE_NORMAL = "normal"
    控件可用状态 / Widget is enabled and interactive
  • STATE_DISABLED = "disabled"
    控件禁用状态 / Widget is disabled
  • STATE_READONLY = "readonly"
    控件只读状态 / Widget is read-only

9. 🧭 锚点位置 / Anchor Positions

  • ANCHOR_CENTER = "center"
    居中对齐 / Center alignment
  • ANCHOR_N = "n"
    北对齐(上) / North (top) alignment
  • ANCHOR_S = "s"
    南对齐(下) / South (bottom) alignment
  • ANCHOR_E = "e"
    东对齐(右) / East (right) alignment
  • ANCHOR_W = "w"
    西对齐(左) / West (left) alignment
  • ANCHOR_NE = "ne"
    东北对齐 / Northeast alignment
  • ANCHOR_NW = "nw"
    西北对齐 / Northwest alignment
  • ANCHOR_SE = "se"
    东南对齐 / Southeast alignment
  • ANCHOR_SW = "sw"
    西南对齐 / Southwest alignment

10. 📐 布局扩展 / Layout Expand Options

  • EXPAND_BOTH = "both"
    同时扩展 / Expand both horizontally and vertically
  • EXPAND_X = "x"
    横向扩展 / Expand horizontally
  • EXPAND_Y = "y"
    纵向扩展 / Expand vertically

11. 📦 填充方向 / Fill Options

  • FILL_X = "x"
    横向填充 / Fill horizontally
  • FILL_Y = "y"
    纵向填充 / Fill vertically
  • FILL_BOTH = "both"
    横纵填充 / Fill both directions
  • FILL_NONE = "none"
    不填充 / No fill

12. 🧱 排列方向 / Layout Side Options

  • SIDE_TOP = "top"
    顶部排列 / Pack to the top
  • SIDE_BOTTOM = "bottom"
    底部排列 / Pack to the bottom
  • SIDE_LEFT = "left"
    左侧排列 / Pack to the left
  • SIDE_RIGHT = "right"
    右侧排列 / Pack to the right

13. 📐 对齐方式 / Justify Options

  • JUSTIFY_LEFT = "left"
    左对齐 / Left justify
  • JUSTIFY_CENTER = "center"
    居中对齐 / Center justify
  • JUSTIFY_RIGHT = "right"
    右对齐 / Right justify

14. 🧱 边框样式 / Relief Styles

  • RELIEF_RAISED = "raised"
    凸起边框样式 / Raised relief style
  • RELIEF_SUNKEN = "sunken"
    凹陷边框样式 / Sunken relief style
  • RELIEF_FLAT = "flat"
    平直边框样式 / Flat relief style
  • RELIEF_GROOVE = "groove"
    沟槽边框样式 / Groove relief style
  • RELIEF_RIDGE = "ridge"
    山脊边框样式 / Ridge relief style
  • RELIEF_SOLID = "solid"
    实线边框样式 / Solid relief style

15. 🔤 其他常用值 / Other Useful Constants

  • YES = "yes"
    Tkinter 中的“是”值 / 'yes' in layout options
  • NO = "no"
    Tkinter 中的“否”值 / 'no' in layout options
  • TRUE = "1"
    Tkinter 中的“真”值 / '1' as True
  • FALSE = "0"
    Tkinter 中的“假”值 / '0' as False
  • DEFAULT = "default"
    Tkinter 中默认选项 / Default option

🙌 感谢使用 / Thanks for Using

感谢你使用 TkinterTabMore!如果你有任何建议或问题,欢迎提交 issue 或 PR。
Thanks for using TkinterTabMore! If you have any suggestions or issues, feel free to open an issue or pull request.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tkintertabmore-0.0.1.tar.gz (6.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tkintertabmore-0.0.1-py3-none-any.whl (8.1 kB view details)

Uploaded Python 3

File details

Details for the file tkintertabmore-0.0.1.tar.gz.

File metadata

  • Download URL: tkintertabmore-0.0.1.tar.gz
  • Upload date:
  • Size: 6.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.5

File hashes

Hashes for tkintertabmore-0.0.1.tar.gz
Algorithm Hash digest
SHA256 3e569e1f791f6d02059598e6645c1f5f3286ed28e057eed3581e6d32aaf47e51
MD5 785a86ca4d2113f2208e461500c94bfa
BLAKE2b-256 9842192d7c27e10465129906d92df7d7d62801be476461812b504963471c5207

See more details on using hashes here.

File details

Details for the file tkintertabmore-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: tkintertabmore-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 8.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.5

File hashes

Hashes for tkintertabmore-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a5c0eb09fe17de926a3a199739adc80301896da15c6e026e9d5e67b97d41363e
MD5 d121531928ceab2f7d01f8beb65eb71d
BLAKE2b-256 ed2003d43dd8e0ab8d6a716d00bff6c7ec2747762944ad5a56f9ad15d61e10a7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page