class AnswerWindow: def __init__(self, parent=None, numTab=5): self.w = QDialog() self.parent = parent self.tables = [] self.numTab = numTab self.initUI() def closeWindow(self): self.w.close() def show(self): self.setData() self.w.exec_() def setData(self, data=None): horHeaders = [u'条件', u'値'] condNames = [ u'線材種', u'回転方向', u'回転速度', u'送り速度', u'切り込み量', u'突き出し量', u'乗せ率', u'パス回数', u'摩耗量' ] for i in range(self.numTab): table = self.tables[i] table.setHorizontalHeaderLabels(horHeaders) for m in condNames: item = QTableWidgetItem(m) table.setItem(condNames.index(m), 0, item) def initUI(self): self.w.setWindowTitle(u'回答結果') vbox = QVBoxLayout() ansBtn = QPushButton(u"閉じる") ansBtn.clicked.connect(self.closeWindow) self.tabs = QTabWidget() for i in range(self.numTab): tab = QTableWidget() tab.setRowCount(9) # あとで9のところは変更してください。 tab.setColumnCount(2) self.tabs.addTab(tab, "第" + str(i + 1) + "候補") self.tables.append(tab) vbox.addWidget(self.tabs) vbox.addWidget(ansBtn) self.w.setLayout(vbox)
class SignalDialogButton(QPushButton): """QPushButton to launch a QDialog with a PyDMWidget""" text = NotImplemented icon = NotImplemented parent_widget_class = QtWidgets.QWidget def __init__(self, init_channel, text=None, icon=None, parent=None): self.text = text or self.text self.icon = icon or self.icon super().__init__(qta.icon(self.icon), self.text, parent=parent) self.clicked.connect(self.show_dialog) self.dialog = None self.channel = init_channel self.setIconSize(QSize(15, 15)) def widget(self, channel): """Return a widget created with channel""" raise NotImplementedError def show_dialog(self): """Show the channel in a QDialog""" # Dialog Creation if not self.dialog: logger.debug("Creating QDialog for %r", self.channel) # Set up the QDialog parent = utils.find_parent_with_class(self, self.parent_widget_class) self.dialog = QDialog(parent) self.dialog.setWindowTitle(self.channel) self.dialog.setLayout(QVBoxLayout()) self.dialog.layout().setContentsMargins(2, 2, 2, 2) # Add the widget widget = self.widget() self.dialog.layout().addWidget(widget) # Handle a lost dialog else: logger.debug("Redisplaying QDialog for %r", self.channel) self.dialog.close() # Show the dialog logger.debug("Showing QDialog for %r", self.channel) self.dialog.show()
def final_dialog(self, label): """ Final dialog that to show where the calculated collapsed cube was put. :param label: :return: """ final_dialog = QDialog() # Create data component label and input box widget_desc = QLabel( 'The collapsed cube was added as an overlay with label "{}"'. format(label)) widget_desc.setWordWrap(True) widget_desc.setFixedWidth(350) widget_desc.setAlignment((Qt.AlignLeft | Qt.AlignTop)) hb_desc = QHBoxLayout() hb_desc.addWidget(widget_desc) # Create Ok button okButton = QPushButton("Ok") okButton.clicked.connect(lambda: final_dialog.close()) okButton.setDefault(True) hb_buttons = QHBoxLayout() hb_buttons.addStretch(1) hb_buttons.addWidget(okButton) # Add description and buttons to popup box vbl = QVBoxLayout() vbl.addLayout(hb_desc) vbl.addLayout(hb_buttons) final_dialog.setLayout(vbl) final_dialog.setMaximumWidth(400) final_dialog.show()
def final_dialog(self, label): """ Final dialog that to show where the calculated collapsed cube was put. :param label: :return: """ final_dialog = QDialog() # Create data component label and input box widget_desc = QLabel('The collapsed cube was added as an overlay with label "{}". {}'.format( label, self._extra_message)) widget_desc.setWordWrap(True) widget_desc.setFixedWidth(350) widget_desc.setAlignment((Qt.AlignLeft | Qt.AlignTop)) hb_desc = QHBoxLayout() hb_desc.addWidget(widget_desc) # Create Ok button okButton = QPushButton("Ok") okButton.clicked.connect(lambda: final_dialog.close()) okButton.setDefault(True) hb_buttons = QHBoxLayout() hb_buttons.addStretch(1) hb_buttons.addWidget(okButton) # Add description and buttons to popup box vbl = QVBoxLayout() vbl.addLayout(hb_desc) vbl.addLayout(hb_buttons) final_dialog.setLayout(vbl) final_dialog.setMaximumWidth(400) final_dialog.show()