I'm working on tic tac toe game with GUI in Python and I'm using PyQt5. I'm struggling with setting my background image in one place and not letting it move at all. I tried using
self.window.setStyleSheet("background-image: url(tictactoe.png); background-attachment: fixed; background-repeat: no-repeat; background-position: center; background-color: qlineargradient( x1:0 y1:0, x2:1 y2:0, stop:0 #ffc982, stop:1 #ff9982);")
but any option is not working for me. Whevener I add button, label, or anything my image is moving with it.
Here is rest of the code:
class App(QMainWindow):
def __init__(self):
super().__init__()
self.setWindowTitle("Tic Tac Toe")
self.app = QApplication([])
self.window = QWidget()
self.window.setGeometry(800,350,800,800)
self.layout = QVBoxLayout()
self.empty = QLabel('')
self.buttonstart = QPushButton('Start', clicked = lambda: self.start())
self.layout.addWidget(self.empty)
self.window.setStyleSheet("background-image: url(tictactoe.png); background-attachment: fixed; background-repeat: no-repeat; background-position: center; background-color: qlineargradient( x1:0 y1:0, x2:1 y2:0, stop:0 #ffc982, stop:1 #ff9982);")
self.buttonstart.setStyleSheet("background-image: url(); border-width: 4px; border-style: solid; border-radius: 10%; border-color: black; background-color: transparent; color: black; max-width: 200%; height: 80px; font-size: 30px;")
self.buttonstart.setGeometry(100,100,100,100) #not working too
self.layout.addWidget(self.buttonstart)
self.window.setLayout(self.layout)
self.window.show()
self.app.exec_()
It looks like that: The problem:
question from:
https://stackoverflow.com/questions/65909615/cant-set-background-image-fixed-still 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…