def show_ext_filter_selection_dialog(self): self.dlg = QDialog(self) self.dlg.setWindowTitle(self.tr('Extension Name To Show')) self.dlg.setLayout(QVBoxLayout()) self.dlg.layout().addWidget(QLabel('过滤文件名')) check_box = QCheckBox() self.dlg.check_box = check_box check_box.setChecked(self.filter_exts) self.dlg.layout().addWidget(check_box) check_box.stateChanged.connect( lambda stat: self.signal_ext_filter_adapt.emit(stat)) check_widget = PMCheckTree(data=self.exts_to_filter) self.dlg.check_widget = check_widget self.dlg.layout().addWidget(check_widget) buttonBox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel) buttonBox.accepted.connect(self.on_ext_filter_changed) buttonBox.rejected.connect(self.dlg.deleteLater) # 清除选择功能不完善目前禁用 # button_clear = buttonBox.addButton(self.tr('Clear Filter'), QDialogButtonBox.ApplyRole) # button_clear.clicked.connect(self.clear_ext_filter) self.dlg.layout().addWidget(buttonBox) self.dlg.exec_()
def _ask_overwrite(self): msg = QDialog() msg.setWindowTitle('Load overwrite') layout = QGridLayout() layout.addWidget( QLabel('Instrument %s already exists in memory. Overwrite this?'), 0, 0, 1, -1) buttons = [ QPushButton(label) for label in ['Load and overwrite', 'Cancel Load', 'Load and rename to'] ] locations = [[1, 0], [1, 1], [2, 0]] self.overwrite_flag = 1 def overwriteCB(idx): self.overwrite_flag = idx msg.accept() for idx, button in enumerate(buttons): button.clicked.connect(lambda _, idx=idx: overwriteCB(idx)) layout.addWidget(button, locations[idx][0], locations[idx][1]) newname = QLineEdit() newname.editingFinished.connect(lambda: overwriteCB(2)) layout.addWidget(newname, 2, 1) msg.setLayout(layout) msg.exec_() newname = str(newname.text()) if not newname or newname in self.instruments: self.errormessage('Invalid instrument name. Cancelling load.') self.overwrite_flag = 1 return self.overwrite_flag, newname
def show_tb(parent): tbdialog = QDialog(parent=parent.parent()) tbdialog.setModal(True) # this is about the minimum width to not get rewrap # and the minimum height to not have scrollbar tbdialog.resize(650, 270) tbdialog.setLayout(QVBoxLayout()) text = QTextEdit() theme = get_theme( get_settings().appearance.theme, as_dict=False ) _highlight = Pylighter( # noqa: F841 text.document(), "python", theme.syntax_style ) text.setText(notification.as_text()) text.setReadOnly(True) btn = QPushButton(trans._('Enter Debugger')) def _enter_debug_mode(): btn.setText( trans._( 'Now Debugging. Please quit debugger in console to continue' ) ) _debug_tb(notification.exception.__traceback__) btn.setText(trans._('Enter Debugger')) btn.clicked.connect(_enter_debug_mode) tbdialog.layout().addWidget(text) tbdialog.layout().addWidget(btn, 0, Qt.AlignRight) tbdialog.show()
def _command(self, node, channel): attrs = ['name', 'path', 'description', 'hidden', 'groups', 'enum', 'typeStr', 'disp'] if node.isinstance(pyrogue.RemoteCommand): attrs += ['offset', 'bitSize', 'bitOffset', 'varBytes'] msgBox = QDialog() msgBox.setWindowTitle("Command Information For {}".format(node.name)) msgBox.setMinimumWidth(400) vb = QVBoxLayout() msgBox.setLayout(vb) fl = QFormLayout() fl.setRowWrapPolicy(QFormLayout.DontWrapRows) fl.setFormAlignment(Qt.AlignHCenter | Qt.AlignTop) fl.setLabelAlignment(Qt.AlignRight) vb.addLayout(fl) pb = QPushButton('Close') pb.pressed.connect(msgBox.close) vb.addWidget(pb) for a in attrs: le = QLineEdit() le.setReadOnly(True) le.setText(str(getattr(node,a))) fl.addRow(a,le) le = QLineEdit() le.setReadOnly(True) le.setText(channel.address) fl.addRow('PyDM Path',le) msgBox.exec()
def _build_waverange_dialog(self, wave_range, line_list): dialog = QDialog(parent=self.centralWidget) loadUi(os.path.join(os.path.dirname(__file__), "ui", "linelists_waverange.ui"), dialog) dialog.min_text.setText("%.2f" % wave_range[0].value) dialog.max_text.setText("%.2f" % wave_range[1].value) validator = QDoubleValidator() validator.setBottom(0.0) validator.setDecimals(2) dialog.min_text.setValidator(validator) dialog.max_text.setValidator(validator) dialog.nlines_label = self._compute_nlines_in_waverange(line_list, dialog.min_text, dialog.max_text, dialog.nlines_label) dialog.min_text.editingFinished.connect(lambda: self._compute_nlines_in_waverange(line_list, dialog.min_text, dialog.max_text, dialog.nlines_label)) dialog.max_text.editingFinished.connect(lambda: self._compute_nlines_in_waverange(line_list, dialog.min_text, dialog.max_text, dialog.nlines_label)) accepted = dialog.exec_() > 0 amin = amax = None if accepted: return self._get_range_from_textfields(dialog.min_text, dialog.max_text) return (amin, amax)
def onHelp(self): """ Shows the help page """ try: from pymantidplot.proxies import showCustomInterfaceHelp showCustomInterfaceHelp("PyChop") except ImportError: helpTxt = "PyChop is a tool to allow direct inelastic neutron\nscattering users to estimate the inelastic resolution\n" helpTxt += "and incident flux for a given spectrometer setting.\n\nFirst select the instrument, chopper settings and\n" helpTxt += "Ei, and then click 'Calculate and Plot'. Data for all\nthe graphs will be generated (may take 1-2s) and\n" helpTxt += "all graphs will be updated. If the 'Hold current plot'\ncheck box is ticked, additional settings will be\n" helpTxt += "overplotted on the existing graphs if they are\ndifferent from previous settings.\n\nMore in-depth help " helpTxt += "can be obtained from the\nMantid help pages." self.hlpwin = QDialog() self.hlpedt = QLabel(helpTxt) self.hlpbtn = QPushButton('OK') self.hlpwin.layout = QVBoxLayout(self.hlpwin) self.hlpwin.layout.addWidget(self.hlpedt) self.hlpwin.layout.addWidget(self.hlpbtn) self.hlpbtn.clicked.connect(self.hlpwin.deleteLater) self.hlpwin.setWindowTitle('Help') self.hlpwin.setWindowModality(Qt.ApplicationModal) self.hlpwin.setAttribute(Qt.WA_DeleteOnClose) self.hlpwin.setMinimumSize(370, 300) self.hlpwin.resize(370, 300) self.hlpwin.show() self.hlploop = QEventLoop() self.hlploop.exec_()
def show_tb(parent): tbdialog = QDialog(parent=parent.parent()) tbdialog.setModal(True) # this is about the minimum width to not get rewrap # and the minimum height to not have scrollbar tbdialog.resize(650, 270) tbdialog.setLayout(QVBoxLayout()) text = QTextEdit() text.setHtml(notification.as_html()) text.setReadOnly(True) btn = QPushButton('Enter Debugger') def _enter_debug_mode(): btn.setText( 'Now Debugging. Please quit debugger in console ' 'to continue' ) _debug_tb(notification.exception.__traceback__) btn.setText('Enter Debugger') btn.clicked.connect(_enter_debug_mode) tbdialog.layout().addWidget(text) tbdialog.layout().addWidget(btn, 0, Qt.AlignRight) tbdialog.show()
def _device(self, node, channel): attrs = ['name', 'path', 'description', 'hidden', 'groups'] msgBox = QDialog() msgBox.setWindowTitle("Device Information For {}".format(node.name)) msgBox.setMinimumWidth(400) vb = QVBoxLayout() msgBox.setLayout(vb) fl = QFormLayout() fl.setRowWrapPolicy(QFormLayout.DontWrapRows) fl.setFormAlignment(Qt.AlignHCenter | Qt.AlignTop) fl.setLabelAlignment(Qt.AlignRight) vb.addLayout(fl) pb = QPushButton('Close') pb.pressed.connect(msgBox.close) vb.addWidget(pb) for a in attrs: le = QLineEdit() le.setReadOnly(True) le.setText(str(getattr(node,a))) fl.addRow(a,le) le = QLineEdit() le.setReadOnly(True) le.setText(channel.address) fl.addRow('PyDM Path',le) msgBox.exec()
def showText(self): """ Creates a dialog to show the generated text output. """ try: generatedText = self.genText() except ValueError: return self.txtwin = QDialog() self.txtedt = QTextEdit() self.txtbtn = QPushButton('OK') self.txtwin.layout = QVBoxLayout(self.txtwin) self.txtwin.layout.addWidget(self.txtedt) self.txtwin.layout.addWidget(self.txtbtn) self.txtbtn.clicked.connect(self.txtwin.deleteLater) self.txtedt.setText(generatedText) self.txtedt.setReadOnly(True) self.txtwin.setWindowTitle('Resolution information') self.txtwin.setWindowModality(Qt.ApplicationModal) self.txtwin.setAttribute(Qt.WA_DeleteOnClose) self.txtwin.setMinimumSize(400, 600) self.txtwin.resize(400, 600) self.txtwin.show() self.txtloop = QEventLoop() self.txtloop.exec_()
def tagsSim(): self.reject() Dialog = QDialog() file = open(path, "r", encoding="utf8", errors='ignore') jsonContent = json.loads(file.read().strip()) file.close() lista = procesador.similaritiesTAGS(str(jsonContent["tags"])) ui = Ui_Dialog(Dialog) ui.setupUi(lista, path)
def searchSim(): self.reject() Dialog = QDialog() file = open(path, "r", encoding="utf8", errors='ignore') jsonContent = json.loads(file.read().strip()) file.close() lista = procesador.search(str(jsonContent["noticia"])) ui = Ui_Dialog(Dialog) ui.setupUi(lista, path)
def on_edit_ports(self): from pmgwidgets import PMGPanel from qtpy.QtWidgets import QDialog, QVBoxLayout dlg = QDialog(self.base_rect.scene().flow_widget) sp = PMGPanel() p: 'CustomPort' = None input_ids, output_ids = [], [] input_texts, output_texts = [], [] self._last_var = 0 def new_id_input(): node_id = self.id max_val = 0 for p in self.input_ports: n, t, p = p.parse_id() if max_val < int(p): max_val = int(p) self._last_var += 1 return '%s:input:%d' % (node_id, max_val + self._last_var) def new_id_output(): node_id = self.id max_val = 0 for p in self.output_ports: n, t, p = p.parse_id() if max_val < int(p): max_val = int(p) self._last_var += 1 return '%s:output:%d' % (node_id, max_val + self._last_var) for p in self.input_ports: input_ids.append(p.id) input_texts.append(p.text) for p in self.output_ports: output_ids.append(p.id) output_texts.append(p.text) views = [] # views += self.content.get_settings_params() views += [ ('line_ctrl', 'text', 'Node Text', self.text), ] if self.content.ports_changable[0]: views.append(('list_ctrl', 'inputs', 'Set Inputs', [input_ids, input_texts], new_id_input)) if self.content.ports_changable[1]: views.append(('list_ctrl', 'outputs', 'Set Outputs', [output_ids, output_texts], new_id_output)) sp.set_items(views) dlg.setLayout(QVBoxLayout()) dlg.layout().addWidget(sp) dlg.exec_() dic = sp.get_value() self.change_ports_property(dic)
def showAbout(qt_viewer): d = QDialog() d.setObjectName('QtAboutKeybindings') d.setStyleSheet(qt_viewer.styleSheet()) d.setWindowTitle('Keybindings') qt_viewer._about_keybindings = QtAboutKeybindings(qt_viewer.viewer, d) d.show() d.setWindowModality(Qt.NonModal) d.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) qt_viewer._about_keybindings_dialog = d
def on_value_show_requested(self): from qtpy.QtWidgets import QDialog, QVBoxLayout val_dlg = QDialog() val_dlg.setLayout(QVBoxLayout()) text_show = QTextEdit() text = 'inputs:\n' + repr( self.node.content.input_args) + '\n' + 'results:\n' + repr( self.node.content.results) text_show.setText(text) val_dlg.layout().addWidget(text_show) val_dlg.exec_()
def set_bounds(self): dialog = QDialog() loadUi(os.path.join(UI_PATH, "roi_bounds_dialog.ui"), dialog) dialog.min_line_edit.setText("{:g}".format(self.getRegion()[0])) dialog.max_line_edit.setText("{:g}".format(self.getRegion()[-1])) if dialog.exec_(): self.setRegion([ float(dialog.min_line_edit.text()), float(dialog.max_line_edit.text()) ])
def __show_qrcode(self) -> None: """Save to image file.""" dlg = QDialog(self) dlg.setWindowTitle("Mechanism QR code") dlg.setModal(True) layout = QVBoxLayout(dlg) label = QLabel(dlg) layout.addWidget(label) label.setPixmap(self.image) dlg.setFixedSize(self.image.size()) dlg.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) dlg.show()
def openFileNameDialog(self): options = QFileDialog.Options() options |= QFileDialog.DontUseNativeDialog fileName, _ = QFileDialog.getOpenFileName(self, "Elige tu archivo", "", "Text Files (*.txt)", options=options) if fileName: Dialog = QDialog() ui = Noticia_Dialog(Dialog) ui.setupUi(fileName)
def show_about_dialog(parent: QWidget = None) -> None: label = QLabel() label.setText("Digital pathology for local <i>in vivo</i> drug delivery.") layout = QHBoxLayout() layout.addWidget(label) dialog = QDialog(parent=parent) dialog.setWindowModality(Qt.ApplicationModal) dialog.setLayout(layout) dialog.setWindowTitle("About") dialog.exec_()
def main(): args = sys.argv qapp = QApplication(args) dialog = QDialog() species_popup = SpeciesPopup(dialog, phases='GL') species_popup.show() # exit with Ctrl-C at the terminal signal.signal(signal.SIGINT, signal.SIG_DFL) qapp.exec_() qapp.deleteLater() sys.exit()
def __init__(self): app = QApplication(sys.argv) hcDialog = QDialog() hcui = HCGUI() hcui.setupUi(hcDialog) hcDialog.setWindowTitle("HC") hcDialog.show() eaDialog = QDialog() eaui = EAGUI() eaui.setupUi(eaDialog) eaDialog.setWindowTitle("EA") eaDialog.show() posDialog = QDialog() posui = POSGUI() posui.setupUi(posDialog) posDialog.setWindowTitle("POS") posDialog.show() sys.exit(app.exec_())
def show_tb(parent): tbdialog = QDialog(parent=parent.parent()) tbdialog.setModal(True) # this is about the minimum width to not get rewrap # and the minimum height to not have scrollbar tbdialog.resize(650, 270) tbdialog.setLayout(QVBoxLayout()) text = QTextEdit() text.setHtml(notification.as_html()) text.setReadOnly(True) tbdialog.layout().addWidget(text) tbdialog.show()
def ProxyDialog(self): def SetProxy(): self.use_proxy = bool(self.checkUseProxy.isChecked()) self.proxy_config = self.textProxyConfig.text() if os.environ['QT_API'] == 'pyqt': self.settings.setValue("use_proxy", self.use_proxy) self.settings.setValue("proxy_config", str(self.proxy_config)) elif os.environ['QT_API'] == 'pyqt5': self.settings.setValue("use_proxy", QtCore.QVariant(self.use_proxy)) self.settings.setValue("proxy_config", QtCore.QVariant(str(self.proxy_config))) d.done(0) d = QDialog() box = QVBoxLayout() hBox_proxy = QHBoxLayout() hBox_proxy.setSpacing(5) label = QLabel('Proxy') hBox_proxy.addWidget(label) self.textProxyConfig = QLineEdit() try: self.textProxyConfig.setText( self.settings.value('proxy_config', str)) except: self.textProxyConfig.setText(bombo.PROXY_DATA) self.textProxyConfig.setMinimumWidth(200) hBox_proxy.addWidget(self.textProxyConfig) box.addLayout(hBox_proxy) self.checkUseProxy = QCheckBox("Use proxy") try: self.checkUseProxy.setChecked( self.settings.value('use_proxy', bool)) except: self.checkUseProxy.setChecked(bool(bombo.USE_PROXY)) box.addWidget(self.checkUseProxy) button = QPushButton("Save configuration") button.clicked.connect(SetProxy) box.addWidget(button) d.setWindowTitle("Proxy configuration") d.setLayout(box) d.setWindowModality(QtCore.Qt.ApplicationModal) d.exec_()
def verify(): try: text = input_widget.document().toPlainText() l = eval(text) if isinstance(l, list): dialog2 = QDialog(dialog) sp2 = PMGPanel(parent=None, views=l) dialog2.setLayout(QHBoxLayout()) dialog2.layout().addWidget(sp2) dialog2.layout().addLayout(edit_layout) dialog2.exec_() except: import traceback traceback.print_exc()
def import_pythonpath(self): """Import from PYTHONPATH environment variable""" env_pypath = os.environ.get('PYTHONPATH', '') if env_pypath: env_pypath = env_pypath.split(os.pathsep) dlg = QDialog(self) dlg.setWindowTitle(_("PYTHONPATH")) dlg.setWindowIcon(ima.icon('pythonpath')) dlg.setAttribute(Qt.WA_DeleteOnClose) dlg.setMinimumWidth(400) label = QLabel("The following paths from your PYTHONPATH " "environment variable will be imported.") listw = QListWidget(dlg) listw.addItems(env_pypath) bbox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel) bbox.accepted.connect(dlg.accept) bbox.rejected.connect(dlg.reject) layout = QVBoxLayout() layout.addWidget(label) layout.addWidget(listw) layout.addWidget(bbox) dlg.setLayout(layout) if dlg.exec(): spy_pypath = self.get_path_dict() n = len(spy_pypath) for path in reversed(env_pypath): if (path in spy_pypath) or not self.check_path(path): continue item = self._create_item(path) self.listwidget.insertItem(n, item) self.refresh() else: QMessageBox.information( self, _("PYTHONPATH"), _("Your <tt>PYTHONPATH</tt> environment variable is empty, so " "there is nothing to import."), QMessageBox.Ok)
def _open_matrix_sel(self): wid = QDialog(self) wid.setObjectName(self._csorb.acc + 'App') wid.setLayout(QVBoxLayout()) cbbox = QComboBox(wid) cbbox.setEditable(True) cbbox.setMaxVisibleItems(10) corrnames = self._csorb.ch_names + self._csorb.cv_names if self._csorb.acc in {'SI', 'BO'}: corrnames.append('RF') cbbox.addItems(corrnames) wid.layout().addWidget(QLabel('Choose the corrector:', wid)) wid.layout().addWidget(cbbox) ledit = QDoubleSpinBoxPlus(wid) ledit.setMinimum(float('-inf')) ledit.setMaximum(float('inf')) ledit.setValue(1.0) wid.layout().addWidget(QLabel('Choose the Kick [urad]:', wid)) wid.layout().addWidget(ledit) ledit.valueChanged.connect(_part(self._accept_mat_sel, ledit, cbbox)) cbbox.currentIndexChanged.connect( _part(self._accept_mat_sel, ledit, cbbox)) hlay = QHBoxLayout() cancel = QPushButton('Cancel', wid) confirm = QPushButton('Ok', wid) cancel.clicked.connect(wid.reject) confirm.clicked.connect(wid.accept) confirm.clicked.connect(_part(self._accept_mat_sel, ledit, cbbox)) confirm.setDefault(True) hlay.addStretch() hlay.addWidget(cancel) hlay.addStretch() hlay.addWidget(confirm) hlay.addStretch() wid.layout().addItem(hlay) res = wid.exec_() if res != QDialog.Accepted: self._reset_orbit()
def _show_plugin_list(self, plugin_manager=None): """Show dialog with a table of installed plugins and metadata.""" if not plugin_manager: from ..plugins import plugin_manager dialog = QDialog(self._qt_window) dialog.setMaximumHeight(800) dialog.setMaximumWidth(1280) layout = QVBoxLayout() # maybe someday add a search bar here? title = QLabel("Installed Plugins") title.setObjectName("h2") layout.addWidget(title) # get metadata for successfully registered plugins plugin_manager.discover() data = plugin_manager.list_plugin_metadata() data = list(filter(lambda x: x['plugin_name'] != 'builtins', data)) # create a table for it dialog.table = QtDictTable( self._qt_window, data, headers=[ 'plugin_name', 'package', 'version', 'url', 'author', 'license', ], min_section_width=60, ) dialog.table.setObjectName("pluginTable") dialog.table.horizontalHeader().setObjectName("pluginTableHeader") dialog.table.verticalHeader().setObjectName("pluginTableHeader") dialog.table.setGridStyle(Qt.NoPen) # prevent editing of table dialog.table.setEditTriggers(QAbstractItemView.NoEditTriggers) layout.addWidget(dialog.table) dialog.setLayout(layout) dialog.setAttribute(Qt.WA_DeleteOnClose) self._plugin_list = dialog dialog.exec_()
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 _build_waverange_dialog(self, wave_range, line_list): dialog = QDialog(parent=self.centralWidget) dialog.setWindowTitle("Wavelength range") dialog.setWindowModality(Qt.ApplicationModal) dialog.resize(370, 250) button_ok = QPushButton("OK") button_ok.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) button_cancel = QPushButton("Cancel") button_cancel.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) button_ok.clicked.connect(dialog.accept) button_cancel.clicked.connect(dialog.reject) min_text = QLineEdit("%.2f" % wave_range[0].value) max_text = QLineEdit("%.2f" % wave_range[1].value) validator = QDoubleValidator() validator.setBottom(0.0) validator.setDecimals(2) min_text.setValidator(validator) max_text.setValidator(validator) min_text.setFixedWidth(150) max_text.setFixedWidth(150) min_text.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) max_text.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) min_text.setToolTip("Minimum wavelength to read from list.") max_text.setToolTip("Maximum wavelength to read from list.") nlines_label = self._compute_nlines_in_waverange( line_list, min_text, max_text) min_text.editingFinished.connect( lambda: self._compute_nlines_in_waverange( line_list, min_text, max_text, label=nlines_label)) max_text.editingFinished.connect( lambda: self._compute_nlines_in_waverange( line_list, min_text, max_text, label=nlines_label)) # set up layouts and widgets for the dialog. text_pane = QWidget() text_layout = QGridLayout() text_layout.addWidget(min_text, 1, 0) text_layout.addWidget(QLabel("Minimum wavelength"), 0, 0) text_layout.addWidget(max_text, 1, 1) text_layout.addWidget(QLabel("Maximum wavelength"), 0, 1) spacerItem = QSpacerItem(40, 10, QSizePolicy.Expanding, QSizePolicy.Minimum) text_layout.addItem(spacerItem, 1, 2) text_pane.setLayout(text_layout) label_pane = QWidget() label_layout = QHBoxLayout() label_layout.addWidget(nlines_label) label_layout.addWidget(QLabel(" lines included in range.")) label_layout.addStretch() label_pane.setLayout(label_layout) button_pane = QWidget() button_layout = QHBoxLayout() button_layout.addStretch() button_layout.addWidget(button_cancel) button_layout.addWidget(button_ok) button_pane.setLayout(button_layout) dialog_layout = QVBoxLayout() dialog_layout.setSizeConstraint(QLayout.SetMaximumSize) dialog_layout.addWidget(text_pane) dialog_layout.addWidget(label_pane) dialog_layout.addStretch() dialog_layout.addWidget(button_pane) dialog.setLayout(dialog_layout) button_ok.setDefault(True) button_cancel.setDefault(False) accepted = dialog.exec_() > 0 amin = amax = None if accepted: return self._get_range_from_textfields(min_text, max_text) return (amin, amax)
def PlotSpecificAreaDialog(self): def PlotSpecificArea(): # Save coordinates for the next time if os.environ['QT_API'] == 'pyqt': self.settings.setValue("last_point_coord_lat", self.spinboxLatDec.value()) self.settings.setValue("last_point_coord_lon", self.spinboxLonDec.value()) elif os.environ['QT_API'] == 'pyqt5': self.settings.setValue( "last_point_coord_lat", QtCore.QVariant(self.spinboxLatDec.value())) self.settings.setValue( "last_point_coord_lon", QtCore.QVariant(self.spinboxLonDec.value())) # Select the 3D Map tab self.tab.setCurrentIndex(2) # Plot if self.check3DMapSelection.isChecked(): tile_selection = 'auto' else: tile_selection = self.text3DMapName.text() terrain, track, warnings = bombo.Generate3DMap( [self.spinboxLatDec.value()], [self.spinboxLonDec.value()], tile_selection=tile_selection, margin=self.spinbox3DMargin.value(), elevation_scale=self.spinbox3DElevationScale.value(), mapping='coords', use_osm_texture=True, texture_type='osm', texture_zoom=self.spinbox3DOSMZoom.value(), texture_invert=self.check3DOSMInvert.isChecked(), use_proxy=self.use_proxy, proxy_data=self.proxy_config, verbose=False) self.textWarningConsole.append(warnings) if terrain is not None: self.map3d.update_plot(terrain, track) d.done(0) def Convert(): try: dd = bombo.parse_dms(self.textLatLonGMS.text()) self.spinboxLatDec.setValue(dd[0]) self.spinboxLonDec.setValue(dd[1]) except: pass d = QDialog() grid = QGridLayout() hBox_coordsGMS = QHBoxLayout() hBox_coordsGMS.setSpacing(5) label = QLabel('Coordinates (gms)') grid.addWidget(label, 0, 0) self.textLatLonGMS = QLineEdit() self.textLatLonGMS.setText("") grid.addWidget(self.textLatLonGMS, 0, 1, 1, 2) button1 = QPushButton("Convert to decimal") button1.clicked.connect(Convert) grid.addWidget(button1, 0, 3) label = QLabel('Coordinates (decimal)') grid.addWidget(label, 1, 0) self.spinboxLatDec = QDoubleSpinBox() self.spinboxLatDec.setRange(-90, +90) self.spinboxLatDec.setSingleStep(0.0000001) self.spinboxLatDec.setDecimals(7) grid.addWidget(self.spinboxLatDec, 1, 1) self.spinboxLonDec = QDoubleSpinBox() self.spinboxLonDec.setRange(-180, +180) self.spinboxLonDec.setSingleStep(0.0000001) self.spinboxLonDec.setDecimals(7) grid.addWidget(self.spinboxLonDec, 1, 2) # Try to recover the last used points try: old_lat = self.settings.value("last_point_coord_lat", type=float) old_lon = self.settings.value("last_point_coord_lon", type=float) self.spinboxLatDec.setValue(old_lat) self.spinboxLonDec.setValue(old_lon) except: # Coordinates of Mt. Rinjani in Indonesia self.spinboxLatDec.setValue(-8.4166000) self.spinboxLonDec.setValue(116.4666000) button2 = QPushButton("Show 3D map") button2.clicked.connect(PlotSpecificArea) grid.addWidget(button2, 1, 3) d.setWindowTitle("Show point on 3D map") d.setLayout(grid) d.setWindowModality(QtCore.Qt.ApplicationModal) d.exec_()