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
File details
Details for the file pyqt-font-dialog-0.0.14.tar.gz
.
File metadata
- Download URL: pyqt-font-dialog-0.0.14.tar.gz
- Upload date:
- Size: 4.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/0.0.0 CPython/3.7.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | dc2085a736cbee7da7593e9bf9e3bab239e6308b9f79eff41e2333db807469f6 |
|
MD5 | 6f840585bc062b7bc7da3635643d8fae |
|
BLAKE2b-256 | e31013f735e20beb9c0bf2a520f98277c76b091ee8bfa18b504653034d5ca719 |
File details
Details for the file pyqt_font_dialog-0.0.14-py3-none-any.whl
.
File metadata
- Download URL: pyqt_font_dialog-0.0.14-py3-none-any.whl
- Upload date:
- Size: 7.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/0.0.0 CPython/3.7.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2ce162f75806a8065cb61ee196ffb2212a9276ea64313bdd3dd0bb0fe98c504b |
|
MD5 | 82ba38a713e66ffc4e02ebd973b10be3 |
|
BLAKE2b-256 | ab42e456e3b0008cdd1669dadbef3866aaa9ffa0a2405b10fbdd3db9e6ab6dd9 |