Python Forum
set font from dialog box pyside python
Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
set font from dialog box pyside python
#1
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
Reply
#2
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?
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Question [WxPython] [SOLVED] Simple dialog without app? Winfried 5 1,420 Oct-07-2025, 02:30 PM
Last Post: Winfried
Smile [Tkinter] Trying to make Fond Dialog box TheTiger 11 4,151 Oct-16-2024, 01:56 AM
Last Post: menator01
  [PySide / PyQt] Offset two images with keyboard increments carecavoador 1 3,289 Sep-09-2023, 12:53 PM
Last Post: deanhystad
Question Rows and colums list. PySide 6 britesc 2 2,523 May-31-2023, 09:00 PM
Last Post: deanhystad
  How a QMainWindow can open a dialog? panoss 4 6,896 Feb-03-2022, 04:33 PM
Last Post: panoss
  [Tkinter] question for a tkinter dialog box RobertAlvarez424 2 3,698 Aug-25-2021, 03:08 PM
Last Post: RobertAlvarez424
  [Tkinter] cancelling open dialog gives empty string rwahdan 2 6,057 Jul-17-2021, 09:17 PM
Last Post: steve_shambles
  Drawing in PySide Leo_Red 3 5,109 Jun-26-2021, 09:30 AM
Last Post: Axel_Erfurt
  [WxPython] Return code when closing the dialog ioprst 1 4,576 Aug-13-2019, 11:47 AM
Last Post: jefsummers
  PyQT5 : Unable to Create Another Dialog While One is Open iMuny 3 6,273 Jul-17-2019, 11:40 AM
Last Post: iMuny

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020