Use ide as pycharm
1. Code
from PyQt5.Qt import *
class Window(QWidget):
def __init__(self):
super().__init__()
self.setWindowTitle("pyqt")
self.resize(500,500)
self.setup_ui()
#setup_ui是建立不同的对象,更加清楚
def setup_ui(self):
$code$
#$code$是让模板生效后光标默认停留的位置
#code是变量名可以自己修改,位置也可以自己修改
#用于测试,如果不用可以删除
if __name__ == '__main__':
import sys
app = QApplication(sys.argv)
windwos=Window()
windwos.show()
sys.exit(app.exec_())
pycharm settings
1. Enter settings
2. Enter the event template
Search live will appear complete
3. Create a template
(1) Click python, then click the + sign
(2) add
(3) to take effect,
click define, then select python
and then click apply, then click ok to take effect
4. Show
Enter the table key to take effect