| #!/usr/bin/env python | |
| import gtk, webkit, webbrowser | |
| gtk.gdk.threads_init() | |
| html = """ | |
| <html> | |
| <head> | |
| <style> | |
| body { | |
| background: %s; | |
| } | |
| .button { | |
| display: inline-block; | |
| padding: 8px; | |
| text-align: center; | |
| border: 2px solid #729FCF; | |
| -webkit-border-radius: 5px; | |
| background: #729FCF -webkit-gradient(linear, left top, left bottom, | |
| from(rgba(255, 255, 255, 0.45)), | |
| to(rgba(255, 255, 255, 0.50)), | |
| color-stop(0.4, rgba(255, 255, 255, 0.25)), | |
| color-stop(0.6, rgba(255, 255, 255, 0.0)), | |
| color-stop(0.9, rgba(255, 255, 255, 0.10))); | |
| -webkit-user-select: none; | |
| cursor: default; | |
| } | |
| .button:hover { | |
| border: 2px solid #3E3E3E; | |
| } | |
| .icon { | |
| -webkit-user-drag: none; | |
| } | |
| </style> | |
| </head> | |
| <body> | |
| <a href="program:/test"> | |
| <div class="button"> | |
| <img class="icon" src="http://gwibber.com/icons/22x22/twitter.png" /> | |
| </div> | |
| </a> | |
| </body> | |
| </html> | |
| """ | |
| window = gtk.Window() | |
| window.connect("destroy", gtk.main_quit) | |
| window.resize(800, 500) | |
| window.realize() | |
| bgcolor = window.get_style().bg[gtk.STATE_NORMAL] | |
| def on_click_link(view, frame, req): | |
| uri = req.get_uri() | |
| if uri.startswith("file:///"): return False | |
| elif uri.startswith("program:/"): | |
| print uri.split("/")[1] | |
| else: webbrowser.open(uri) | |
| return True | |
| web = webkit.WebView() | |
| web.load_html_string(html % bgcolor, "file:///") | |
| web.connect("navigation-requested", on_click_link) | |
| scroll = gtk.ScrolledWindow() | |
| scroll.add(web) | |
| window.add(scroll) | |
| window.show_all() | |
| gtk.main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment