def createPropertiesWidget(self, propertiesWidget): self.propertyEditor = weakref.ref(propertiesWidget) baseCategory = CollapsibleFormWidget(headName="Base") le_name = QLineEdit(self.getName()) le_name.setReadOnly(True) baseCategory.addWidget("Name", le_name) leUid = QLineEdit(str(self._rawNode.graph().name)) leUid.setReadOnly(True) baseCategory.addWidget("Owning graph", leUid) text = "{0}".format(self.packageName) if self._rawNode.lib: text += " | {0}".format(self._rawNode.lib) text += " | {0}".format(self._rawNode.__class__.__name__) leType = QLineEdit(text) leType.setReadOnly(True) baseCategory.addWidget("Type", leType) self.propertyEditor().addWidget(baseCategory) self.createInputWidgets(self.propertyEditor()) Info = CollapsibleFormWidget(headName="Info", collapsed=True) doc = QTextBrowser() doc.setOpenExternalLinks(True) doc.setHtml(self.description()) Info.addWidget(widget=doc) self.propertyEditor().addWidget(Info)
def createPropertiesWidget(self, propertiesWidget): baseCategory = CollapsibleFormWidget(headName="Base") # name le_name = QLineEdit(self.getName()) le_name.setReadOnly(True) # if self.isRenamable(): le_name.setReadOnly(False) le_name.returnPressed.connect(lambda: self.setName(le_name.text())) baseCategory.addWidget("Name", le_name) # type leType = QLineEdit(self.__class__.__name__) leType.setReadOnly(True) baseCategory.addWidget("Type", leType) # pos le_pos = QLineEdit("{0} x {1}".format(self.pos().x(), self.pos().y())) baseCategory.addWidget("Pos", le_pos) propertiesWidget.addWidget(baseCategory) appearanceCategory = CollapsibleFormWidget(headName="Appearance") pb = QPushButton("...") pb.clicked.connect(lambda: self.onChangeColor(True)) appearanceCategory.addWidget("Color", pb) propertiesWidget.addWidget(appearanceCategory) infoCategory = CollapsibleFormWidget(headName="Info") doc = QTextBrowser() doc.setOpenExternalLinks(True) doc.setHtml(self.description()) infoCategory.addWidget("", doc) propertiesWidget.addWidget(infoCategory)
def __init__(self, page, parent=None): super(HelpForm, self).__init__(parent) self.setAttribute(Qt.WA_DeleteOnClose) self.setAttribute(Qt.WA_GroupLeader) backAction = QAction(QIcon(":/back.png"), "&Back", self) backAction.setShortcut(QKeySequence.Back) homeAction = QAction(QIcon(":/home.png"), "&Home", self) homeAction.setShortcut("Home") self.pageLabel = QLabel() toolBar = QToolBar() toolBar.addAction(backAction) toolBar.addAction(homeAction) toolBar.addWidget(self.pageLabel) self.textBrowser = QTextBrowser() layout = QVBoxLayout() layout.addWidget(toolBar) layout.addWidget(self.textBrowser, 1) self.setLayout(layout) backAction.triggered.connect(self.tbackward) homeAction.triggered.connect(self.thome) self.textBrowser.sourceChanged.connect(self.updatePageTitle) self.textBrowser.setSearchPaths([":/help"]) self.textBrowser.setSource(QUrl(page)) self.resize(400, 600) self.setWindowTitle("{0} Help".format(QApplication.applicationName()))
def onUpdatePropertyView(self, formLayout): # name le_name = QLineEdit(self.getName()) le_name.setReadOnly(True) if self.label().IsRenamable(): le_name.setReadOnly(False) le_name.returnPressed.connect(lambda: self.setName(le_name.text())) formLayout.addRow("Name", le_name) # uid leUid = QLineEdit(str(self.uid)) leUid.setReadOnly(True) #formLayout.addRow("Uuid", leUid) # type leType = QLineEdit(self.__class__.__name__) leType.setReadOnly(True) formLayout.addRow("Type", leType) # pos #le_pos = QLineEdit("{0} x {1}".format(self.pos().x(), self.pos().y())) #formLayout.addRow("Pos", le_pos) # inputs if len([i for i in self.inputs.values()]) != 0: for inp in self.inputs.values(): dataSetter = inp.call if inp.dataType == DataTypes.Exec else inp.setData if not inp.hasConnections(): w = getInputWidget(inp.dataType, dataSetter, inp.defaultValue(), inp.getUserStruct()) if w: w.setWidgetValue(inp.currentData()) w.setObjectName(inp.getName()) formLayout.addRow(inp.name, w) if inp.hasConnections(): w.setEnabled(False) w.hide() if self.asGraphSides: # outputs if len([i for i in self.outputs.values()]) != 0: for out in self.outputs.values(): dataSetter = out.call if out.dataType == DataTypes.Exec else out.setData w = getInputWidget(out.dataType, dataSetter, out.defaultValue(), out.getUserStruct()) if w: w.setWidgetValue(out.currentData()) w.setObjectName(out.getName()) formLayout.addRow(out.name, w) if out.hasConnections(): w.setEnabled(True) doc_lb = QLabel() doc_lb.setStyleSheet("background-color: black;") doc_lb.setText("Description") #formLayout.addRow("", doc_lb) doc = QTextBrowser() doc.setOpenExternalLinks(True) doc.setHtml(self.description())
def _build_ui(self): layout = QGridLayout() self.text = QTextBrowser() font = QFontDatabase.systemFont(QFontDatabase.FixedFont) self.text.setFont(font) layout.addWidget(self.text, 0, 0) self.ui_area.setLayout(layout) self.manage(None)
def _build_ui(self): layout = QVBoxLayout() self.results = QTextBrowser() font = QFontDatabase.systemFont(QFontDatabase.FixedFont) self.results.setFont(font) layout.insertWidget(0, self.results, 1) self.ui_area.setLayout(layout) self.manage(None)
def __init__(self): super(LoggerTool, self).__init__() self.logView = QTextBrowser() self.logView.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu) self.logView.setOpenLinks(False) self.logView.setReadOnly(True) self.logView.setStyleSheet( "background-color: %s; Font: 10pt 'Consolas'" % "rgba%s" % str(editableStyleSheet().LoggerBgColor.getRgb())) self.clearAction = QAction("Clear", None) self.clearAction.triggered.connect(self.clearView) self.logView.addAction(self.clearAction) self.logView.anchorClicked.connect(self.anchorClickedMethod) self.logView.setTextColor(QtGui.QColor('white')) self.setWidget(self.logView) ##################################################### # Sys Output Redirection ##################################################### self.handler = None if REDIRECT: self.handler = QtHandler(self) else: self.handler = logging.StreamHandler(sys.stdout) self.handler.setFormatter(LoggerTool.formater) logger.addHandler(self.handler) logger.setLevel(logging.DEBUG) sys.excepthook = LoggerTool.exceptHook if self.handler and REDIRECT: self.handler.messageHolder.messageWritten.connect( lambda value: self.logPython(value, 0)) self.handler.messageHolder.warningWritten.connect( lambda value: self.logPython(value, 1)) self.handler.messageHolder.errorWritten.connect( lambda value: self.logPython(value, 2)) self.handler.messageHolder.flushSig.connect(self.flushPython)
def onUpdatePropertyView(self, formLayout): # name le_name = QLineEdit(self.getName()) le_name.setReadOnly(True) if self.label().IsRenamable(): le_name.setReadOnly(False) le_name.returnPressed.connect(lambda: self.setName(le_name.text())) formLayout.addRow("Name", le_name) # uid leUid = QLineEdit(str(self.uid)) leUid.setReadOnly(True) formLayout.addRow("Uuid", leUid) # type leType = QLineEdit(self.__class__.__name__) leType.setReadOnly(True) formLayout.addRow("Type", leType) # pos le_pos = QLineEdit("{0} x {1}".format(self.pos().x(), self.pos().y())) formLayout.addRow("Pos", le_pos) pb = QPushButton("...") pb.clicked.connect(self.onChangeColor) formLayout.addRow("Color", pb) doc_lb = QLabel() doc_lb.setStyleSheet("background-color: black;") doc_lb.setText("Description") formLayout.addRow("", doc_lb) doc = QTextBrowser() doc.setOpenExternalLinks(True) doc.setHtml(self.description()) formLayout.addRow("", doc)
def _build_ui(self): #each group has an empty widget at the bottom so they resize the way I want while also having the #labels where I want them layout = QGridLayout() self.tab_widget = QTabWidget() layout.addWidget(self.tab_widget) #layout for absolute thermo stuff absolute_widget = QWidget() absolute_layout = QGridLayout(absolute_widget) #box for sp sp_area_widget = QGroupBox("Single-point") sp_layout = QFormLayout(sp_area_widget) self.sp_selector = FilereaderComboBox(self.session, otherItems=['energy']) self.sp_selector.currentIndexChanged.connect(self.set_sp) sp_layout.addRow(self.sp_selector) self.sp_table = QTableWidget() self.sp_table.setColumnCount(3) self.sp_table.setShowGrid(False) self.sp_table.horizontalHeader().hide() self.sp_table.verticalHeader().hide() self.sp_table.setFrameShape(QTableWidget.NoFrame) self.sp_table.setSelectionMode(QTableWidget.NoSelection) self.sp_table.insertRow(0) sp_layout.addRow(self.sp_table) #box for thermo therm_area_widget = QGroupBox("Thermal corrections") thermo_layout = QFormLayout(therm_area_widget) self.thermo_selector = FilereaderComboBox(self.session, otherItems=['frequency']) self.thermo_selector.currentIndexChanged.connect(self.set_thermo_mdl) thermo_layout.addRow(self.thermo_selector) self.temperature_line = QDoubleSpinBox() self.temperature_line.setMaximum(2**31 - 1) self.temperature_line.setValue(298.15) self.temperature_line.setSingleStep(10) self.temperature_line.setSuffix(" K") self.temperature_line.setMinimum(0) self.temperature_line.valueChanged.connect(self.set_thermo) thermo_layout.addRow("T =", self.temperature_line) self.v0_edit = QDoubleSpinBox() self.v0_edit.setMaximum(4000) self.v0_edit.setValue(self.settings.w0) self.v0_edit.setSingleStep(25) self.v0_edit.setSuffix(" cm\u207b\u00b9") self.v0_edit.valueChanged.connect(self.set_thermo) self.v0_edit.setMinimum(0) self.v0_edit.setToolTip( "frequency parameter for quasi treatments of entropy") thermo_layout.addRow("𝜔<sub>0</sub> =", self.v0_edit) self.thermo_table = QTableWidget() self.thermo_table.setColumnCount(3) self.thermo_table.setShowGrid(False) self.thermo_table.horizontalHeader().hide() self.thermo_table.verticalHeader().hide() self.thermo_table.setFrameShape(QTableWidget.NoFrame) self.thermo_table.setSelectionMode(QTableWidget.NoSelection) thermo_layout.addRow(self.thermo_table) # for for total sum_area_widget = QGroupBox("Thermochemistry") sum_layout = QFormLayout(sum_area_widget) self.sum_table = QTableWidget() self.sum_table.setColumnCount(3) self.sum_table.setShowGrid(False) self.sum_table.horizontalHeader().hide() self.sum_table.verticalHeader().hide() self.sum_table.setFrameShape(QTableWidget.NoFrame) self.sum_table.setSelectionMode(QTableWidget.NoSelection) sum_layout.addRow(self.sum_table) splitter = QSplitter(Qt.Horizontal) splitter.setChildrenCollapsible(False) splitter.addWidget(sp_area_widget) splitter.addWidget(therm_area_widget) splitter.addWidget(sum_area_widget) absolute_layout.addWidget(splitter) self.status = QStatusBar() self.status.setSizeGripEnabled(False) self.status.setStyleSheet("color: red") absolute_layout.addWidget(self.status, 1, 0, 1, 1, Qt.AlignTop) self.tab_widget.addTab(absolute_widget, "absolute") relative_widget = QWidget() relative_layout = QGridLayout(relative_widget) size = [self.settings.ref_col_1, self.settings.ref_col_2] self.ref_group = ThermoGroup("reference group", self.session, self.nrg_fr, self.thermo_co, size) self.ref_group.changes.connect(self.calc_relative_thermo) relative_layout.addWidget(self.ref_group, 0, 0, 1, 3, Qt.AlignTop) size = [self.settings.other_col_1, self.settings.other_col_2] self.other_group = ThermoGroup("other group", self.session, self.nrg_fr, self.thermo_co, size) self.other_group.changes.connect(self.calc_relative_thermo) relative_layout.addWidget(self.other_group, 0, 3, 1, 3, Qt.AlignTop) self.relative_temperature = QDoubleSpinBox() self.relative_temperature.setMaximum(2**31 - 1) self.relative_temperature.setValue(self.settings.rel_temp) self.relative_temperature.setSingleStep(10) self.relative_temperature.setSuffix(" K") self.relative_temperature.setMinimum(0) self.relative_temperature.valueChanged.connect( self.calc_relative_thermo) relative_layout.addWidget(QLabel("T ="), 1, 0, 1, 1, Qt.AlignRight | Qt.AlignVCenter) relative_layout.addWidget(self.relative_temperature, 1, 1, 1, 5, Qt.AlignLeft | Qt.AlignVCenter) self.relative_v0 = QDoubleSpinBox() self.relative_v0.setMaximum(2**31 - 1) self.relative_v0.setValue(self.settings.w0) self.relative_v0.setSingleStep(25) self.relative_v0.setSuffix(" cm\u207b\u00b9") self.relative_v0.setMinimum(0) self.relative_v0.setToolTip( "frequency parameter for quasi treatments of entropy") self.relative_v0.valueChanged.connect(self.calc_relative_thermo) relative_layout.addWidget(QLabel("𝜔<sub>0</sub> ="), 2, 0, 1, 1, Qt.AlignRight | Qt.AlignVCenter) relative_layout.addWidget(self.relative_v0, 2, 1, 1, 5, Qt.AlignLeft | Qt.AlignVCenter) relative_layout.addWidget( QLabel("Boltzmann-weighted relative energies in kcal/mol:"), 3, 0, 1, 6, Qt.AlignVCenter | Qt.AlignLeft) self.relative_table = QTextBrowser() self.relative_table.setMaximumHeight( 4 * self.relative_table.fontMetrics().boundingRect("Q").height()) relative_layout.addWidget(self.relative_table, 4, 0, 1, 6, Qt.AlignTop) relative_layout.setRowStretch(0, 1) relative_layout.setRowStretch(1, 0) relative_layout.setRowStretch(2, 0) relative_layout.setRowStretch(3, 0) relative_layout.setRowStretch(4, 0) self.tab_widget.addTab(relative_widget, "relative") #menu stuff menu = QMenuBar() export = menu.addMenu("&Export") copy = QAction("&Copy CSV to clipboard", self.tool_window.ui_area) copy.triggered.connect(self.copy_csv) shortcut = QKeySequence(Qt.CTRL + Qt.Key_C) copy.setShortcut(shortcut) export.addAction(copy) self.copy = copy save = QAction("&Save CSV...", self.tool_window.ui_area) save.triggered.connect(self.save_csv) #this shortcut interferes with main window's save shortcut #I've tried different shortcut contexts to no avail #thanks Qt... #shortcut = QKeySequence(Qt.CTRL + Qt.Key_S) #save.setShortcut(shortcut) #save.setShortcutContext(Qt.WidgetShortcut) export.addAction(save) delimiter = export.addMenu("Delimiter") comma = QAction("comma", self.tool_window.ui_area, checkable=True) comma.setChecked(self.settings.delimiter == "comma") comma.triggered.connect(lambda *args, delim="comma": self.settings. __setattr__("delimiter", delim)) delimiter.addAction(comma) tab = QAction("tab", self.tool_window.ui_area, checkable=True) tab.setChecked(self.settings.delimiter == "tab") tab.triggered.connect(lambda *args, delim="tab": self.settings. __setattr__("delimiter", delim)) delimiter.addAction(tab) space = QAction("space", self.tool_window.ui_area, checkable=True) space.setChecked(self.settings.delimiter == "space") space.triggered.connect(lambda *args, delim="space": self.settings. __setattr__("delimiter", delim)) delimiter.addAction(space) semicolon = QAction("semicolon", self.tool_window.ui_area, checkable=True) semicolon.setChecked(self.settings.delimiter == "semicolon") semicolon.triggered.connect(lambda *args, delim="semicolon": self. settings.__setattr__("delimiter", delim)) delimiter.addAction(semicolon) add_header = QAction("&Include CSV header", self.tool_window.ui_area, checkable=True) add_header.setChecked(self.settings.include_header) add_header.triggered.connect(self.header_check) export.addAction(add_header) comma.triggered.connect( lambda *args, action=tab: action.setChecked(False)) comma.triggered.connect( lambda *args, action=space: action.setChecked(False)) comma.triggered.connect( lambda *args, action=semicolon: action.setChecked(False)) tab.triggered.connect( lambda *args, action=comma: action.setChecked(False)) tab.triggered.connect( lambda *args, action=space: action.setChecked(False)) tab.triggered.connect( lambda *args, action=semicolon: action.setChecked(False)) space.triggered.connect( lambda *args, action=comma: action.setChecked(False)) space.triggered.connect( lambda *args, action=tab: action.setChecked(False)) space.triggered.connect( lambda *args, action=semicolon: action.setChecked(False)) semicolon.triggered.connect( lambda *args, action=comma: action.setChecked(False)) semicolon.triggered.connect( lambda *args, action=tab: action.setChecked(False)) semicolon.triggered.connect( lambda *args, action=space: action.setChecked(False)) menu.setNativeMenuBar(False) self._menu = menu layout.setMenuBar(menu) menu.setVisible(True) self.tool_window.ui_area.setLayout(layout) self.tool_window.manage(None)