PyQt font dialog and widget
Project description
pyqt-font-dialog
PyQt "select the font" dialog and widget
Requirements
PyQt5 >= 5.8
Setup
python -m pip install pyqt-font-dialog
Class/Method Overview
-
FontDialog(font: QFont = QFont('Arial', 10), title='Font')
- font is font, title is title of the dialog.getFont()
- get the selected font.
-
FontWidget(font: QFont = QFont('Arial', 10))
-
fontChanged(QFont)
- When current font item is changed, this will be emitted. -
getFont()
- get the selected font.
-
Usage
1. As a dialog
dialog = FontDialog(textEdit.currentFont())
reply = dialog.exec()
if reply == QDialog.Accepted:
textEdit.setCurrentFont(dialog.getFont())
Preview
2. As a part of window
from PyQt5.QtWidgets import QMainWindow, QApplication, QHBoxLayout, QWidget, QTextEdit
from pyqt_font_dialog.fontWidget import FontWidget
class Window(QMainWindow):
def __init__(self):
super().__init__()
self.__initUi()
def __initUi(self):
self.__te = QTextEdit()
fontWidget = FontWidget()
fontWidget.fontChanged.connect(self.fontChanged)
lay = QHBoxLayout()
lay.addWidget(self.__te)
lay.addWidget(fontWidget)
mainWidget = QWidget()
mainWidget.setLayout(lay)
self.setCentralWidget(mainWidget)
def fontChanged(self, font):
self.__te.selectAll()
self.__te.setFont(font)
cur = self.__te.textCursor()
cur.clearSelection()
self.__te.setTextCursor(cur)
if __name__ == "__main__":
import sys
app = QApplication(sys.argv)
ex = Window()
ex.show()
sys.exit(app.exec_())
Preview
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for pyqt_font_dialog-0.0.14-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2ce162f75806a8065cb61ee196ffb2212a9276ea64313bdd3dd0bb0fe98c504b |
|
MD5 | 82ba38a713e66ffc4e02ebd973b10be3 |
|
BLAKE2b-256 | ab42e456e3b0008cdd1669dadbef3866aaa9ffa0a2405b10fbdd3db9e6ab6dd9 |