简体   繁体   中英

How can I run PyQt5 in sublime text

from PyQt5 import QtWidgets
from PyQt5.QtWidgets import QApplication, QMainWindow
import sys

def window():
    app = QApplication(sys.argv)
    win = QMainWindow()
    win.setGeometry(200, 200, 300, 300)
    win.setWindowTitle("Tech wit me")
    win.show()
    sys.exit(app.exec_())
window()

i wrote this piece of code and just got black screen. It works on spyder but ST makes issue. Can you help me about that?

You can do a small change to your Sublime Text configuration, so that the problem may fix.

Just follow this:

Tools > Build System > New Build system

and Copy this and paste it

{ 
 "cmd":["C:/Users/<username>/AppData/Local/Programs/Python/Python38-32/python.exe", "-u", "$file"], 
 "file_regex": "^[ ]File \"(...?)\", line ([0-9]*)", 
 "selector": "source.python",
 "shell": "true",
}

instead of <username> , use your username. Instead of Python38-32 , use your Python version. 38 denotes the Python version 3.8 and 32 denotes the 32 bit architecture.

The line 'shell": "True", is added.

Hope this works.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM