def frac_name_changed(self, name): """ Called when Region Line Edit is changed.""" self.have_default_name = False if self.is_unique_frac_name(name): self.image.setPixmap( icon.get_app_icon("sign-check").pixmap( self.fracture_name.sizeHint().height())) self.image.setToolTip('Unique name is OK.') self._tranform_button.setEnabled(True) else: self.image.setPixmap( icon.get_app_icon("warning").pixmap( self.fracture_name.sizeHint().height())) self.image.setToolTip('Name is not unique!') self._tranform_button.setEnabled(False)
def __init__(self): # load config cfg.init(None) # main window self._app = QtWidgets.QApplication(sys.argv) #print("Model app: ", str(self._app)) self._app.setWindowIcon(icon.get_app_icon("me-geomap")) self.mainwindow = MainWindow(self) cfg.main_window = self.mainwindow # set default values self._update_document_name() # show self.mainwindow.show() self.autosave = Autosave(cfg.config.CONFIG_DIR, lambda: cfg.curr_file, self.mainwindow.editor.text) """Object handling automatic saving""" self._restore_backup() if len(cfg.document) > 0: self.mainwindow.reload() self.mainwindow.editor.textChanged.connect(self.autosave.start_autosave) self.reloader_timer = QtCore.QTimer() """timer for file time checking in ms""" self.reloader_timer.timeout.connect(self.check_file) self.reloader_timer.start(RELOAD_INTERVAL)
def __init__(self, init_dialog=True): # main window self._app = QtWidgets.QApplication(sys.argv) self._app.setStyleSheet(style_sheet) #print("Layer app: ", str(self._app)) self._app.setWindowIcon(icon.get_app_icon("le-geomap")) # load config cfg.init() # set default font to layers #cfg.layers.font = self._app.font() # set geomop root dir cfg.geomop_root = os.path.dirname( os.path.dirname(os.path.realpath(__file__))) self.mainwindow = MainWindow(self) cfg.set_main(self.mainwindow) self.exit = False # save_fn = lambda: json.dumps(cfg.le_serializer.cfg_to_geometry( # cfg, self.autosave.backup_filename()).serialize(), # indent=4, sort_keys=True) save_fn = lambda c=cfg: cfg.le_serializer.save(c) self.autosave = Autosave(cfg.config.CONFIG_DIR, lambda: cfg.curr_file, save_fn) # Try to restore Untitled.yaml. if self._restore_backup(): init_dlg_result = QtWidgets.QDialog.Accepted else: if init_dialog: init_dlg = SetDiagramDlg() init_dlg_result = init_dlg.exec_() if init_dlg.closed: self.exit = True return else: init_dlg_result = QtWidgets.QDialog.Accepted cfg.diagram.area.set_area([0, 0, 100, 100], [0, 100, 100, 0]) # show self.mainwindow.show() if init_dlg_result != QtWidgets.QDialog.Accepted: if not self.open_file(): self.mainwindow.close() self.mainwindow._layer_editor = None del self.mainwindow self.exit = True return # set default values self.mainwindow.paint_new_data() self._update_document_name() self.autosave.start_autosave()
def __init__(self, min, max, copy_block, parent=None): super(SplitLayerDlg, self).__init__(parent) self.setWindowTitle("Split Layer") grid = QtWidgets.QGridLayout(self) d_layer_name = QtWidgets.QLabel("Layer Name:", self) self.layer_name = QtWidgets.QLineEdit() self.layer_name.setToolTip( "New Layer name (New layer is in the bottom)") self.have_default_name = True self.set_default_name() self.layer_name.textChanged.connect(self.lay_name_changed) self.image = QtWidgets.QLabel(self) self.image.setMinimumWidth(self.layer_name.sizeHint().height()) self.image.setPixmap( icon.get_app_icon("sign-check").pixmap( self.layer_name.sizeHint().height())) self.image.setToolTip('Layer name is unique, everything is fine.') grid.addWidget(d_layer_name, 0, 0) grid.addWidget(self.layer_name, 0, 1) grid.addWidget(self.image, 0, 2) d_split_type = QtWidgets.QLabel("Split Interface Type:", self) self.split_type = LayersHelpers.split_type_combo(copy_block) grid.addWidget(d_split_type, 1, 0) grid.addWidget(self.split_type, 1, 1) d_surface = QtWidgets.QLabel("Split in Surface:", self) grid.addWidget(d_surface, 2, 0) i = LayersHelpers.add_surface_to_grid(self, grid, 3) self.validator = QtGui.QDoubleValidator() self.validator.setBottom(min) self.validator.setTop(max) self.elevation.setValidator(self.validator) self.elevation.setText(str((min + max) / 2)) self._tranform_button = QtWidgets.QPushButton("Split", self) self._tranform_button.clicked.connect(self.accept) self._cancel_button = QtWidgets.QPushButton("Cancel", self) self._cancel_button.clicked.connect(self.reject) button_box = QtWidgets.QDialogButtonBox() button_box.addButton(self._tranform_button, QtWidgets.QDialogButtonBox.AcceptRole) button_box.addButton(self._cancel_button, QtWidgets.QDialogButtonBox.RejectRole) grid.addWidget(button_box, i, 1, 1, 2) self.setLayout(grid)
def __init__(self, fracture_positions, parent=None): super(AddFractureDlg, self).__init__(parent) self.setWindowTitle("Add Fracture") grid = QtWidgets.QGridLayout(self) d_fracture_name = QtWidgets.QLabel("Fracture Name:", self) self.fracture_name = QtWidgets.QLineEdit() self.have_default_name = True self.set_default_name() self.fracture_name.textChanged.connect(self.frac_name_changed) self.image = QtWidgets.QLabel(self) self.image.setMinimumWidth(self.fracture_name.sizeHint().height()) self.image.setPixmap( icon.get_app_icon("sign-check").pixmap( self.fracture_name.sizeHint().height())) self.image.setToolTip('Fracture name is unique, everything is fine.') grid.addWidget(d_fracture_name, 0, 0) grid.addWidget(self.fracture_name, 0, 1) grid.addWidget(self.image, 0, 2) next_row = 1 self.fracture_position = None if fracture_positions is not None: d_fracture_position = QtWidgets.QLabel("Fracture position:", self) self.fracture_position = QtWidgets.QComboBox() for description, value in fracture_positions.items(): self.fracture_position.addItem(description, value) self.fracture_position.setCurrentIndex(0) grid.addWidget(d_fracture_position, 1, 0) grid.addWidget(self.fracture_position, 1, 1) next_row = 2 self._tranform_button = QtWidgets.QPushButton("Add", self) self._tranform_button.clicked.connect(self.accept) self._cancel_button = QtWidgets.QPushButton("Cancel", self) self._cancel_button.clicked.connect(self.reject) button_box = QtWidgets.QDialogButtonBox() button_box.addButton(self._tranform_button, QtWidgets.QDialogButtonBox.AcceptRole) button_box.addButton(self._cancel_button, QtWidgets.QDialogButtonBox.RejectRole) grid.addWidget(button_box, next_row, 1) self.setLayout(grid)
def _make_button(self, icon_name, text, tooltip, method): """ Make PushButton instance. :param icon_name: icon name in global repository. :param button text string :param tooltip: Tooltip string. :param method: Method to call on clicked signal. :return: the button object """ button = QtWidgets.QPushButton() # Parent is Grid set in addWidget if icon_name is not None: button.setIcon(icon.get_app_icon(icon_name)) if text is not None: button.setText(text) button.setToolTip(tooltip) button.clicked.connect(method) return button
def __init__(self): # load config cfg.init() # main window self._app = QtWidgets.QApplication(sys.argv) self._app.setWindowIcon(icon.get_app_icon("me-geomap")) self.mainwindow = MainWindow(self) # show self.mainwindow.show() #test import ui.data as data diagram = data.Diagram() n1 = diagram.add_node(100, 200, 0) n2 = diagram.add_node(100, 400, 0) diagram.add_connection(n1, n2) self.mainwindow.set_diagram_data(diagram)
def __init__(self, args): """Initialization of UI with executive code""" # setup qt app self._app = QtWidgets.QApplication(args) #icon self._app.setWindowIcon(icon.get_app_icon("geomap")) # load data container self._data = DataContainer() Installation.set_init_paths(CONFIG_DIR, self._data.workspaces.get_path()) # setup com manager #self._com_manager = ComManager(self._data) # todo: presunuto z main_window, nevim jeslti to je v poradku # select workspace if none is selected if self._data.workspaces.get_path() is None: import sys sel_dir = QtWidgets.QFileDialog.getExistingDirectory( None, "Choose workspace") if not sel_dir: sys.exit(0) elif sys.platform == "win32": sel_dir = sel_dir.replace('/', '\\') self._data.reload_workspace(sel_dir) # setup frontend service self._frontend_service = ServiceFrontend(self._data) # setup qt UI self._main_window = MainWindow(data=self._data, frontend_service=self._frontend_service) # connect save all on exit self._app.aboutToQuit.connect(self._data.save_all)
def setup_ui(self, dialog): # dialog properties dialog.setObjectName("FormDialog") dialog.setWindowTitle("Form dialog") dialog.setModal(True) # main dialog layout self.mainVerticalLayoutWidget = QtWidgets.QWidget(dialog) self.mainVerticalLayout = QtWidgets.QVBoxLayout( self.mainVerticalLayoutWidget) # labels sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Maximum, QtWidgets.QSizePolicy.Maximum) # title label self.titleLabel = QtWidgets.QLabel(self.mainVerticalLayoutWidget) titleFont = QtGui.QFont() titleFont.setPointSize(15) titleFont.setBold(True) titleFont.setWeight(75) self.titleLabel.setFont(titleFont) self.titleLabel.setObjectName("titleLabel") self.titleLabel.setText("Title") self.titleLabel.setSizePolicy(sizePolicy) # self.titleLabel.setWordWrap(True) self.mainVerticalLayout.addWidget(self.titleLabel) # subtitle label #self.subtitleLabel = QtWidgets.QLabel(self.mainVerticalLayoutWidget) self.subtitleLabel = QtWidgets.QLabel() subtitleFont = QtGui.QFont() subtitleFont.setWeight(50) self.subtitleLabel.setFont(subtitleFont) self.subtitleLabel.setObjectName("subtitleLabel") self.subtitleLabel.setText("Subtitle text") self.subtitleLabel.setSizePolicy(sizePolicy) # self.subtitleLabel.setWordWrap(True) #self.mainVerticalLayout.addWidget(self.subtitleLabel) # divider self.headerDivider = QtWidgets.QFrame(self.mainVerticalLayoutWidget) self.headerDivider.setObjectName("headerDivider") self.headerDivider.setFrameShape(QtWidgets.QFrame.HLine) self.headerDivider.setFrameShadow(QtWidgets.QFrame.Sunken) self.mainVerticalLayout.addWidget(self.headerDivider) # form layout self.formLayout = QtWidgets.QFormLayout() self.formLayout.setObjectName("formLayout") self.formLayout.setContentsMargins(0, 5, 0, 5) # add form to main layout self.mainVerticalLayout.addLayout(self.formLayout) # button box (order of of buttons is set by system default) self.buttonBox = QtWidgets.QDialogButtonBox( self.mainVerticalLayoutWidget) self.buttonBox.setOrientation(QtCore.Qt.Horizontal) self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.Close | QtWidgets.QDialogButtonBox.Save) self.buttonBox.setObjectName("buttonBox") self.mainVerticalLayout.addWidget(self.buttonBox) # dialog properties dialog.resize(900, 440) # validators self.validator = PresetsValidationColorizer() # form layout # hidden row self.idLabel = QtWidgets.QLabel(self.mainVerticalLayoutWidget) self.idLabel.setObjectName("idLabel") self.idLabel.setText("Id:") self.idLabel.setVisible(False) # self.formLayout.setWidget(0, QtWidgets.QFormLayout.LabelRole, # self.idLabel) self.idLineEdit = QtWidgets.QLineEdit(self.mainVerticalLayoutWidget) self.idLineEdit.setObjectName("idLineEdit") self.idLineEdit.setPlaceholderText("This should be hidden") self.idLineEdit.setVisible(False) # self.formLayout.setWidget(0, QtWidgets.QFormLayout.FieldRole, # self.idLineEdit) # 1 row self.analysisLabel = QtWidgets.QLabel(self.mainVerticalLayoutWidget) self.analysisLabel.setObjectName("analysisLabel") self.analysisLabel.setText("Analysis:") self.formLayout.setWidget(1, QtWidgets.QFormLayout.LabelRole, self.analysisLabel) self.analysisComboBox = QtWidgets.QComboBox( self.mainVerticalLayoutWidget) self.analysisComboBox.setObjectName("analysisComboBox") self.validator.add('analysis', self.analysisComboBox) self.formLayout.setWidget(1, QtWidgets.QFormLayout.FieldRole, self.analysisComboBox) # separator sep = QtWidgets.QLabel(self.mainVerticalLayoutWidget) sep.setText("") self.formLayout.setWidget(2, QtWidgets.QFormLayout.LabelRole, sep) # font labelFont = QtGui.QFont() labelFont.setPointSize(11) labelFont.setWeight(65) # multijob label self.multiJobLabel = QtWidgets.QLabel(self.mainVerticalLayoutWidget) self.multiJobLabel.setFont(labelFont) self.multiJobLabel.setText("MultiJob") self.formLayout.setWidget(3, QtWidgets.QFormLayout.LabelRole, self.multiJobLabel) # 4 row self.multiJobSshPresetLabel = QtWidgets.QLabel( self.mainVerticalLayoutWidget) self.multiJobSshPresetLabel.setText(self.SSH_PRESET_LABEL) self.formLayout.setWidget(4, QtWidgets.QFormLayout.LabelRole, self.multiJobSshPresetLabel) self.multiJobSshPresetComboBox = QtWidgets.QComboBox( self.mainVerticalLayoutWidget) self.validator.add('mj_ssh_preset', self.multiJobSshPresetComboBox) self.formLayout.setWidget(4, QtWidgets.QFormLayout.FieldRole, self.multiJobSshPresetComboBox) # 5 row self.multiJobPbsPresetLabel = QtWidgets.QLabel( self.mainVerticalLayoutWidget) self.multiJobPbsPresetLabel.setText(self.PBS_PRESET_LABEL) self.formLayout.setWidget(5, QtWidgets.QFormLayout.LabelRole, self.multiJobPbsPresetLabel) self.multiJobPbsPresetComboBox = QtWidgets.QComboBox( self.mainVerticalLayoutWidget) self.validator.add('mj_pbs_preset', self.multiJobPbsPresetComboBox) self.formLayout.setWidget(5, QtWidgets.QFormLayout.FieldRole, self.multiJobPbsPresetComboBox) # separator sep = QtWidgets.QLabel(self.mainVerticalLayoutWidget) sep.setText("") self.formLayout.setWidget(6, QtWidgets.QFormLayout.LabelRole, sep) # job label self.jobLabel = QtWidgets.QLabel(self.mainVerticalLayoutWidget) self.jobLabel.setFont(labelFont) self.jobLabel.setText("Job") self.formLayout.setWidget(7, QtWidgets.QFormLayout.LabelRole, self.jobLabel) # 8 row self.jobSshPresetLabel = QtWidgets.QLabel( self.mainVerticalLayoutWidget) self.jobSshPresetLabel.setText(self.SSH_PRESET_LABEL) self.formLayout.setWidget(8, QtWidgets.QFormLayout.LabelRole, self.jobSshPresetLabel) self.jobSshPresetComboBox = QtWidgets.QComboBox( self.mainVerticalLayoutWidget) self.validator.add('j_ssh_preset', self.jobSshPresetComboBox) self.formLayout.setWidget(8, QtWidgets.QFormLayout.FieldRole, self.jobSshPresetComboBox) # 9 row self.jobPbsPresetLabel = QtWidgets.QLabel( self.mainVerticalLayoutWidget) self.jobPbsPresetLabel.setText(self.PBS_PRESET_LABEL) self.formLayout.setWidget(9, QtWidgets.QFormLayout.LabelRole, self.jobPbsPresetLabel) self.jobPbsPresetComboBox = QtWidgets.QComboBox( self.mainVerticalLayoutWidget) self.validator.add('j_pbs_preset', self.jobPbsPresetComboBox) self.formLayout.setWidget(9, QtWidgets.QFormLayout.FieldRole, self.jobPbsPresetComboBox) # separator sep = QtWidgets.QLabel(self.mainVerticalLayoutWidget) sep.setText("") self.formLayout.setWidget(10, QtWidgets.QFormLayout.LabelRole, sep) # 11 row self.nameLabel = QtWidgets.QLabel(self.mainVerticalLayoutWidget) self.nameLabel.setObjectName("nameLabel") self.nameLabel.setText("Name:") self.formLayout.setWidget(11, QtWidgets.QFormLayout.LabelRole, self.nameLabel) self.nameLineEdit = QtWidgets.QLineEdit(self.mainVerticalLayoutWidget) self.nameLineEdit.setObjectName("nameLineEdit") self.nameLineEdit.setPlaceholderText("Only alphanumeric characters " "and - or _") self.nameLineEdit.setProperty("clearButtonEnabled", True) self.validator.add('name', self.nameLineEdit) self.formLayout.setWidget(11, QtWidgets.QFormLayout.FieldRole, self.nameLineEdit) # 12 row self.logLevelLabel = QtWidgets.QLabel(self.mainVerticalLayoutWidget) self.logLevelLabel.setObjectName("logLevelLabel") self.logLevelLabel.setText("Log Level:") self.formLayout.setWidget(12, QtWidgets.QFormLayout.LabelRole, self.logLevelLabel) self.logLevelComboBox = QtWidgets.QComboBox( self.mainVerticalLayoutWidget) self.logLevelComboBox.setObjectName("logLevelComboBox") self.logLevelComboBox.addItem(logging.getLevelName(logging.INFO), logging.INFO) self.logLevelComboBox.addItem(logging.getLevelName(logging.WARNING), logging.WARNING) self.logLevelComboBox.setCurrentIndex(0) self.formLayout.setWidget(12, QtWidgets.QFormLayout.FieldRole, self.logLevelComboBox) self.horizontalLayout = QtWidgets.QHBoxLayout(dialog) self.horizontalLayout.addWidget(self.mainVerticalLayoutWidget) self.pbsVerticalLayoutWidget = QtWidgets.QWidget(dialog) self.horizontalLayout.addWidget(self.pbsVerticalLayoutWidget) dialog.setLayout(self.horizontalLayout) # PBS options ############# self.pbs_validator = PbsPresetsValidationColorizer() # form layout self.pbs_formLayout = QtWidgets.QFormLayout() self.pbs_formLayout.setContentsMargins(10, 15, 10, 15) self.pbsVerticalLayoutWidget.setLayout(self.pbs_formLayout) # form layout # separator sep = QtWidgets.QLabel(self.pbsVerticalLayoutWidget) sep.setText("") sep.setMinimumHeight(40) self.pbs_formLayout.setWidget(1, QtWidgets.QFormLayout.LabelRole, sep) # PBS options label label = QtWidgets.QLabel(self.pbsVerticalLayoutWidget) label.setFont(labelFont) label.setText("PBS options") self.pbs_formLayout.setWidget(2, QtWidgets.QFormLayout.LabelRole, label) # 2 row self.pbs_nameLabel = QtWidgets.QLabel(self.pbsVerticalLayoutWidget) self.pbs_nameLabel.setText("Name:") self.pbs_formLayout.setWidget(3, QtWidgets.QFormLayout.LabelRole, self.pbs_nameLabel) self.pbs_nameComboBox = PbsComboBox(self.pbsVerticalLayoutWidget) self.pbs_nameComboBox.setCompleter(None) self.pbs_validator.add('name', self.pbs_nameComboBox) self.pbs_AddButton = QtWidgets.QPushButton( self.pbsVerticalLayoutWidget) self.pbs_AddButton.setIcon(icon.get_app_icon("add")) self.pbs_AddButton.setToolTip('Create new PBS preset') self.pbs_AddButton.setMaximumWidth(45) self.pbs_RemoveButton = QtWidgets.QPushButton( self.pbsVerticalLayoutWidget) self.pbs_RemoveButton.setIcon(icon.get_app_icon("remove")) self.pbs_RemoveButton.setToolTip('Remove PBS preset') self.pbs_RemoveButton.setMaximumWidth(45) layout = QtWidgets.QHBoxLayout() layout.addWidget(self.pbs_nameComboBox) layout.addWidget(self.pbs_AddButton) layout.addWidget(self.pbs_RemoveButton) self.pbs_formLayout.setLayout(3, QtWidgets.QFormLayout.FieldRole, layout) # 3 row self.pbs_pbsSystemLabel = QtWidgets.QLabel( self.pbsVerticalLayoutWidget) self.pbs_pbsSystemLabel.setText("PBS System:") self.pbs_formLayout.setWidget(4, QtWidgets.QFormLayout.LabelRole, self.pbs_pbsSystemLabel) self.pbs_pbsSystemComboBox = QtWidgets.QComboBox( self.pbsVerticalLayoutWidget) self.pbs_validator.add('pbs_system', self.pbs_pbsSystemComboBox) self.pbs_formLayout.setWidget(4, QtWidgets.QFormLayout.FieldRole, self.pbs_pbsSystemComboBox) # 4 row self.pbs_queueLabel = QtWidgets.QLabel(self.pbsVerticalLayoutWidget) self.pbs_queueLabel.setText("Queue:") self.pbs_formLayout.setWidget(5, QtWidgets.QFormLayout.LabelRole, self.pbs_queueLabel) self.pbs_queueLineEdit = QtWidgets.QLineEdit( self.pbsVerticalLayoutWidget) self.pbs_queueLineEdit.setProperty("clearButtonEnabled", True) self.pbs_validator.add('queue', self.pbs_queueLineEdit) self.pbs_formLayout.setWidget(5, QtWidgets.QFormLayout.FieldRole, self.pbs_queueLineEdit) # 5 row self.pbs_walltimeLabel = QtWidgets.QLabel(self.pbsVerticalLayoutWidget) self.pbs_walltimeLabel.setText("Walltime:") self.pbs_formLayout.setWidget(6, QtWidgets.QFormLayout.LabelRole, self.pbs_walltimeLabel) self.pbs_walltimeLineEdit = QtWidgets.QLineEdit( self.pbsVerticalLayoutWidget) self.pbs_walltimeLineEdit.setPlaceholderText("number of hours") self.pbs_walltimeLineEdit.setProperty("clearButtonEnabled", True) self.pbs_validator.add('walltime', self.pbs_walltimeLineEdit) self.pbs_formLayout.setWidget(6, QtWidgets.QFormLayout.FieldRole, self.pbs_walltimeLineEdit) # 6 row self.pbs_nodesLabel = QtWidgets.QLabel(self.pbsVerticalLayoutWidget) self.pbs_nodesLabel.setText("Number of Nodes:") self.pbs_formLayout.setWidget(7, QtWidgets.QFormLayout.LabelRole, self.pbs_nodesLabel) self.pbs_nodesSpinBox = QtWidgets.QSpinBox( self.pbsVerticalLayoutWidget) self.pbs_nodesSpinBox.setButtonSymbols( QtWidgets.QAbstractSpinBox.PlusMinus) self.pbs_nodesSpinBox.setMinimum(1) self.pbs_nodesSpinBox.setMaximum(1000) self.pbs_nodesSpinBox.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignTrailing | QtCore.Qt.AlignVCenter) self.pbs_validator.add('nodes', self.pbs_nodesSpinBox) self.pbs_formLayout.setWidget(7, QtWidgets.QFormLayout.FieldRole, self.pbs_nodesSpinBox) # 7 row self.pbs_ppnLabel = QtWidgets.QLabel(self.pbsVerticalLayoutWidget) self.pbs_ppnLabel.setText("Processes per Node:") self.pbs_formLayout.setWidget(8, QtWidgets.QFormLayout.LabelRole, self.pbs_ppnLabel) self.pbs_ppnSpinBox = QtWidgets.QSpinBox(self.pbsVerticalLayoutWidget) self.pbs_ppnSpinBox.setButtonSymbols( QtWidgets.QAbstractSpinBox.PlusMinus) self.pbs_ppnSpinBox.setMinimum(1) self.pbs_ppnSpinBox.setMaximum(100) self.pbs_ppnSpinBox.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignTrailing | QtCore.Qt.AlignVCenter) self.pbs_validator.add('ppn', self.pbs_ppnSpinBox) self.pbs_formLayout.setWidget(8, QtWidgets.QFormLayout.FieldRole, self.pbs_ppnSpinBox) # 8 row self.pbs_memoryLabel = QtWidgets.QLabel(self.pbsVerticalLayoutWidget) self.pbs_memoryLabel.setText("Memory:") self.pbs_formLayout.setWidget(9, QtWidgets.QFormLayout.LabelRole, self.pbs_memoryLabel) self.pbs_memoryLineEdit = QtWidgets.QLineEdit( self.pbsVerticalLayoutWidget) self.pbs_memoryLineEdit.setPlaceholderText("300mb or 1gb") self.pbs_memoryLineEdit.setProperty("clearButtonEnabled", True) self.pbs_validator.add('memory', self.pbs_memoryLineEdit) self.pbs_formLayout.setWidget(9, QtWidgets.QFormLayout.FieldRole, self.pbs_memoryLineEdit) # 9 row self.pbs_infinibandLabel = QtWidgets.QLabel( self.pbsVerticalLayoutWidget) self.pbs_infinibandLabel.setText("Infiniband:") self.pbs_formLayout.setWidget(10, QtWidgets.QFormLayout.LabelRole, self.pbs_infinibandLabel) self.pbs_infinibandCheckBox = QtWidgets.QCheckBox( self.pbsVerticalLayoutWidget) self.pbs_validator.add('infiniband', self.pbs_infinibandCheckBox) self.pbs_formLayout.setWidget(10, QtWidgets.QFormLayout.FieldRole, self.pbs_infinibandCheckBox) return dialog
def __init__(self, parent=None): super(AddRegionDlg, self).__init__(parent) self.setWindowTitle("Add Region") grid = QtWidgets.QGridLayout(self) d_region_dim = QtWidgets.QLabel("Region Dimension:", self) self.region_dim = QtWidgets.QComboBox() self.region_dim.addItem(self.REGION_DESCRIPTION[RegionDim.point], RegionDim.point) self.region_dim.addItem(self.REGION_DESCRIPTION[RegionDim.well], RegionDim.well) self.region_dim.addItem(self.REGION_DESCRIPTION[RegionDim.fracture], RegionDim.fracture) self.region_dim.addItem(self.REGION_DESCRIPTION[RegionDim.bulk], RegionDim.bulk) selected_regions = cfg.main_window.diagramScene.selection max_selected_dim = 3 if not selected_regions.selected_polygons: max_selected_dim -= 1 if not selected_regions.selected_lines: max_selected_dim -= 1 if not selected_regions.selected_points: max_selected_dim -= 1 if cfg.diagram.regions.current_layer_id < 0: max_selected_dim -= 1 self.region_dim.setCurrentIndex(max_selected_dim) d_region_name = QtWidgets.QLabel("Region Name:", self) self.region_name = QtWidgets.QLineEdit() self.image = QtWidgets.QLabel(self) self.image.setMinimumWidth(self.region_name.sizeHint().height()) self.image.setPixmap( icon.get_app_icon("sign-check").pixmap( self.region_name.sizeHint().height())) self.image.setToolTip('Region name is unique, everything is fine.') self.have_default_name = True self.set_default_name(max_selected_dim) self.region_name.textChanged.connect(self.reg_name_changed) grid.addWidget(d_region_name, 0, 0) grid.addWidget(self.region_name, 0, 1) grid.addWidget(self.image, 0, 2) self.region_dim.currentIndexChanged[int].connect(self.set_default_name) grid.addWidget(d_region_dim, 1, 0) grid.addWidget(self.region_dim, 1, 1, 1, 2) self._tranform_button = QtWidgets.QPushButton("Add", self) self._tranform_button.clicked.connect(self.accept) self._cancel_button = QtWidgets.QPushButton("Cancel", self) self._cancel_button.clicked.connect(self.reject) button_box = QtWidgets.QDialogButtonBox() button_box.addButton(self._tranform_button, QtWidgets.QDialogButtonBox.AcceptRole) button_box.addButton(self._cancel_button, QtWidgets.QDialogButtonBox.RejectRole) grid.addWidget(button_box, 2, 1) self.setLayout(grid)
def setup_ui(self, dialog): # dialog properties dialog.setModal(True) # main dialog layout self.mainVerticalLayoutWidget = QtWidgets.QWidget(dialog) self.mainVerticalLayoutWidget.setObjectName("mainVerticalLayoutWidget") self.mainVerticalLayout = QtWidgets.QVBoxLayout( self.mainVerticalLayoutWidget) self.mainVerticalLayout.setObjectName("mainVerticalLayout") # form layout self.formLayout = QtWidgets.QFormLayout() self.formLayout.setObjectName("formLayout") self.formLayout.setContentsMargins(0, 5, 0, 5) # add form to main layout self.mainVerticalLayout.addLayout(self.formLayout) # dialog properties dialog.resize(680, 510) # name self.nameLabel = QtWidgets.QLabel(self.mainVerticalLayoutWidget) self.nameLabel.setObjectName("nameLabel") self.nameLabel.setText("Name:") self.nameValueLabel = QtWidgets.QLabel(self.mainVerticalLayoutWidget) self.nameValueLabel.setObjectName("nameValueLabel") self.formLayout.addRow(self.nameLabel, self.nameValueLabel) # directory self.dirLabel = QtWidgets.QLabel(self.mainVerticalLayoutWidget) self.dirLabel.setObjectName("dirLabel") self.dirLabel.setText("Directory:") self.dirPathLabel = QtWidgets.QLabel(self.mainVerticalLayoutWidget) self.dirPathLabel.setObjectName("dirPathLabel") self.formLayout.addRow(self.dirLabel, self.dirPathLabel) # separator sep = QtWidgets.QLabel(self.mainVerticalLayoutWidget) sep.setText("") self.formLayout.addRow(sep) # layers file self.layersFileLabel = QtWidgets.QLabel(self.mainVerticalLayoutWidget) self.layersFileLabel.setText("Layers file:") self.layersFileComboBox = QtWidgets.QComboBox( self.mainVerticalLayoutWidget) self.layersFileComboBox.setMinimumWidth(150) self.layersFileEditButton = QtWidgets.QPushButton() self.layersFileEditButton.setText("Edit") self.layersFileEditButton.setIcon(icon.get_app_icon("le-geomap")) self.layersFileEditButton.setToolTip('Edit in Layer Editor') self.layersFileEditButton.setMaximumWidth(100) self.layersFileEditButton.setMinimumWidth(100) layout = QtWidgets.QHBoxLayout() layout.addWidget(self.layersFileComboBox) layout.addWidget(self.layersFileEditButton) self.formLayout.addRow(self.layersFileLabel, layout) # flow input self.flowInputLabel = QtWidgets.QLabel(self.mainVerticalLayoutWidget) self.flowInputLabel.setText("Flow123d input:") self.flowInputComboBox = QtWidgets.QComboBox( self.mainVerticalLayoutWidget) self.flowInputEditButton = QtWidgets.QPushButton() self.flowInputEditButton.setText("Edit") self.flowInputEditButton.setIcon(icon.get_app_icon("me-geomap")) self.flowInputEditButton.setToolTip('Edit in Model Editor') self.flowInputEditButton.setMaximumWidth(100) self.flowInputEditButton.setMinimumWidth(100) layout = QtWidgets.QHBoxLayout() layout.addWidget(self.flowInputComboBox) layout.addWidget(self.flowInputEditButton) self.formLayout.addRow(self.flowInputLabel, layout) # flow version self.flowVersionLabel = QtWidgets.QLabel(self.mainVerticalLayoutWidget) self.flowVersionLabel.setText("Flow123d version:") self.flowVersionComboBox = QtWidgets.QComboBox( self.mainVerticalLayoutWidget) self.flowVersionComboBox.addItems(FLOW123D_VERSION_LIST) sep = QtWidgets.QLabel(self.mainVerticalLayoutWidget) sep.setMaximumWidth(100) sep.setMinimumWidth(100) layout = QtWidgets.QHBoxLayout() layout.addWidget(self.flowVersionComboBox) layout.addWidget(sep) self.formLayout.addRow(self.flowVersionLabel, layout) # script file self.scriptLabel = QtWidgets.QLabel(self.mainVerticalLayoutWidget) self.scriptLabel.setText("Analysis script:") self.scriptComboBox = QtWidgets.QComboBox( self.mainVerticalLayoutWidget) self.scriptMakeButton = QtWidgets.QPushButton() self.scriptMakeButton.setText("Make script") self.scriptMakeButton.setToolTip('Generate default Flow execution') self.scriptMakeButton.setMaximumWidth(100) self.scriptMakeButton.setMinimumWidth(100) layout = QtWidgets.QHBoxLayout() layout.addWidget(self.scriptComboBox) layout.addWidget(self.scriptMakeButton) self.formLayout.addRow(self.scriptLabel, layout) self.refreshButton = QtWidgets.QPushButton() self.refreshButton.setText("Refresh files") self.refreshButton.setToolTip( 'Refresh files according to actual directory content.') self.refreshButton.setMaximumWidth(120) self.mainVerticalLayout.addWidget(self.refreshButton) spacerItem = QtWidgets.QSpacerItem(10, 100, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding) self.mainVerticalLayout.addItem(spacerItem) self.mainVerticalLayout.addStretch(1) # analysis list tree widget self.analysisListTreeWidget = QtWidgets.QTreeWidget(dialog) self.analysisListTreeWidget.setAlternatingRowColors(True) self.analysisListTreeWidget.setHeaderLabels(["Name"]) self.analysisListTreeWidget.setSortingEnabled(True) self.analysisListTreeWidget.sortByColumn(0, QtCore.Qt.AscendingOrder) # buttons self.buttonLayout = QtWidgets.QHBoxLayout() self.buttonLayout.setObjectName("buttonLayout") self.btnAdd = QtWidgets.QPushButton(dialog) self.btnAdd.setText("&Add") self.btnAdd.setObjectName("btnAdd") self.buttonLayout.addWidget(self.btnAdd) self.btnSave = QtWidgets.QPushButton(dialog) self.btnSave.setText("&Save") self.btnSave.setObjectName("btnSave") self.buttonLayout.addWidget(self.btnSave) self.btnRestore = QtWidgets.QPushButton(dialog) self.btnRestore.setText("&Restore") self.btnRestore.setObjectName("btnRestore") self.buttonLayout.addWidget(self.btnRestore) spacerItem = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Minimum) self.buttonLayout.addItem(spacerItem) self.btnClose = QtWidgets.QPushButton(dialog) self.btnClose.setText("C&lose") self.btnClose.setObjectName("btnClose") self.buttonLayout.addWidget(self.btnClose) self.horizontalLayout = QtWidgets.QHBoxLayout() self.horizontalLayout.addWidget(self.analysisListTreeWidget) self.horizontalLayout.addWidget(self.mainVerticalLayoutWidget) self.superMainVerticalLayout = QtWidgets.QVBoxLayout(dialog) self.superMainVerticalLayout.addLayout(self.horizontalLayout) self.superMainVerticalLayout.addLayout(self.buttonLayout) dialog.setLayout(self.superMainVerticalLayout) return dialog
def __init__(self, parent, min_elevation=None, max_elevation=None, prepend=False, add=False): super(AppendLayerDlg, self).__init__(parent) if add: self.setWindowTitle("Add Layer to Shadow Block") elif prepend: self.setWindowTitle("Prepend Layer") else: self.setWindowTitle("Append Layer") grid = QtWidgets.QGridLayout(self) d_layer_name = QtWidgets.QLabel("Layer Name:", self) self.layer_name = QtWidgets.QLineEdit() self.have_default_name = True self.set_default_name() self.layer_name.textChanged.connect(self.lay_name_changed) self.image = QtWidgets.QLabel(self) self.image.setMinimumWidth(self.layer_name.sizeHint().height()) self.image.setPixmap( icon.get_app_icon("sign-check").pixmap( self.layer_name.sizeHint().height())) self.image.setToolTip('Layer name is unique, everything is fine.') grid.addWidget(d_layer_name, 0, 0) grid.addWidget(self.layer_name, 0, 1) grid.addWidget(self.image, 0, 2) d_surface = QtWidgets.QLabel("Bottom Interface Surface:", self) grid.addWidget(d_surface, 1, 0) i = LayersHelpers.add_surface_to_grid(self, grid, 2) self.validator = QtGui.QDoubleValidator() if add: self.validator.setBottom(min_elevation) self.validator.setTop(max_elevation) self.elevation.setText(str((min_elevation + max_elevation) / 2)) elif prepend: self.validator.setBottom(min_elevation) self.elevation.setText(str(min_elevation + 100)) else: self.validator.setTop(max_elevation) self.elevation.setText(str(max_elevation - 100)) self.elevation.setValidator(self.validator) if add: self._tranform_button = QtWidgets.QPushButton("Add", self) elif prepend: self._tranform_button = QtWidgets.QPushButton("Prepend", self) else: self._tranform_button = QtWidgets.QPushButton("Append", self) self._tranform_button.clicked.connect(self.accept) self._cancel_button = QtWidgets.QPushButton("Cancel", self) self._cancel_button.clicked.connect(self.reject) button_box = QtWidgets.QDialogButtonBox() button_box.addButton(self._tranform_button, QtWidgets.QDialogButtonBox.AcceptRole) button_box.addButton(self._cancel_button, QtWidgets.QDialogButtonBox.RejectRole) grid.addWidget(button_box, i, 3, 1, 3) self.setLayout(grid)
def set_icon(self): visible = self.isChecked() if visible: self.setIcon(icon.get_app_icon("visible")) else: self.setIcon(icon.get_app_icon("hidden"))
def _add_region_panel(self, layer_id, region): """add one region panel to tool box and set region data""" data = cfg.diagram.regions grid = QtWidgets.QGridLayout() # select and add region pom_lambda = lambda ii: lambda: self._region_set(ii) self.regions[layer_id] = QtWidgets.QComboBox() for i in range(0, len(data.regions)): label = data.regions[i].name + " (" + AddRegionDlg.REGION_DESCRIPTION_DIM[data.regions[i].dim] + ")" self.regions[layer_id].addItem(label, i) data.current_regions[layer_id] = region curr_index = self.regions[layer_id].findData([key for key, value in data.regions.items() if value == region][0]) self._emit_regionChanged = False self.regions[layer_id].setCurrentIndex(curr_index) self._emit_regionChanged = True self.regions[layer_id].currentIndexChanged.connect(pom_lambda(layer_id)) self.add_button[layer_id] = QtWidgets.QPushButton() self.add_button[layer_id].setIcon(icon.get_app_icon("add")) self.add_button[layer_id].setToolTip('Create new region') self.add_button[layer_id].clicked.connect(self._add_region) self.remove_button[layer_id] = QtWidgets.QPushButton() self.remove_button[layer_id].setIcon(icon.get_app_icon("remove")) self.remove_button[layer_id].clicked.connect(self._remove_region) self.remove_button[layer_id].setEnabled(False) self.remove_button[layer_id].setToolTip('Default region cannot be removed!') grid.addWidget(self.regions[layer_id], 0, 0) grid.addWidget(self.add_button[layer_id], 0, 1) grid.addWidget(self.remove_button[layer_id], 0, 2) # name pom_lamda = lambda ii: lambda: self._name_set(ii) name_label = QtWidgets.QLabel("Name:", self) self.name[layer_id] = QtWidgets.QLineEdit() self.name[layer_id].setText(region.name) self.name[layer_id].editingFinished.connect(pom_lamda(layer_id)) grid.addWidget(name_label, 1, 0) grid.addWidget(self.name[layer_id], 1, 1, 1, 2) #color button self.color_label[layer_id] = QtWidgets.QLabel("Color:", self) pom_lamda = lambda ii: lambda: self._color_set(ii) self.color_button[layer_id] = QtWidgets.QPushButton() pixmap = QtGui.QPixmap(25, 25) pixmap.fill(QtGui.QColor(region.color)) iconPix = QtGui.QIcon(pixmap) self.color_button[layer_id].setIcon(iconPix) self.color_button[layer_id].setFixedSize( 25, 25 ) self.color_button[layer_id].clicked.connect(pom_lamda(layer_id)) grid.addWidget(self.color_label[layer_id], 2, 0) grid.addWidget(self.color_button[layer_id], 2, 1) # dimension self.dim_label[layer_id] = QtWidgets.QLabel("Dimension:", self) self.dims[layer_id] = QtWidgets.QLabel(AddRegionDlg.REGION_DESCRIPTION_DIM[region.dim], self) grid.addWidget(self.dim_label[layer_id], 3, 0) grid.addWidget(self.dims[layer_id], 3, 1) # boundary pom_lamda = lambda ii: lambda: self._boundary_set(ii) self.boundary_label[layer_id] = QtWidgets.QLabel("Boundary:", self) self.boundary[layer_id] = QtWidgets.QCheckBox() self.boundary[layer_id].setChecked(region.boundary) self.boundary[layer_id].stateChanged.connect(pom_lamda(layer_id)) grid.addWidget(self.boundary_label[layer_id], 4, 0) grid.addWidget(self.boundary[layer_id], 4, 1) # not use pom_lamda = lambda ii: lambda: self._not_used_set(ii) self.notused_label[layer_id] = QtWidgets.QLabel("Not Use:", self) self.notused[layer_id] = QtWidgets.QCheckBox() self.notused[layer_id].setChecked(region.not_used) self.notused[layer_id].stateChanged.connect(pom_lamda(layer_id)) grid.addWidget(self.notused_label[layer_id], 5, 0) grid.addWidget(self.notused[layer_id], 5, 1) # mesh step action = lambda l_id: lambda: self._mesh_step_set(l_id) mesh_step_label = QtWidgets.QLabel("Mesh step:", self) mesh_step_edit = QtWidgets.QLineEdit() mesh_step_edit.setMinimumWidth(80) mesh_step_edit.setMaximumWidth(80) mesh_step_edit.setText(str(region.mesh_step)) validator = QtGui.QDoubleValidator() validator.setRange(0.0, 1e+7, 7) # assuming unit in meters and dimesion fo the whole earth :-) mesh_step_edit.setValidator(validator) mesh_step_edit.editingFinished.connect(action(layer_id)) self.mesh_step_label[layer_id] = mesh_step_label self.mesh_step[layer_id] = mesh_step_edit grid.addWidget(mesh_step_label, 6, 0) grid.addWidget(mesh_step_edit, 6, 1) self._set_visibility(layer_id, region.dim!=RegionDim.none) sp1 = QtWidgets.QSpacerItem(0, 0, QtWidgets.QSizePolicy.Maximum, QtWidgets.QSizePolicy.Expanding) sp2 = QtWidgets.QSpacerItem(0, 0, QtWidgets.QSizePolicy.Maximum, QtWidgets.QSizePolicy.Expanding) grid.addItem(sp1, 7, 0) grid.addItem(sp2, 7, 1) widget = QtWidgets.QWidget(self) widget.setLayout(grid) return widget