I have very limited knowledge of PyQt5 but was given a script that I'm having some problems altering. At startup the script is designed to show a frame upon which an image appears, together with a menubar.
The main part of the script at the bottom of the file is this:
def main():
global window
app = QApplication([])
window = MainMenu()
window.show()
sys.exit(app.exec_())
if __name__ == '__main__':
main()
MainMenu
itself is a class, defined earlier, which starts out as follows:
class MainMenu(QMainWindow):
def __init__(self):
super(MainMenu, self).__init__()
self.window()
layout = self.frame_layout()
self.create_menubar()
def window(self):
screen_width, screen_height = pyautogui.size()
self.setGeometry(0, 0, screen_width - 25, screen_height - 180)
self.showMaximized()
startup_background(self)
...and so on.
startup_background
in the last line above is a function that is designed to create the initial background using a specified .png file. I tried to create this function using the following in the startup_background
function:
pixmap = QPixmap(background.png).scaled(window.width(), window.height(),QtCore.Qt.KeepAspectRatio)
palette = QPalette()
palette.setBrush(QPalette.Background, QBrush(pixmap))
window.setPalette(palette)
The problem is that the background image, which is a simple multiple time series plot, essentially appears more than once as shown by the ''chopped off'' right portion of the image below:
I also tried using a label by replacing the lines above with pallette with a label:
label = QLabel(window)
label.setPixmap(pixmap)
This produced nothing.