Python Forum

Full Version: set font from dialog box pyside python
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
i am setting a simple text editor and one of its item is the capability of formatting the font. i am using a dialog box to chose the font and giving a default value; i am using QFont to set the default. I would like to set the default to 'consolas' or 'liberation mono'; i found the former to be easier to implement. however when i launch the window, the default font is not 'consolas'. 

how shall i set the code for QFont in order to get 'consolas' or 'liberation mono' regular?
this is the code i wrote:

def fontChange(self):
    (font, ok) = QFontDialog.getFont(QFont("Consolas", 11), self)
    if ok:
        self.textEdit.setCurrentFont(font)
thanks
Your question is clear, however, I would like to know exactly what packages you're using? Would it be possible to supply your source code, or at least some keys parts of it and your imports?