python - wxPython -- how to use an installed font on Ubuntu -


i have found references how pull font installed windows system, can't find or figure out how on ubuntu. i'm using ubuntu 14.04, wxpython 3.0 , have font installed in usr/share/fonts/truetype.

i'm not worried platform independence, strictly personal project used on ubuntu machine.

converting comment answer - recommend using fontenumerator widget. allows select , set font installed on system. there example in wxpython demo.

here demo uses demo basis:

import wx  ######################################################################## class testpanel(wx.panel):      #----------------------------------------------------------------------     def __init__(self, parent):         wx.panel.__init__(self, parent, -1)          e = wx.fontenumerator()         e.enumeratefacenames()         elist= e.getfacenames()          elist.sort()          s1 = wx.statictext(self, -1, "face names:")          self.lb1 = wx.listbox(self, -1, wx.defaultposition, (200, 250),                               elist, wx.lb_single)          self.bind(wx.evt_listbox, self.onselect, id=self.lb1.getid())          self.txt = wx.statictext(self, -1, "sample text...", (285, 50))          row = wx.boxsizer(wx.horizontal)         row.add(s1, 0, wx.all, 5)         row.add(self.lb1, 0, wx.all, 5)         row.add(self.txt, 0, wx.all|wx.adjust_minsize, 5)          sizer = wx.boxsizer(wx.vertical)         sizer.add(row, 0, wx.all, 30)         self.setsizer(sizer)         self.layout()          self.lb1.setselection(0)         self.onselect(none)         wx.futurecall(300, self.settextsize)      #----------------------------------------------------------------------     def settextsize(self):         self.txt.setsize(self.txt.getbestsize())      #----------------------------------------------------------------------     def onselect(self, evt):         face = self.lb1.getstringselection()         font = wx.font(28, wx.default, wx.normal, wx.normal, false, face)         self.txt.setlabel(face)         self.txt.setfont(font)         if wx.platform == "__wxmac__": self.refresh()  ######################################################################## class myform(wx.frame):      #----------------------------------------------------------------------     def __init__(self):         wx.frame.__init__(self, none,                           title="wx.fontenumerator tutorial",                           size=(800,600))         panel = testpanel(self)   #---------------------------------------------------------------------- # run program if __name__ == "__main__":     app = wx.app(false)     frame = myform()     frame.show()     app.mainloop() 

for further reference, see below:


Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -