I tried running PyQt5 in pycharm which works initially as i can see an window popping up with a title fixed to it
import sys
from PyQt5 import QtCore
from PyQt5.QtGui import QCursor
from PyQt5.QtGui import QPixmap
from PyQt5.QtWidgets import QApplication, QLabel, QPushButton, QWidget, QGridLayout
app = QApplication(sys.argv)
window = QWidget()
window.setWindowTitle("Who wants to be a programmer?")
window.setFixedWidth(1000)
window.show()
sys.exit(app.exec())
if I run this code then a window appears with a title, But if I try to work on it more and run the code, a window appears on the taskbar but I cannot see or open it!
Try subclassing QWidget or QMainWindow.Will give better controllability.
import sys
from PyQt5 import QtCore
from PyQt5.QtGui import QCursor
from PyQt5.QtGui import QPixmap
from PyQt5.QtWidgets import QApplication, QLabel, QPushButton, QWidget, QGridLayout
app = QApplication(sys.argv)
window = QWidget()
window.setWindowTitle("Who wants to be a programmer?")
window.setFixedWidth(1000)
b11=QPushButton(window)
class w2(QWidget):
def __init__(self):
super(QWidget,self).__init__()
self.b1=QPushButton(self)
w_2=w2()
w_2.show()
sys.exit(app.exec())
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.