Krita Source Code Documentation
Loading...
Searching...
No Matches
dropbutton.py
Go to the documentation of this file.
1# SPDX-License-Identifier: CC0-1.0
2
3try:
4 from PyQt6.QtWidgets import QPushButton
5 from PyQt6.QtGui import QPixmap, QIcon
6 from PyQt6.QtCore import QSize
7except:
8 from PyQt5.QtWidgets import QPushButton
9 from PyQt5.QtGui import QPixmap, QIcon
10 from PyQt5.QtCore import QSize
11
12
13class DropButton(QPushButton):
14
15 def __init__(self, parent):
16 super(DropButton, self).__init__(parent)
17
18 self.presetChooser = None
19
20 self.preset = None
21 self.setFixedSize(64, 64)
22 self.setIconSize(QSize(64, 64))
23
24 def selectPreset(self):
25 if self.presetChooser.currentPreset():
26 self.preset = self.presetChooser.currentPreset().name()
27 current_preset = self.presetChooser.currentPreset()
28 self.setIcon(QIcon(QPixmap.fromImage(current_preset.image())))