Since the webbrowser.open function does not check whether the URL is valid, this application can be improved by including a basic hyperlink validation. For instance, you can use the urlparse function to verify that the URL has a network location:
from urllib.parse import urlparse
def validate_hyperlink(self, url):
return urlparse(url).netloc
Although this solution is not intended to handle some corner cases, it might serve as a first approach to discarding most invalid URLs.
In general, you can use tags to create complex text-based programs, such as an IDE with syntax highlighting. In fact, IDLE—bundled in the default Python implementation—is based on Tkinter.