Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/yjg30737/pyqt-font-dialog
PyQt font dialog and widget
https://github.com/yjg30737/pyqt-font-dialog
dialog font prompt py37 pyqt-examples pyqt-tutorial pyqt5 pyqt5-desktop-application pyqt5-examples pyqt5-font-dialog pyqt5-gui pyqt5-tutorial python3 qdialog qfont qfontdialog
Last synced: 13 days ago
JSON representation
PyQt font dialog and widget
- Host: GitHub
- URL: https://github.com/yjg30737/pyqt-font-dialog
- Owner: yjg30737
- License: mit
- Created: 2021-11-25T08:42:20.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2024-02-25T12:39:35.000Z (9 months ago)
- Last Synced: 2024-04-26T12:20:48.249Z (7 months ago)
- Topics: dialog, font, prompt, py37, pyqt-examples, pyqt-tutorial, pyqt5, pyqt5-desktop-application, pyqt5-examples, pyqt5-font-dialog, pyqt5-gui, pyqt5-tutorial, python3, qdialog, qfont, qfontdialog
- Language: Python
- Homepage:
- Size: 89.8 KB
- Stars: 2
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 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.
* `getFontWidget()` - get the main FontWidget of the dialog.
* `FontWidget(font: QFont = QFont('Arial', 10))`
* `fontChanged(QFont)` - When current font item is changed, this will be emitted.
* `getFont()` - get the selected font.
* `setCurrentFont(QFont)` - set the current font.## Usage
### 1. As a dialog
```python
dialog = FontDialog(textEdit.currentFont())
reply = dialog.exec()
if reply == QDialog.Accepted:
textEdit.setCurrentFont(dialog.getFont())
```### Preview
![image](https://user-images.githubusercontent.com/55078043/167970048-cd8e1d76-d2f2-4c63-964d-87158d8dc53c.png)### 2. As a part of window
```python
from PyQt5.QtWidgets import QMainWindow, QApplication, QHBoxLayout, QWidget, QTextEdit
from pyqt_font_dialog.fontWidget import FontWidgetclass 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.setFont(font)if __name__ == "__main__":
import sysapp = QApplication(sys.argv)
ex = Window()
ex.show()
sys.exit(app.exec_())
```### Preview
https://user-images.githubusercontent.com/55078043/189460933-387d3570-e153-4df9-8a21-d02a46fbfe64.mp4