From f37354b0546b9c0b3be8e4489cb59e1fc335c7bf Mon Sep 17 00:00:00 2001 From: Christophe Simonis Date: Thu, 12 Jun 2014 12:28:27 +0200 Subject: [PATCH] [FIX] runbot: badges: Tkinter require a X server. use matplotlib to compute text width --- runbot/runbot.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/runbot/runbot.py b/runbot/runbot.py index dea8bbca..b47db918 100644 --- a/runbot/runbot.py +++ b/runbot/runbot.py @@ -13,11 +13,11 @@ import signal import simplejson import subprocess import time -import Tkinter -import tkFont import dateutil.parser import requests +from matplotlib.font_manager import FontProperties +from matplotlib.textpath import TextToPath import werkzeug import openerp @@ -943,7 +943,10 @@ class RunbotController(http.Controller): 'warning': "#fe7d37", }[state] - text_width = tkFont.Font(Tkinter.Tk(), family='Verdana', size=11).measure + def text_width(s): + fp = FontProperties(family='DejaVu Sans', size=11) + w, h, d = TextToPath().get_text_width_height_descent(s, fp, False) + return int(w + 1) class Text(object): __slot__ = ['text', 'color', 'width']