add refresh button to log viewer
This commit is contained in:
parent
18b0a47555
commit
66b4ed35e5
|
@ -52,19 +52,44 @@ class GuiLogView:
|
||||||
|
|
||||||
self.listview = gtk.TreeView(model=self.liststore)
|
self.listview = gtk.TreeView(model=self.liststore)
|
||||||
self.listview.set_grid_lines(gtk.TREE_VIEW_GRID_LINES_NONE)
|
self.listview.set_grid_lines(gtk.TREE_VIEW_GRID_LINES_NONE)
|
||||||
|
self.listcols = []
|
||||||
|
|
||||||
scrolledwindow = gtk.ScrolledWindow()
|
scrolledwindow = gtk.ScrolledWindow()
|
||||||
scrolledwindow.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
|
scrolledwindow.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
|
||||||
self.vbox.pack_start(scrolledwindow, expand=True, fill=True, padding=0)
|
|
||||||
scrolledwindow.add(self.listview)
|
scrolledwindow.add(self.listview)
|
||||||
|
self.vbox.pack_start(scrolledwindow, expand=True, fill=True, padding=0)
|
||||||
|
|
||||||
|
refreshbutton = gtk.Button("Refresh")
|
||||||
|
refreshbutton.connect("clicked", self.refresh, None)
|
||||||
|
self.vbox.pack_start(refreshbutton, False, False, 3)
|
||||||
|
refreshbutton.show()
|
||||||
|
|
||||||
self.listview.show()
|
self.listview.show()
|
||||||
scrolledwindow.show()
|
scrolledwindow.show()
|
||||||
self.vbox.show()
|
self.vbox.show()
|
||||||
|
|
||||||
|
col = self.addColumn("Date/Time", 0)
|
||||||
|
col = self.addColumn("Module", 1)
|
||||||
|
col = self.addColumn("Level", 2)
|
||||||
|
col = self.addColumn("Text", 3)
|
||||||
|
|
||||||
self.loadLog()
|
self.loadLog()
|
||||||
self.vbox.show_all()
|
self.vbox.show_all()
|
||||||
|
|
||||||
|
def addColumn(self, title, n):
|
||||||
|
col = gtk.TreeViewColumn(title)
|
||||||
|
self.listview.append_column(col)
|
||||||
|
cRender = gtk.CellRendererText()
|
||||||
|
cRender.set_property("wrap-mode", pango.WRAP_WORD_CHAR)
|
||||||
|
col.pack_start(cRender, True)
|
||||||
|
col.add_attribute(cRender, 'text', n)
|
||||||
|
col.set_max_width(1000)
|
||||||
|
col.set_spacing(0) # no effect
|
||||||
|
self.listcols.append(col)
|
||||||
|
col.set_clickable(True)
|
||||||
|
col.connect("clicked", self.sortCols, n)
|
||||||
|
return(col)
|
||||||
|
|
||||||
def loadLog(self):
|
def loadLog(self):
|
||||||
|
|
||||||
#self.configStore = gtk.TreeStore(gobject.TYPE_PYOBJECT, gobject.TYPE_STRING, gobject.TYPE_STRING)
|
#self.configStore = gtk.TreeStore(gobject.TYPE_PYOBJECT, gobject.TYPE_STRING, gobject.TYPE_STRING)
|
||||||
|
@ -73,12 +98,6 @@ class GuiLogView:
|
||||||
self.liststore.clear()
|
self.liststore.clear()
|
||||||
self.listcols = []
|
self.listcols = []
|
||||||
|
|
||||||
col = self.addColumn("Date/Time", 0)
|
|
||||||
|
|
||||||
col = self.addColumn("Module", 1)
|
|
||||||
col = self.addColumn("Level", 2)
|
|
||||||
col = self.addColumn("Text", 3)
|
|
||||||
|
|
||||||
# count number of lines in file
|
# count number of lines in file
|
||||||
f = open('logging.out', "r+")
|
f = open('logging.out', "r+")
|
||||||
buf = mmap.mmap(f.fileno(), 0)
|
buf = mmap.mmap(f.fileno(), 0)
|
||||||
|
@ -107,20 +126,6 @@ class GuiLogView:
|
||||||
line = readline()
|
line = readline()
|
||||||
f.close()
|
f.close()
|
||||||
|
|
||||||
def addColumn(self, title, n):
|
|
||||||
col = gtk.TreeViewColumn(title)
|
|
||||||
self.listview.append_column(col)
|
|
||||||
cRender = gtk.CellRendererText()
|
|
||||||
cRender.set_property("wrap-mode", pango.WRAP_WORD_CHAR)
|
|
||||||
col.pack_start(cRender, True)
|
|
||||||
col.add_attribute(cRender, 'text', n)
|
|
||||||
col.set_max_width(1000)
|
|
||||||
col.set_spacing(0) # no effect
|
|
||||||
self.listcols.append(col)
|
|
||||||
col.set_clickable(True)
|
|
||||||
col.connect("clicked", self.sortCols, n)
|
|
||||||
return(col)
|
|
||||||
|
|
||||||
def sortCols(self, col, n):
|
def sortCols(self, col, n):
|
||||||
try:
|
try:
|
||||||
if not col.get_sort_indicator() or col.get_sort_order() == gtk.SORT_ASCENDING:
|
if not col.get_sort_indicator() or col.get_sort_order() == gtk.SORT_ASCENDING:
|
||||||
|
@ -139,6 +144,9 @@ class GuiLogView:
|
||||||
print "***sortCols error: " + str(sys.exc_info()[1])
|
print "***sortCols error: " + str(sys.exc_info()[1])
|
||||||
print "\n".join( [e[0]+':'+str(e[1])+" "+e[2] for e in err] )
|
print "\n".join( [e[0]+':'+str(e[1])+" "+e[2] for e in err] )
|
||||||
|
|
||||||
|
def refresh(self, widget, data):
|
||||||
|
self.loadLog()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if __name__=="__main__":
|
if __name__=="__main__":
|
||||||
|
|
Loading…
Reference in New Issue
Block a user