Skip to content

Conversation

@atticus-lv
Copy link

maybe a easier way to use it

import clipette

# old
if clipette.open_clipboard():
    clipette.empty_cliboard()
    clipette.set_UNICODETEXT("<some text>")
    clipette.close_clipboard()

# new
with clipette.clipboard():
    clipette.empty_cliboard()
    clipette.set_UNICODETEXT("<some text>")

@b-init
Copy link
Owner

b-init commented Nov 24, 2023

Using a context manager makes a lot of sense for this. Thanks for the PR.

But testing this made me realize a flaw that existed earlier too, if a non-custom exception is raised after successfully opening the clipboard, it'll halt the program without calling close_clipboard(). It seems that can also be fixed using contextmanagers? Perhaps the current system of having custom exceptions and calling close_clipboard() in them separately can be improved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants