컴퓨터/vscode

vscode snippets python pyqt5

풍경소리^^ 2022. 5. 14. 21:44

https://singa-korean.tistory.com/44

 

[VSCode] User Snippets 설정 & 사용법

1. User Snippets이란? 코딩을 할 때 반복적으로 작성해야하는 코드들이 분명히 있다. 이 반복되는 틀을 간편하게 불러오기 위한 기능이 User Snippets이다. VSCode에서 리액트의 컴포넌트 코드를 만들어

singa-korean.tistory.com

import sys
from PyQt5.QtWidgets import QApplication, QWidget, QHBoxLayout, QVBoxLayout
from PyQt5.QtCore import Qt
class MyApp(QWidget):
    def __init__(self):
        super().__init__()
        self.window_width, self.window_height = 700, 500
        self.resize(self.window_width, self.window_height)
        layout = QVBoxLayout()
        self.setLayout(layout)
if __name__ == '__main__':
    app = QApplication(sys.argv)
    app.setStyleSheet('''
        QWidget {
            font-size: 17px;
        }
    ''')
    myApp = MyApp()
    myApp.show()
    try:
        sys.exit(app.exec_())
    except SystemExit:
        print('Closing Window...')

스니핏파일--------------------

{
	// Place your GLOBAL snippets here. Each snippet is defined under a snippet name and has a scope, prefix, body and 
	// description. Add comma separated ids of the languages where the snippet is applicable in the scope field. If scope 
	// is left empty or omitted, the snippet gets applied to all languages. The prefix is what is 
	// used to trigger the snippet and the body will be expanded and inserted. Possible variables are: 
	// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. 
	// Placeholders with the same ids are connected.
	// Example:
	// "Print to console": {
	// 	"scope": "javascript,typescript",
	// 	"prefix": "log",
	// 	"body": [
	// 		"console.log('$1');",
	// 		"$2"
	// 	],
	// 	"description": "Log output to console"
	"PyQt5": {
		"scope": "python",
		"prefix": "pyqt5",
		"body": [
			"import sys",
			"from PyQt5.QtWidgets import QApplication, QWidget, QHBoxLayout, QVBoxLayout",
			"from PyQt5.QtCore import Qt",
			"",
			"class MyApp(QWidget):",
			"    def __init__(self):",
			"        super().__init__()",
			"        self.window_width, self.window_height = 700, 500",
			"        self.resize(self.window_width, self.window_height)",
			"",
			"        layout = QVBoxLayout()",
			"        self.setLayout(layout)",
			"",
			"if __name__ == '__main__':",
			"    app = QApplication(sys.argv)",
			"    app.setStyleSheet('''",
			"        QWidget {",
			"            font-size: 17px;",
			"        }",
			"    ''')",
			"",
			"    myApp = MyApp()",
			"    myApp.show()",
			"",
			"    try:",
			"        sys.exit(app.exec_())",
			"    except SystemExit:",
			"        print('Closing Window...')"
		],
		"description": "pyqt5 스니핏"
	}
}

====================