0

I'd like for this python gtk app to be "docked" at the top of the screen. Is there a way to disable the close, maximize, and minimize buttons and keep it on top of the other applications?

#!/usr/bin/env python
import sys
import gtk
import webkit
DEFAULT_URL = 'http://webpage.com'
class SimpleBrowser:
def __init__(self):
    self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
    self.window.connect('delete_event', self.close_application)
    self.window.set_default_size(1024, 125)
    vbox = gtk.VBox(spacing=5)
    vbox.set_border_width(5)
    self.txt_url = gtk.Entry()
    self.txt_url.connect('activate', self._txt_url_activate)
    self.scrolled_window = gtk.ScrolledWindow()
    self.webview = webkit.WebView()
    self.scrolled_window.add(self.webview)
    vbox.pack_start(self.scrolled_window, fill=True, expand=True)
    self.window.add(vbox)
def _txt_url_activate(self, entry):
    self._load(entry.get_text())
def _load(self, url):
    self.webview.open(url)
def open(self, url):
    self.txt_url.set_text(url)
    self.window.set_title('%s' % url)
    self._load(url)
def show(self):
    self.window.show_all()
def close_application(self, widget, event, data=None):
    gtk.main_quit()
if __name__ == '__main__':
if len(sys.argv) > 1:
    url = sys.argv[1]
else:
    url = DEFAULT_URL
gtk.gdk.threads_init()
browser = SimpleBrowser()
browser.open(url)
browser.show()
gtk.main()
Ned Deily
  • 83,389
  • 16
  • 128
  • 151
c0nfus3d
  • 1,403
  • 3
  • 13
  • 25

1 Answers1

2

Close, Maximize & Minimize in the toolbar are part of window manager decorations. If you want to get rid of them then disable decorations using gtk.Window.set_decorated and setting the decorations settings to false. Regarding always on top you can try gtk.Window.set_keep_above. This again is a "hint" to the window manager. There is a possibility that your window manager may choose to ignore it. This question discusses about "always on top" window and this question discusses more about X11 and the window manager hint to set the window as "always on top".
Hope this helps!

Community
  • 1
  • 1
another.anon.coward
  • 11,087
  • 1
  • 32
  • 38