-3

I created a project using PyQt5. This code attempts to display a window:

import sys

from PyQt5 import QtWidgets

def Pencere():

    app = QtWidgets.QApplication(sys.argv)

    pencere = QtWidgets.QWidget()

    pencere.setWindowTitle("PyQt5 Class 1")

    pencere.show()

    sys.exit(app.exec_())

I can run this code in PyCharm, and I receive no errors. But no window is displayed.

CrazyChucky
  • 3,263
  • 4
  • 11
  • 25
  • 1
    Please provide a [mre] – musicamante May 04 '22 at 11:32
  • i tryed to show with the pic. – Yunus Balıkcı May 04 '22 at 11:58
  • [Please do not upload images of code/data/errors when asking a question.](//meta.stackoverflow.com/q/285551) Now, in this case, an image showing the window you want to appear could make sense, sure, but you *also* need to include actual code (as formatted text) that reproduces the problem for you. – CrazyChucky May 04 '22 at 12:05
  • @YunusBalıkcı I specifically asked to provide a MRE, not an image of the result. Please read the link above and follow its directions. – musicamante May 04 '22 at 13:05
  • Please provide enough code so others can better understand or reproduce the problem. – Community May 04 '22 at 15:11
  • So... I'm confused. In the code currently shown, you never *call* your `Pencere()` function, which is why nothing happens. In your earlier [screenshot](https://i.stack.imgur.com/PrAfZ.png), you *do* call it (just barely visible at the bottom), which would explain why there is in fact a window visible. Running the code with the function call included works just fine for me. – CrazyChucky May 04 '22 at 22:54

1 Answers1

-1

I could imagine that this has something to do with the backend PyQt5. If you do not need to use this specific backend you might want to switch to TkAgg. For me this worked, when I encountered the same problem with matplotlib.

How to change the backend in my case (not certain, which particular package you are using to display your output):

You can change the backend instructions in the matplotlibrc file, which you can find in C:\Anaconda3\pkgs\matplotlib-2.0.2-np113py35_0\Lib\site-packages\matplotlib\mpl-data\, if you are using Anaconda.

Inside this matplotlibrc file you can change the backend to TkAgg.

For further details see: https://stackoverflow.com/a/45309706/17915836

Maybe this also helps in your case...

Simon
  • 58
  • 5
  • It looks like they're just using PyQt5 directly, not as a backend for something else, based on the screenshot. – CrazyChucky May 04 '22 at 12:09
  • @Simon from what (little) can be seen in the image, the issue has nothing to do with the backend, but the fact that they are just using it in the wrong way. – musicamante May 04 '22 at 13:01
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community May 04 '22 at 15:58