Hi,
I have some widgets (see pic) and im trying to put a border around them all.
The code below is adding the border around all the widgets individually instead of globally.
What am I doing wrong? How to I get the result seem in the example image?
thanks
def __init__(self):
super(myFrame, self).__init__()
self.setStyleSheet("border: 1px solid black")
self.
label = QLabel('Tracker01') self.setMinimumWidth(60)
self.label.setMaximumWidth(100)
self.colorSwatch.setFixedWidth(20)
self.colorSwatch.setFixedHeight(20)
self.colorSwatch.setStyleSheet("border: 1px solid black")
self.X_LineEdit.setMaximumWidth(60)
self.Y_LineEdit.setMaximumWidth(60)
self.Z_LineEdit.setMaximumWidth(60)
self.X_Label.setMaximumWidth(10)
self.Y_Label.setMaximumWidth(10)
self.Z_Label.setMaximumWidth(10)
self.CopyValues.setMaximumWidth(30)
self.CreateCard.setMaximumWidth(30)
self.MarkPoint.setMaximumWidth(30)
self.layout.addWidget(self.label)
self.layout.addWidget(self.colorSwatch)
self.layout.addWidget(self.X_Label)
self.layout.addWidget(self.X_LineEdit)
self.layout.addWidget(self.Y_Label)
self.layout.addWidget(self.Y_LineEdit)
self.layout.addWidget(self.Z_Label)
self.layout.addWidget(self.Z_LineEdit)
self.layout.addWidget(self.CreateCard)
self.layout.addWidget(self.CopyValues)
self.layout.addWidget(self.MarkPoint)
self.setLayout(self.layout)
def __init__(self):
super(myPanel, self).__init__()
self.masterLayout.addWidget(myFrame(),0,0)
self.masterLayout.addWidget(myFrame(),1,0)
self.setLayout(self.masterLayout)
Class myFrame(QFrame):
def __init__(self):
super(myFrame, self).__init__()
self.setStyleSheet("border: 1px solid black")
self.label = QLabel('Tracker01')
self.setMinimumWidth(60)
self.label.setMaximumWidth(100)
self.colorSwatch = QFrame()
self.colorSwatch.setFixedWidth(20)
self.colorSwatch.setFixedHeight(20)
self.colorSwatch.setStyleSheet("border: 1px solid black")
self.X_LineEdit = QLineEdit()
self.Y_LineEdit = QLineEdit()
self.Z_LineEdit = QLineEdit()
self.X_LineEdit.setMaximumWidth(60)
self.Y_LineEdit.setMaximumWidth(60)
self.Z_LineEdit.setMaximumWidth(60)
self.X_Label = QLabel('x')
self.Y_Label = QLabel('y')
self.Z_Label = QLabel('z')
self.X_Label.setMaximumWidth(10)
self.Y_Label.setMaximumWidth(10)
self.Z_Label.setMaximumWidth(10)
self.CopyValues = QPushButton('Cp')
self.CreateCard = QPushButton('Cr')
self.MarkPoint = QPushButton('Mk')
self.CopyValues.setMaximumWidth(30)
self.CreateCard.setMaximumWidth(30)
self.MarkPoint.setMaximumWidth(30)
self.layout = QHBoxLayout()
self.layout.addWidget(self.label)
self.layout.addWidget(self.colorSwatch)
self.layout.addWidget(self.X_Label)
self.layout.addWidget(self.X_LineEdit)
self.layout.addWidget(self.Y_Label)
self.layout.addWidget(self.Y_LineEdit)
self.layout.addWidget(self.Z_Label)
self.layout.addWidget(self.Z_LineEdit)
self.layout.addWidget(self.CreateCard)
self.layout.addWidget(self.CopyValues)
self.layout.addWidget(self.MarkPoint)
self.setLayout(self.layout)
class myPanel(QDialog):
def __init__(self):
super(myPanel, self).__init__()
self.masterLayout = QGridLayout()
self.masterLayout.addWidget(myFrame(),0,0)
self.masterLayout.addWidget(myFrame(),1,0)
self.setLayout(self.masterLayout)
To copy to clipboard, switch view to plain text mode
ex1.JPG
ex2.JPG
Bookmarks