Answer the question
In order to leave comments, you need to log in
How to scale a background image with aspect ratio with PyQt?
Good afternoon!
While it turned out to be done without maintaining the aspect ratio.
class Interface(QMainWindow):
def __init__(self):
super().__init__()
self.main_window()
def main_window(self):
QToolTip.setFont(QFont('TimesNewRoman', 12))
start_button = QPushButton('Start', self)
start_button.setFlat(True)
start_button.setStyleSheet("QPushButton {background-color: rgba(255, 0, 0, 0);"
"border-radius: 100px;}")
start_button.resize(200, 200)
start_button.move(100, 100)
start_button.setFont(QFont('Calibri', 42))
start_button.clicked.connect(run_convertor)
start_button.setToolTip('Button tip')
self.resize(1000, 500)
self.center()
self.setWindowTitle('jpgTabaki')
self.setWindowIcon(QIcon('icon.png'))
self.setToolTip('Window tip')
self.setStyleSheet("QMainWindow {border-image: url(x_pic.png);"
"background-repeat: no-repeat; background-position: center;}")
self.show()
def center(self):
q_screen = self.frameGeometry()
q_resolution = QDesktopWidget().availableGeometry().center()
q_screen.moveCenter(q_resolution)
self.move(q_screen.topLeft())
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question