#!/usr/bin/env python from Tkinter import * from time import time import bmpFont_X11 import bmpFont_gif class tkApp(Frame): def __init__(self, master=None): Frame.__init__(self, master) self.grid(sticky=N+S+E+W) sumX11 = 0 sumGif = 0 for x in range(10): print "Run: " + str(x) tmpT = time() self.bitmapFont=bmpFont_gif.bmpFont() tmp2 = time() print "gif - " + str(tmp2-tmpT) sumGif = sumGif + (tmp2-tmpT) self.bitmapFont=None tmpT = time() self.bitmapFont=bmpFont_X11.bmpFont() tmp2 = time() print "X11 - " + str(tmp2-tmpT) sumX11 = sumX11 + (tmp2-tmpT) self.bitmapFont=None print "Average: X11 - " + str(sumX11/10) print "Average: gif - " + str(sumGif/10) print "gif/X11 - " + str((sumGif/10) / (sumX11/10)) self.bitmapFont=bmpFont_gif.bmpFont() self.canvasItems=[] self.createWidgets() return def createWidgets(self): self.tst = Canvas(self) xOffset = self.bitmapFont.fontHeight yOffset = self.bitmapFont.fontWidth row = 0 col = 0 for f in self.bitmapFont.glyphs: col = col + 1 if col > 15: col = 0 row = row + 1 i = self.tst.create_image( (col * self.bitmapFont.fontWidth) + xOffset, (row * self.bitmapFont.fontHeight) + yOffset, image = f ) self.canvasItems.append(i) self.tst.pack() width = 16 * self.bitmapFont.fontWidth + (xOffset * 2) height = row * self.bitmapFont.fontHeight + (yOffset * 2) # limit canvas to 80% of full screen res, min of if (width > (self.winfo_screenwidth() * 0.8 ) ): width = self.winfo_screenwidth() * 0.8 if (height > (self.winfo_screenheight() * 0.8 ) ): height = self.winfo_screenheight() * 0.8 self.tst.config(width=width) self.tst.config(height=height) return #---------------------------------------------- if __name__ == '__main__': app = tkApp() app.master.title("tkTestApp") # uncomment to make non-resizeable app.master.resizable(0, 0) app.mainloop()