File size: 2,046 Bytes
078ce08 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | from PyQt5.QtWidgets import QLineEdit
from PyQt5.QtGui import QPainter, QPalette
class CustomTextBox(QLineEdit):
def __init__(self, parent=None):
super().__init__(parent)
self.setStyleSheet(
'''
QLineEdit {
background-color: transparent;
border:2px solid;
border-radius: 5px;
border-color: #ffffff;
font-size: 18px;
color: #ffffff;
font-weight: bold;
height: 40px;
width: 10px;
}
'''
)
def paintEvent(self, event):
painter = QPainter(self)
painter.setRenderHint(QPainter.Antialiasing)
border_color = self.palette().color(QPalette.Text)
border_color.setAlpha(50)
painter.setPen(border_color)
painter.drawRoundedRect(
0,
0,
self.width(),
self.height(),
5,
5
)
super().paintEvent(event)
class CustomTextBoxForImageGen(QLineEdit):
def __init__(self, parent=None):
super().__init__(parent)
self.setStyleSheet(
'''
QLineEdit {
background-color: transparent;
border:1.2px solid;
border-radius: 5px;
border-color: #fae69e;
font-size: 18px;
color: #ffffff;
padding: 8px 16px;
font-weight: semi-bold;
height: 40px;
}
'''
)
def paintEvent(self, event):
painter = QPainter(self)
painter.setRenderHint(QPainter.Antialiasing)
border_color = self.palette().color(QPalette.Text)
border_color.setAlpha(50)
painter.setPen(border_color)
painter.drawRoundedRect(
0,
0,
self.width(),
self.height(),
5,
5
)
super().paintEvent(event) |