Compare commits
2 Commits
master
...
gtk-status
Author | SHA1 | Date | |
---|---|---|---|
e6f4038fb5 | |||
6fc219338f |
4
README.txt
Normal file
4
README.txt
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
Pinger.py -- A ping tool that sits in your system tray
|
||||||
|
|
||||||
|
+ Saves your sanity when the wifi sucks
|
||||||
|
+ Doesn't clutter up your screen with ping windows
|
BIN
activity.png
Normal file
BIN
activity.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 8.6 KiB |
|
@ -26,7 +26,6 @@
|
||||||
#
|
#
|
||||||
|
|
||||||
from gi.repository import Gtk
|
from gi.repository import Gtk
|
||||||
from gi.repository import AppIndicator3 as appindicator
|
|
||||||
|
|
||||||
# Timer
|
# Timer
|
||||||
from gi.repository import GObject as gobject
|
from gi.repository import GObject as gobject
|
||||||
|
@ -52,7 +51,8 @@ class HelloWorld:
|
||||||
else:
|
else:
|
||||||
m = re.search('time=(.*) ms', out)
|
m = re.search('time=(.*) ms', out)
|
||||||
label = m.group(1)+" ms"
|
label = m.group(1)+" ms"
|
||||||
ind.set_label (label, "100.0 ms")
|
#ind.set_label (label, "100.0 ms")
|
||||||
|
status.set_title(label)
|
||||||
#self.ping_menu_item.set_label(out)
|
#self.ping_menu_item.set_label(out)
|
||||||
gobject.timeout_add_seconds(self.timeout, self.ping)
|
gobject.timeout_add_seconds(self.timeout, self.ping)
|
||||||
|
|
||||||
|
@ -85,13 +85,17 @@ def create_menu_item(menu, text, callback):
|
||||||
return menu_items
|
return menu_items
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
ind = appindicator.Indicator.new (
|
status = Gtk.StatusIcon()
|
||||||
"pinger",
|
status.set_title("0.0 ms")
|
||||||
"", #indicator-messages
|
status.set_from_stock(Gtk.STOCK_HOME)
|
||||||
appindicator.IndicatorCategory.COMMUNICATIONS)
|
status.connect("activate",Gtk.Window.present)
|
||||||
ind.set_status (appindicator.IndicatorStatus.ACTIVE)
|
#ind = appindicator.Indicator.new (
|
||||||
|
# "pinger",
|
||||||
|
# "", #indicator-messages
|
||||||
|
# appindicator.IndicatorCategory.COMMUNICATIONS)
|
||||||
|
#ind.set_status (appindicator.IndicatorStatus.ACTIVE)
|
||||||
#ind.set_attention_icon ("indicator-messages-new")
|
#ind.set_attention_icon ("indicator-messages-new")
|
||||||
ind.set_label ("0.0 ms", "100.0 ms")
|
#ind.set_label ("0.0 ms", "100.0 ms")
|
||||||
|
|
||||||
# create a menu
|
# create a menu
|
||||||
menu = Gtk.Menu()
|
menu = Gtk.Menu()
|
||||||
|
@ -104,7 +108,7 @@ if __name__ == "__main__":
|
||||||
create_menu_item(menu, "Exit", hello.destroy)
|
create_menu_item(menu, "Exit", hello.destroy)
|
||||||
|
|
||||||
# Add the menu to our statusbar
|
# Add the menu to our statusbar
|
||||||
ind.set_menu(menu)
|
#ind.set_menu(menu)
|
||||||
|
|
||||||
# Runtime loop
|
# Runtime loop
|
||||||
Gtk.main()
|
Gtk.main()
|
||||||
|
|
32
new_gtk.py
Normal file
32
new_gtk.py
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
import gtk
|
||||||
|
|
||||||
|
class Main(gtk.Window):
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
super(Main, self).__init__()
|
||||||
|
self.connect('delete-event', self.on_delete_event)
|
||||||
|
self.set_title("Virtual Machine Monitor")
|
||||||
|
self.set_position(gtk.WIN_POS_CENTER)
|
||||||
|
self.set_default_size(640,600)
|
||||||
|
self.set_geometry_hints(min_width=640, min_height=600)
|
||||||
|
self.set_icon_from_file("activity.png")
|
||||||
|
#menubar = self.add_menubar()
|
||||||
|
|
||||||
|
pixbuf = gtk.gdk.pixbuf_new_from_file_at_size("activity.png",25,25)
|
||||||
|
statusicon = gtk.StatusIcon()
|
||||||
|
statusicon.set_title("0.0 ms")
|
||||||
|
statusicon = gtk.status_icon_new_from_pixbuf(pixbuf)
|
||||||
|
statusicon.connect("activate",self.tray_activate)
|
||||||
|
self.show_all()
|
||||||
|
|
||||||
|
def on_delete_event(self, widget, event):
|
||||||
|
self.hide()
|
||||||
|
return True
|
||||||
|
|
||||||
|
def tray_activate(self, widget):
|
||||||
|
self.present()
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
Main()
|
||||||
|
gtk.main()
|
Loading…
Reference in New Issue
Block a user