def initUI(self): """Draw the UI.""" QToolTip.setFont(QFont('SansSerif', 12)) grid = QGridLayout() self.setLayout(grid) lbl_source = QLabel('Source:', self) lbl_source.setAlignment(Qt.AlignCenter) lbl_destination = QLabel('Destination:', self) lbl_destination.setAlignment(Qt.AlignCenter) self.cmb_source = QComboBox(self) self.populate_cmb_source() self.cmb_source.activated.connect(self.source_activated) self.cmb_source.setToolTip("Select either a source USB device " "or a source 'nb' backup directory") self.cmb_destination = QComboBox(self) self.populate_cmb_destination() self.cmb_destination.activated.connect(self.destination_activated) self.cmb_destination.setToolTip('Select a destination USB device') self.lbl_status = QLabel('', self) self.lbl_status.setAlignment(Qt.AlignLeft) self.btn_copy = QPushButton('Copy', self) # self.btn_copy.setFixedWidth(80) self.btn_copy.setFixedWidth(self.btn_copy.width()) self.btn_copy.clicked.connect(self.start_copy) self.btn_copy.setEnabled(False) hbox = QHBoxLayout() hbox.addWidget(self.lbl_status, Qt.AlignLeft) hbox.addStretch(1) hbox.addWidget(self.btn_copy, Qt.AlignRight) hbox.maximumSize() grid.addWidget(lbl_source, 0, 0, Qt.AlignRight) grid.addWidget(self.cmb_source, 0, 1) grid.addWidget(lbl_destination, 1, 0, Qt.AlignRight) grid.addWidget(self.cmb_destination, 1, 1) grid.addLayout(hbox, 2, 1) grid.setColumnStretch(0, 0) grid.setColumnStretch(1, 1) self.setWindowTitle('%s %s' % (ProgName, ProgVersion)) self.setMinimumWidth(MinimumWidth) self.show() self.setFixedHeight(self.height())
def initUI(self): """Draw the UI.""" QToolTip.setFont(QFont('SansSerif', 12)) grid = QGridLayout() self.setLayout(grid) lbl_source = QLabel('Source:', self) lbl_source.setAlignment(Qt.AlignCenter) lbl_destination = QLabel('Destination:', self) lbl_destination.setAlignment(Qt.AlignCenter) self.cmb_source = QComboBox(self) self.populate_cmb_source() self.cmb_source.activated.connect(self.source_activated) self.cmb_source.setToolTip("Select either a source USB device " "or a source 'nb' backup directory") self.cmb_destination = QComboBox(self) self.populate_cmb_destination() self.cmb_destination.activated.connect(self.destination_activated) self.cmb_destination.setToolTip('Select a destination USB device') self.lbl_status = QLabel('', self) self.lbl_status.setAlignment(Qt.AlignLeft) self.btn_copy = QPushButton('Copy', self) # self.btn_copy.setFixedWidth(80) self.btn_copy.setFixedWidth(self.btn_copy.width()) self.btn_copy.clicked.connect(self.start_copy) self.btn_copy.setEnabled(False) hbox = QHBoxLayout() hbox.addWidget(self.lbl_status, Qt.AlignLeft) hbox.addStretch(1) hbox.addWidget(self.btn_copy, Qt.AlignRight) hbox.maximumSize() grid.addWidget(lbl_source, 0, 0, Qt.AlignRight) grid.addWidget(self.cmb_source, 0, 1) grid.addWidget(lbl_destination, 1, 0, Qt.AlignRight) grid.addWidget(self.cmb_destination, 1, 1) grid.addLayout(hbox, 2, 1) grid.setColumnStretch(0, 0) grid.setColumnStretch(1, 1) self.setWindowTitle('%s %s' % (ProgName, ProgVersion)) self.setMinimumWidth(MinimumWidth) self.show() self.setFixedHeight(self.height())
def __init__(self, ui, title, recent_message, timestamp_ms, parent=None): super().__init__(parent) self.row = QVBoxLayout() # self.row.maximumSize = ui.conversationsList.maximumSize() title = truncate(title, 15) recent_message = truncate(recent_message, 30) heading_row = QHBoxLayout() heading_row.maximumSize = ui.conversationsList.maximumSize() title_font = QFont("Sans Serif", 10) title_label = QLabel(title) title_label.setFont(title_font) heading_row.addWidget(title_label) heading_row.setStretchFactor(title_label, 1) time_font = QFont("Sans Serif", 10) time_string = timestamp_ms_to_timestring(timestamp_ms) time_label = QLabel(time_string) time_label.setFont(time_font) heading_row.addWidget(time_label) heading_row.setStretchFactor(time_label, 0) self.row.addItem(heading_row) preview_font = QFont("Sans Serif", 9) preview_label = QLabel(recent_message) preview_label.setFont(preview_font) preview_label.setStyleSheet("QLabel {color: #555555;}") self.row.addWidget(preview_label) self.setLayout(self.row)