[FIX] runbot: badges: Tkinter require a X server. use matplotlib to compute text width

This commit is contained in:
Christophe Simonis 2014-06-12 12:28:27 +02:00
parent 52b10975e9
commit f37354b054

View File

@ -13,11 +13,11 @@ import signal
import simplejson import simplejson
import subprocess import subprocess
import time import time
import Tkinter
import tkFont
import dateutil.parser import dateutil.parser
import requests import requests
from matplotlib.font_manager import FontProperties
from matplotlib.textpath import TextToPath
import werkzeug import werkzeug
import openerp import openerp
@ -943,7 +943,10 @@ class RunbotController(http.Controller):
'warning': "#fe7d37", 'warning': "#fe7d37",
}[state] }[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): class Text(object):
__slot__ = ['text', 'color', 'width'] __slot__ = ['text', 'color', 'width']