Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/345.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python PyQt5使用所需字体打开'QFontDialog'_Python_Pyqt5 - Fatal编程技术网

Python PyQt5使用所需字体打开'QFontDialog'

Python PyQt5使用所需字体打开'QFontDialog',python,pyqt5,Python,Pyqt5,这是我的字体: font = 'Algerian' 当我打开QFontDialog时,我希望显示已选择的字体 getFont()方法(我假设您正在使用该方法)允许您设置初始字体,因此任务很简单: initial_font = QtGui.QFont("Algerian") selected_font, ok = QtWidgets.QFontDialog.getFont(initial_font) if ok: print(selected_font)

这是我的字体:

font = 'Algerian'
当我打开
QFontDialog
时,我希望显示已选择的字体

getFont()方法(我假设您正在使用该方法)允许您设置初始字体,因此任务很简单:

initial_font = QtGui.QFont("Algerian") 
selected_font, ok = QtWidgets.QFontDialog.getFont(initial_font)
if ok:
    print(selected_font)