vimrc

My Vim configuration
git clone git://pcardenasb.com/vimrc
Log | Files | Refs | Submodules

pyside.snippets (945B)


      1 snippet pyside "pyside" b
      2 import sys
      3 from PySide6.QtWidgets import QApplication
      4 
      5 
      6 app = QApplication(sys.argv)
      7 
      8 ${0:${VISUAL:# ...}}
      9 
     10 sys.exit(app.exec())
     11 endsnippet
     12 
     13 
     14 snippet QWidget "QWidget" b
     15 from PySide6.QtWidgets import QWidget
     16 
     17 class ${1:MyWidget}(QWidget):
     18 	def __init__(self):
     19 		super().__init__()
     20 
     21 		self.hello = ['uno', 'dos', 'tres']
     22 		self.button = QPushButton('Click me!')
     23 		self.text = QLabel("Hello World")
     24 
     25 		self.layout = QVBoxLayout()
     26 		self.layout.addWidget(self.text)
     27 		self.layout.addWidget(self.button)
     28 
     29 		self.setLayout(self.layout)
     30 
     31 		self.button.clicked.connect(self.magic)
     32 
     33 	def magic(self):
     34 		self.text.setText(random.choice(self.hello))
     35 endsnippet
     36 
     37 
     38 snippet QUILoader "QUILoader" b
     39 from PySide6.QtUiTools import QUiLoader
     40 from PySide6.QtCore import QFile
     41 
     42 ui_file = QFile(${1:"mainwindow.ui"})
     43 ui_file.open(QFile.ReadOnly)
     44 
     45 loader = QUiLoader()
     46 window = loader.load(ui_file)
     47 ui_file.close()
     48 window.show()
     49 endsnippet