Hey, we can get even better!!
class FactTree(gtk.TreeView): [...] def __init__(self): [...] try : _test_context = pixmap.cairo_create() self._test_layout = _test_context.create_layout() font = pango.FontDescription(gtk.Style().font_desc.to_string()) self._test_layout.set_font_description(font) except : return
[...]
def update_longest_dimensions(self, fact): interval = "%s -" % fact["start_time"].strftime("%H:%M") if fact["end_time"]: interval = "%s %s" % (interval, fact["end_time"].strftime("%H:%M"))
try : self._test_layout.set_markup(interval) w, h = self._test_layout.get_pixel_size() self.longest_interval = max(self.longest_interval, w + 20)
self._test_layout.set_markup("%s - <small>%s</small> " % (stuff.escape_pango(fact["name"]), stuff.escape_pango(fact["category"]))) w, h = self._test_layout.get_pixel_size() self.longest_activity_category = max(self.longest_activity_category, w + 10)
self._test_layout.set_markup("%s" % stuff.format_duration(fact["delta"])) w, h = self._test_layout.get_pixel_size() self.longest_duration = max(self.longest_duration, w)
except : w = 0 h = 0 self.longest_interval = max(self.longest_interval, w + 120) self.longest_activity_category = max(self.longest_activity_category, w + 70) self.longest_duration = max(self.longest_duration, w)
Hey, we can get even better!!
class FactTree( gtk.TreeView) :
_test_ context = pixmap. cairo_create( )
self. _test_layout = _test_context. create_ layout( ) iption( gtk.Style( ).font_ desc.to_ string( ))
self. _test_layout. set_font_ description( font)
[...]
def __init__(self):
[...]
try :
font = pango.FontDescr
except :
return
[...]
def update_ longest_ dimensions( self, fact): time"]. strftime( "%H:%M" )
interval = "%s %s" % (interval, fact["end_ time"]. strftime( "%H:%M" ))
interval = "%s -" % fact["start_
if fact["end_time"]:
try :
self. _test_layout. set_markup( interval) layout. get_pixel_ size()
self. longest_ interval = max(self. longest_ interval, w + 20)
w, h = self._test_
w, h = self._test_
w, h = self._test_
except :
self. longest_ interval = max(self. longest_ interval, w + 120)
self. longest_ activity_ category = max(self. longest_ activity_ category, w + 70)
self. longest_ duration = max(self. longest_ duration, w)
w = 0
h = 0