Skip to main content

Hoptex

If you are Vim user you heard about EasyMotion and Hop. This library is exactly this concept but for Textual! Just type your shortcut and focus/press widget you want. No mouse needed!

Please always pin version of this library as API may change rapidly. It is experimental project and some staff may be modified.

Demo

DemoScreen HoptexScreen

Installation

Just simply install via pip:

pip3 install hoptex

Documentation

Hoptex allow to focus object and additionaly press it. By default:

  • space will highlight focusable widgets and allow to focus choosen one
  • ctrl+o will focus and press widgets that are focusable and have on_click or _on_click method.

Usage

The most basic usage is just adding decorator on your Textual app like this:

from textual.app import App
from hoptex import hoptex

@hoptex()
class NewTextualApp(App):
    ...

That is all. Super easy, right?

Allow and Block list

To choose which widgets will be highlighted Hoptex checks for three condition:

  • Widget have property focusable=True.
  • Widget is in allow list (then will be forced to be highlighted)
  • Widget is in blocked list (it have priority to exclude widget over allow list)

This parameters can be changed in @hoptex parameter filter_lists using HoptexFilterWidgetsConfig. By default allow_list and block_list are empty and include_focusable=True. Example can be like this:

from textual.demo import DemoApp, LocationLink  # Tested on Texutal 0.30.0 Demo App
from textual.widgets import TextLog
from hoptex import hoptex
from hoptex.configs import HoptexWidgetsFiltersConfig

widgets_filters = HoptexWidgetsFiltersConfig(allow_list=[LocationLink], block_list=[TextLog])


@hoptex(widgets_filters=widgets_filters)
class WrappedDemoApp(DemoApp):
    ...

Custom bindings

If you do not like default bindings you can change them with HoptexBindingConfig. It has four fields, which you can replace with keybinding like in Textual:

  • focus, default to space -> Run Hoptex screen to focus widget
  • press, default to ctrl+p -> Run Hoptex screen to focus and press/click widget
  • quit, default to escape -> Quits from Hoptex screen
  • unfocus, default to escape -> Unfocuses from any widgets (if you are in e.x. text window, you need first to unfocus to use space)

and also four config fields, that takes dictionary that will be injected in standard Binding field:

  • focus_conf, default to {"description": "Hop Focus"}
  • press_conf, default to {"description": "Hop Press"}
  • quit_conf, default to {"description": "Hop Quit", "show": False}
  • unfocus_conf, default to {"description": "Hop Unfocus", "show": False}
from textual.demo import DemoApp

from hoptex import hoptex
from hoptex.configs import HoptexBindingConfig

bindings = HoptexBindingConfig(press="ctrl+g", press_conf={"description": "Another description"})


@hoptex(bindings=bindings)
class DemoAppMy(DemoApp):
    ...

Custom Appearance

You can also inject custom label appearance, by label value. It should inherit from Static and allow for one argument (the letter that will be displayed). However easier way is to change CSS of HopLabel, which default is to:

HopLabel {
  width: 1;
  height: 1;
  color: yellow;
  text-style: bold;
  background: black;
}

TODO

  • Support more widgets on screen
  • Allow to use hoptex as wrapper for application (open any app with hoptex support)
  • If no place to jump, return
  • Color change
  • list of characters
  • custom Widget to mark
  • https://github.com/python/typing/issues/213

Metadata

Release files for hoptex 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for hoptex 0.2.0
File Size Uploaded Provenance Actions
hoptex-0.2.0.tar.gz 5.8 kB Without provenance Details for hoptex-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for hoptex 0.2.0
File Interpreter ABI Platform Actions
hoptex-0.2.0-py3-none-any.whl Python 3 none any Details for hoptex-0.2.0-py3-none-any.whl

Total release size: 13.2 kB

Release files / hoptex-0.2.0.tar.gz

Download URL hoptex-0.2.0.tar.gz
Size 5.8 kB
Tags Source
SHA-256 checksum
How to use checksums
262712566d3874fd3bc42bd37d701713579df3a1aa9dff8aea0ffe665a6c7019
BLAKE2b-256 checksum
How to use checksums
a33057e9364338444700190b6660ff00f95953d1adba0fd29c5b1541412b096a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.5.1 CPython/3.11.5 Linux/5.15.131-1-MANJARO

Release files / hoptex-0.2.0-py3-none-any.whl

Download URL hoptex-0.2.0-py3-none-any.whl
Size 7.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8d497e1f2596a544a2a5109ad52ddcde4cad01511167d2f1cb614fbe4bcd9a8b
BLAKE2b-256 checksum
How to use checksums
8ee1ba8a168c765ed4bc4bf920138567eb83e2eb126ea218d9b13cdf6ea08335
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.5.1 CPython/3.11.5 Linux/5.15.131-1-MANJARO

Security for hoptex 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page