Showing touch bar button when text selected

This may not be possible, but I was wondering if it was possible to show a button on the touch bar only when text is selected? I would only be using this in one application (PyCharm)

Thanks for any help!

Imprint | Privacy Policy