Skip to main content

Extended widget with a context menu for tkinter, including Cut, Copy, and Paste commands.

Project description

context_menu_widget

PyPI version License: MIT

Description

ContextMenuWidget is a Python package that provides an extended tk.Menu class with a context menu for specified widgets, including commands like Cut, Copy, Paste, and Select All.

Installation

Install the package using pip:

pip install ContextMenuWidget

Usage

from contextmenuwidget import ContextMenuWidget

Current version : V1.0.7

Release Notes

Version 1.0.7 (March 15, 2024)

  • Removing line breaks in Entry widgets

Version 1.0.7 (March 07, 2024)

  • Updating README.md

Version 1.0.5 (March 03, 2024)

  • Fixed a bug related to displaying shortcut (MacOS)

Example usage of the ContextMenuWidget class

import tkinter as tk
from contextmenuwidget import ContextMenuWidget

root = tk.Tk()

label_entry = tk.Label(root, text="Entry Widget : ")
label_entry.grid(column=0, row=0, sticky="w")

widget_entry = tk.Entry(root, width=31)
widget_entry.grid(column=1, row=0, sticky="w")
context_menu = ContextMenuWidget(widget_entry)

label_text = tk.Label(root, text="Text Widget : ")
label_text.grid(column=0, row=1, sticky="wn")

widget_text = tk.Text(root, height=13, width=31, wrap=tk.NONE)
widget_text.grid(column=1, row=1, sticky="w")
context_menu = ContextMenuWidget(widget_text)

vertical_scrollbar = tk.Scrollbar(root, orient=tk.VERTICAL)
vertical_scrollbar.grid(column=2, row=1, sticky="ns")
widget_text.config(yscrollcommand=vertical_scrollbar.set)
vertical_scrollbar.config(command=widget_text.yview)

horizontal_scrollbar = tk.Scrollbar(root, orient=tk.HORIZONTAL)
horizontal_scrollbar.grid(column=1, row=2, sticky="we")
widget_text.config(xscrollcommand=horizontal_scrollbar.set)
horizontal_scrollbar.config(command=widget_text.xview)

root.mainloop()

Features

Context Menu: Extends tk.Menu with Cut, Copy, Paste, and Select All commands. Icons: Utilizes icons for visual representation of menu commands. Dynamic Updates: Dynamically updates menu entry states based on widget content and clipboard status. Cross-Platform: Supports right-click events on different platforms.

Dependencies

tkinter (Ensure that tkinter is installed (Linux))

License

This project is licensed under the MIT License - see the LICENSE file for details.

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

contextmenuwidget-1.0.7.tar.gz (8.0 kB view details)

Uploaded Source

File details

Details for the file contextmenuwidget-1.0.7.tar.gz.

File metadata

  • Download URL: contextmenuwidget-1.0.7.tar.gz
  • Upload date:
  • Size: 8.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.10.12

File hashes

Hashes for contextmenuwidget-1.0.7.tar.gz
Algorithm Hash digest
SHA256 ea5451e73d0bb9cc530b82ef0656d688e80d15fa2214d4ce2f736983b5e01142
MD5 a9aebb88df6f9fa009f6c2cf1b1d72ea
BLAKE2b-256 e680b1efe571478bee032ec22da74504459e4ed2ea3c51b6ae2cf16b775a23c5

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