Навигация
⇒ Python ⇐ CISCO Voice(Asterisk\Cisco) Microsoft Powershell SQL\T-SQL FreeBSD and Nix 1С Общая WEB Разработка ORACLE SQL \ JAVA Мото Стрельба, пневматика, оружие Саморазвитие и психология
|
PyQt 6: позиционирование, буфер обмена
from PyQt4 import QtCore, QtGui
from PyQt4.QtCore import Qt, SIGNAL
import sys, time
class Prog(QtGui.QWidget):
def __init__(self, parent=None):
QtGui.QWidget.__init__(self, parent)
# #----------------------
# #Absolute position
# self.resize(350, 250)
# self.label = QtGui.QLabel("<center>Hello!</center>", self)
# self.btn = QtGui.QPushButton("clipboard", self)
# self.label.setGeometry(30, 30, 300, 50) #width, height, x, y
# self.btn.resize(70, 30) #width, height
# self.btn.move(20, 150) #x, y
# #----------------------
# #clipboard
# self.connect(self.btn, QtCore.SIGNAL("clicked()"), self.des)
#----------------------
#rubber position
self.label1 = QtGui.QLabel("<center>l1</center>")
self.label2 = QtGui.QLabel("<center>l2</center>")
self.label3 = QtGui.QLabel("<center>l3</center>")
self.btn1 = QtGui.QPushButton("b1")
self.btn2= QtGui.QPushButton("b2")
self.btn3= QtGui.QPushButton("b3")
#Vertical
#self.box = QtGui.QVBoxLayout()
#Horisontal
self.box = QtGui.QHBoxLayout()
self.innerBox1 = QtGui.QHBoxLayout()
self.innerBox2 = QtGui.QHBoxLayout()
#alignment=QtCore.Qt. - align:
#AlignLeft, AlignRight, AlignHcenter, AlignJustify, AlignTop, AlignBottom, AlignVcenter, AlignCenter
self.box.addWidget(self.label1, alignment=QtCore.Qt.AlignTop)
self.box.addWidget(self.label2, alignment=QtCore.Qt.AlignBottom)
self.box.addWidget(self.btn1)
self.box.addWidget(self.btn2)
self.setLayout(self.box)
#add widget on last position
self.box.addWidget(self.label3)
#add widget on defined position
self.box.insertWidget(0, self.btn3)
#Add container in container
self.innerLabel1 = QtGui.QLabel("<center>innerLabel1</center>")
self.innerLabel2 = QtGui.QLabel("<center>innerLabel2</center>")
self.innerBox1.addWidget(self.innerLabel1)
self.innerBox2.addWidget(self.innerLabel2)
self.box.addLayout(self.innerBox1)
self.box.insertLayout(0, self.innerBox2)
#Add empty space (static)
self.box.addSpacing(100)
self.box.insertSpacing(0, 100)
def des(self):
clipboard = QtGui.QApplication.clipboard()
self.label.setText(clipboard.text())
app = QtGui.QApplication(sys.argv)
prog = Prog()
prog.show()
sys.exit(app.exec_())
Комментарии пользователей
Анонимам нельзя оставоять комментарии, зарегистрируйтесь!
|