def __init__(self):
        super().__init__()

        self.runaction = widget.OWAction("Write Shadow File", self)
        self.runaction.triggered.connect(self.write_file)
        self.addAction(self.runaction)

        self.setFixedWidth(590)
        self.setFixedHeight(180)

        left_box_1 = oasysgui.widgetBox(self.controlArea, "Shadow File Selection", addSpace=True, orientation="vertical",
                                         width=570, height=100)

        gui.checkBox(left_box_1, self, 'is_automatic_run', 'Automatic Execution')

        gui.separator(left_box_1, height=10)

        figure_box = oasysgui.widgetBox(left_box_1, "", addSpace=True, orientation="horizontal", width=550, height=50)

        self.le_beam_file_name = oasysgui.lineEdit(figure_box, self, "beam_file_name", "Shadow File Name",
                                                    labelWidth=120, valueType=str, orientation="horizontal")
        self.le_beam_file_name.setFixedWidth(330)

        gui.button(figure_box, self, "...", callback=self.selectFile)

        gui.separator(left_box_1, height=10)

        button = gui.button(self.controlArea, self, "Write Shadow File", callback=self.write_file)
        button.setFixedHeight(45)

        gui.rubber(self.controlArea)
    def __init__(self, show_automatic_box=True):
        super().__init__()

        if not show_automatic_box:
            self.TABS_AREA_HEIGHT = 620
        else:
            self.TABS_AREA_HEIGHT = 555

        geom = QApplication.desktop().availableGeometry()
        self.setGeometry(
            QRect(round(geom.width() * 0.05), round(geom.height() * 0.05),
                  round(min(geom.width() * 0.98, self.MAX_WIDTH)),
                  round(min(geom.height() * 0.95, self.MAX_HEIGHT))))

        self.setMaximumHeight(self.geometry().height())
        self.setMaximumWidth(self.geometry().width())

        self.controlArea.setFixedWidth(self.CONTROL_AREA_WIDTH)

        self.general_options_box = gui.widgetBox(self.controlArea,
                                                 "General Options",
                                                 addSpace=False,
                                                 orientation="horizontal")
        self.general_options_box.setFixedHeight(70)

        if show_automatic_box:
            gui.checkBox(self.general_options_box, self, 'is_automatic_run',
                         'Automatic Execution')
    def __init__(self):
        super().__init__()

        self.dataset = None
        self.sample = None
        self.otherdata = None

        # GUI
        box = gui.widgetBox(self.controlArea, "Info")
        self.infoa = gui.widgetLabel(
            box, 'No data on input yet, waiting to get something.')
        self.infob = gui.widgetLabel(box, '')

        gui.separator(self.controlArea)
        self.optionsBox = gui.widgetBox(self.controlArea, "Options")
        gui.spin(self.optionsBox,
                 self,
                 'proportion',
                 minv=10,
                 maxv=90,
                 step=10,
                 label='Sample Size [%]:',
                 callback=[self.selection, self.checkCommit])
        gui.checkBox(self.optionsBox, self, 'commitOnChange',
                     'Commit data on selection change')
        gui.button(self.optionsBox, self, "Commit", callback=self.commit)
        self.optionsBox.setDisabled(True)

        self.resize(100, 50)
    def _setup_control_area(self) -> None:
        box = gui.widgetBox(self.controlArea, "Word Scoring Methods")
        for value, (n, _, tt) in SCORING_METHODS.items():
            b = gui.hBox(box, margin=0)
            gui.checkBox(
                b,
                self,
                value,
                label=n,
                callback=self.__setting_changed,
                tooltip=tt,
            )
            if value in ADDITIONAL_OPTIONS:
                value, options = ADDITIONAL_OPTIONS[value]
                gui.comboBox(
                    b,
                    self,
                    value,
                    items=options,
                    callback=self.__setting_changed,
                )

        box = gui.widgetBox(self.controlArea, "Aggregation")
        gui.comboBox(
            box,
            self,
            "aggregation",
            items=[n for n in AGGREGATIONS],
            callback=self.__setting_changed,
        )

        gui.rubber(self.controlArea)
        gui.auto_send(self.buttonsArea, self, "auto_commit")
Exemple #5
0
    def __init__(self, show_automatic_box=True):
        super().__init__()

        geom = QApplication.desktop().availableGeometry()
        self.setGeometry(
            QRect(round(geom.width() * 0.05), round(geom.height() * 0.05),
                  round(min(geom.width() * 0.98, self.MAX_WIDTH)),
                  round(min(geom.height() * 0.95, self.MAX_HEIGHT))))

        self.setMaximumHeight(self.geometry().height())
        self.setMaximumWidth(self.geometry().width())

        self.controlArea.setFixedWidth(self.CONTROL_AREA_WIDTH)

        self.general_options_box = gui.widgetBox(self.controlArea,
                                                 "General Options",
                                                 addSpace=True,
                                                 orientation="horizontal")

        if show_automatic_box:
            gui.checkBox(self.general_options_box, self, 'is_automatic_run',
                         'Automatic Execution')

        trace = gui.checkBox(self.general_options_box, self, 'trace_shadow',
                             'Display Shadow Output')
        trace.setVisible(False)
    def test_set_checked(self):
        widget = OWBaseWidget()

        widget.some_option = False
        cb = gui.checkBox(widget,
                          widget,
                          "some_option",
                          "foo",
                          stateWhenDisabled=False)
        self.assertFalse(cb.isChecked())
        cb.setEnabled(False)
        cb.setChecked(True)
        self.assertFalse(cb.isChecked())
        cb.setEnabled(True)
        self.assertTrue(cb.isChecked())

        widget.some_option = True
        cb = gui.checkBox(widget,
                          widget,
                          "some_option",
                          "foo",
                          stateWhenDisabled=True)
        self.assertTrue(cb.isChecked())
        cb.setEnabled(False)
        cb.setChecked(False)
        self.assertTrue(cb.isChecked())
        cb.setEnabled(True)
        self.assertFalse(cb.isChecked())
Exemple #7
0
        def build_combo(container,
                        master,
                        field_name,
                        label,
                        has_combo=True,
                        combo_field_name=None,
                        cb_items=items):
            box = gui.widgetBox(container, "", orientation="horizontal")
            gui.checkBox(box,
                         master,
                         "check_" + field_name,
                         label="" if has_combo else label)
            if has_combo:
                gui.comboBox(
                    box,
                    master,
                    "n_" +
                    field_name if not combo_field_name else combo_field_name,
                    label=label,
                    items=cb_items,
                    labelWidth=350,
                    sendSelectedValue=False,
                    orientation="horizontal")
            box.setEnabled(False)

            return box
Exemple #8
0
    def __init__(self):
        super().__init__()

        self.component = DummyComponent(self)
        self.foo_control = gui.checkBox(self.controlArea, self, "foo", "")
        self.component_foo_control = \
            gui.checkBox(self.controlArea, self, "component.foo", "")
Exemple #9
0
    def __init__(self):
        super().__init__()

        self.runaction = widget.OWAction("Write Shadow File", self)
        self.runaction.triggered.connect(self.write_file)
        self.addAction(self.runaction)

        self.setFixedWidth(590)
        self.setFixedHeight(190)

        left_box_1 = oasysgui.widgetBox(self.controlArea, "Shadow File Selection", addSpace=True, orientation="vertical",
                                         width=570, height=110)

        gui.checkBox(left_box_1, self, 'is_automatic_run', 'Automatic Execution')

        gui.separator(left_box_1, height=10)

        figure_box = oasysgui.widgetBox(left_box_1, "", addSpace=True, orientation="horizontal", width=550, height=35)

        self.le_beam_file_name = oasysgui.lineEdit(figure_box, self, "beam_file_name", "Shadow File Name",
                                                    labelWidth=120, valueType=str, orientation="horizontal")
        self.le_beam_file_name.setFixedWidth(330)

        gui.button(figure_box, self, "...", callback=self.selectFile)

        button = gui.button(self.controlArea, self, "Write Shadow File", callback=self.write_file)
        button.setFixedHeight(45)

        gui.rubber(self.controlArea)
Exemple #10
0
    def __init__(self):
        super().__init__()

        # sets self.curvePoints, self.steps equidistant points from
        # 1/self.steps to 1
        self.updateCurvePoints()

# [start-snippet-2]
        self.scoring = [
            ("Classification Accuracy", Orange.evaluation.scoring.CA),
            ("AUC", Orange.evaluation.scoring.AUC),
            ("Precision", Orange.evaluation.scoring.Precision),
            ("Recall", Orange.evaluation.scoring.Recall)
        ]
# [end-snippet-2]
        #: input data on which to construct the learning curve
        self.data = None
        #: A {input_id: Learner} mapping of current learners from input channel
        self.learners = OrderedDict()
        #: A {input_id: List[Results]} mapping of input id to evaluation
        #: results list, one for each curve point
        self.results = OrderedDict()
        #: A {input_id: List[float]} mapping of input id to learning curve
        #: point scores
        self.curves = OrderedDict()

        # GUI
        box = gui.widgetBox(self.controlArea, "Info")
        self.infoa = gui.widgetLabel(box, 'No data on input.')
        self.infob = gui.widgetLabel(box, 'No learners.')

        gui.separator(self.controlArea)

        box = gui.widgetBox(self.controlArea, "Evaluation Scores")
        gui.comboBox(box, self, "scoringF",
                     items=[x[0] for x in self.scoring],
                     callback=self._invalidate_curves)

        gui.separator(self.controlArea)

        box = gui.widgetBox(self.controlArea, "Options")
        gui.spin(box, self, 'folds', 2, 100, step=1,
                 label='Cross validation folds:  ', keyboardTracking=False,
                 callback=lambda:
                 self._invalidate_results() if self.commitOnChange else None)
        gui.spin(box, self, 'steps', 2, 100, step=1,
                 label='Learning curve points:  ', keyboardTracking=False,
                 callback=[self.updateCurvePoints,
                           lambda: self._invalidate_results() if self.commitOnChange else None])
        gui.checkBox(box, self, 'commitOnChange', 'Apply setting on any change')
        self.commitBtn = gui.button(box, self, "Apply Setting",
                                    callback=self._invalidate_results,
                                    disabled=True)

        gui.rubber(self.controlArea)

        # table widget
        self.table = gui.table(self.mainArea,
                               selectionMode=QTableWidget.NoSelection)
Exemple #11
0
    def test_set_check_state(self):
        widget = OWBaseWidget()

        widget.some_option = 0
        cb = gui.checkBox(widget,
                          widget,
                          "some_option",
                          "foo",
                          stateWhenDisabled=Qt.Unchecked)
        cb.setCheckState(Qt.Unchecked)
        cb.setEnabled(False)
        self.assertEqual(cb.checkState(), Qt.Unchecked)

        cb.setCheckState(Qt.PartiallyChecked)
        self.assertEqual(cb.checkState(), Qt.Unchecked)
        cb.setEnabled(True)
        self.assertEqual(cb.checkState(), Qt.PartiallyChecked)
        cb.setEnabled(False)
        self.assertEqual(cb.checkState(), Qt.Unchecked)

        cb.setCheckState(Qt.Checked)
        self.assertEqual(cb.checkState(), Qt.Unchecked)
        cb.setEnabled(True)
        self.assertEqual(cb.checkState(), Qt.Checked)
        cb.setEnabled(False)
        self.assertEqual(cb.checkState(), Qt.Unchecked)

        widget.some_option = 2
        cb = gui.checkBox(widget,
                          widget,
                          "some_option",
                          "foo",
                          stateWhenDisabled=Qt.PartiallyChecked)
        cb.setCheckState(Qt.Unchecked)
        cb.setEnabled(False)
        self.assertEqual(cb.checkState(), Qt.PartiallyChecked)

        cb.setCheckState(Qt.Unchecked)
        self.assertEqual(cb.checkState(), Qt.PartiallyChecked)
        cb.setEnabled(True)
        self.assertEqual(cb.checkState(), Qt.Unchecked)
        cb.setEnabled(False)
        self.assertEqual(cb.checkState(), Qt.PartiallyChecked)

        cb.setCheckState(Qt.Checked)
        self.assertEqual(cb.checkState(), Qt.PartiallyChecked)
        cb.setEnabled(True)
        self.assertEqual(cb.checkState(), Qt.Checked)
        cb.setEnabled(False)
        self.assertEqual(cb.checkState(), Qt.PartiallyChecked)
Exemple #12
0
    def __init__(self):
        super().__init__()
        self.data = None

        layout = QFormLayout()
        gui.widgetBox(self.controlArea, box="Coordinates:", orientation=layout)
        self.variable_model = DomainModel(order=DomainModel.MIXED,
                                          valid_types=(ContinuousVariable, ))
        args = dict(contentsLength=100,
                    searchable=True,
                    model=self.variable_model,
                    orientation=Qt.Horizontal)
        layout.addRow("Latitude:", gui.comboBox(None, self, "attr_lat",
                                                **args))
        layout.addRow("Longitude:", gui.comboBox(None, self, "attr_lon",
                                                 **args))
        layout.addWidget(
            gui.checkBox(
                None,
                self,
                "replace_original",
                "Replace original coordinates",
                tooltip="If unchecked, the original coordinates are retained "
                "and new coordinates are added as separate variables."))

        layout = QFormLayout()
        gui.widgetBox(self.controlArea, "Transformation:", orientation=layout)
        args["model"] = PyListModelTooltip(self.EPSG_CODES,
                                           list(self.EPSG_CODES))
        layout.addRow("From:", gui.comboBox(None, self, "from_idx", **args))
        layout.addRow("To:", gui.comboBox(None, self, "to_idx", **args))

        self.commit_button = gui.button(self.controlArea, self, "&Commit",
                                        self.apply)
Exemple #13
0
    def __init__(self, show_automatic_box=True):
        super().__init__()

        geom = QApplication.desktop().availableGeometry()

        if self.want_main_area:
            max_width = self.MAX_WIDTH_MAIN
            self.CONTROL_AREA_WIDTH = self.CONTROL_AREA_WIDTH_MAIN
        else:
            max_width = self.MAX_WIDTH_NO_MAIN
            self.CONTROL_AREA_WIDTH = self.CONTROL_AREA_WIDTH_NO_MAIN

        self.setGeometry(
            QRect(round(geom.width() * 0.01), round(geom.height() * 0.01),
                  round(min(geom.width() * 0.95, max_width)),
                  round(min(geom.height() * 0.95, self.get_max_height()))))

        self.setMinimumWidth(self.geometry().width() / 2)
        self.setMinimumHeight(self.geometry().height() / 2)
        self.setMaximumHeight(self.geometry().height())
        self.setMaximumWidth(self.geometry().width())

        self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)

        self.controlArea.setFixedWidth(self.CONTROL_AREA_WIDTH)

        self.general_options_box = gui.widgetBox(self.controlArea,
                                                 "General Options",
                                                 addSpace=True,
                                                 orientation="horizontal")

        if show_automatic_box:
            orangegui.checkBox(self.general_options_box, self,
                               'is_automatic_run', 'Automatic')

        gui.button(self.general_options_box,
                   self,
                   "Reset Fields",
                   callback=self.callResetSettings)
        gui.button(self.general_options_box,
                   self,
                   "Show Available Parameters",
                   callback=self.show_available_parameters)
    def __init__(self, show_automatic_box=True):
        super().__init__()

        geom = QApplication.desktop().availableGeometry()
        self.setGeometry(QRect(round(geom.width()*0.05),
                               round(geom.height()*0.05),
                               round(min(geom.width()*0.98, self.MAX_WIDTH)),
                               round(min(geom.height()*0.95, self.MAX_HEIGHT))))

        self.setMaximumHeight(self.geometry().height())
        self.setMaximumWidth(self.geometry().width())

        self.controlArea.setFixedWidth(self.CONTROL_AREA_WIDTH)

        self.general_options_box = gui.widgetBox(self.controlArea, "General Options", addSpace=True, orientation="horizontal")

        if show_automatic_box :
            gui.checkBox(self.general_options_box, self, 'is_automatic_run', 'Automatic Execution')

        trace = gui.checkBox(self.general_options_box, self, 'trace_shadow', 'Display Shadow Output')
        trace.setVisible(False)
Exemple #15
0
            def __init__(self, *args, **kwargs):
                super().__init__(*args, **kwargs)

                self.option = False
                self.autocommit = False

                self.checkbox = gui.checkBox(self,
                                             self,
                                             "option",
                                             "foo",
                                             callback=self.apply.deferred)

                self.commit_button = gui.auto_commit(self,
                                                     self,
                                                     'autocommit',
                                                     'Commit',
                                                     commit=self.apply)
    def __init__(self):
        super().__init__()

        # sets self.curvePoints, self.steps equidistant points from
        # 1/self.steps to 1
        self.updateCurvePoints()

        self.scoring = [("Classification Accuracy",
                         Orange.evaluation.scoring.CA),
                        ("AUC", Orange.evaluation.scoring.AUC),
                        ("Precision", Orange.evaluation.scoring.Precision),
                        ("Recall", Orange.evaluation.scoring.Recall)]
        #: Input data on which to construct the learning curve
        self.data = None
        #: Optional test data
        self.testdata = None
        #: LearnerData for each learner input
        self.learners: List[LearnerData] = []

        # [start-snippet-3]
        #: The current evaluating task (if any)
        self._task = None  # type: Optional[Task]
        #: An executor we use to submit learner evaluations into a thread pool
        self._executor = concurrent.futures.ThreadPoolExecutor()
        # [end-snippet-3]

        # GUI
        box = gui.widgetBox(self.controlArea, "Info")
        self.infoa = gui.widgetLabel(box, 'No data on input.')
        self.infob = gui.widgetLabel(box, 'No learners.')

        gui.separator(self.controlArea)

        box = gui.widgetBox(self.controlArea, "Evaluation Scores")
        gui.comboBox(box,
                     self,
                     "scoringF",
                     items=[x[0] for x in self.scoring],
                     callback=self._invalidate_curves)

        gui.separator(self.controlArea)

        box = gui.widgetBox(self.controlArea, "Options")
        gui.spin(box,
                 self,
                 'folds',
                 2,
                 100,
                 step=1,
                 label='Cross validation folds:  ',
                 keyboardTracking=False,
                 callback=lambda: self._invalidate_results()
                 if self.commitOnChange else None)
        gui.spin(box,
                 self,
                 'steps',
                 2,
                 100,
                 step=1,
                 label='Learning curve points:  ',
                 keyboardTracking=False,
                 callback=[
                     self.updateCurvePoints,
                     lambda: self._invalidate_results()
                     if self.commitOnChange else None
                 ])
        gui.checkBox(box, self, 'commitOnChange',
                     'Apply setting on any change')
        self.commitBtn = gui.button(box,
                                    self,
                                    "Apply Setting",
                                    callback=self._invalidate_results,
                                    disabled=True)

        gui.rubber(self.controlArea)

        # table widget
        self.table = gui.table(self.mainArea,
                               selectionMode=QTableWidget.NoSelection)
Exemple #17
0
    def build_gui(self):
        runaction = OWAction("Find Best Focus Position", self)
        runaction.triggered.connect(self.do_best_focus_calculation)
        self.addAction(runaction)

        runaction = OWAction("Interrupt Best Focus Calculation", self)
        runaction.triggered.connect(self.stop_best_focus_calculation)
        self.addAction(runaction)

        self.view_type = 1
        self.button_box.setVisible(False)

        self.tabs_setting = oasysgui.tabWidget(self.controlArea)
        self.tabs_setting.setFixedHeight(self.TABS_AREA_HEIGHT)
        self.tabs_setting.setFixedWidth(self.CONTROL_AREA_WIDTH-5)

        self.tab_bas = oasysgui.createTabPage(self.tabs_setting, "Detector Setting")
        self.tab_pro = oasysgui.createTabPage(self.tabs_setting, "Advanced Setting")

        main_box = oasysgui.widgetBox(self.tab_bas, "Detector Parameters", orientation="vertical", width=self.CONTROL_AREA_WIDTH-20)

        oasysgui.lineEdit(main_box, self, "detector_size", "Detector Size [" + u"\u03BC" + "m]", labelWidth=240, valueType=float, orientation="horizontal")

        gui.separator(main_box)

        gui.comboBox(main_box, self, "calculation_type", label="Numeric Integration",
                     items=["Automatic Number of Points", "User Defined Number of Points"], labelWidth=140,
                     callback=self.set_CalculationType, sendSelectedValue=False, orientation="horizontal")

        self.detector_box = oasysgui.widgetBox(main_box, "", orientation="vertical", width=self.CONTROL_AREA_WIDTH-40, height=30)

        le_calculated_number_of_points = oasysgui.lineEdit(self.detector_box, self, "calculated_number_of_points", "Calculated Number of Points", labelWidth=240, valueType=float, orientation="horizontal")
        le_calculated_number_of_points.setReadOnly(True)
        font = QFont(le_calculated_number_of_points.font())
        font.setBold(True)
        le_calculated_number_of_points.setFont(font)
        palette = QPalette(le_calculated_number_of_points.palette())
        palette.setColor(QPalette.Text, QColor('dark blue'))
        palette.setColor(QPalette.Base, QColor(243, 240, 140))
        le_calculated_number_of_points.setPalette(palette)

        self.number_box = oasysgui.widgetBox(main_box, "", orientation="vertical", width=self.CONTROL_AREA_WIDTH-40, height=30)

        oasysgui.lineEdit(self.number_box, self, "number_of_points", "Number of Points", labelWidth=240, valueType=int, orientation="horizontal")

        self.set_CalculationType()

        self.le_oe_f2 = oasysgui.lineEdit(main_box, self, "oe_f2", "O.E. F2", labelWidth=240, valueType=float, orientation="horizontal")
        self.le_oe_f2.setReadOnly(True)
        font = QFont(self.le_oe_f2.font())
        font.setBold(True)
        self.le_oe_f2.setFont(font)
        palette = QPalette(self.le_oe_f2.palette())
        palette.setColor(QPalette.Text, QColor('dark blue'))
        palette.setColor(QPalette.Base, QColor(243, 240, 140))
        self.le_oe_f2.setPalette(palette)

        self.le_defocus_sweep = oasysgui.lineEdit(main_box, self, "defocus_sweep", "Defocus sweep", labelWidth=240, valueType=float, orientation="horizontal")

        gui.button(main_box, self, "Compute", callback=self.compute, height=35)

        best_focus_box = oasysgui.widgetBox(self.tab_bas, "Best Focus Calculation", orientation="vertical", width=self.CONTROL_AREA_WIDTH-20)

        self.le_defocus_start = oasysgui.lineEdit(best_focus_box, self, "defocus_start", "Defocus sweep start", labelWidth=240, valueType=float, orientation="horizontal")
        self.le_defocus_stop  = oasysgui.lineEdit(best_focus_box, self, "defocus_stop", "Defocus sweep stop", labelWidth=240, valueType=float, orientation="horizontal")
        self.le_defocus_step  = oasysgui.lineEdit(best_focus_box, self, "defocus_step", "Defocus sweep step", labelWidth=240, valueType=float, orientation="horizontal")

        gui.separator(best_focus_box, height=5)

        gui.checkBox(best_focus_box, self, "show_animation", "Show animation during calculation")

        gui.separator(best_focus_box, height=5)


        button_box = oasysgui.widgetBox(best_focus_box, "", orientation="horizontal", width=self.CONTROL_AREA_WIDTH-40)

        gui.button(button_box, self, "Find Best Focus Position", callback=self.do_best_focus_calculation, height=35)
        stop_button = gui.button(button_box, self, "Interrupt", callback=self.stop_best_focus_calculation, height=35)
        font = QFont(stop_button.font())
        font.setBold(True)
        stop_button.setFont(font)
        palette = QPalette(stop_button.palette()) # make a copy of the palette
        palette.setColor(QPalette.ButtonText, QColor('red'))
        stop_button.setPalette(palette) # assign new palette

        self.save_button = gui.button(best_focus_box, self, "Save Best Focus Calculation Complete Results", callback=self.save_best_focus_results, height=35)
        self.save_button.setEnabled(False)

        parallel_box = oasysgui.widgetBox(self.tab_pro, "Parallel Computing", orientation="vertical", width=self.CONTROL_AREA_WIDTH-20)

        gui.comboBox(parallel_box, self, "use_multipool", label="Use Parallel Processing",
                     items=["No", "Yes"], labelWidth=240,
                     callback=self.set_Multipool, sendSelectedValue=False, orientation="horizontal")

        self.use_multipool_box = oasysgui.widgetBox(parallel_box, "", addSpace=True, orientation="vertical", height=30, width=self.CONTROL_AREA_WIDTH-40)
        self.use_multipool_box_empty = oasysgui.widgetBox(parallel_box, "", addSpace=True, orientation="vertical", height=30, width=self.CONTROL_AREA_WIDTH-40)

        oasysgui.lineEdit(self.use_multipool_box, self, "n_pools", "Nr. Parallel Processes", labelWidth=240, valueType=int, orientation="horizontal")

        self.set_Multipool()

        self.best_focus_slider = None
Exemple #18
0
    def build_mirror_specific_gui(self, container_box):

        self.tab_best = oasysgui.createTabPage(self.tabs_setting,
                                               "Find Best Focus")

        best_focus_box = oasysgui.widgetBox(self.tab_best,
                                            "",
                                            orientation="vertical",
                                            width=self.CONTROL_AREA_WIDTH - 20)

        bestFocusLabel = "Use for: \n* best focus metrics (HEW, position)\n* intensity profile at best focus position\n* high computational speed\n"

        gui.label(best_focus_box,
                  self,
                  bestFocusLabel,
                  labelWidth=None,
                  box=None,
                  orientation=2)

        self.le_defocus_start = oasysgui.lineEdit(best_focus_box,
                                                  self,
                                                  "defocus_start",
                                                  "Start [mm]",
                                                  labelWidth=240,
                                                  valueType=float,
                                                  orientation="horizontal")
        self.le_defocus_stop = oasysgui.lineEdit(best_focus_box,
                                                 self,
                                                 "defocus_stop",
                                                 "Stop [mm]",
                                                 labelWidth=240,
                                                 valueType=float,
                                                 orientation="horizontal")
        # self.le_defocus_step = oasysgui.lineEdit(best_focus_box, self, "defocus_step", "Step [mm]", labelWidth=240, valueType=float, orientation="horizontal")
        self.le_max_iter = oasysgui.lineEdit(best_focus_box,
                                             self,
                                             "max_iter",
                                             "Max. iterations",
                                             labelWidth=240,
                                             valueType=int,
                                             orientation="horizontal")

        # gui.separator(best_focus_box, height=5)

        # gui.checkBox(best_focus_box, self, "show_animation", "Show animation during calculation")

        gui.separator(best_focus_box, height=5)

        button_box = oasysgui.widgetBox(best_focus_box,
                                        "",
                                        orientation="horizontal",
                                        width=self.CONTROL_AREA_WIDTH - 20)

        gui.button(button_box,
                   self,
                   "Scan Start",
                   callback=self.do_find_focus_calculation,
                   height=35)
        stop_button = gui.button(button_box,
                                 self,
                                 "Interrupt",
                                 callback=self.stop_best_focus_calculation,
                                 height=35)
        font = QFont(stop_button.font())
        font.setBold(True)
        stop_button.setFont(font)
        palette = QPalette(stop_button.palette())  # make a copy of the palette
        palette.setColor(QPalette.ButtonText, QColor('red'))
        stop_button.setPalette(palette)  # assign new palette

        self.save_button = gui.button(best_focus_box,
                                      self,
                                      "Save Complete Calculation Results",
                                      callback=self.save_best_focus_results,
                                      height=35)
        self.save_button.setEnabled(False)

        # PROBLEM HERE! STR AND FLOAT!

        le_BD = oasysgui.lineEdit(best_focus_box,
                                  self,
                                  "ActualBestDefocus",
                                  "Best focus at [m]",
                                  labelWidth=220,
                                  valueType=float,
                                  orientation="horizontal")
        le_BD.setReadOnly(True)
        font = QFont(le_BD.font())
        # font.setBold(True)
        le_BD.setFont(font)
        palette = QPalette(le_BD.palette())
        palette.setColor(QPalette.Text, QColor('grey'))
        palette.setColor(QPalette.Base, QColor(243, 240, 140))
        le_BD.setPalette(palette)

        le_HEW = oasysgui.lineEdit(best_focus_box,
                                   self,
                                   "ActualBestHew",
                                   "HEW at best focus [" + u"\u03BC" + "m]",
                                   labelWidth=220,
                                   valueType=float,
                                   orientation="horizontal")
        le_HEW.setReadOnly(True)
        font = QFont(le_HEW.font())
        # font.setBold(True)
        le_HEW.setFont(font)
        palette = QPalette(le_HEW.palette())
        palette.setColor(QPalette.Text, QColor('grey'))
        palette.setColor(QPalette.Base, QColor(243, 240, 140))
        le_HEW.setPalette(palette)

        self.best_focus_slider = None

        self.tab_sweep = oasysgui.createTabPage(self.tabs_setting,
                                                "Focal Scan")

        focus_sweep_box = oasysgui.widgetBox(self.tab_sweep,
                                             "",
                                             orientation="vertical",
                                             width=self.CONTROL_AREA_WIDTH -
                                             20)

        focusSweepLabel = "Use for: \n* a complete plot of the spot size through the focal plane\n* a collection of the intensity profiles\n* below-average computational performance\n"

        gui.label(focus_sweep_box,
                  self,
                  focusSweepLabel,
                  labelWidth=None,
                  box=None,
                  orientation=2)

        self.le_defocus_start = oasysgui.lineEdit(focus_sweep_box,
                                                  self,
                                                  "defocus_start",
                                                  "Lower limit [mm]",
                                                  labelWidth=240,
                                                  valueType=float,
                                                  orientation="horizontal")
        self.le_defocus_stop = oasysgui.lineEdit(focus_sweep_box,
                                                 self,
                                                 "defocus_stop",
                                                 "Upper limit [mm]",
                                                 labelWidth=240,
                                                 valueType=float,
                                                 orientation="horizontal")
        self.le_defocus_Nsteps = oasysgui.lineEdit(focus_sweep_box,
                                                   self,
                                                   "defocus_Nsteps",
                                                   "No. of steps",
                                                   labelWidth=240,
                                                   valueType=int,
                                                   orientation="horizontal",
                                                   callbackOnType=True,
                                                   callback=self.get_StepSize)
        le_defocus_step = oasysgui.lineEdit(focus_sweep_box,
                                            self,
                                            "defocus_step",
                                            "Step [mm]",
                                            labelWidth=240,
                                            valueType=float,
                                            orientation="horizontal")

        le_defocus_step.setReadOnly(True)
        font = QFont(le_defocus_step.font())
        le_defocus_step.setFont(font)
        palette = QPalette(le_defocus_step.palette())
        palette.setColor(QPalette.Text, QColor('grey'))
        palette.setColor(QPalette.Base, QColor(243, 240, 140))
        le_defocus_step.setPalette(palette)

        gui.separator(focus_sweep_box, height=5)

        gui.checkBox(focus_sweep_box, self, "show_animation",
                     "Show animation during calculation")

        gui.separator(focus_sweep_box, height=5)

        button_box = oasysgui.widgetBox(focus_sweep_box,
                                        "",
                                        orientation="horizontal",
                                        width=self.CONTROL_AREA_WIDTH - 20)

        gui.button(button_box,
                   self,
                   "Scan Start",
                   callback=self.do_focus_sweep_calculation,
                   height=35)
        stop_button = gui.button(button_box,
                                 self,
                                 "Interrupt",
                                 callback=self.stop_best_focus_calculation,
                                 height=35)
        font = QFont(stop_button.font())
        font.setBold(True)
        stop_button.setFont(font)
        palette = QPalette(stop_button.palette())  # make a copy of the palette
        palette.setColor(QPalette.ButtonText, QColor('red'))
        stop_button.setPalette(palette)  # assign new palette

        self.save_button = gui.button(focus_sweep_box,
                                      self,
                                      "Save Complete Calculation Results",
                                      callback=self.save_best_focus_results,
                                      height=35)
        self.save_button.setEnabled(False)

        self.best_focus_slider = None
    def build_positioning_directive_box(self, container_box, width, element_type=ElementType.SOURCE):

        box = oasysgui.widgetBox(container_box, "Positioning Directives", orientation="vertical", width=width)

        box_combos = oasysgui.widgetBox(box, "", orientation="vertical", width=width-20)

        box_Distance = oasysgui.widgetBox(box, "", orientation="horizontal", width=width-20)
        box_Distance_check = oasysgui.widgetBox(box_Distance, "", orientation="horizontal", width=20)
        box_Distance_value = oasysgui.widgetBox(box_Distance, "", orientation="horizontal")

        box_XYCentre = oasysgui.widgetBox(box, "", orientation="horizontal", width=width-20)
        box_XYCentre_check = oasysgui.widgetBox(box_XYCentre, "", orientation="horizontal", width=20)
        box_XYCentre_value = oasysgui.widgetBox(box_XYCentre, "", orientation="vertical")

        '''
        box_GrazingAngle = oasysgui.widgetBox(box, "", orientation="horizontal", width=width-20)
        box_GrazingAngle_check = oasysgui.widgetBox(box_GrazingAngle, "", orientation="horizontal", width=20)
        box_GrazingAngle_value = oasysgui.widgetBox(box_GrazingAngle, "", orientation="horizontal")

        box_Angle = oasysgui.widgetBox(box, "", orientation="horizontal", width=width-20)
        box_Angle_check = oasysgui.widgetBox(box_Angle, "", orientation="horizontal", width=20)
        box_Angle_value = oasysgui.widgetBox(box_Angle, "", orientation="horizontal")

        def set_WhichAngle():
            box_GrazingAngle.setVisible(getattr(self, "WhichAngle") == positioning_directives_which_angle[0])
            box_Angle.setVisible(getattr(self, "WhichAngle") != positioning_directives_which_angle[0])
        '''

        def set_Distance_checked():
            box_Distance_value.setEnabled(getattr(self, "Distance_checked") == 1)

        def set_XYCentre_checked():
            box_XYCentre_value.setEnabled(getattr(self, "XYCentre_checked") == 1)

        '''
        def set_GrazingAngle_checked():
            box_GrazingAngle_value.setEnabled(getattr(self, "GrazingAngle_checked") == 1)

        def set_Angle_checked():
            box_Angle_value.setEnabled(getattr(self, "Angle_checked") == 1)
        '''

        def set_positioning_directives():
            pass
            #set_WhichAngle()

        box_what = oasysgui.widgetBox(box_combos, "", orientation="horizontal")
        gui.label(box_what, self, label="  ", labelWidth=20)
        gui.comboBox(box_what, self, "What", label="",
                     items=positioning_directives_what,
                     sendSelectedValue=True, orientation="horizontal", callback=set_positioning_directives)
        gui.label(box_what, self, label=" of this O.E.", labelWidth=80)

        box_where = oasysgui.widgetBox(box_combos, "", orientation="horizontal")
        gui.label(box_where, self, label="at", labelWidth=20)
        gui.comboBox(box_where, self, "Where", label="",
                     items=positioning_directives_where,
                     sendSelectedValue=True, orientation="horizontal", callback=set_positioning_directives)
        gui.label(box_where, self, label=" of", labelWidth=80)

        box_refer_to = oasysgui.widgetBox(box_combos, "", orientation="horizontal")
        gui.label(box_refer_to, self, label=" ", labelWidth=20)
        gui.comboBox(box_refer_to, self, "ReferTo", label="",
                     items=positioning_directives_refer_to,
                     sendSelectedValue=True, orientation="horizontal", callback=set_positioning_directives)
        gui.label(box_refer_to, self, label=" O.E.", labelWidth=80)

        '''
        gui.comboBox(box_combos, self, "WhichAngle", label="Type Of Angle",
                     items=positioning_directives_which_angle, labelWidth=box_combos.width()-150,
                     sendSelectedValue=True, orientation="horizontal", callback=set_WhichAngle)
        '''

        gui.separator(box_combos)

        gui.checkBox(box_Distance_check, self, "Distance_checked", "", callback=set_Distance_checked)
        gui.checkBox(box_XYCentre_check, self, "XYCentre_checked", "", callback=set_XYCentre_checked)
        '''
        gui.checkBox(box_GrazingAngle_check, self, "GrazingAngle_checked", "", callback=set_GrazingAngle_checked)
        gui.checkBox(box_Angle_check, self, "Angle_checked", "", callback=set_Angle_checked)
        '''

        set_Distance_checked()
        set_XYCentre_checked()
        '''
        set_Angle_checked()
        set_GrazingAngle_checked()
        '''

        self.le_Distance = oasysgui.lineEdit(box_Distance_value, self, "Distance", "Distance", labelWidth=200, valueType=float, orientation="horizontal")
        self.le_XCentre = oasysgui.lineEdit(box_XYCentre_value, self, "XCentre", "X Centre", labelWidth=200, valueType=float, orientation="horizontal")
        self.le_YCentre = oasysgui.lineEdit(box_XYCentre_value, self, "YCentre", "Y Centre", labelWidth=200, valueType=float, orientation="horizontal")

        '''
        oasysgui.lineEdit(box_Angle_value, self, "Angle", "Angle [deg]", labelWidth=200, valueType=float, orientation="horizontal")
        oasysgui.lineEdit(box_GrazingAngle_value, self, "GrazingAngle", "Grazing Angle [deg]", labelWidth=200, valueType=float, orientation="horizontal")
        '''
        set_positioning_directives()
Exemple #20
0
    def _setup_control_area(self) -> None:
        box = gui.widgetBox(self.controlArea, "Word Scoring Methods")
        for value, (n, _, tt) in SCORING_METHODS.items():
            b = gui.hBox(box, margin=0)
            gui.checkBox(
                b,
                self,
                value,
                label=n,
                callback=self.__setting_changed,
                tooltip=tt,
            )
            if value in ADDITIONAL_OPTIONS:
                value, options = ADDITIONAL_OPTIONS[value]
                gui.comboBox(
                    b,
                    self,
                    value,
                    items=options,
                    callback=self.__setting_changed,
                )

        box = gui.widgetBox(self.controlArea, "Aggregation")
        gui.comboBox(
            box,
            self,
            "aggregation",
            items=[n for n in AGGREGATIONS],
            callback=self.__setting_changed,
        )

        gui.rubber(self.controlArea)

        # select words box
        box = gui.vBox(self.buttonsArea, "Select Documents")
        grid = QGridLayout()
        grid.setContentsMargins(0, 0, 0, 0)

        self._sel_method_buttons = QButtonGroup()
        for method, label in enumerate(SelectionMethods.ITEMS):
            button = QRadioButton(label)
            button.setChecked(method == self.sel_method)
            grid.addWidget(button, method, 0)
            self._sel_method_buttons.addButton(button, method)
        self._sel_method_buttons.buttonClicked[int].connect(
            self.__set_selection_method)

        spin = gui.spin(
            box,
            self,
            "n_selected",
            1,
            999,
            addToLayout=False,
            callback=lambda: self.__set_selection_method(SelectionMethods.
                                                         N_BEST),
        )
        grid.addWidget(spin, 3, 1)
        box.layout().addLayout(grid)

        # autocommit
        gui.auto_send(self.buttonsArea, self, "auto_commit")
Exemple #21
0
    def __init__(self):
        super().__init__()

        left_box_1 = oasysgui.widgetBox(self.controlArea, "GID_SL Request Form", addSpace=False, orientation="vertical",
                                         width=500, height=680)

        self.central_tabs = oasysgui.tabWidget(left_box_1)
        tab_template = oasysgui.createTabPage(self.central_tabs, "Template Options")
        tab_input = oasysgui.createTabPage(self.central_tabs, "Input Options")

        left_box_1_1 = oasysgui.widgetBox(tab_template, "", addSpace=False, orientation="vertical", width=480, height=670)

        gui.separator(left_box_1_1)

        gui.comboBox(left_box_1_1, self, "template_type", label="Template Type", labelWidth=100,
                     items=["Simplified (coplanar geometries only)", "Full"],
                     callback=self.set_TemplateType, sendSelectedValue=False, orientation="horizontal")

        self.simplified_box = oasysgui.widgetBox(left_box_1_1, "", addSpace=False, orientation="horizontal", width=470, height=220)

        gui.radioButtons(self.simplified_box, self, "simplified_form",
                         ["Symmetric Bragg diffraction from perfect crystals",
                          "Symmetric Bragg diffraction from multilayers and superlattices",
                          "Symmetric Bragg diffraction at Bragg angle of 90 degrees (\"back diffraction\")",
                          "Energy scanning of symmetric Bragg diffraction peaks"],
                         callback=self.set_SimplifiedForm)

        self.full_box = oasysgui.widgetBox(left_box_1_1, "", addSpace=False, orientation="horizontal", width=470, height=220)

        gui.radioButtons(self.full_box, self, "full_form",
                         ["Symmetric Bragg diffraction from perfect crystals",
                          "Symmetric Bragg diffraction from multilayers and superlattices",
                          "Coplanar extremely asymmetric diffraction of synchrotron radiation",
                          "Grazing incidence (\"surface\") diffraction from perfect crystals",
                          "Grazing incidence (\"surface\") diffraction from multilayers in the scheme\nwith position sensitive detector (PSD)",
                          "Non-coplanar Bragg-Laue diffraction from crystals with a few degrees\nsurface miscut"],
                         callback=self.set_FullForm)

        # -------------------------------------------------------------
        # -------------------------------------------------------------
        # -------------------------------------------------------------

        gui.separator(tab_input)

        left_box_2 = oasysgui.widgetBox(tab_input, "", addSpace=False, orientation="vertical", width=470)

        left_box_2_1 = oasysgui.widgetBox(left_box_2, "", addSpace=False, orientation="horizontal", width=470)

        gui.comboBox(left_box_2_1, self, "xway", label="X-rays specified by",
                     items=["Wavelength (Å)", "Energy (keV)", "Bragg angle (deg)", "X-ray line"],
                     callback=self.set_xway, sendSelectedValue=False, orientation="horizontal")

        self.box_wave = oasysgui.widgetBox(left_box_2_1, "", addSpace=False, orientation="horizontal", width=100)
        oasysgui.lineEdit(self.box_wave, self, "wave", label="", labelWidth=0, addSpace=False, valueType=float, orientation="horizontal")

        self.box_line = oasysgui.widgetBox(left_box_2_1, "", addSpace=False, orientation="horizontal", width=100)
        XRayServerGui.combobox_text(self.box_line, self, "line", label="", labelWidth=0,
                               items=self.get_lines(),
                               sendSelectedValue=True, orientation="horizontal", selectedValue=self.line)

        button = gui.button(self.box_line, self, "?", callback=self.help_lines)
        button.setFixedWidth(15)

        self.set_xway()

        gui.comboBox(left_box_2_1, self, "ipol", label="Polarization",
                     items=["Sigma", "Pi", "Mixed"], sendSelectedValue=False, orientation="horizontal")


        # -------------------------------------------------------------

        left_box_3 = oasysgui.widgetBox(tab_input, "", addSpace=False, orientation="vertical", width=470)

        left_box_3_1 = oasysgui.widgetBox(left_box_3, "", addSpace=False, orientation="horizontal", width=470)
        XRayServerGui.combobox_text(left_box_3_1, self, "code", label="Crystal", labelWidth=40,
                               items=self.get_crystals(),
                               sendSelectedValue=True, orientation="horizontal", selectedValue=self.code)

        button = gui.button(left_box_3_1, self, "?", callback=self.help_crystals)
        button.setFixedWidth(15)

        gui.comboBox(left_box_3_1, self, "df1df2", label=" ", labelWidth=20,
                     items=["Auto DB for f\', f\'\'",
                            "X0h data (0.5-2.5 A)",
                            "Henke (0.4-1200 A)",
                            "Brennan (0.02-400 A)"],
                     sendSelectedValue=False, orientation="horizontal")

        left_box_3_2 = oasysgui.widgetBox(left_box_3, "", addSpace=False, orientation="horizontal", width=470)

        oasysgui.lineEdit(left_box_3_2, self, "sigma", label="Sigma", labelWidth=80, addSpace=False, valueType=float, orientation="horizontal")
        oasysgui.lineEdit(left_box_3_2, self, "w0", label="A      W0", labelWidth=50, addSpace=False, valueType=float, orientation="horizontal")
        oasysgui.lineEdit(left_box_3_2, self, "wh", label="        Wh", labelWidth=50, addSpace=False, valueType=float, orientation="horizontal")

        # -------------------------------------------------------------

        left_box_4 = oasysgui.widgetBox(tab_input, "", addSpace=False, orientation="horizontal", width=470)

        left_box_4_1 = oasysgui.widgetBox(left_box_4, "", addSpace=False, orientation="horizontal", width=240)

        oasysgui.lineEdit(left_box_4_1, self, "i1", label="Bragg Reflection", labelWidth=97, addSpace=False, valueType=int, orientation="horizontal")
        oasysgui.lineEdit(left_box_4_1, self, "i2", label=" ", labelWidth=1, addSpace=False, valueType=int, orientation="horizontal")
        oasysgui.lineEdit(left_box_4_1, self, "i3", label=" ", labelWidth=1, addSpace=False, valueType=int, orientation="horizontal")

        left_box_4_2 = oasysgui.widgetBox(left_box_4, "", addSpace=False, orientation="horizontal", width=228)

        oasysgui.lineEdit(left_box_4_2, self, "daa", label="  Substrate da/a", labelWidth=135, addSpace=False, valueType=float, orientation="horizontal")

        # -------------------------------------------------------------
        # -------------------------------------------------------------

        self.simplified_input_box = oasysgui.widgetBox(tab_input, "", addSpace=False, orientation="vertical", width=470, height=290)

        gui.comboBox(self.simplified_input_box, self, "igie", label="Geometry specified by",
                     items=["angle of Bragg planes to surface ('+' for g0>gh)",
                            "incidence angle of K0",
                            "exit angle of Kh",
                            "asymmetry factor beta=g0/gh"],
                     callback=self.set_igie_s, sendSelectedValue=False, orientation="horizontal")

        simplified_input_box_1 = oasysgui.widgetBox(self.simplified_input_box, "", addSpace=False, orientation="horizontal", width=470)

        oasysgui.lineEdit(simplified_input_box_1, self, "fcentre", label="Value", labelWidth=280, addSpace=False, valueType=float, orientation="horizontal")

        self.unic_combo_s = gui.comboBox(simplified_input_box_1, self, "unic", label=" ", labelWidth=1,
                                       items=[" ",
                                              "degr.",
                                              "min.",
                                              "mrad.",
                                              "sec.",
                                              "urad"],
                                       sendSelectedValue=False, orientation="horizontal")

        self.set_igie_s()

        simplified_input_box_2 = oasysgui.widgetBox(self.simplified_input_box, "", addSpace=False, orientation="horizontal", width=470)

        oasysgui.lineEdit(simplified_input_box_2, self, "scanmin", label="Scan: From", labelWidth=70, addSpace=False, valueType=float, orientation="horizontal")
        oasysgui.lineEdit(simplified_input_box_2, self, "scanmax", label="To", labelWidth=15, addSpace=False, valueType=float, orientation="horizontal")

        self.simplified_input_box_scan_1_1 = oasysgui.widgetBox(simplified_input_box_2, "", addSpace=False, orientation="horizontal")

        gui.comboBox(self.simplified_input_box_scan_1_1, self, "unis", label=" ", labelWidth=1,
                     items=["degr.",
                            "min.",
                            "mrad.",
                            "sec.",
                            "urad"],
                     sendSelectedValue=False, orientation="horizontal")

        oasysgui.lineEdit(self.simplified_input_box_scan_1_1, self, "nscan", label="Points", labelWidth=40, addSpace=False, valueType=int, orientation="horizontal")

        self.simplified_input_box_scan_1_2 = oasysgui.widgetBox(self.simplified_input_box, "", addSpace=False, orientation="horizontal", width=470)

        gui.checkBox(self.simplified_input_box_scan_1_2, self, "invert", "Invert axis", labelWidth=190)
        gui.comboBox(self.simplified_input_box_scan_1_2, self, "column", label="Plot argument", labelWidth=100,
                                       items=["scan angle",
                                              "incidence angle",
                                              "exit angle"],
                                       sendSelectedValue=False, orientation="horizontal")

        self.simplified_input_box_scan_2_1 = oasysgui.widgetBox(simplified_input_box_2, "", addSpace=False, orientation="horizontal")

        self.unis_combo_s = gui.comboBox(self.simplified_input_box_scan_2_1, self, "unis", label=" ", labelWidth=1,
                                         items=["degr.",
                                                "min.",
                                                "mrad.",
                                                "sec.",
                                                "urad",
                                                "eV"],
                                         sendSelectedValue=False, orientation="horizontal")

        oasysgui.lineEdit(self.simplified_input_box_scan_2_1, self, "nscan", label="Points", labelWidth=40, addSpace=False, valueType=int, orientation="horizontal")

        self.simplified_input_box_scan_2_2 = oasysgui.widgetBox(self.simplified_input_box, "", addSpace=False, orientation="horizontal")

        gui.comboBox(self.simplified_input_box_scan_2_2, self, "axis", label="Scan Type", labelWidth=290,
                     items=["[k0 x h]",
                            "Energy (eV)",
                            "Energy (eV), no X0h recalc"],
                     sendSelectedValue=False, orientation="horizontal", callback=self.set_scan_type_s)

        self.set_scan_type_s()

        # -------------------------------------------------------------
        # -------------------------------------------------------------

        self.full_input_box = oasysgui.widgetBox(tab_input, "", addSpace=True, orientation="vertical", width=470, height=290)

        gui.comboBox(self.full_input_box, self, "igie", label="Geom. by", labelWidth=60,
                     items=["[1]. Surface orientation & incidence angle of K0",
                            "[2]. Surface orientation & exit angle of Kh",
                            "[3]. Surface orientation & condition of coplanar grazing incidence",
                            "[4]. Surface orientation & condition of coplanar grazing exit",
                            "[5]. Surface orientation & condition of symmetric Bragg case",
                            "[6]. Condition of coplanar reflection & angle of Bragg planes to surface",
                            "[7]. Condition of coplanar reflection & incidence angle of K0",
                            "[8]. Condition of coplanar reflection & exit angle of Kh",
                            "[9]. Condition of coplanar reflection & asymmetry factor beta=g0/gh"],
                     callback=self.set_igie_f, sendSelectedValue=False, orientation="horizontal")

        gui.label(self.full_input_box, self, "-- Geom. parameter ([1,7]=incidence angle, [2,8]=exit angle, [6]=Bragg planes")

        full_input_box_1 = oasysgui.widgetBox(self.full_input_box, "", addSpace=False, orientation="vertical", width=470)

        full_input_box_1_1 = oasysgui.widgetBox(full_input_box_1, "", addSpace=False, orientation="horizontal", width=470)

        self.le_fcentre = oasysgui.lineEdit(full_input_box_1_1, self, "fcentre", label="                                   angle, [9]=g0/gh)",
                                       labelWidth=250, addSpace=False, valueType=float, orientation="horizontal")

        self.unic_combo_f = gui.comboBox(full_input_box_1_1, self, "unic", label=" ", labelWidth=1,
                                         items=[" ",
                                              "degr.",
                                              "min.",
                                              "mrad.",
                                              "sec.",
                                              "urad"],
                                         sendSelectedValue=False, orientation="horizontal")

        self.set_igie_f()

        full_input_box_1_2 = oasysgui.widgetBox(full_input_box_1, "", addSpace=False, orientation="horizontal", width=270)

        oasysgui.lineEdit(full_input_box_1_2, self, "n1", label="-- Surface plane ([1-5])", labelWidth=135, addSpace=False, valueType=int, orientation="horizontal")
        oasysgui.lineEdit(full_input_box_1_2, self, "n2", label=" ", labelWidth=1, addSpace=False, valueType=int, orientation="horizontal")
        oasysgui.lineEdit(full_input_box_1_2, self, "n3", label=" ", labelWidth=1, addSpace=False, valueType=int, orientation="horizontal")

        full_input_box_2 = oasysgui.widgetBox(self.full_input_box, "", addSpace=False, orientation="horizontal", width=470)

        full_input_box_2_1 = oasysgui.widgetBox(full_input_box_2, "", addSpace=False, orientation="horizontal", width=270)

        oasysgui.lineEdit(full_input_box_2_1, self, "m1", label="Miscut direction", labelWidth=135, addSpace=False, valueType=int, orientation="horizontal")
        oasysgui.lineEdit(full_input_box_2_1, self, "m2", label=" ", labelWidth=1, addSpace=False, valueType=int, orientation="horizontal")
        oasysgui.lineEdit(full_input_box_2_1, self, "m3", label=" ", labelWidth=1, addSpace=False, valueType=int, orientation="horizontal")

        full_input_box_2_2 = oasysgui.widgetBox(full_input_box_2, "", addSpace=False, orientation="horizontal")

        oasysgui.lineEdit(full_input_box_2_2, self, "miscut", label="Miscut angle", addSpace=False, valueType=float, orientation="horizontal")

        gui.comboBox(full_input_box_2_2, self, "unim", label=" ", labelWidth=1,
                                         items=["degr.",
                                              "min.",
                                              "mrad.",
                                              "sec.",
                                              "urad"],
                                         sendSelectedValue=False, orientation="horizontal")

        full_input_box_3 = oasysgui.widgetBox(self.full_input_box, "", addSpace=False, orientation="vertical", width=470)

        full_input_box_3_1 = oasysgui.widgetBox(full_input_box_3, "", addSpace=False, orientation="horizontal", width=470)

        gui.comboBox(full_input_box_3_1, self, "axis", label="Scan Type", labelWidth=190,
                     items=["Surface normal (N_surface)",
                            "[k0 x N_surface]",
                            "Reciprocal latt.vector (h)",
                            "[k0 x h]",
                            "Other axis",
                            "Takeoff spectrum (PSD)"],
                     sendSelectedValue=False, orientation="horizontal", callback=self.set_scan_type_f)

        gui.checkBox(full_input_box_3_1, self, "invert", "Invert axis", labelWidth=90)

        full_input_box_3_2 = oasysgui.widgetBox(full_input_box_3, "", addSpace=False, orientation="horizontal", width=470)

        self.le_a1 = oasysgui.lineEdit(full_input_box_3_2, self, "a1", label="Indices, if other scan axis", labelWidth=290, addSpace=False, valueType=int, orientation="horizontal")
        self.le_a2 = oasysgui.lineEdit(full_input_box_3_2, self, "a2", label=" ", labelWidth=1, addSpace=False, valueType=int, orientation="horizontal")
        self.le_a3 = oasysgui.lineEdit(full_input_box_3_2, self, "a3", label=" ", labelWidth=1, addSpace=False, valueType=int, orientation="horizontal")

        self.set_scan_type_f()

        full_input_box_5 = oasysgui.widgetBox(self.full_input_box, "", addSpace=False, orientation="vertical", width=470)

        full_input_box_5_1 = oasysgui.widgetBox(full_input_box_5, "", addSpace=False, orientation="horizontal", width=470)

        oasysgui.lineEdit(full_input_box_5_1, self, "scanmin", label="Scan: From", labelWidth=70, addSpace=False, valueType=float, orientation="horizontal")
        oasysgui.lineEdit(full_input_box_5_1, self, "scanmax", label="To", labelWidth=15, addSpace=False, valueType=float, orientation="horizontal")

        gui.comboBox(full_input_box_5_1, self, "unis", label=" ", labelWidth=1,
                     items=["degr.",
                            "min.",
                            "mrad.",
                            "sec.",
                            "urad"],
                     sendSelectedValue=False, orientation="horizontal")

        oasysgui.lineEdit(full_input_box_5_1, self, "nscan", label="Points", labelWidth=40, addSpace=False, valueType=int, orientation="horizontal")

        full_input_box_5_2 = oasysgui.widgetBox(full_input_box_5, "", addSpace=False, orientation="horizontal", width=470)

        gui.comboBox(full_input_box_5_2, self, "column", label="Plot argument", labelWidth=290,
                                       items=["scan angle",
                                              "incidence angle",
                                              "exit angle"],
                                       sendSelectedValue=False, orientation="horizontal")

        # -------------------------------------------------------------

        box_alpha = oasysgui.widgetBox(tab_input, "", addSpace=False, orientation="horizontal", width=280)

        self.le_alphamax = oasysgui.lineEdit(box_alpha, self, "alphamax", label="Approximations: alpha_max", labelWidth=170, addSpace=False, valueType=float, orientation="horizontal")
        gui.label(box_alpha, self, "*|xh|")

        gui.separator(tab_input)

        # -------------------------------------------------------------

        box_top = oasysgui.widgetBox(tab_input, "", addSpace=False, orientation="vertical", width=470)

        box_top_0 = oasysgui.widgetBox(box_top, "", addSpace=False, orientation="horizontal", width=470)

        box_top_0_1 = oasysgui.widgetBox(box_top_0, "", addSpace=False, orientation="vertical", width=100)

        gui.label(box_top_0_1, self, "Top layer profile\n(optional):")

        button = gui.button(box_top_0_1, self, "? (sintax)", callback=self.help_profile)
        button.setFixedWidth(90)

        box_top_0_2 = oasysgui.widgetBox(box_top_0, "", addSpace=False, orientation="horizontal", width=360)

        self.profile_area = QtWidgets.QTextEdit()
        self.profile_area.setStyleSheet("background-color: white;")
        self.profile_area.setMaximumHeight(110)
        self.profile_area.setMaximumWidth(360)
        box_top_0_2.layout().addWidget(self.profile_area)


        box_top_labels = oasysgui.widgetBox(box_top, "", addSpace=False, orientation="horizontal", width=470)

        box_top_labels_1 = oasysgui.widgetBox(box_top_labels, "", addSpace=False, orientation="horizontal", width=100)

        gui.label(box_top_labels_1, self, "Available Codes:")

        box_top_labels_2 = oasysgui.widgetBox(box_top_labels, "", addSpace=False, orientation="horizontal", width=360)

        gui.label(box_top_labels_2, self, "Crystals")
        gui.label(box_top_labels_2, self, "Non-Crystals")
        gui.label(box_top_labels_2, self, "Elements")

        box_top_1 = oasysgui.widgetBox(box_top, "", addSpace=False, orientation="horizontal", width=470)

        oasysgui.widgetBox(box_top_1, "", addSpace=False, orientation="horizontal", width=100)
        box_top_1_2 = oasysgui.widgetBox(box_top_1, "", addSpace=False, orientation="horizontal", width=360)

        crystals_area = QtWidgets.QTextEdit()
        crystals_area.setStyleSheet("background-color: white;")
        crystals_area.setMaximumHeight(100)
        crystals_area.setMaximumWidth(120)
        crystals_area.setText("\n".join(ListUtility.get_list("crystals")))
        crystals_area.setReadOnly(True)

        non_crystals_area = QtWidgets.QTextEdit()
        non_crystals_area.setStyleSheet("background-color: white;")
        non_crystals_area.setMaximumHeight(100)
        non_crystals_area.setMaximumWidth(120)
        non_crystals_area.setText("\n".join(ListUtility.get_list("amorphous")))
        non_crystals_area.setReadOnly(True)

        elements_area = QtWidgets.QTextEdit()
        elements_area.setStyleSheet("background-color: white;")
        elements_area.setMaximumHeight(100)
        elements_area.setMaximumWidth(120)
        elements_area.setText("\n".join(ListUtility.get_list("atoms")))
        elements_area.setReadOnly(True)

        box_top_1_2.layout().addWidget(crystals_area)
        box_top_1_2.layout().addWidget(non_crystals_area)
        box_top_1_2.layout().addWidget(elements_area)

        # -----------------------------------------------------------


        button = gui.button(tab_input, self, "Submit Query!", callback=self.submit)
        button.setFixedHeight(30)

        gui.rubber(self.controlArea)

        self.tabs = []
        self.tabs_widget = oasysgui.tabWidget(self.mainArea)
        self.initializeTabs()

        self.set_TemplateType(change_values=False)

        self.profile_area.textChanged.connect(self.set_profile)
        self.le_alphamax.focusOutEvent = self.alphamax_focusOutEvent
        self.alphamax_focusOutEvent(None)

        gui.rubber(self.mainArea)
    def __init__(self):
        self.setFixedWidth(590)
        self.setFixedHeight(550)

        left_box_1 = oasysgui.widgetBox(self.controlArea, "CCD Image", addSpace=True, orientation="vertical")

        gui.comboBox(left_box_1, self, "is_textual", label="Image Type", labelWidth=250, items=["JPEG/PNG", "Textual"], sendSelectedValue=False, orientation="horizontal", callback=self.setTextual)

        ########################################

        self.select_file_box_1 = oasysgui.widgetBox(left_box_1, "Textual Image Parameters", addSpace=True, orientation="horizontal", height=250)

        self.le_image_txt_file_name = oasysgui.lineEdit(self.select_file_box_1, self, "image_file_name", "Image File Name", labelWidth=120, valueType=str, orientation="horizontal")
        self.le_image_txt_file_name.setFixedWidth(300)

        gui.button(self.select_file_box_1, self, "...", callback=self.selectTxtFile)


        self.select_file_box_2 = oasysgui.widgetBox(left_box_1, "Image Parameters", addSpace=True, orientation="vertical", height=250)

        select_file_box_2_int = oasysgui.widgetBox(self.select_file_box_2, "", addSpace=True, orientation="horizontal")

        self.le_image_file_name = oasysgui.lineEdit(select_file_box_2_int, self, "image_file_name", "Image File Name", labelWidth=120, valueType=str, orientation="horizontal")
        self.le_image_file_name.setFixedWidth(300)

        gui.button(select_file_box_2_int, self, "...", callback=self.selectFile)

        figure_box = oasysgui.widgetBox(self.select_file_box_2, "Preview", addSpace=True, orientation="vertical", width=350, height=180)

        self.preview_box = QtGui.QLabel("")
        self.preview_box.setFixedHeight(100)

        figure_box.layout().addWidget(self.preview_box)

        le = oasysgui.lineEdit(figure_box, self, "number_of_x_pixels", "Number of x Pixels", labelWidth=200, valueType=int, orientation="horizontal")
        le.setReadOnly(True)
        font = QtGui.QFont(le.font())
        font.setBold(True)
        le.setFont(font)
        palette = QtGui.QPalette(le.palette()) # make a copy of the palette
        palette.setColor(QtGui.QPalette.Text, QtGui.QColor('dark blue'))
        palette.setColor(QtGui.QPalette.Base, QtGui.QColor(243, 240, 160))
        le.setPalette(palette)
        le = oasysgui.lineEdit(figure_box, self, "number_of_z_pixels", "Number of z Pixels", labelWidth=200, valueType=int, orientation="horizontal")
        le.setReadOnly(True)
        font = QtGui.QFont(le.font())
        font.setBold(True)
        le.setFont(font)
        palette = QtGui.QPalette(le.palette()) # make a copy of the palette
        palette.setColor(QtGui.QPalette.Text, QtGui.QColor('dark blue'))
        palette.setColor(QtGui.QPalette.Base, QtGui.QColor(243, 240, 160))
        le.setPalette(palette)

        ########################################

        self.setTextual()
        self.loadImage()

        oasysgui.lineEdit(left_box_1, self, "pixel_size", "Pixel Size [um]", labelWidth=200, valueType=float, orientation="horizontal")
        oasysgui.lineEdit(left_box_1, self, "number_of_x_bins", "Number of Bin per Pixel [x]", labelWidth=200, valueType=int, orientation="horizontal")
        oasysgui.lineEdit(left_box_1, self, "number_of_z_bins", "Number of Bin per Pixel [z]", labelWidth=200, valueType=int, orientation="horizontal")
        gui.checkBox(left_box_1, self, "flip_vertically", "Flip Vertically")
        gui.checkBox(left_box_1, self, "flip_horizontally", "Flip Horizontally")

        gui.separator(self.controlArea)

        button = gui.button(self.controlArea, self, "Convert To Beam", callback=self.convertToBeam)
        button.setFixedHeight(45)

        gui.rubber(self.controlArea)
    def __init__(self, show_automatic_box=True, show_general_option_box=True):
        super().__init__()  # show_automatic_box=show_automatic_box)

        geom = QApplication.desktop().availableGeometry()
        self.setGeometry(
            QRect(round(geom.width() * 0.05), round(geom.height() * 0.05),
                  round(min(geom.width() * 0.98, self.MAX_WIDTH)),
                  round(min(geom.height() * 0.95, self.MAX_HEIGHT))))

        self.setMaximumHeight(self.geometry().height())
        self.setMaximumWidth(self.geometry().width())

        self.controlArea.setFixedWidth(self.CONTROL_AREA_WIDTH)

        self.general_options_box = gui.widgetBox(self.controlArea,
                                                 "General Options",
                                                 addSpace=True,
                                                 orientation="horizontal")
        self.general_options_box.setVisible(show_general_option_box)

        if show_automatic_box:
            gui.checkBox(self.general_options_box, self, 'is_automatic_run',
                         'Automatic Execution')

        #
        #
        #
        button_box = oasysgui.widgetBox(self.controlArea,
                                        "",
                                        addSpace=False,
                                        orientation="horizontal")

        button = gui.button(button_box,
                            self,
                            "Refresh Script",
                            callback=self.refresh_script)
        font = QFont(button.font())
        font.setBold(True)
        button.setFont(font)
        palette = QPalette(button.palette())  # make a copy of the palette
        palette.setColor(QPalette.ButtonText, QColor('Dark Blue'))
        button.setPalette(palette)  # assign new palette
        button.setFixedHeight(45)

        gui.separator(self.controlArea)

        gen_box = oasysgui.widgetBox(self.controlArea,
                                     "Scan modes",
                                     addSpace=False,
                                     orientation="vertical",
                                     width=self.CONTROL_AREA_WIDTH - 5)
        oasysgui.lineEdit(gen_box,
                          self,
                          "mode_index_max",
                          "Max mode (index)",
                          labelWidth=150,
                          valueType=int,
                          orientation="horizontal",
                          callback=self.refresh_script)

        gen_box = oasysgui.widgetBox(self.controlArea,
                                     "Script file",
                                     addSpace=False,
                                     orientation="vertical",
                                     width=self.CONTROL_AREA_WIDTH - 5)
        gui.comboBox(gen_box,
                     self,
                     "script_file_flag",
                     label="write file with script",
                     items=["No", "Yes"],
                     labelWidth=300,
                     sendSelectedValue=False,
                     orientation="horizontal")
        box1 = gui.widgetBox(gen_box, orientation="horizontal")
        oasysgui.lineEdit(box1,
                          self,
                          "script_file_name",
                          "Script File Name",
                          labelWidth=150,
                          valueType=str,
                          orientation="horizontal")
        self.show_at("self.script_file_flag == 1", box1)

        gen_box = oasysgui.widgetBox(self.controlArea,
                                     "Output Graph and Data",
                                     addSpace=False,
                                     orientation="vertical",
                                     width=self.CONTROL_AREA_WIDTH - 5)
        gui.comboBox(gen_box,
                     self,
                     "show_graph_flag",
                     label="show plots",
                     items=["No", "Yes"],
                     labelWidth=300,
                     sendSelectedValue=False,
                     orientation="horizontal")

        gui.comboBox(gen_box,
                     self,
                     "graph_file_flag",
                     label="dump plots to file",
                     items=["No", "Yes [png]", "Yes [pdf]"],
                     labelWidth=300,
                     sendSelectedValue=False,
                     orientation="horizontal")

        gui.comboBox(gen_box,
                     self,
                     "data_file_flag",
                     label="dump plot data to file",
                     items=["No", "Yes"],
                     labelWidth=300,
                     sendSelectedValue=False,
                     orientation="horizontal")

        box3 = gui.widgetBox(gen_box, orientation="horizontal")
        oasysgui.lineEdit(box3,
                          self,
                          "root_file_name",
                          "Data File Name Root",
                          labelWidth=150,
                          valueType=str,
                          orientation="horizontal")

        self.show_at("self.graph_file_flag > 0 or self.data_file_flag == 1",
                     box3)

        tabs_setting = oasysgui.tabWidget(self.mainArea)
        tabs_setting.setFixedHeight(self.IMAGE_HEIGHT)
        tabs_setting.setFixedWidth(self.IMAGE_WIDTH)

        tab_scr = oasysgui.createTabPage(tabs_setting, "Python Script")
        tab_out = oasysgui.createTabPage(tabs_setting, "System Output")

        self.pythonScript = oasysgui.textArea(readOnly=False)
        self.pythonScript.setStyleSheet(
            "background-color: white; font-family: Courier, monospace;")
        self.pythonScript.setMaximumHeight(self.IMAGE_HEIGHT - 250)

        script_box = oasysgui.widgetBox(tab_scr,
                                        "",
                                        addSpace=False,
                                        orientation="vertical",
                                        height=self.IMAGE_HEIGHT - 10,
                                        width=self.IMAGE_WIDTH - 10)
        script_box.layout().addWidget(self.pythonScript)

        console_box = oasysgui.widgetBox(script_box,
                                         "",
                                         addSpace=True,
                                         orientation="vertical",
                                         height=150,
                                         width=self.IMAGE_WIDTH - 10)

        self.console = PythonConsole(self.__dict__, self)
        console_box.layout().addWidget(self.console)

        self.wofry_output = oasysgui.textArea()

        out_box = oasysgui.widgetBox(tab_out,
                                     "System Output",
                                     addSpace=True,
                                     orientation="horizontal",
                                     height=self.IMAGE_WIDTH - 45)
        out_box.layout().addWidget(self.wofry_output)

        #############################

        button_box = oasysgui.widgetBox(tab_scr,
                                        "",
                                        addSpace=True,
                                        orientation="horizontal")

        gui.button(button_box,
                   self,
                   "Run Script",
                   callback=self.execute_script,
                   height=40)
        # gui.button(button_box, self, "Save Script to File", callback=self.save_script, height=40)

        gui.rubber(self.controlArea)

        self.process_showers()
Exemple #24
0
    def __init__(self):
        super().__init__()

        self.in_data = None
        self.in_distance = None
        self.in_learner = None
        self.in_classifier = None
        self.in_object_1 = None
        self.in_object_2 = None
        self.in_object_3 = None
        self.in_object_4 = None
        self.in_object_5 = None
        self.in_object_6 = None
        self.in_object_7 = None
        self.in_object_8 = None
        self.in_object_9 = None
        self.in_object_10 = None

        # MODIFIED BY LUCA REBUFFI 14/10/2014
        #self.auto_execute = False

        for s in self.libraryListSource:
            s.flags = 0

        self._cachedDocuments = {}

        self.infoBox = gui.widgetBox(self.controlArea, 'Info')
        gui.label(
            self.infoBox, self,
            "<p>Execute python script.</p><p>Input variables:<ul><li> " + \
            "<li>".join([self.inputs[0].name, ".",".",".", self.inputs[-1].name]) + \
            "</ul></p><p>Output variables:<ul><li>" + \
            "<li>".join(t.name for t in self.outputs) + \
            "</ul></p>"
        )

        self.optionBox = oasysgui.widgetBox(self.controlArea, 'Options')

        gui.comboBox(self.optionBox,
                     self,
                     "font_size",
                     label="Font Size",
                     labelWidth=120,
                     items=self.fonts,
                     sendSelectedValue=False,
                     orientation="horizontal",
                     callback=self.changeFont)

        self.libraryList = itemmodels.PyListModel(
            [],
            self,
            flags=Qt.ItemIsSelectable | Qt.ItemIsEnabled | Qt.ItemIsEditable)

        self.libraryList.wrap(self.libraryListSource)

        self.controlBox = gui.widgetBox(self.controlArea, 'Library')
        self.controlBox.layout().setSpacing(1)

        self.libraryView = QListView(
            editTriggers=QListView.DoubleClicked | QListView.EditKeyPressed,
            sizePolicy=QSizePolicy(QSizePolicy.Ignored, QSizePolicy.Preferred))
        self.libraryView.setItemDelegate(ScriptItemDelegate(self))
        self.libraryView.setModel(self.libraryList)

        self.libraryView.selectionModel().selectionChanged.connect(
            self.onSelectedScriptChanged)
        self.controlBox.layout().addWidget(self.libraryView)

        w = itemmodels.ModelActionsWidget()

        self.addNewScriptAction = action = QAction("+", self)
        action.setToolTip("Add a new script to the library")
        action.triggered.connect(self.onAddScript)
        w.addAction(action)

        action = QAction(unicodedata.lookup("MINUS SIGN"), self)
        action.setToolTip("Remove script from library")
        action.triggered.connect(self.onRemoveScript)
        w.addAction(action)

        action = QAction("Update", self)
        action.setToolTip("Save changes in the editor to library")
        action.setShortcut(QKeySequence(QKeySequence.Save))
        action.triggered.connect(self.commitChangesToLibrary)
        w.addAction(action)

        action = QAction("More", self, toolTip="More actions")

        new_from_file = QAction("Import a script from a file", self)
        save_to_file = QAction("Save selected script to a file", self)
        save_to_file.setShortcut(QKeySequence(QKeySequence.SaveAs))

        new_from_file.triggered.connect(self.onAddScriptFromFile)
        save_to_file.triggered.connect(self.saveScript)

        menu = QMenu(w)
        menu.addAction(new_from_file)
        menu.addAction(save_to_file)
        action.setMenu(menu)
        button = w.addAction(action)
        button.setPopupMode(QToolButton.InstantPopup)

        w.layout().setSpacing(1)

        self.controlBox.layout().addWidget(w)

        self.runBox = gui.widgetBox(self.controlArea, 'Run')
        gui.button(self.runBox, self, "Execute", callback=self.execute)
        gui.checkBox(self.runBox,
                     self,
                     "auto_execute",
                     "Auto execute",
                     tooltip="Run the script automatically whenever " +
                     "the inputs to the widget change.")

        self.splitCanvas = QSplitter(Qt.Vertical, self.mainArea)
        self.mainArea.layout().addWidget(self.splitCanvas)

        self.defaultFont = defaultFont = \
            "Monaco" if sys.platform == "darwin" else "Courier"

        self.textBox = gui.widgetBox(self, 'Python script')
        self.splitCanvas.addWidget(self.textBox)
        self.text = PythonScriptEditor(self)
        self.textBox.layout().addWidget(self.text)

        self.textBox.setAlignment(Qt.AlignVCenter)
        self.text.setTabStopWidth(4)

        self.text.modificationChanged[bool].connect(self.onModificationChanged)

        self.saveAction = action = QAction("&Save", self.text)
        action.setToolTip("Save script to file")
        action.setShortcut(QKeySequence(QKeySequence.Save))
        action.setShortcutContext(Qt.WidgetWithChildrenShortcut)
        action.triggered.connect(self.saveScript)

        self.consoleBox = gui.widgetBox(self, 'Console')
        self.splitCanvas.addWidget(self.consoleBox)
        self.console = PythonConsole(self.__dict__, self)
        self.consoleBox.layout().addWidget(self.console)
        self.console.document().setDefaultFont(QFont(defaultFont))
        self.consoleBox.setAlignment(Qt.AlignBottom)
        self.console.setTabStopWidth(4)

        select_row(self.libraryView, self.currentScriptIndex)

        self.splitCanvas.setSizes([2, 1])
        if self.splitterState is not None:
            self.splitCanvas.restoreState(QByteArray(self.splitterState))

        self.splitCanvas.splitterMoved[int, int].connect(self.onSpliterMoved)
        self.controlArea.layout().addStretch(1)
        self.resize(800, 600)

        self.changeFont()
Exemple #25
0
    def __init__(self):
        super().__init__()

        left_box_1 = oasysgui.widgetBox(self.controlArea, "X0h Request Form", addSpace=True, orientation="vertical",
                                         width=400, height=630)

        left_box_2 = oasysgui.widgetBox(left_box_1, "X-rays", addSpace=True, orientation="horizontal", width=380, height=110)

        left_box_2_1 = oasysgui.widgetBox(left_box_2, "", addSpace=True, orientation="vertical", width=150, height=110)

        gui.radioButtons(left_box_2_1, self, "xway", ["Wavelength (Å)", "Energy (keV)", "Characteristic line"], callback=self.set_xway )

        self.box_wave = oasysgui.widgetBox(left_box_2, "", addSpace=True, orientation="vertical", width=190)
        gui.separator(self.box_wave, height=10)
        oasysgui.lineEdit(self.box_wave, self, "wave", label="", labelWidth=0, addSpace=False, valueType=float, orientation="horizontal")

        self.box_line = oasysgui.widgetBox(left_box_2, "", addSpace=True, orientation="horizontal", width=190, height=110)
        gui.separator(self.box_line, height=120)
        XRayServerGui.combobox_text(self.box_line, self, "line", label="", labelWidth=0,
                               items=self.get_lines(),
                               sendSelectedValue=True, orientation="horizontal", selectedValue=self.line)

        button = gui.button( self.box_line, self, "?", callback=self.help_lines)
        button.setFixedWidth(15)

        self.set_xway()

        left_box_3 = oasysgui.widgetBox(left_box_1, "Target", addSpace=True, orientation="horizontal", width=380, height=140)

        left_box_3_1 = oasysgui.widgetBox(left_box_3, "", addSpace=True, orientation="vertical", width=125, height=110)

        gui.radioButtons(left_box_3_1, self, "coway", ["Crystal", "Other Material", "Chemical Formula"], callback=self.set_coway )

        self.box_crystal = oasysgui.widgetBox(left_box_3, "", addSpace=True, orientation="horizontal", width=210)
        XRayServerGui.combobox_text(self.box_crystal, self, "code", label="", labelWidth=0,
                               items=self.get_crystals(),
                               sendSelectedValue=True, orientation="horizontal", selectedValue=self.code)


        button = gui.button( self.box_crystal, self, "?", callback=self.help_crystals)
        button.setFixedWidth(15)

        self.box_other = oasysgui.widgetBox(left_box_3, "", addSpace=True, orientation="horizontal", width=210)
        gui.separator(self.box_other, height=75)
        XRayServerGui.combobox_text(self.box_other, self, "amor", label="", labelWidth=0,
                               items=self.get_others(),
                               sendSelectedValue=True, orientation="horizontal", selectedValue=self.amor)

        button = gui.button( self.box_other, self, "?", callback=self.help_others)
        button.setFixedWidth(15)

        self.box_chemical = oasysgui.widgetBox(left_box_3, "", addSpace=True, orientation="vertical", width=210, height=140)
        gui.separator(self.box_chemical, height=50)

        oasysgui.lineEdit(self.box_chemical, self, "chem", label=" ", labelWidth=1, addSpace=False, valueType=str, orientation="horizontal", callback=self.set_rho)
        oasysgui.lineEdit(self.box_chemical, self, "rho", label=u"\u03C1" + " (g/cm3)", labelWidth=60, addSpace=False, valueType=float, orientation="horizontal")

        self.set_coway()

        left_box_4 = oasysgui.widgetBox(left_box_1, "Reflection", addSpace=True, orientation="horizontal", width=380, height=60)

        oasysgui.lineEdit(left_box_4, self, "i1", label="Miller indices", labelWidth=200, addSpace=False, valueType=int, orientation="horizontal")
        oasysgui.lineEdit(left_box_4, self, "i2", label=" ", labelWidth=1, addSpace=False, valueType=int, orientation="horizontal")
        oasysgui.lineEdit(left_box_4, self, "i3", label=" ", labelWidth=1, addSpace=False, valueType=int, orientation="horizontal")

        left_box_5 = oasysgui.widgetBox(left_box_1, "Database Options for dispersion corrections df1, df2", addSpace=True, orientation="vertical", width=380, height=185)

        gui.radioButtons(left_box_5, self, "df1df2", ["Auto (Henke at low energy, X0h at mid, Brennan-Cowan\nat high)",
                                                      "Use X0h data (5-25 keV or 0.5-2.5 A), recommended for\nBragg diffraction",
                                                      "Use Henke data (0.01-30 keV or 0.4-1200 A),\nrecommended for soft x-rays",
                                                      "Use Brennan-Cowan data (0.03-700 keV or 0.02-400 A)",
                                                      "Compare results for all of the above sources"])

        left_box_6 = oasysgui.widgetBox(left_box_1, "Output Options", addSpace=True, orientation="vertical", width=380, height=50)

        gui.checkBox(left_box_6, self, "detail", "Print atomic coordinates", labelWidth=250)

        button = gui.button(self.controlArea, self, "Get X0h!", callback=self.submit)
        button.setFixedHeight(30)

        gui.rubber(self.controlArea)

        self.tabs = []
        self.tabs_widget = oasysgui.tabWidget(self.mainArea)
        self.initializeTabs()

        self.x0h_output = QWebView(self.tabs[0])

        self.tabs[0].layout().addWidget(self.x0h_output)

        self.x0h_output.setFixedHeight(640)
        self.x0h_output.setFixedWidth(740)
Exemple #26
0
    def __init__(self):
        super().__init__()

        geom = QApplication.desktop().availableGeometry()
        self.setGeometry(
            QRect(round(geom.width() * 0.05), round(geom.height() * 0.05),
                  round(min(geom.width() * 0.98, self.MAX_WIDTH)),
                  round(min(geom.height() * 0.95, self.MAX_HEIGHT))))

        self.setMaximumHeight(self.geometry().height())
        self.setMaximumWidth(self.geometry().width())

        self.runaction = OWAction("Run Action", self)
        self.runaction.triggered.connect(self.run_action)
        self.addAction(self.runaction)

        # CONTROL AREA
        self.controlArea.setFixedWidth(self.CONTROL_AREA_WIDTH)

        general_options_box = oasysgui.widgetBox(self.controlArea,
                                                 "General Options",
                                                 addSpace=True,
                                                 orientation="vertical",
                                                 width=400)

        oasysgui.lineEdit(general_options_box,
                          self,
                          "field_1",
                          label="Field 1",
                          labelWidth=250,
                          addSpace=False,
                          valueType=float,
                          orientation="horizontal")

        oasysgui.lineEdit(general_options_box,
                          self,
                          "field_2",
                          label="Field 2",
                          labelWidth=250,
                          addSpace=False,
                          valueType=str,
                          orientation="horizontal")

        gui.comboBox(general_options_box,
                     self,
                     "field_3",
                     label="Field 3",
                     items=["Option 1", "Option 2", "Option 3", "Option 4"],
                     sendSelectedValue=False,
                     orientation="horizontal",
                     callback=self.set_field_3)

        gui.radioButtons(general_options_box,
                         self,
                         "field_4",
                         ["Option 1", "Option 2", "Option 3", "Option 4"],
                         callback=self.set_field_4)

        gui.checkBox(general_options_box, self, 'field_5', 'Field 5')

        file_box = oasysgui.widgetBox(general_options_box,
                                      "",
                                      addSpace=False,
                                      orientation="horizontal",
                                      height=25)

        self.le_file = oasysgui.lineEdit(file_box,
                                         self,
                                         "file",
                                         label="some file",
                                         addSpace=False,
                                         orientation="horizontal")

        gui.button(file_box, self, "...", callback=self.select_file)

        text_area_box = oasysgui.widgetBox(general_options_box,
                                           "",
                                           addSpace=False,
                                           orientation="vertical",
                                           width=390,
                                           height=330)

        self.text_area = oasysgui.textArea(height=320,
                                           width=380,
                                           readOnly=False)
        self.text_area.setText(self.notes)
        self.text_area.textChanged.connect(self.set_text_area)

        text_area_box.layout().addWidget(self.text_area)

        gui.separator(general_options_box)

        gui.button(general_options_box,
                   self,
                   "Run Action",
                   callback=self.run_action,
                   height=45)

        self.call_callbacks()

        # MAIN AREA
        self.main_tabs = oasysgui.tabWidget(self.mainArea)

        plot_tab = oasysgui.createTabPage(self.main_tabs, "Plots")
        out_tab = oasysgui.createTabPage(self.main_tabs, "Output")
Exemple #27
0
    def __init__(self):
        super().__init__()

        left_box_1 = oasysgui.widgetBox(self.controlArea, "TER_SL Request Form", addSpace=False, orientation="vertical",
                                         width=500, height=680)

        self.central_tabs = oasysgui.tabWidget(left_box_1)
        tab_template = oasysgui.createTabPage(self.central_tabs, "Template Options")
        tab_input = oasysgui.createTabPage(self.central_tabs, "Input Options")

        left_box_1_1 = oasysgui.widgetBox(tab_template, "", addSpace=False, orientation="vertical", width=480, height=670)

        gui.separator(left_box_1_1)

        ter_sl_box = oasysgui.widgetBox(left_box_1_1, "", addSpace=False, orientation="horizontal", width=470, height=220)

        gui.radioButtons(ter_sl_box, self, "ter_sl_form",
                         ["Specular reflection from perfect reflectors",
                          "Specular reflection from multilayers",
                          "Specular reflection from perfect reflectors + standing waves",
                          "Specular reflection from multilayers + standing waves"],
                         callback=self.set_TerSLForm)

        # -------------------------------------------------------------
        # -------------------------------------------------------------
        # -------------------------------------------------------------

        gui.separator(tab_input)

        left_box_2 = oasysgui.widgetBox(tab_input, "", addSpace=False, orientation="vertical", width=470)


        left_box_2_1 = oasysgui.widgetBox(left_box_2, "", addSpace=False, orientation="horizontal", width=470)

        gui.comboBox(left_box_2_1, self, "xway", label="X-rays specified by",
                     items=["Wavelength (Å)", "Energy (keV)", "Bragg angle (deg)", "X-ray line"],
                     callback=self.set_xway, sendSelectedValue=False, orientation="horizontal")

        self.box_wave = oasysgui.widgetBox(left_box_2_1, "", addSpace=False, orientation="horizontal", width=100)
        oasysgui.lineEdit(self.box_wave, self, "wave", label="", labelWidth=0, addSpace=False, valueType=float, orientation="horizontal")

        self.box_line = oasysgui.widgetBox(left_box_2_1, "", addSpace=False, orientation="horizontal", width=100)
        XRayServerGui.combobox_text(self.box_line, self, "line", label="", labelWidth=0,
                               items=self.get_lines(),
                               sendSelectedValue=True, orientation="horizontal", selectedValue=self.line)

        button = gui.button(self.box_line, self, "?", callback=self.help_lines)
        button.setFixedWidth(15)

        self.set_xway()

        gui.comboBox(left_box_2_1, self, "ipol", label="Polarization",
                     items=["Sigma", "Pi", "Mixed"], sendSelectedValue=False, orientation="horizontal")


        # -------------------------------------------------------------

        left_box_3 = oasysgui.widgetBox(tab_input, "", addSpace=True, orientation="vertical", width=470)

        gui.separator(left_box_3, height=4)

        left_box_3_top = oasysgui.widgetBox(left_box_3, "", addSpace=False, orientation="horizontal", width=470)
        gui.label(left_box_3_top, self, "Substrate:")

        left_box_3_content = oasysgui.widgetBox(left_box_3, "", addSpace=False, orientation="horizontal", width=470)

        left_box_3_left = oasysgui.widgetBox(left_box_3_content, "", addSpace=False, orientation="vertical", width=20)
        left_box_3_right = oasysgui.widgetBox(left_box_3_content, "", addSpace=False, orientation="vertical", width=445)

        gui.radioButtons(left_box_3_left, self, "subway", [" ", " ", " "], callback=self.set_subway)

        self.left_box_3_1 = oasysgui.widgetBox(left_box_3_right, "", addSpace=False, orientation="horizontal", width=445)
        XRayServerGui.combobox_text(self.left_box_3_1, self, "code", label="Crystal", labelWidth=45,
                               items=self.get_crystals(),
                               sendSelectedValue=True, orientation="horizontal", selectedValue=self.code)

        button = gui.button(self.left_box_3_1, self, "?", callback=self.help_crystals)
        button.setFixedWidth(15)

        gui.comboBox(self.left_box_3_1, self, "df1df2", label=" ", labelWidth=1,
                     items=["Auto DB for f\', f\'\'",
                            "X0h data (0.5-2.5 A)",
                            "Henke (0.4-1200 A)",
                            "Brennan (0.02-400 A)"],
                     sendSelectedValue=False, orientation="horizontal")

        self.left_box_3_2 = oasysgui.widgetBox(left_box_3_right, "", addSpace=False, orientation="horizontal", width=445)

        oasysgui.lineEdit(self.left_box_3_2, self, "chem", label="Chemical Formula", labelWidth=110, addSpace=False, valueType=str, orientation="horizontal", callback=self.set_rho)
        oasysgui.lineEdit(self.left_box_3_2, self, "rho", label=u"\u03C1" + " (g/cm3)", labelWidth=60, addSpace=False, valueType=float, orientation="horizontal")

        self.left_box_3_3 = oasysgui.widgetBox(left_box_3_right, "", addSpace=False, orientation="vertical", width=445)

        left_box_3_3_1 = oasysgui.widgetBox(self.left_box_3_3, "", addSpace=False, orientation="horizontal", width=445)

        oasysgui.lineEdit(left_box_3_3_1, self, "x0", label="Susceptibility x0        (", labelWidth=130, addSpace=False, valueType=float, orientation="horizontal")
        gui.label(left_box_3_3_1, self, " )  format: x0=(Re(x0), Im(x0))", labelWidth=230 )

        left_box_3_3_2 = oasysgui.widgetBox(self.left_box_3_3, "", addSpace=False, orientation="horizontal", width=445)

        oasysgui.lineEdit(left_box_3_3_2, self, "w0", label="x0 correction: w0", labelWidth=130, addSpace=False, valueType=float, orientation="horizontal")
        gui.label(left_box_3_3_2, self, "  this is used as: x0 = w0 * x0", labelWidth=230)

        left_box_3_3_3 = oasysgui.widgetBox(self.left_box_3_3, "", addSpace=False, orientation="horizontal", width=445)

        oasysgui.lineEdit(left_box_3_3_3, self, "sigma", label="Roughness: sigma [Å]", labelWidth=130, addSpace=False, valueType=float, orientation="horizontal")
        gui.label(left_box_3_3_3, self, "   OR   ")
        oasysgui.lineEdit(left_box_3_3_3, self, "tr", label="Transition layer tr [Å]", labelWidth=120, addSpace=False, valueType=float, orientation="horizontal")

        self.set_subway()

        # -------------------------------------------------------------

        left_box_4 = oasysgui.widgetBox(tab_input, "", addSpace=False, orientation="horizontal", width=470)

        left_box_4_1 = oasysgui.widgetBox(left_box_4, "", addSpace=False, orientation="vertical", width=470)

        gui.label(left_box_4_1, self, "Incidence angle limits:")

        left_box_4_1_1 = oasysgui.widgetBox(left_box_4_1, "", addSpace=False, orientation="horizontal", width=470)

        oasysgui.lineEdit(left_box_4_1_1, self, "scanmin", label="     From", labelWidth=70, addSpace=False, valueType=float, orientation="horizontal")
        oasysgui.lineEdit(left_box_4_1_1, self, "scanmax", label="To", labelWidth=15, addSpace=False, valueType=float, orientation="horizontal")

        gui.comboBox(left_box_4_1_1, self, "unis", label=" ", labelWidth=1,
                     items=["degr.",
                            "min.",
                            "mrad.",
                            "sec.",
                            "urad"],
                     sendSelectedValue=False, orientation="horizontal")

        oasysgui.lineEdit(left_box_4_1_1, self, "nscan", label="Points", labelWidth=40, addSpace=False, valueType=int, orientation="horizontal")

        # -------------------------------------------------------------
        # -------------------------------------------------------------

        self.standing_waves_box = oasysgui.widgetBox(tab_input, "", addSpace=False, orientation="vertical", width=470, height=140)
        self.standing_waves_box_hidden = oasysgui.widgetBox(tab_input, "", addSpace=False, orientation="horizontal", width=470, height=140)

        gui.separator(self.standing_waves_box, 10)

        standing_waves_box_1 = oasysgui.widgetBox(self.standing_waves_box, "", addSpace=False, orientation="horizontal", width=120)
        gui.checkBox(standing_waves_box_1, self, "swflag", "", callback=self.set_swflag)
        gui.label(standing_waves_box_1, self, "Standing waves:")

        self.standing_waves_box_2 = oasysgui.widgetBox(self.standing_waves_box, "", addSpace=False, orientation="vertical", width=470)

        standing_waves_box_2_1 = oasysgui.widgetBox(self.standing_waves_box_2, "", addSpace=False, orientation="horizontal", width=270)
        oasysgui.lineEdit(standing_waves_box_2_1, self, "swref", label="Reference interface", labelWidth=130, addSpace=False, valueType=int, orientation="horizontal")
        gui.label(standing_waves_box_2_1, self, " (0=surface)")

        standing_waves_box_2_2 = oasysgui.widgetBox(self.standing_waves_box_2, "", addSpace=False, orientation="horizontal", width=270)
        oasysgui.lineEdit(standing_waves_box_2_2, self, "swmin", label="Start offset", labelWidth=130, addSpace=False, valueType=float, orientation="horizontal")
        gui.label(standing_waves_box_2_2, self, " [Å]", labelWidth=70)

        standing_waves_box_2_3 = oasysgui.widgetBox(self.standing_waves_box_2, "", addSpace=False, orientation="horizontal", width=270)
        oasysgui.lineEdit(standing_waves_box_2_3, self, "swmax", label="End offset", labelWidth=130, addSpace=False, valueType=float, orientation="horizontal")
        gui.label(standing_waves_box_2_3, self, " [Å]", labelWidth=70)

        standing_waves_box_2_4 = oasysgui.widgetBox(self.standing_waves_box_2, "", addSpace=False, orientation="horizontal", width=270)
        oasysgui.lineEdit(standing_waves_box_2_4, self, "swpts", label="Number of offsets", labelWidth=130, addSpace=False, valueType=float, orientation="horizontal")
        gui.label(standing_waves_box_2_4, self, " (max = 401)")

        self.set_swflag()

        gui.separator(tab_input)

        # -------------------------------------------------------------

        box_top = oasysgui.widgetBox(tab_input, "", addSpace=False, orientation="vertical", width=470)

        box_top_0 = oasysgui.widgetBox(box_top, "", addSpace=False, orientation="horizontal", width=250)

        gui.label(box_top_0, self, "Top layer profile (optional):")

        button = gui.button(box_top_0, self, "? (sintax)", callback=self.help_profile)
        button.setFixedWidth(90)

        box_top_1 = oasysgui.widgetBox(box_top, "", addSpace=False, orientation="horizontal", width=470)

        self.profile_area = QtWidgets.QTextEdit()
        self.profile_area.setStyleSheet("background-color: white;")
        self.profile_area.setMaximumHeight(240)
        self.profile_area.setMaximumWidth(335)
        self.profile_area.setLineWrapMode(QtWidgets.QTextEdit.NoWrap)

        box_top_1.layout().addWidget(self.profile_area)
        
        gui.separator(box_top_1)

        box_top_labels = oasysgui.widgetBox(box_top_1, "", addSpace=False, orientation="vertical", width=130)

        gui.label(box_top_labels, self, "Available Codes:")

        crystals_area = QtWidgets.QTextEdit()
        crystals_area.setStyleSheet("background-color: white;")
        crystals_area.setMaximumHeight(295)
        crystals_area.setMaximumWidth(130)
        crystals_area.setText("\n".join(ListUtility.get_list("crystals")))
        crystals_area.setReadOnly(True)

        box_top_labels.layout().addWidget(crystals_area)

        gui.separator(box_top)

        # -----------------------------------------------------------


        button = gui.button(tab_input, self, "Submit Query!", callback=self.submit)
        button.setFixedHeight(30)

        gui.rubber(self.controlArea)

        self.tabs = []
        self.tabs_widget = oasysgui.tabWidget(self.mainArea)
        self.initializeTabs()

        self.set_TerSLForm(change_values=False, switch_page=False)

        self.profile_area.textChanged.connect(self.set_profile)
        def add_parameter_box(container_box, variable, label):
            box = oasysgui.widgetBox(container_box,
                                     "",
                                     addSpace=False,
                                     orientation="horizontal")
            oasysgui.lineEdit(box,
                              self,
                              variable,
                              label,
                              labelWidth=50,
                              valueType=float,
                              orientation="horizontal")
            gui.label(box, self, " ", labelWidth=58)

            box = oasysgui.widgetBox(container_box,
                                     "",
                                     addSpace=False,
                                     orientation="horizontal")

            setattr(
                self, "le_" + variable + "_min",
                oasysgui.lineEdit(box,
                                  self,
                                  variable + "_min",
                                  "Min",
                                  labelWidth=50,
                                  valueType=float,
                                  orientation="horizontal"))
            setattr(
                self, "le_" + variable + "_max",
                oasysgui.lineEdit(box,
                                  self,
                                  variable + "_max",
                                  "Max",
                                  labelWidth=35,
                                  valueType=float,
                                  orientation="horizontal"))

            gui.checkBox(box,
                         self,
                         variable + "_fixed",
                         "Fixed",
                         callback=getattr(self, "set_" + variable))

            box = oasysgui.widgetBox(container_box,
                                     "",
                                     addSpace=False,
                                     orientation="horizontal")

            le = oasysgui.lineEdit(box,
                                   self,
                                   variable + "_out",
                                   "Fitted",
                                   labelWidth=50,
                                   valueType=float,
                                   orientation="horizontal")
            le.setEnabled(False)
            le.setStyleSheet(
                "color: blue; background-color: rgb(254, 244, 205); font:bold")

            def set_variable_fit():
                setattr(self, variable, getattr(self, variable + "_out"))

            gui.button(box,
                       self,
                       "<- Use",
                       width=58,
                       callback=set_variable_fit)

            getattr(self, "set_" + variable)()
Exemple #29
0
    def __init__(self):
        super().__init__()

        left_box_1 = oasysgui.widgetBox(self.controlArea, "GID_SL Request Form", addSpace=False, orientation="vertical",
                                         width=500, height=680)

        self.central_tabs = oasysgui.tabWidget(left_box_1)
        tab_template = oasysgui.createTabPage(self.central_tabs, "Template Options")
        tab_input = oasysgui.createTabPage(self.central_tabs, "Input Options")

        left_box_1_1 = oasysgui.widgetBox(tab_template, "", addSpace=False, orientation="vertical", width=480, height=670)

        gui.separator(left_box_1_1)

        gui.comboBox(left_box_1_1, self, "template_type", label="Template Type", labelWidth=100,
                     items=["Simplified (coplanar geometries only)", "Full"],
                     callback=self.set_TemplateType, sendSelectedValue=False, orientation="horizontal")

        self.simplified_box = oasysgui.widgetBox(left_box_1_1, "", addSpace=False, orientation="horizontal", width=470, height=220)

        gui.radioButtons(self.simplified_box, self, "simplified_form",
                         ["Symmetric Bragg diffraction from perfect crystals",
                          "Symmetric Bragg diffraction from multilayers and superlattices",
                          "Symmetric Bragg diffraction at Bragg angle of 90 degrees (\"back diffraction\")",
                          "Energy scanning of symmetric Bragg diffraction peaks"],
                         callback=self.set_SimplifiedForm)

        self.full_box = oasysgui.widgetBox(left_box_1_1, "", addSpace=False, orientation="horizontal", width=470, height=220)

        gui.radioButtons(self.full_box, self, "full_form",
                         ["Symmetric Bragg diffraction from perfect crystals",
                          "Symmetric Bragg diffraction from multilayers and superlattices",
                          "Coplanar extremely asymmetric diffraction of synchrotron radiation",
                          "Grazing incidence (\"surface\") diffraction from perfect crystals",
                          "Grazing incidence (\"surface\") diffraction from multilayers in the scheme\nwith position sensitive detector (PSD)",
                          "Non-coplanar Bragg-Laue diffraction from crystals with a few degrees\nsurface miscut"],
                         callback=self.set_FullForm)

        # -------------------------------------------------------------
        # -------------------------------------------------------------
        # -------------------------------------------------------------

        gui.separator(tab_input)

        left_box_2 = oasysgui.widgetBox(tab_input, "", addSpace=False, orientation="vertical", width=470)

        left_box_2_1 = oasysgui.widgetBox(left_box_2, "", addSpace=False, orientation="horizontal", width=470)

        gui.comboBox(left_box_2_1, self, "xway", label="X-rays specified by",
                     items=["Wavelength (Å)", "Energy (keV)", "Bragg angle (deg)", "X-ray line"],
                     callback=self.set_xway, sendSelectedValue=False, orientation="horizontal")

        self.box_wave = oasysgui.widgetBox(left_box_2_1, "", addSpace=False, orientation="horizontal", width=100)
        gui.lineEdit(self.box_wave, self, "wave", label="", labelWidth=0, addSpace=False, valueType=float, orientation="horizontal")

        self.box_line = oasysgui.widgetBox(left_box_2_1, "", addSpace=False, orientation="horizontal", width=100)
        XRayServerGui.combobox_text(self.box_line, self, "line", label="", labelWidth=0,
                               items=self.get_lines(),
                               sendSelectedValue=True, orientation="horizontal", selectedValue=self.line)

        button = gui.button(self.box_line, self, "?", callback=self.help_lines)
        button.setFixedWidth(15)

        self.set_xway()

        gui.comboBox(left_box_2_1, self, "ipol", label="Polarization",
                     items=["Sigma", "Pi", "Mixed"], sendSelectedValue=False, orientation="horizontal")


        # -------------------------------------------------------------

        left_box_3 = oasysgui.widgetBox(tab_input, "", addSpace=False, orientation="vertical", width=470)

        left_box_3_1 = oasysgui.widgetBox(left_box_3, "", addSpace=False, orientation="horizontal", width=470)
        XRayServerGui.combobox_text(left_box_3_1, self, "code", label="Crystal", labelWidth=40,
                               items=self.get_crystals(),
                               sendSelectedValue=True, orientation="horizontal", selectedValue=self.code)

        button = gui.button(left_box_3_1, self, "?", callback=self.help_crystals)
        button.setFixedWidth(15)

        gui.comboBox(left_box_3_1, self, "df1df2", label=" ", labelWidth=20,
                     items=["Auto DB for f\', f\'\'",
                            "X0h data (0.5-2.5 A)",
                            "Henke (0.4-1200 A)",
                            "Brennan (0.02-400 A)"],
                     sendSelectedValue=False, orientation="horizontal")

        left_box_3_2 = oasysgui.widgetBox(left_box_3, "", addSpace=False, orientation="horizontal", width=470)

        gui.lineEdit(left_box_3_2, self, "sigma", label="Sigma", labelWidth=80, addSpace=False, valueType=float, orientation="horizontal")
        gui.lineEdit(left_box_3_2, self, "w0", label="A      W0", labelWidth=50, addSpace=False, valueType=float, orientation="horizontal")
        gui.lineEdit(left_box_3_2, self, "wh", label="        Wh", labelWidth=50, addSpace=False, valueType=float, orientation="horizontal")

        # -------------------------------------------------------------

        left_box_4 = oasysgui.widgetBox(tab_input, "", addSpace=False, orientation="horizontal", width=470)

        left_box_4_1 = oasysgui.widgetBox(left_box_4, "", addSpace=False, orientation="horizontal", width=240)

        gui.lineEdit(left_box_4_1, self, "i1", label="Bragg Reflection", labelWidth=97, addSpace=False, valueType=int, orientation="horizontal")
        gui.lineEdit(left_box_4_1, self, "i2", label=" ", labelWidth=1, addSpace=False, valueType=int, orientation="horizontal")
        gui.lineEdit(left_box_4_1, self, "i3", label=" ", labelWidth=1, addSpace=False, valueType=int, orientation="horizontal")

        left_box_4_2 = oasysgui.widgetBox(left_box_4, "", addSpace=False, orientation="horizontal", width=228)

        gui.lineEdit(left_box_4_2, self, "daa", label="  Substrate da/a", labelWidth=135, addSpace=False, valueType=float, orientation="horizontal")

        # -------------------------------------------------------------
        # -------------------------------------------------------------

        self.simplified_input_box = oasysgui.widgetBox(tab_input, "", addSpace=False, orientation="vertical", width=470, height=290)

        gui.comboBox(self.simplified_input_box, self, "igie", label="Geometry specified by",
                     items=["angle of Bragg planes to surface ('+' for g0>gh)",
                            "incidence angle of K0",
                            "exit angle of Kh",
                            "asymmetry factor beta=g0/gh"],
                     callback=self.set_igie_s, sendSelectedValue=False, orientation="horizontal")

        simplified_input_box_1 = oasysgui.widgetBox(self.simplified_input_box, "", addSpace=False, orientation="horizontal", width=470)

        gui.lineEdit(simplified_input_box_1, self, "fcentre", label="Value", labelWidth=280, addSpace=False, valueType=float, orientation="horizontal")

        self.unic_combo_s = gui.comboBox(simplified_input_box_1, self, "unic", label=" ", labelWidth=1,
                                       items=[" ",
                                              "degr.",
                                              "min.",
                                              "mrad.",
                                              "sec.",
                                              "urad"],
                                       sendSelectedValue=False, orientation="horizontal")

        self.set_igie_s()

        simplified_input_box_2 = oasysgui.widgetBox(self.simplified_input_box, "", addSpace=False, orientation="horizontal", width=470)

        gui.lineEdit(simplified_input_box_2, self, "scanmin", label="Scan: From", labelWidth=70, addSpace=False, valueType=float, orientation="horizontal")
        gui.lineEdit(simplified_input_box_2, self, "scanmax", label="To", labelWidth=15, addSpace=False, valueType=float, orientation="horizontal")

        self.simplified_input_box_scan_1_1 = oasysgui.widgetBox(simplified_input_box_2, "", addSpace=False, orientation="horizontal")

        gui.comboBox(self.simplified_input_box_scan_1_1, self, "unis", label=" ", labelWidth=1,
                     items=["degr.",
                            "min.",
                            "mrad.",
                            "sec.",
                            "urad"],
                     sendSelectedValue=False, orientation="horizontal")

        gui.lineEdit(self.simplified_input_box_scan_1_1, self, "nscan", label="Points", labelWidth=40, addSpace=False, valueType=int, orientation="horizontal")

        self.simplified_input_box_scan_1_2 = oasysgui.widgetBox(self.simplified_input_box, "", addSpace=False, orientation="horizontal", width=470)

        gui.checkBox(self.simplified_input_box_scan_1_2, self, "invert", "Invert axis", labelWidth=190)
        gui.comboBox(self.simplified_input_box_scan_1_2, self, "column", label="Plot argument", labelWidth=100,
                                       items=["scan angle",
                                              "incidence angle",
                                              "exit angle"],
                                       sendSelectedValue=False, orientation="horizontal")

        self.simplified_input_box_scan_2_1 = oasysgui.widgetBox(simplified_input_box_2, "", addSpace=False, orientation="horizontal")

        self.unis_combo_s = gui.comboBox(self.simplified_input_box_scan_2_1, self, "unis", label=" ", labelWidth=1,
                                         items=["degr.",
                                                "min.",
                                                "mrad.",
                                                "sec.",
                                                "urad",
                                                "eV"],
                                         sendSelectedValue=False, orientation="horizontal")

        gui.lineEdit(self.simplified_input_box_scan_2_1, self, "nscan", label="Points", labelWidth=40, addSpace=False, valueType=int, orientation="horizontal")

        self.simplified_input_box_scan_2_2 = oasysgui.widgetBox(self.simplified_input_box, "", addSpace=False, orientation="horizontal")

        gui.comboBox(self.simplified_input_box_scan_2_2, self, "axis", label="Scan Type", labelWidth=290,
                     items=["[k0 x h]",
                            "Energy (eV)",
                            "Energy (eV), no X0h recalc"],
                     sendSelectedValue=False, orientation="horizontal", callback=self.set_scan_type_s)

        self.set_scan_type_s()

        # -------------------------------------------------------------
        # -------------------------------------------------------------

        self.full_input_box = oasysgui.widgetBox(tab_input, "", addSpace=True, orientation="vertical", width=470, height=290)

        gui.comboBox(self.full_input_box, self, "igie", label="Geom. by", labelWidth=60,
                     items=["[1]. Surface orientation & incidence angle of K0",
                            "[2]. Surface orientation & exit angle of Kh",
                            "[3]. Surface orientation & condition of coplanar grazing incidence",
                            "[4]. Surface orientation & condition of coplanar grazing exit",
                            "[5]. Surface orientation & condition of symmetric Bragg case",
                            "[6]. Condition of coplanar reflection & angle of Bragg planes to surface",
                            "[7]. Condition of coplanar reflection & incidence angle of K0",
                            "[8]. Condition of coplanar reflection & exit angle of Kh",
                            "[9]. Condition of coplanar reflection & asymmetry factor beta=g0/gh"],
                     callback=self.set_igie_f, sendSelectedValue=False, orientation="horizontal")

        gui.label(self.full_input_box, self, "-- Geom. parameter ([1,7]=incidence angle, [2,8]=exit angle, [6]=Bragg planes")

        full_input_box_1 = oasysgui.widgetBox(self.full_input_box, "", addSpace=False, orientation="vertical", width=470)

        full_input_box_1_1 = oasysgui.widgetBox(full_input_box_1, "", addSpace=False, orientation="horizontal", width=470)

        self.le_fcentre = gui.lineEdit(full_input_box_1_1, self, "fcentre", label="                                   angle, [9]=g0/gh)",
                                       labelWidth=250, addSpace=False, valueType=float, orientation="horizontal")

        self.unic_combo_f = gui.comboBox(full_input_box_1_1, self, "unic", label=" ", labelWidth=1,
                                         items=[" ",
                                              "degr.",
                                              "min.",
                                              "mrad.",
                                              "sec.",
                                              "urad"],
                                         sendSelectedValue=False, orientation="horizontal")

        self.set_igie_f()

        full_input_box_1_2 = oasysgui.widgetBox(full_input_box_1, "", addSpace=False, orientation="horizontal", width=270)

        gui.lineEdit(full_input_box_1_2, self, "n1", label="-- Surface plane ([1-5])", labelWidth=135, addSpace=False, valueType=int, orientation="horizontal")
        gui.lineEdit(full_input_box_1_2, self, "n2", label=" ", labelWidth=1, addSpace=False, valueType=int, orientation="horizontal")
        gui.lineEdit(full_input_box_1_2, self, "n3", label=" ", labelWidth=1, addSpace=False, valueType=int, orientation="horizontal")

        full_input_box_2 = oasysgui.widgetBox(self.full_input_box, "", addSpace=False, orientation="horizontal", width=470)

        full_input_box_2_1 = oasysgui.widgetBox(full_input_box_2, "", addSpace=False, orientation="horizontal", width=270)

        gui.lineEdit(full_input_box_2_1, self, "m1", label="Miscut direction", labelWidth=135, addSpace=False, valueType=int, orientation="horizontal")
        gui.lineEdit(full_input_box_2_1, self, "m2", label=" ", labelWidth=1, addSpace=False, valueType=int, orientation="horizontal")
        gui.lineEdit(full_input_box_2_1, self, "m3", label=" ", labelWidth=1, addSpace=False, valueType=int, orientation="horizontal")

        full_input_box_2_2 = oasysgui.widgetBox(full_input_box_2, "", addSpace=False, orientation="horizontal")

        gui.lineEdit(full_input_box_2_2, self, "miscut", label="Miscut angle", addSpace=False, valueType=float, orientation="horizontal")

        gui.comboBox(full_input_box_2_2, self, "unim", label=" ", labelWidth=1,
                                         items=["degr.",
                                              "min.",
                                              "mrad.",
                                              "sec.",
                                              "urad"],
                                         sendSelectedValue=False, orientation="horizontal")

        full_input_box_3 = oasysgui.widgetBox(self.full_input_box, "", addSpace=False, orientation="vertical", width=470)

        full_input_box_3_1 = oasysgui.widgetBox(full_input_box_3, "", addSpace=False, orientation="horizontal", width=470)

        gui.comboBox(full_input_box_3_1, self, "axis", label="Scan Type", labelWidth=190,
                     items=["Surface normal (N_surface)",
                            "[k0 x N_surface]",
                            "Reciprocal latt.vector (h)",
                            "[k0 x h]",
                            "Other axis",
                            "Takeoff spectrum (PSD)"],
                     sendSelectedValue=False, orientation="horizontal", callback=self.set_scan_type_f)

        gui.checkBox(full_input_box_3_1, self, "invert", "Invert axis", labelWidth=90)

        full_input_box_3_2 = oasysgui.widgetBox(full_input_box_3, "", addSpace=False, orientation="horizontal", width=470)

        self.le_a1 = gui.lineEdit(full_input_box_3_2, self, "a1", label="Indices, if other scan axis", labelWidth=290, addSpace=False, valueType=int, orientation="horizontal")
        self.le_a2 = gui.lineEdit(full_input_box_3_2, self, "a2", label=" ", labelWidth=1, addSpace=False, valueType=int, orientation="horizontal")
        self.le_a3 = gui.lineEdit(full_input_box_3_2, self, "a3", label=" ", labelWidth=1, addSpace=False, valueType=int, orientation="horizontal")

        self.set_scan_type_f()

        full_input_box_5 = oasysgui.widgetBox(self.full_input_box, "", addSpace=False, orientation="vertical", width=470)

        full_input_box_5_1 = oasysgui.widgetBox(full_input_box_5, "", addSpace=False, orientation="horizontal", width=470)

        gui.lineEdit(full_input_box_5_1, self, "scanmin", label="Scan: From", labelWidth=70, addSpace=False, valueType=float, orientation="horizontal")
        gui.lineEdit(full_input_box_5_1, self, "scanmax", label="To", labelWidth=15, addSpace=False, valueType=float, orientation="horizontal")

        gui.comboBox(full_input_box_5_1, self, "unis", label=" ", labelWidth=1,
                     items=["degr.",
                            "min.",
                            "mrad.",
                            "sec.",
                            "urad"],
                     sendSelectedValue=False, orientation="horizontal")

        gui.lineEdit(full_input_box_5_1, self, "nscan", label="Points", labelWidth=40, addSpace=False, valueType=int, orientation="horizontal")

        full_input_box_5_2 = oasysgui.widgetBox(full_input_box_5, "", addSpace=False, orientation="horizontal", width=470)

        gui.comboBox(full_input_box_5_2, self, "column", label="Plot argument", labelWidth=290,
                                       items=["scan angle",
                                              "incidence angle",
                                              "exit angle"],
                                       sendSelectedValue=False, orientation="horizontal")

        # -------------------------------------------------------------

        box_alpha = oasysgui.widgetBox(tab_input, "", addSpace=False, orientation="horizontal", width=280)

        self.le_alphamax = gui.lineEdit(box_alpha, self, "alphamax", label="Approximations: alpha_max", labelWidth=170, addSpace=False, valueType=float, orientation="horizontal")
        gui.label(box_alpha, self, "*|xh|")

        gui.separator(tab_input)

        # -------------------------------------------------------------

        box_top = oasysgui.widgetBox(tab_input, "", addSpace=False, orientation="vertical", width=470)

        box_top_0 = oasysgui.widgetBox(box_top, "", addSpace=False, orientation="horizontal", width=470)

        box_top_0_1 = oasysgui.widgetBox(box_top_0, "", addSpace=False, orientation="vertical", width=100)

        gui.label(box_top_0_1, self, "Top layer profile\n(optional):")

        button = gui.button(box_top_0_1, self, "? (sintax)", callback=self.help_profile)
        button.setFixedWidth(90)

        box_top_0_2 = oasysgui.widgetBox(box_top_0, "", addSpace=False, orientation="horizontal", width=360)

        self.profile_area = QtWidgets.QTextEdit()
        self.profile_area.setMaximumHeight(110)
        self.profile_area.setMaximumWidth(360)
        box_top_0_2.layout().addWidget(self.profile_area)


        box_top_labels = oasysgui.widgetBox(box_top, "", addSpace=False, orientation="horizontal", width=470)

        box_top_labels_1 = oasysgui.widgetBox(box_top_labels, "", addSpace=False, orientation="horizontal", width=100)

        gui.label(box_top_labels_1, self, "Available Codes:")

        box_top_labels_2 = oasysgui.widgetBox(box_top_labels, "", addSpace=False, orientation="horizontal", width=360)

        gui.label(box_top_labels_2, self, "Crystals")
        gui.label(box_top_labels_2, self, "Non-Crystals")
        gui.label(box_top_labels_2, self, "Elements")

        box_top_1 = oasysgui.widgetBox(box_top, "", addSpace=False, orientation="horizontal", width=470)

        oasysgui.widgetBox(box_top_1, "", addSpace=False, orientation="horizontal", width=100)
        box_top_1_2 = oasysgui.widgetBox(box_top_1, "", addSpace=False, orientation="horizontal", width=360)

        crystals_area = QtWidgets.QTextEdit()
        crystals_area.setMaximumHeight(100)
        crystals_area.setMaximumWidth(120)
        crystals_area.setText("\n".join(ListUtility.get_list("crystals")))
        crystals_area.setReadOnly(True)

        non_crystals_area = QtWidgets.QTextEdit()
        non_crystals_area.setMaximumHeight(100)
        non_crystals_area.setMaximumWidth(120)
        non_crystals_area.setText("\n".join(ListUtility.get_list("amorphous")))
        non_crystals_area.setReadOnly(True)

        elements_area = QtWidgets.QTextEdit()
        elements_area.setMaximumHeight(100)
        elements_area.setMaximumWidth(120)
        elements_area.setText("\n".join(ListUtility.get_list("atoms")))
        elements_area.setReadOnly(True)

        box_top_1_2.layout().addWidget(crystals_area)
        box_top_1_2.layout().addWidget(non_crystals_area)
        box_top_1_2.layout().addWidget(elements_area)

        # -----------------------------------------------------------


        button = gui.button(tab_input, self, "Submit Query!", callback=self.submit)
        button.setFixedHeight(30)

        gui.rubber(self.controlArea)

        self.tabs = []
        self.tabs_widget = oasysgui.tabWidget(self.mainArea)
        self.initializeTabs()

        self.set_TemplateType(change_values=False)

        self.profile_area.textChanged.connect(self.set_profile)
        self.le_alphamax.focusOutEvent = self.alphamax_focusOutEvent
        self.alphamax_focusOutEvent(None)

        gui.rubber(self.mainArea)
Exemple #30
0
    def create_box_in_widget(cls,
                             widget,
                             parent_box,
                             var,
                             label=None,
                             disable_function=False,
                             add_callback=False,
                             label_width=40,
                             min_value=None,
                             min_accepted=True,
                             max_value=None,
                             max_accepted=True,
                             trim=50):
        box = gui.widgetBox(parent_box,
                            "",
                            orientation="horizontal",
                            width=widget.CONTROL_AREA_WIDTH - trim,
                            height=25)

        box_value_width = 100 - (label_width - 40)

        box_label = gui.widgetBox(box,
                                  "",
                                  orientation="horizontal",
                                  width=label_width,
                                  height=25)
        box_value = gui.widgetBox(box,
                                  "",
                                  orientation="horizontal",
                                  width=box_value_width,
                                  height=25)
        box_fixed = gui.widgetBox(box, "", orientation="horizontal", height=25)
        box_min_max = gui.widgetBox(box,
                                    "",
                                    orientation="horizontal",
                                    height=30)
        box_function = gui.widgetBox(box,
                                     "",
                                     orientation="horizontal",
                                     height=25)
        box_function_value = gui.widgetBox(box,
                                           "",
                                           orientation="horizontal",
                                           height=25)

        gui.widgetLabel(box_label, var if label is None else label)
        if add_callback:
            le_var = gui.lineEdit(box_value,
                                  widget,
                                  var,
                                  " ",
                                  labelWidth=0,
                                  valueType=float,
                                  validator=QDoubleValidator(),
                                  callback=getattr(widget, "callback_" + var))
        else:
            le_var = gui.lineEdit(box_value,
                                  widget,
                                  var,
                                  " ",
                                  labelWidth=0,
                                  valueType=float,
                                  validator=QDoubleValidator())

        def set_flags():
            fixed = getattr(widget, var + "_fixed") == 1
            function = getattr(widget, var + "_function") == 1
            if disable_function:
                function = False
                setattr(widget, var + "_function", 0)

            if function:
                setattr(widget, var + "_fixed", 0)

                box_min_max.setVisible(False)
                box_fixed.setVisible(False)
                le_var.setVisible(False)
                box_value.setFixedWidth(5)
                box_function.setVisible(True)
                box_function_value.setVisible(True)
            elif fixed:
                setattr(widget, var + "_function", 0)

                box_min_max.setVisible(False)
                box_fixed.setVisible(True)
                le_var.setVisible(True)
                box_value.setFixedWidth(box_value_width)
                box_function.setVisible(False)
                box_function_value.setVisible(False)
            else:
                setattr(widget, var + "_fixed", 0)
                setattr(widget, var + "_function", 0)

                box_min_max.setVisible(True)
                box_fixed.setVisible(True)
                le_var.setVisible(True)
                box_value.setFixedWidth(box_value_width)
                box_function.setVisible(True)
                box_function_value.setVisible(False)

            if add_callback: getattr(widget, "callback_" + var)()

        widget.parameter_functions[var] = set_flags

        orangegui.checkBox(box_fixed,
                           widget,
                           var + "_fixed",
                           "fix",
                           callback=set_flags)

        def set_min():
            setattr(widget, var + "_has_min", 1)
            if add_callback: getattr(widget, "callback_" + var)()

        def set_max():
            setattr(widget, var + "_has_max", 1)
            if add_callback: getattr(widget, "callback_" + var)()

        min_validator = QMinValueValidator(
            min_value, max_value, min_accepted) if not min_value is None else (
                QDoubleValidator() if max_value is None else
                QMaxValueValidator(max_value, min_value, True))
        max_validator = QMaxValueValidator(
            max_value, min_value, max_accepted) if not max_value is None else (
                QDoubleValidator() if min_value is None else
                QMinValueValidator(min_value, max_value, True))

        if add_callback:
            cb_min = orangegui.checkBox(box_min_max,
                                        widget,
                                        var + "_has_min",
                                        "min",
                                        callback=getattr(
                                            widget, "callback_" + var))
            gui.lineEdit(box_min_max,
                         widget,
                         var + "_min",
                         " ",
                         labelWidth=0,
                         valueType=float,
                         validator=min_validator,
                         callback=set_min)
            cb_max = orangegui.checkBox(box_min_max,
                                        widget,
                                        var + "_has_max",
                                        "max",
                                        callback=getattr(
                                            widget, "callback_" + var))
            gui.lineEdit(box_min_max,
                         widget,
                         var + "_max",
                         " ",
                         labelWidth=0,
                         valueType=float,
                         validator=max_validator,
                         callback=set_max)

            cb = orangegui.checkBox(box_function,
                                    widget,
                                    var + "_function",
                                    "f(x)",
                                    callback=set_flags)
            cb.setEnabled(not disable_function)

            gui.lineEdit(box_function_value,
                         widget,
                         var + "_function_value",
                         "expression",
                         valueType=str,
                         callback=getattr(widget, "callback_" + var))
        else:
            cb_min = orangegui.checkBox(box_min_max, widget, var + "_has_min",
                                        "min")
            gui.lineEdit(box_min_max,
                         widget,
                         var + "_min",
                         " ",
                         labelWidth=0,
                         valueType=float,
                         validator=min_validator,
                         callback=set_min)
            cb_max = orangegui.checkBox(box_min_max, widget, var + "_has_max",
                                        "max")
            gui.lineEdit(box_min_max,
                         widget,
                         var + "_max",
                         " ",
                         labelWidth=0,
                         valueType=float,
                         validator=max_validator,
                         callback=set_max)

            cb = orangegui.checkBox(box_function,
                                    widget,
                                    var + "_function",
                                    "f(x)",
                                    callback=set_flags)
            cb.setEnabled(not disable_function)

            gui.lineEdit(box_function_value,
                         widget,
                         var + "_function_value",
                         "expression",
                         valueType=str)

        if not min_value is None:
            setattr(widget, var + "_has_min", 1)
            setattr(widget, var + "_min", min_value)
            cb_min.setEnabled(False)

        if not max_value is None:
            setattr(widget, var + "_has_max", 1)
            setattr(widget, var + "_max", max_value)
            cb_max.setEnabled(False)

        set_flags()
Exemple #31
0
    def __init__(self,
                 widget=None,
                 parent=None,
                 index=0,
                 filename="<input file>",
                 twotheta_min=0.0,
                 twotheta_has_min=0,
                 twotheta_max=0.0,
                 twotheta_has_max=0,
                 diffraction_pattern_name=""):
        super(DiffractionPatternBox, self).__init__()

        self.setLayout(QVBoxLayout())
        self.layout().setAlignment(Qt.AlignTop)
        self.setFixedWidth(widget.CONTROL_AREA_WIDTH - 35)
        self.setFixedHeight(500)

        self.widget = widget
        self.index = index

        self.filename = filename
        self.twotheta_min = twotheta_min
        self.twotheta_has_min = twotheta_has_min
        self.twotheta_max = twotheta_max
        self.twotheta_has_max = twotheta_has_max
        self.diffraction_pattern_name = diffraction_pattern_name

        self.CONTROL_AREA_WIDTH = widget.CONTROL_AREA_WIDTH - 45

        parent.layout().addWidget(self)
        container = self

        gui.lineEdit(container,
                     self,
                     "diffraction_pattern_name",
                     "Sample Name\n(will appear in tabs and plots)",
                     labelWidth=180,
                     valueType=str,
                     callback=widget.dump_diffraction_pattern_name)

        file_box = gui.widgetBox(container,
                                 "",
                                 orientation="horizontal",
                                 width=self.CONTROL_AREA_WIDTH)

        self.le_filename = gui.lineEdit(file_box,
                                        self,
                                        value="filename",
                                        valueType=str,
                                        label="File",
                                        labelWidth=50,
                                        callback=widget.dump_filename,
                                        orientation="horizontal")

        orangegui.button(file_box, self, "...", callback=self.open_folders)

        box = gui.widgetBox(container,
                            "",
                            orientation="horizontal",
                            width=self.CONTROL_AREA_WIDTH)

        orangegui.checkBox(box,
                           self,
                           "twotheta_has_min",
                           "2\u03b8 min [deg]",
                           labelWidth=350,
                           callback=widget.dump_twotheta_has_min)
        gui.lineEdit(box,
                     self,
                     "twotheta_min",
                     " ",
                     labelWidth=5,
                     valueType=float,
                     validator=QDoubleValidator(),
                     callback=self.set_twotheta_min,
                     orientation="horizontal")

        box = gui.widgetBox(container,
                            "",
                            orientation="horizontal",
                            width=self.CONTROL_AREA_WIDTH)

        orangegui.checkBox(box,
                           self,
                           "twotheta_has_max",
                           "2\u03b8 max [deg]",
                           labelWidth=350,
                           callback=widget.dump_twotheta_has_max)
        gui.lineEdit(box,
                     self,
                     "twotheta_max",
                     " ",
                     labelWidth=5,
                     valueType=float,
                     validator=QDoubleValidator(),
                     callback=self.set_twotheta_max,
                     orientation="horizontal")

        self.is_on_init = False
    def __init__(self):
        super().__init__()

        self.in_data = None
        self.in_distance = None
        self.in_learner = None
        self.in_classifier = None
        self.in_object = None

        # MODIFIED BY LUCA REBUFFI 14/10/2014
        #self.auto_execute = False

        for s in self.libraryListSource:
            s.flags = 0

        self._cachedDocuments = {}

        self.infoBox = gui.widgetBox(self.controlArea, 'Info')
        gui.label(
            self.infoBox, self,
            "<p>Execute python script.</p><p>Input variables:<ul><li> " + \
            "<li>".join(t.name for t in self.inputs) + \
            "</ul></p><p>Output variables:<ul><li>" + \
            "<li>".join(t.name for t in self.outputs) + \
            "</ul></p>"
        )

        self.libraryList = itemmodels.PyListModel(
            [], self,
            flags=Qt.ItemIsSelectable | Qt.ItemIsEnabled | Qt.ItemIsEditable)

        self.libraryList.wrap(self.libraryListSource)

        self.controlBox = gui.widgetBox(self.controlArea, 'Library')
        self.controlBox.layout().setSpacing(1)

        self.libraryView = QListView(
            editTriggers=QListView.DoubleClicked |
                         QListView.EditKeyPressed,
            sizePolicy=QSizePolicy(QSizePolicy.Ignored,
                                   QSizePolicy.Preferred)
        )
        self.libraryView.setItemDelegate(ScriptItemDelegate(self))
        self.libraryView.setModel(self.libraryList)

        self.libraryView.selectionModel().selectionChanged.connect(
            self.onSelectedScriptChanged
        )
        self.controlBox.layout().addWidget(self.libraryView)

        w = itemmodels.ModelActionsWidget()

        self.addNewScriptAction = action = QAction("+", self)
        action.setToolTip("Add a new script to the library")
        action.triggered.connect(self.onAddScript)
        w.addAction(action)

        action = QAction(unicodedata.lookup("MINUS SIGN"), self)
        action.setToolTip("Remove script from library")
        action.triggered.connect(self.onRemoveScript)
        w.addAction(action)

        action = QAction("Update", self)
        action.setToolTip("Save changes in the editor to library")
        action.setShortcut(QKeySequence(QKeySequence.Save))
        action.triggered.connect(self.commitChangesToLibrary)
        w.addAction(action)

        action = QAction("More", self, toolTip="More actions")

        new_from_file = QAction("Import a script from a file", self)
        save_to_file = QAction("Save selected script to a file", self)
        save_to_file.setShortcut(QKeySequence(QKeySequence.SaveAs))

        new_from_file.triggered.connect(self.onAddScriptFromFile)
        save_to_file.triggered.connect(self.saveScript)

        menu = QMenu(w)
        menu.addAction(new_from_file)
        menu.addAction(save_to_file)
        action.setMenu(menu)
        button = w.addAction(action)
        button.setPopupMode(QToolButton.InstantPopup)

        w.layout().setSpacing(1)

        self.controlBox.layout().addWidget(w)

        self.runBox = gui.widgetBox(self.controlArea, 'Run')
        gui.button(self.runBox, self, "Execute", callback=self.execute)
        gui.checkBox(self.runBox, self, "auto_execute", "Auto execute",
                       tooltip="Run the script automatically whenever " +
                               "the inputs to the widget change.")

        self.splitCanvas = QSplitter(Qt.Vertical, self.mainArea)
        self.mainArea.layout().addWidget(self.splitCanvas)

        self.defaultFont = defaultFont = \
            "Monaco" if sys.platform == "darwin" else "Courier"

        self.textBox = gui.widgetBox(self, 'Python script')
        self.splitCanvas.addWidget(self.textBox)
        self.text = PythonScriptEditor(self)
        self.textBox.layout().addWidget(self.text)

        self.textBox.setAlignment(Qt.AlignVCenter)
        self.text.setTabStopWidth(4)

        self.text.modificationChanged[bool].connect(self.onModificationChanged)

        self.saveAction = action = QAction("&Save", self.text)
        action.setToolTip("Save script to file")
        action.setShortcut(QKeySequence(QKeySequence.Save))
        action.setShortcutContext(Qt.WidgetWithChildrenShortcut)
        action.triggered.connect(self.saveScript)

        self.consoleBox = gui.widgetBox(self, 'Console')
        self.splitCanvas.addWidget(self.consoleBox)
        self.console = PythonConsole(self.__dict__, self)
        self.consoleBox.layout().addWidget(self.console)
        self.console.document().setDefaultFont(QFont(defaultFont))
        self.consoleBox.setAlignment(Qt.AlignBottom)
        self.console.setTabStopWidth(4)

        select_row(self.libraryView, self.currentScriptIndex)

        self.splitCanvas.setSizes([2, 1])
        if self.splitterState is not None:
            self.splitCanvas.restoreState(QByteArray(self.splitterState))

        self.splitCanvas.splitterMoved[int, int].connect(self.onSpliterMoved)
        self.controlArea.layout().addStretch(1)
        self.resize(800, 600)
Exemple #33
0
    def build_positioning_directive_box(self,
                                        container_box,
                                        width,
                                        element_type=ElementType.SOURCE):

        box = oasysgui.widgetBox(container_box,
                                 "",
                                 orientation="vertical",
                                 width=width - 20)

        box_combos = oasysgui.widgetBox(box,
                                        "",
                                        orientation="vertical",
                                        width=width - 20)

        box_Distance = oasysgui.widgetBox(box,
                                          "",
                                          orientation="vertical",
                                          width=width - 20)
        '''
        box_GrazingAngle = oasysgui.widgetBox(box, "", orientation="horizontal", width=width-20)
        box_GrazingAngle_check = oasysgui.widgetBox(box_GrazingAngle, "", orientation="horizontal", width=20)
        box_GrazingAngle_value = oasysgui.widgetBox(box_GrazingAngle, "", orientation="horizontal")

        box_Angle = oasysgui.widgetBox(box, "", orientation="horizontal", width=width-20)
        box_Angle_check = oasysgui.widgetBox(box_Angle, "", orientation="horizontal", width=20)
        box_Angle_value = oasysgui.widgetBox(box_Angle, "", orientation="horizontal")

        def set_WhichAngle():
            box_GrazingAngle.setVisible(getattr(self, "WhichAngle") == positioning_directives_which_angle[0])
            box_Angle.setVisible(getattr(self, "WhichAngle") != positioning_directives_which_angle[0])
        '''
        def set_Distance_checked():
            box_Distance_value.setEnabled(
                getattr(self, "Distance_checked") == 1)

        def set_XYCentre_checked():
            box_XYCentre_value.setEnabled(
                getattr(self, "XYCentre_checked") == 1)

        '''
        def set_GrazingAngle_checked():
            box_GrazingAngle_value.setEnabled(getattr(self, "GrazingAngle_checked") == 1)

        def set_Angle_checked():
            box_Angle_value.setEnabled(getattr(self, "Angle_checked") == 1)
        '''

        def set_positioning_directives():
            '''
            This function correctly sets the positioning directives by setting correct
            settings for self.What, self.Where and self.ReferTo from the descriptive
            phrases.
            Possibilities are:
                Autofocus - self.What='centre', self.Where='downstream focus', self.ReferTo='upstream'
                DistanceFromSource - self.What='centre', self.Where='centre', self.ReferTo='source'
                Custom - allows you to set your own self.What, self.Where and self.ReferTo
            '''

            if element_type == ElementType.SOURCE:
                self.Distance_checked = 0
                self.UseDistance = 0
                self.UseDefocus = 0
                self.UseCustom = 1

                self.What = None
                self.Where = None
                self.ReferTo = PositioningDirectives.ReferTo.AbsoluteReference

            else:
                self.set_UseDistance()
                self.set_UseDefocus()
                self.set_UseCustom()
                self.set_Orientation()

                if self.WhatWhereReferTo == PositioningDirectivesPhrases.Type.OasysDefault:
                    self.What = PositioningDirectives.What.Centre
                    self.Where = PositioningDirectives.Where.Centre
                    self.ReferTo = PositioningDirectives.ReferTo.UpstreamElement
                    self.UseAsReference = True

                elif self.WhatWhereReferTo == PositioningDirectivesPhrases.Type.Autofocus:
                    self.What = PositioningDirectives.What.Centre
                    self.Where = PositioningDirectives.Where.DownstreamFocus
                    self.ReferTo = PositioningDirectives.ReferTo.UpstreamElement

                elif self.WhatWhereReferTo == PositioningDirectivesPhrases.Type.DistanceFromSource:
                    self.What = PositioningDirectives.What.Centre
                    self.Where = PositioningDirectives.Where.Centre
                    self.ReferTo = PositioningDirectives.ReferTo.Source

                elif self.WhatWhereReferTo == PositioningDirectivesPhrases.Type.Custom:
                    pass

                else:
                    raise Exception(
                        "Wrong PositioningDirectives, only WhatWhereReferTo are allowed!"
                    )

                self.use_distance_box.setVisible(self.UseDistance)
                self.use_distance_box_empty.setVisible(self.UseDistance)

                self.use_defocus_box.setVisible(self.UseDefocus)
                self.use_defocus_box_empty.setVisible(self.UseDefocus)

            self.use_custom_box.setVisible(self.UseCustom)
            self.use_custom_box_empty.setVisible(self.UseCustom)

            pass
            #set_WhichAngle()

        # Build a combo box with the choice of positioning directions phrases
        if element_type != ElementType.SOURCE:

            # le = oasysgui.lineEdit(box_Distance, self, "ReferenceOE", "Reference O.E.", labelWidth=220,
            #                        valueType=str, orientation="horizontal")
            #
            # le.setReadOnly(True)
            # font = QFont(le.font())
            # # font.setBold(True)
            # le.setFont(font)
            # palette = QPalette(le.palette())
            # palette.setColor(QPalette.Text, QColor('grey'))
            # palette.setColor(QPalette.Base, QColor(243, 240, 140))
            # le.setPalette(palette)

            box_orientation = oasysgui.widgetBox(box_combos,
                                                 "",
                                                 orientation="horizontal",
                                                 width=width - 20)
            gui.label(box_orientation,
                      self,
                      label="Orientation",
                      labelWidth=87)
            gui.comboBox(box_orientation,
                         self,
                         "OrientationGUI",
                         items=positioning_directives_orientation,
                         sendSelectedValue=True,
                         orientation="horizontal",
                         callback=set_positioning_directives)

            box_type = oasysgui.widgetBox(box_combos,
                                          "",
                                          orientation="horizontal",
                                          width=width - 20)
            gui.label(box_type, self, label="Position", labelWidth=87)
            gui.comboBox(box_type,
                         self,
                         "WhatWhereReferTo",
                         items=positioning_directives_combos,
                         sendSelectedValue=True,
                         orientation="horizontal",
                         callback=set_positioning_directives)  # Send the value

            gui.separator(box_combos)

            self.use_distance_box = oasysgui.widgetBox(
                box_Distance, "", orientation="horizontal", width=width - 20)
            self.use_distance_box_empty = oasysgui.widgetBox(
                box_Distance, "", orientation="horizontal", width=width - 20)

            self.le_Distance_default = oasysgui.lineEdit(
                self.use_distance_box,
                self,
                "Distance",
                "Distance [m]",
                labelWidth=220,
                valueType=float,
                orientation="horizontal")

            self.use_defocus_box = oasysgui.widgetBox(box_Distance,
                                                      "",
                                                      orientation="horizontal",
                                                      width=width - 20)
            self.use_defocus_box_empty = oasysgui.widgetBox(
                box_Distance, "", orientation="horizontal", width=width - 20)

            self.le_defocus = oasysgui.lineEdit(self.use_defocus_box,
                                                self,
                                                "Distance",
                                                "Defocus [m]",
                                                labelWidth=220,
                                                valueType=float,
                                                orientation="horizontal")

            self.use_custom_box = oasysgui.widgetBox(box,
                                                     "",
                                                     orientation="vertical",
                                                     width=width - 20)
            self.use_custom_box_empty = oasysgui.widgetBox(
                box, "", orientation="vertical", width=width - 20)
            box_XYDistance = oasysgui.widgetBox(self.use_custom_box,
                                                "",
                                                orientation="horizontal",
                                                width=width - 20)
            box_Distance_check = oasysgui.widgetBox(box_XYDistance,
                                                    "",
                                                    orientation="horizontal",
                                                    width=20)
            box_Distance_value = oasysgui.widgetBox(box_XYDistance,
                                                    "",
                                                    orientation="vertical")
            box_XYCentre = oasysgui.widgetBox(self.use_custom_box,
                                              "",
                                              orientation="horizontal",
                                              width=width - 20)
            box_XYCentre_check = oasysgui.widgetBox(box_XYCentre,
                                                    "",
                                                    orientation="horizontal",
                                                    width=20)
            box_XYCentre_value = oasysgui.widgetBox(box_XYCentre,
                                                    "",
                                                    orientation="vertical")
            # = oasysgui.widgetBox(box_Distance, "", orientation="vertical", width=width - 20)
            #    	self.use_custom_box_empty = oasysgui.widgetBox(box_Distance, "", orientation="horizontal", width=width - 20)

            box_what = oasysgui.widgetBox(self.use_custom_box,
                                          "",
                                          orientation="horizontal")
            gui.label(box_what, self, label="Place", labelWidth=87)
            gui.comboBox(box_what,
                         self,
                         "What",
                         label="",
                         items=positioning_directives_what,
                         sendSelectedValue=True,
                         orientation="horizontal",
                         callback=set_positioning_directives)
            gui.label(box_what, self, label=" of this O.E.", labelWidth=80)

            box_where = oasysgui.widgetBox(self.use_custom_box,
                                           "",
                                           orientation="horizontal")
            gui.label(box_where, self, label="at", labelWidth=87)
            gui.comboBox(box_where,
                         self,
                         "Where",
                         label="",
                         items=positioning_directives_where,
                         sendSelectedValue=True,
                         orientation="horizontal",
                         callback=set_positioning_directives)
            gui.label(box_where, self, label=" of", labelWidth=80)

            box_refer_to = oasysgui.widgetBox(self.use_custom_box,
                                              "",
                                              orientation="horizontal")
            gui.label(box_refer_to, self, label=" ", labelWidth=87)
            gui.comboBox(box_refer_to,
                         self,
                         "ReferTo",
                         label="",
                         items=positioning_directives_refer_to,
                         sendSelectedValue=True,
                         orientation="horizontal",
                         callback=set_positioning_directives)
            gui.label(box_refer_to, self, label=" O.E.", labelWidth=80)
            '''
            gui.comboBox(box_combos, self, "WhichAngle", label="Type Of Angle",
                         items=positioning_directives_which_angle, labelWidth=box_combos.width()-150,
                         sendSelectedValue=True, orientation="horizontal", callback=set_WhichAngle)
            '''

            gui.checkBox(box_Distance_check,
                         self,
                         "Distance_checked",
                         "",
                         callback=set_Distance_checked)
            gui.checkBox(box_XYCentre_check,
                         self,
                         "XYCentre_checked",
                         "",
                         callback=set_XYCentre_checked)
            '''
            gui.checkBox(box_GrazingAngle_check, self, "GrazingAngle_checked", "", callback=set_GrazingAngle_checked)
            gui.checkBox(box_Angle_check, self, "Angle_checked", "", callback=set_Angle_checked)
            '''

            set_Distance_checked()
            set_XYCentre_checked()
            '''
            set_Angle_checked()
            set_GrazingAngle_checked()
            '''

            self.le_Distance = oasysgui.lineEdit(box_Distance_value,
                                                 self,
                                                 "Distance",
                                                 "Distance [m]",
                                                 labelWidth=196,
                                                 valueType=float,
                                                 orientation="horizontal")
            self.le_XCentre = oasysgui.lineEdit(box_XYCentre_value,
                                                self,
                                                "XCentre",
                                                "X Centre [m]",
                                                labelWidth=196,
                                                valueType=float,
                                                orientation="horizontal")
            self.le_YCentre = oasysgui.lineEdit(box_XYCentre_value,
                                                self,
                                                "YCentre",
                                                "Y Centre [m]",
                                                labelWidth=196,
                                                valueType=float,
                                                orientation="horizontal")
            '''
            oasysgui.lineEdit(box_Angle_value, self, "Angle", "Angle [deg]", labelWidth=200, valueType=float, orientation="horizontal")
            oasysgui.lineEdit(box_GrazingAngle_value, self, "GrazingAngle", "Grazing Angle [deg]", labelWidth=200, valueType=float, orientation="horizontal")
            '''

        elif element_type == ElementType.SOURCE:  # For source, the positioning directives are limited

            box_orientation = oasysgui.widgetBox(box_combos,
                                                 "",
                                                 orientation="horizontal",
                                                 width=width - 20)
            gui.label(box_orientation,
                      self,
                      label="Orientation",
                      labelWidth=87)
            gui.comboBox(box_orientation,
                         self,
                         "OrientationGUI",
                         items=positioning_directives_orientation,
                         sendSelectedValue=True,
                         orientation="horizontal",
                         callback=set_positioning_directives)

            box_type = oasysgui.widgetBox(box_combos,
                                          "",
                                          orientation="horizontal",
                                          width=width - 20)
            gui.label(box_type, self, label="Position", labelWidth=87)
            gui.comboBox(box_type,
                         self,
                         "WhatWhereReferTo",
                         items=positioning_directives_combos_source,
                         sendSelectedValue=True,
                         orientation="horizontal",
                         callback=set_positioning_directives)  # Send the value

            gui.separator(box_combos)

            self.use_custom_box = oasysgui.widgetBox(box,
                                                     "",
                                                     orientation="vertical",
                                                     width=width - 20)
            self.use_custom_box_empty = oasysgui.widgetBox(
                box, "", orientation="vertical", width=width - 20)
            box_XYCentre = oasysgui.widgetBox(self.use_custom_box,
                                              "",
                                              orientation="horizontal",
                                              width=width - 20)
            box_XYCentre_check = oasysgui.widgetBox(box_XYCentre,
                                                    "",
                                                    orientation="horizontal",
                                                    width=20)
            box_XYCentre_value = oasysgui.widgetBox(box_XYCentre,
                                                    "",
                                                    orientation="vertical")
            # = oasysgui.widgetBox(box_Distance, "", orientation="vertical", width=width - 20)
            #    	self.use_custom_box_empty = oasysgui.widgetBox(box_Distance, "", orientation="horizontal", width=width - 20)

            # box_what = oasysgui.widgetBox(self.use_custom_box, "", orientation="horizontal")
            # gui.label(box_what, self, label="Place", labelWidth=87)
            # gui.comboBox(box_what, self, "What", label="",
            #              items=positioning_directives_what,
            #              sendSelectedValue=True, orientation="horizontal", callback=set_positioning_directives)
            # gui.label(box_what, self, label=" of this O.E.", labelWidth=80)
            #
            # box_where = oasysgui.widgetBox(self.use_custom_box, "", orientation="horizontal")
            # gui.label(box_where, self, label="at", labelWidth=87)
            # gui.comboBox(box_where, self, "Where", label="",
            #              items=positioning_directives_where,
            #              sendSelectedValue=True, orientation="horizontal", callback=set_positioning_directives)
            # gui.label(box_where, self, label=" of", labelWidth=80)
            #
            # box_refer_to = oasysgui.widgetBox(self.use_custom_box, "", orientation="horizontal")
            # gui.label(box_refer_to, self, label=" ", labelWidth=87)
            # gui.comboBox(box_refer_to, self, "ReferTo", label="",
            #              items=positioning_directives_refer_to,
            #              sendSelectedValue=True, orientation="horizontal", callback=set_positioning_directives)
            # gui.label(box_refer_to, self, label=" O.E.", labelWidth=80)
            '''
            gui.comboBox(box_combos, self, "WhichAngle", label="Type Of Angle",
                         items=positioning_directives_which_angle, labelWidth=box_combos.width()-150,
                         sendSelectedValue=True, orientation="horizontal", callback=set_WhichAngle)
            '''

            gui.checkBox(box_XYCentre_check,
                         self,
                         "XYCentre_checked",
                         "",
                         callback=set_XYCentre_checked)
            '''
            gui.checkBox(box_GrazingAngle_check, self, "GrazingAngle_checked", "", callback=set_GrazingAngle_checked)
            gui.checkBox(box_Angle_check, self, "Angle_checked", "", callback=set_Angle_checked)
            '''

            set_XYCentre_checked()
            '''
            set_Angle_checked()
            set_GrazingAngle_checked()
            '''

            self.le_XCentre = oasysgui.lineEdit(box_XYCentre_value,
                                                self,
                                                "XCentre",
                                                "X Centre",
                                                labelWidth=196,
                                                valueType=float,
                                                orientation="horizontal")
            self.le_YCentre = oasysgui.lineEdit(box_XYCentre_value,
                                                self,
                                                "YCentre",
                                                "Y Centre",
                                                labelWidth=196,
                                                valueType=float,
                                                orientation="horizontal")
            '''
            oasysgui.lineEdit(box_Angle_value, self, "Angle", "Angle [deg]", labelWidth=200, valueType=float, orientation="horizontal")
            oasysgui.lineEdit(box_GrazingAngle_value, self, "GrazingAngle", "Grazing Angle [deg]", labelWidth=200, valueType=float, orientation="horizontal")
            '''
        set_positioning_directives()
    def __init__(self):
        super().__init__()

        tabs_setting = gui.tabWidget(self.controlArea)
        tabs_setting.setFixedWidth(450)

        gui.button(self.controlArea, self, "Refresh", callback=self.plot_results)

        # graph tab
        tab_gen = ShadowGui.createTabPage(tabs_setting, "General")
        # FOR FUTURE DEVELOPMENTS
        #tab_his = ShadowGui.createTabPage(tabs_setting, "Histograms")
        #tab_col = ShadowGui.createTabPage(tabs_setting, "Color")

        incremental_box = ShadowGui.widgetBox(tab_gen, "Incremental Result", addSpace=True, orientation="horizontal", height=80)

        gui.checkBox(incremental_box, self, "keep_result", "Keep Result")
        gui.button(incremental_box, self, "Clear", callback=self.clearResults)

        screen_box = ShadowGui.widgetBox(tab_gen, "Screen Position Settings", addSpace=True, orientation="vertical", height=140)

        self.image_plane_combo = gui.comboBox(screen_box, self, "image_plane", label="Position of the Image",
                                            items=["On Image Plane", "Retraced"],
                                            callback=self.set_ImagePlane, sendSelectedValue=False, orientation="horizontal")

        self.image_plane_box = ShadowGui.widgetBox(screen_box, "", addSpace=True, orientation="vertical", width=350, height=110)
        self.image_plane_box_empty = ShadowGui.widgetBox(screen_box, "", addSpace=True, orientation="vertical", width=350, height=110)

        ShadowGui.lineEdit(self.image_plane_box, self, "image_plane_new_position", "Image Plane new Position", labelWidth=220, valueType=float, orientation="horizontal")

        gui.comboBox(self.image_plane_box, self, "image_plane_rel_abs_position", label="Position Type", labelWidth=250,
                     items=["Absolute", "Relative"], sendSelectedValue=False, orientation="horizontal")

        self.set_ImagePlane()

        general_box = ShadowGui.widgetBox(tab_gen, "General Settings", addSpace=True, orientation="vertical", height=350)

        self.x_column = gui.comboBox(general_box, self, "x_column_index", label="X Column",labelWidth=80,
                                     items=["1: X",
                                            "2: Y",
                                            "3: Z",
                                            "4: X'",
                                            "5: Y'",
                                            "6: Z'",
                                            "7: Es X",
                                            "8: Es Y",
                                            "9: Es Z",
                                            "10: Ray Flag",
                                            "11: Energy",
                                            "12: Ray Index",
                                            "13: Optical Path",
                                            "14: Phase s",
                                            "15: Phase p",
                                            "16: Ep X",
                                            "17: Ep Y",
                                            "18: Ep Z",
                                            "19: Wavelength",
                                            "20: R = sqrt(X^2 + Y^2 + Z^2)",
                                            "21: Theta (angle from Y axis)",
                                            "22: Magnitude = |Es| + |Ep|",
                                            "23: Total Intensity = |Es|^2 + |Ep|^2",
                                            "24: S Intensity = |Es|^2",
                                            "25: P Intensity = |Ep|^2",
                                            "26: |K|",
                                            "27: K X",
                                            "28: K Y",
                                            "29: K Z",
                                            "30: S0-stokes = |Es|^2 + |Ep|^2",
                                            "31: S1-stokes = |Es|^2 - |Ep|^2",
                                            "32: S2-stokes = 2|Es||Ep|cos(Phase s-Phase p)",
                                            "33: S3-stokes = 2|Es||Ep|sin(Phase s-Phase p)",
                                     ],
                                     sendSelectedValue=False, orientation="horizontal")

        gui.comboBox(general_box, self, "x_range", label="X Range", labelWidth=250,
                                     items=["<Default>",
                                            "Set.."],
                                     callback=self.set_XRange, sendSelectedValue=False, orientation="horizontal")

        self.xrange_box = ShadowGui.widgetBox(general_box, "", addSpace=True, orientation="vertical", width=420, height=100)
        self.xrange_box_empty = ShadowGui.widgetBox(general_box, "", addSpace=True, orientation="vertical", width=420, height=100)

        ShadowGui.lineEdit(self.xrange_box, self, "x_range_min", "X min", labelWidth=220, valueType=float, orientation="horizontal")
        ShadowGui.lineEdit(self.xrange_box, self, "x_range_max", "X max", labelWidth=220, valueType=float, orientation="horizontal")

        self.set_XRange()

        self.y_column = gui.comboBox(general_box, self, "y_column_index", label="Y Column",labelWidth=80,
                                     items=["1: X",
                                            "2: Y",
                                            "3: Z",
                                            "4: X'",
                                            "5: Y'",
                                            "6: Z'",
                                            "7: Es X",
                                            "8: Es Y",
                                            "9: Es Z",
                                            "10: Ray Flag",
                                            "11: Energy",
                                            "12: Ray Index",
                                            "13: Optical Path",
                                            "14: Phase s",
                                            "15: Phase p",
                                            "16: Ep X",
                                            "17: Ep Y",
                                            "18: Ep Z",
                                            "19: Wavelength",
                                            "20: R = sqrt(X^2 + Y^2 + Z^2)",
                                            "21: Theta (angle from Y axis)",
                                            "22: Magnitude = |Es| + |Ep|",
                                            "23: Total Intensity = |Es|^2 + |Ep|^2",
                                            "24: S Intensity = |Es|^2",
                                            "25: P Intensity = |Ep|^2",
                                            "26: |K|",
                                            "27: K X",
                                            "28: K Y",
                                            "29: K Z",
                                            "30: S0-stokes = |Es|^2 + |Ep|^2",
                                            "31: S1-stokes = |Es|^2 - |Ep|^2",
                                            "32: S2-stokes = 2|Es||Ep|cos(Phase s-Phase p)",
                                            "33: S3-stokes = 2|Es||Ep|sin(Phase s-Phase p)",
                                     ],

                                     sendSelectedValue=False, orientation="horizontal")

        gui.comboBox(general_box, self, "y_range", label="Y Range",labelWidth=250,
                                     items=["<Default>",
                                            "Set.."],
                                     callback=self.set_YRange, sendSelectedValue=False, orientation="horizontal")

        self.yrange_box = ShadowGui.widgetBox(general_box, "", addSpace=True, orientation="vertical", width=420, height=100)
        self.yrange_box_empty = ShadowGui.widgetBox(general_box, "", addSpace=True, orientation="vertical", width=420, height=100)

        ShadowGui.lineEdit(self.yrange_box, self, "y_range_min", "Y min", labelWidth=220, valueType=float, orientation="horizontal")
        ShadowGui.lineEdit(self.yrange_box, self, "y_range_max", "Y max", labelWidth=220, valueType=float, orientation="horizontal")

        self.set_YRange()


        gui.comboBox(general_box, self, "rays", label="Rays", labelWidth=250,
                                     items=["All rays",
                                            "Good Only",
                                            "Lost Only"],
                                     sendSelectedValue=False, orientation="horizontal")

        gui.comboBox(general_box, self, "cartesian_axis", label="Cartesian Axis",labelWidth=300,
                                     items=["No",
                                            "Yes"],
                                     sendSelectedValue=False, orientation="horizontal")


        histograms_box = ShadowGui.widgetBox(tab_gen, "Histograms settings", addSpace=True, orientation="vertical", height=70)

        ShadowGui.lineEdit(histograms_box, self, "number_of_bins", "Number of Bins", labelWidth=250, valueType=int, orientation="horizontal")

        self.image_box = gui.widgetBox(self.mainArea, "Plot Result", addSpace=True, orientation="vertical")
        self.image_box.setFixedHeight(self.IMAGE_HEIGHT)
        self.image_box.setFixedWidth(self.IMAGE_WIDTH)

        self.shadow_output = QtGui.QTextEdit()

        out_box = gui.widgetBox(self.mainArea, "Shadow Output", addSpace=True, orientation="horizontal")
        out_box.layout().addWidget(self.shadow_output)
        out_box.setFixedWidth(self.IMAGE_WIDTH)

        self.shadow_output.setFixedHeight(100)
        self.shadow_output.setFixedWidth(self.IMAGE_WIDTH-50)
Exemple #35
0
    def __init__(self):
        self.setFixedWidth(590)
        self.setFixedHeight(550)

        left_box_1 = oasysgui.widgetBox(self.controlArea,
                                        "CCD Image",
                                        addSpace=True,
                                        orientation="vertical")

        gui.comboBox(left_box_1,
                     self,
                     "is_textual",
                     label="Image Type",
                     labelWidth=250,
                     items=["JPEG/PNG", "Textual"],
                     sendSelectedValue=False,
                     orientation="horizontal",
                     callback=self.setTextual)

        ########################################

        self.select_file_box_1 = oasysgui.widgetBox(left_box_1,
                                                    "Textual Image Parameters",
                                                    addSpace=False,
                                                    orientation="horizontal",
                                                    height=250)

        self.le_image_txt_file_name = oasysgui.lineEdit(
            self.select_file_box_1,
            self,
            "image_file_name",
            "Image File Name",
            labelWidth=120,
            valueType=str,
            orientation="horizontal")
        self.le_image_txt_file_name.setFixedWidth(300)

        gui.button(self.select_file_box_1,
                   self,
                   "...",
                   callback=self.selectTxtFile)

        self.select_file_box_2 = oasysgui.widgetBox(left_box_1,
                                                    "Image Parameters",
                                                    addSpace=False,
                                                    orientation="vertical",
                                                    height=250)

        select_file_box_2_int = oasysgui.widgetBox(self.select_file_box_2,
                                                   "",
                                                   addSpace=False,
                                                   orientation="horizontal")

        self.le_image_file_name = oasysgui.lineEdit(select_file_box_2_int,
                                                    self,
                                                    "image_file_name",
                                                    "Image File Name",
                                                    labelWidth=120,
                                                    valueType=str,
                                                    orientation="horizontal")
        self.le_image_file_name.setFixedWidth(300)

        gui.button(select_file_box_2_int,
                   self,
                   "...",
                   callback=self.selectFile)

        select_file_box_2_figure = oasysgui.widgetBox(self.select_file_box_2,
                                                      "",
                                                      addSpace=False,
                                                      orientation="horizontal")

        figure_box = oasysgui.widgetBox(select_file_box_2_figure,
                                        "Preview",
                                        addSpace=False,
                                        orientation="vertical",
                                        width=350,
                                        height=180)

        self.preview_box = QtWidgets.QLabel("")
        self.preview_box.setAlignment(Qt.AlignCenter)
        self.preview_box.setSizePolicy(QtWidgets.QSizePolicy.Expanding,
                                       QtWidgets.QSizePolicy.Expanding)

        figure_box.layout().addWidget(self.preview_box)

        data_box = oasysgui.widgetBox(select_file_box_2_figure,
                                      "Data",
                                      addSpace=False,
                                      orientation="vertical")

        le = oasysgui.lineEdit(data_box,
                               self,
                               "number_of_x_pixels",
                               "Number of x Pixels",
                               valueType=int,
                               orientation="horizontal")
        le.setReadOnly(True)
        font = QtGui.QFont(le.font())
        font.setBold(True)
        le.setFont(font)
        palette = QtGui.QPalette(le.palette())  # make a copy of the palette
        palette.setColor(QtGui.QPalette.Text, QtGui.QColor('dark blue'))
        palette.setColor(QtGui.QPalette.Base, QtGui.QColor(243, 240, 160))
        le.setPalette(palette)
        le = oasysgui.lineEdit(data_box,
                               self,
                               "number_of_z_pixels",
                               "Number of z Pixels",
                               valueType=int,
                               orientation="horizontal")
        le.setReadOnly(True)
        font = QtGui.QFont(le.font())
        font.setBold(True)
        le.setFont(font)
        palette = QtGui.QPalette(le.palette())  # make a copy of the palette
        palette.setColor(QtGui.QPalette.Text, QtGui.QColor('dark blue'))
        palette.setColor(QtGui.QPalette.Base, QtGui.QColor(243, 240, 160))
        le.setPalette(palette)

        ########################################

        self.setTextual()
        self.loadImage()

        oasysgui.lineEdit(left_box_1,
                          self,
                          "pixel_size",
                          "Pixel Size [um]",
                          labelWidth=200,
                          valueType=float,
                          orientation="horizontal")
        oasysgui.lineEdit(left_box_1,
                          self,
                          "number_of_x_bins",
                          "Number of Bin per Pixel [x]",
                          labelWidth=200,
                          valueType=int,
                          orientation="horizontal")
        oasysgui.lineEdit(left_box_1,
                          self,
                          "number_of_z_bins",
                          "Number of Bin per Pixel [z]",
                          labelWidth=200,
                          valueType=int,
                          orientation="horizontal")
        gui.checkBox(left_box_1, self, "flip_vertically", "Flip Vertically")
        gui.checkBox(left_box_1, self, "flip_horizontally",
                     "Flip Horizontally")

        gui.separator(self.controlArea)

        button = gui.button(self.controlArea,
                            self,
                            "Convert To Beam",
                            callback=self.convertToBeam)
        button.setFixedHeight(45)

        gui.rubber(self.controlArea)
    def __init__(self):
        super().__init__()

        self.runaction = OWAction("Compute", self)
        self.runaction.triggered.connect(self.compute)
        self.addAction(self.runaction)

        geom = QApplication.desktop().availableGeometry()
        self.setGeometry(QRect(round(geom.width()*0.05),
                               round(geom.height()*0.05),
                               round(min(geom.width()*0.98, self.MAX_WIDTH)),
                               round(min(geom.height()*0.95, self.MAX_HEIGHT))))

        self.setMaximumHeight(self.geometry().height())
        self.setMaximumWidth(self.geometry().width())

        self.controlArea.setFixedWidth(self.CONTROL_AREA_WIDTH)

        self.general_options_box = gui.widgetBox(self.controlArea, "General Options", addSpace=True, orientation="horizontal")
        gui.checkBox(self.general_options_box, self, 'is_automatic_run', 'Automatic Execution')

        self.button_box = gui.widgetBox(self.controlArea, "", orientation="horizontal")
        #widget buttons: compute, set defaults, help
        gui.button(self.button_box, self, "Compute", callback=self.compute, height=35)
        gui.button(self.button_box, self, "Defaults", callback=self.defaults, height=35)

        gui.separator(self.controlArea, height=10)

        self.build_gui()

        gui.rubber(self.controlArea)

        self.main_tabs = oasysgui.tabWidget(self.mainArea)
        plot_tab = oasysgui.createTabPage(self.main_tabs, "Results")
        out_tab = oasysgui.createTabPage(self.main_tabs, "Output")

        self.view_box = oasysgui.widgetBox(plot_tab, "Results Options", addSpace=False, orientation="horizontal")
        view_box_1 = oasysgui.widgetBox(self.view_box, "", addSpace=False, orientation="vertical", width=350)

        self.view_type_combo = gui.comboBox(view_box_1, self, "view_type", label="View Results",
                                            labelWidth=220,
                                            items=["No", "Yes"],
                                            callback=self.set_ViewType, sendSelectedValue=False, orientation="horizontal")

        oasysgui.widgetBox(self.view_box, "", addSpace=False, orientation="vertical", width=100)


        #* -------------------------------------------------------------------------------------------------------------
        propagation_box = oasysgui.widgetBox(self.view_box, "", addSpace=False, orientation="vertical")

        self.le_wise_live_propagation_mode = gui.lineEdit(propagation_box, self, "wise_live_propagation_mode", "Propagation Mode", labelWidth=150, valueType=str, orientation="horizontal")
        self.le_wise_live_propagation_mode.setAlignment(Qt.AlignCenter)
        self.le_wise_live_propagation_mode.setReadOnly(True)
        font = QFont(self.le_wise_live_propagation_mode.font())
        font.setBold(True)
        self.le_wise_live_propagation_mode.setFont(font)

        self.set_wise_live_propagation_mode()

        #* -------------------------------------------------------------------------------------------------------------

        self.tab = []
        self.tabs = oasysgui.tabWidget(plot_tab)

        self.initializeTabs()

        self.wise_output = QtWidgets.QTextEdit()
        self.wise_output.setReadOnly(True)
        self.wise_output.setStyleSheet("background-color: white;")

        out_box = gui.widgetBox(out_tab, "System Output", addSpace=True, orientation="horizontal")
        out_box.layout().addWidget(self.wise_output)

        self.wise_output.setFixedHeight(590)
        self.wise_output.setFixedWidth(700)

        gui.rubber(self.mainArea)
Exemple #37
0
    def __init__(self):
        super().__init__()

        gui.button(self.controlArea, self, "Refresh", callback=self.plot_results, height=45)
        gui.separator(self.controlArea, 10)

        self.tabs_setting = gui.tabWidget(self.controlArea)
        self.tabs_setting.setFixedWidth(self.CONTROL_AREA_WIDTH - 5)

        # graph tab
        tab_set = oasysgui.createTabPage(self.tabs_setting, "Plot Settings")
        tab_gen = oasysgui.createTabPage(self.tabs_setting, "Histogram Settings")

        screen_box = oasysgui.widgetBox(
            tab_set, "Screen Position Settings", addSpace=True, orientation="vertical", height=110
        )

        self.image_plane_combo = gui.comboBox(
            screen_box,
            self,
            "image_plane",
            label="Position of the Image",
            items=["On Image Plane", "Retraced"],
            labelWidth=260,
            callback=self.set_ImagePlane,
            sendSelectedValue=False,
            orientation="horizontal",
        )

        self.image_plane_box = oasysgui.widgetBox(screen_box, "", addSpace=True, orientation="vertical", height=110)
        self.image_plane_box_empty = oasysgui.widgetBox(
            screen_box, "", addSpace=True, orientation="vertical", height=110
        )

        oasysgui.lineEdit(
            self.image_plane_box,
            self,
            "image_plane_new_position",
            "Image Plane new Position",
            labelWidth=220,
            valueType=float,
            orientation="horizontal",
        )

        gui.comboBox(
            self.image_plane_box,
            self,
            "image_plane_rel_abs_position",
            label="Position Type",
            labelWidth=250,
            items=["Absolute", "Relative"],
            sendSelectedValue=False,
            orientation="horizontal",
        )

        self.set_ImagePlane()

        general_box = oasysgui.widgetBox(tab_set, "General Settings", addSpace=True, orientation="vertical", height=250)

        self.x_column = gui.comboBox(
            general_box,
            self,
            "x_column_index",
            label="Column",
            labelWidth=70,
            items=[
                "1: X",
                "2: Y",
                "3: Z",
                "4: X'",
                "5: Y'",
                "6: Z'",
                "7: Es X",
                "8: Es Y",
                "9: Es Z",
                "10: Ray Flag",
                "11: Energy",
                "12: Ray Index",
                "13: Optical Path",
                "14: Phase s",
                "15: Phase p",
                "16: Ep X",
                "17: Ep Y",
                "18: Ep Z",
                "19: Wavelength",
                "20: R = sqrt(X^2 + Y^2 + Z^2)",
                "21: Theta (angle from Y axis)",
                "22: Magnitude = |Es| + |Ep|",
                "23: Total Intensity = |Es|^2 + |Ep|^2",
                "24: S Intensity = |Es|^2",
                "25: P Intensity = |Ep|^2",
                "26: |K|",
                "27: K X",
                "28: K Y",
                "29: K Z",
                "30: S0-stokes = |Ep|^2 + |Es|^2",
                "31: S1-stokes = |Ep|^2 - |Es|^2",
                "32: S2-stokes = 2|Es||Ep|cos(Phase s-Phase p)",
                "33: S3-stokes = 2|Es||Ep|sin(Phase s-Phase p)",
            ],
            sendSelectedValue=False,
            orientation="horizontal",
        )

        gui.comboBox(
            general_box,
            self,
            "x_range",
            label="X Range",
            labelWidth=250,
            items=["<Default>", "Set.."],
            callback=self.set_XRange,
            sendSelectedValue=False,
            orientation="horizontal",
        )

        self.xrange_box = oasysgui.widgetBox(general_box, "", addSpace=True, orientation="vertical", height=100)
        self.xrange_box_empty = oasysgui.widgetBox(general_box, "", addSpace=True, orientation="vertical", height=100)

        oasysgui.lineEdit(
            self.xrange_box, self, "x_range_min", "X min", labelWidth=220, valueType=float, orientation="horizontal"
        )
        oasysgui.lineEdit(
            self.xrange_box, self, "x_range_max", "X max", labelWidth=220, valueType=float, orientation="horizontal"
        )

        self.set_XRange()

        self.weight_column = gui.comboBox(
            general_box,
            self,
            "weight_column_index",
            label="Weight",
            labelWidth=70,
            items=[
                "0: No Weight",
                "1: X",
                "2: Y",
                "3: Z",
                "4: X'",
                "5: Y'",
                "6: Z'",
                "7: Es X",
                "8: Es Y",
                "9: Es Z",
                "10: Ray Flag",
                "11: Energy",
                "12: Ray Index",
                "13: Optical Path",
                "14: Phase s",
                "15: Phase p",
                "16: Ep X",
                "17: Ep Y",
                "18: Ep Z",
                "19: Wavelength",
                "20: R = sqrt(X^2 + Y^2 + Z^2)",
                "21: Theta (angle from Y axis)",
                "22: Magnitude = |Es| + |Ep|",
                "23: Total Intensity = |Es|^2 + |Ep|^2",
                "24: S Intensity = |Es|^2",
                "25: P Intensity = |Ep|^2",
                "26: |K|",
                "27: K X",
                "28: K Y",
                "29: K Z",
                "30: S0-stokes = |Ep|^2 + |Es|^2",
                "31: S1-stokes = |Ep|^2 - |Es|^2",
                "32: S2-stokes = 2|Es||Ep|cos(Phase s-Phase p)",
                "33: S3-stokes = 2|Es||Ep|sin(Phase s-Phase p)",
            ],
            sendSelectedValue=False,
            orientation="horizontal",
        )

        gui.comboBox(
            general_box,
            self,
            "rays",
            label="Rays",
            labelWidth=250,
            items=["All rays", "Good Only", "Lost Only"],
            sendSelectedValue=False,
            orientation="horizontal",
        )
        incremental_box = oasysgui.widgetBox(
            tab_gen, "Incremental Result", addSpace=True, orientation="horizontal", height=80
        )

        gui.checkBox(incremental_box, self, "keep_result", "Keep Result")
        gui.button(incremental_box, self, "Clear", callback=self.clearResults)

        histograms_box = oasysgui.widgetBox(
            tab_gen, "Histograms settings", addSpace=True, orientation="vertical", height=90
        )

        oasysgui.lineEdit(
            histograms_box,
            self,
            "number_of_bins",
            "Number of Bins",
            labelWidth=250,
            valueType=int,
            orientation="horizontal",
        )

        gui.comboBox(
            histograms_box,
            self,
            "is_conversion_active",
            label="Is U.M. conversion active",
            labelWidth=250,
            items=["No", "Yes"],
            sendSelectedValue=False,
            orientation="horizontal",
        )

        self.main_tabs = gui.tabWidget(self.mainArea)
        plot_tab = gui.createTabPage(self.main_tabs, "Plots")
        out_tab = gui.createTabPage(self.main_tabs, "Output")

        self.image_box = gui.widgetBox(plot_tab, "Plot Result", addSpace=True, orientation="vertical")
        self.image_box.setFixedHeight(self.IMAGE_HEIGHT)
        self.image_box.setFixedWidth(self.IMAGE_WIDTH)

        self.shadow_output = QtGui.QTextEdit()
        self.shadow_output.setReadOnly(True)

        out_box = gui.widgetBox(out_tab, "System Output", addSpace=True, orientation="horizontal")
        out_box.layout().addWidget(self.shadow_output)

        self.shadow_output.setFixedHeight(600)
        self.shadow_output.setFixedWidth(600)
Exemple #38
0
    def __init__(self):
        super().__init__()

        left_box_1 = oasysgui.widgetBox(self.controlArea,
                                        "X0h Request Form",
                                        addSpace=True,
                                        orientation="vertical",
                                        width=400,
                                        height=630)

        left_box_2 = oasysgui.widgetBox(left_box_1,
                                        "X-rays",
                                        addSpace=True,
                                        orientation="horizontal",
                                        width=380,
                                        height=110)

        left_box_2_1 = oasysgui.widgetBox(left_box_2,
                                          "",
                                          addSpace=True,
                                          orientation="vertical",
                                          width=150,
                                          height=110)

        gui.radioButtons(
            left_box_2_1,
            self,
            "xway", ["Wavelength (Å)", "Energy (keV)", "Characteristic line"],
            callback=self.set_xway)

        self.box_wave = oasysgui.widgetBox(left_box_2,
                                           "",
                                           addSpace=True,
                                           orientation="vertical",
                                           width=190)
        gui.separator(self.box_wave, height=10)
        gui.lineEdit(self.box_wave,
                     self,
                     "wave",
                     label="",
                     labelWidth=0,
                     addSpace=False,
                     valueType=float,
                     orientation="horizontal")

        self.box_line = oasysgui.widgetBox(left_box_2,
                                           "",
                                           addSpace=True,
                                           orientation="horizontal",
                                           width=190,
                                           height=110)
        gui.separator(self.box_line, height=120)
        XRayServerGui.combobox_text(self.box_line,
                                    self,
                                    "line",
                                    label="",
                                    labelWidth=0,
                                    items=self.get_lines(),
                                    sendSelectedValue=True,
                                    orientation="horizontal",
                                    selectedValue=self.line)

        button = gui.button(self.box_line, self, "?", callback=self.help_lines)
        button.setFixedWidth(15)

        self.set_xway()

        left_box_3 = oasysgui.widgetBox(left_box_1,
                                        "Target",
                                        addSpace=True,
                                        orientation="horizontal",
                                        width=380,
                                        height=140)

        left_box_3_1 = oasysgui.widgetBox(left_box_3,
                                          "",
                                          addSpace=True,
                                          orientation="vertical",
                                          width=125,
                                          height=110)

        gui.radioButtons(left_box_3_1,
                         self,
                         "coway",
                         ["Crystal", "Other Material", "Chemical Formula"],
                         callback=self.set_coway)

        self.box_crystal = oasysgui.widgetBox(left_box_3,
                                              "",
                                              addSpace=True,
                                              orientation="horizontal",
                                              width=210)
        XRayServerGui.combobox_text(self.box_crystal,
                                    self,
                                    "code",
                                    label="",
                                    labelWidth=0,
                                    items=self.get_crystals(),
                                    sendSelectedValue=True,
                                    orientation="horizontal",
                                    selectedValue=self.code)

        button = gui.button(self.box_crystal,
                            self,
                            "?",
                            callback=self.help_crystals)
        button.setFixedWidth(15)

        self.box_other = oasysgui.widgetBox(left_box_3,
                                            "",
                                            addSpace=True,
                                            orientation="horizontal",
                                            width=210)
        gui.separator(self.box_other, height=75)
        XRayServerGui.combobox_text(self.box_other,
                                    self,
                                    "amor",
                                    label="",
                                    labelWidth=0,
                                    items=self.get_others(),
                                    sendSelectedValue=True,
                                    orientation="horizontal",
                                    selectedValue=self.amor)

        button = gui.button(self.box_other,
                            self,
                            "?",
                            callback=self.help_others)
        button.setFixedWidth(15)

        self.box_chemical = oasysgui.widgetBox(left_box_3,
                                               "",
                                               addSpace=True,
                                               orientation="vertical",
                                               width=210,
                                               height=140)
        gui.separator(self.box_chemical, height=50)

        gui.lineEdit(self.box_chemical,
                     self,
                     "chem",
                     label=" ",
                     labelWidth=1,
                     addSpace=False,
                     valueType=str,
                     orientation="horizontal",
                     callback=self.set_rho)
        gui.lineEdit(self.box_chemical,
                     self,
                     "rho",
                     label=u"\u03C1" + " (g/cm3)",
                     labelWidth=60,
                     addSpace=False,
                     valueType=float,
                     orientation="horizontal")

        self.set_coway()

        left_box_4 = oasysgui.widgetBox(left_box_1,
                                        "Reflection",
                                        addSpace=True,
                                        orientation="horizontal",
                                        width=380,
                                        height=60)

        gui.lineEdit(left_box_4,
                     self,
                     "i1",
                     label="Miller indices",
                     labelWidth=200,
                     addSpace=False,
                     valueType=int,
                     orientation="horizontal")
        gui.lineEdit(left_box_4,
                     self,
                     "i2",
                     label=" ",
                     labelWidth=1,
                     addSpace=False,
                     valueType=int,
                     orientation="horizontal")
        gui.lineEdit(left_box_4,
                     self,
                     "i3",
                     label=" ",
                     labelWidth=1,
                     addSpace=False,
                     valueType=int,
                     orientation="horizontal")

        left_box_5 = oasysgui.widgetBox(
            left_box_1,
            "Database Options for dispersion corrections df1, df2",
            addSpace=True,
            orientation="vertical",
            width=380,
            height=185)

        gui.radioButtons(left_box_5, self, "df1df2", [
            "Auto (Henke at low energy, X0h at mid, Brennan-Cowan\nat high)",
            "Use X0h data (5-25 keV or 0.5-2.5 A), recommended for\nBragg diffraction",
            "Use Henke data (0.01-30 keV or 0.4-1200 A),\nrecommended for soft x-rays",
            "Use Brennan-Cowan data (0.03-700 keV or 0.02-400 A)",
            "Compare results for all of the above sources"
        ])

        left_box_6 = oasysgui.widgetBox(left_box_1,
                                        "Output Options",
                                        addSpace=True,
                                        orientation="vertical",
                                        width=380,
                                        height=50)

        gui.checkBox(left_box_6,
                     self,
                     "detail",
                     "Print atomic coordinates",
                     labelWidth=250)

        button = gui.button(self.controlArea,
                            self,
                            "Get X0h!",
                            callback=self.submit)
        button.setFixedHeight(30)

        gui.rubber(self.controlArea)

        self.tabs = []
        self.tabs_widget = oasysgui.tabWidget(self.mainArea)
        self.initializeTabs()

        self.x0h_output = QWebView(self.tabs[0])

        self.tabs[0].layout().addWidget(self.x0h_output)

        self.x0h_output.setFixedHeight(640)
        self.x0h_output.setFixedWidth(740)
Exemple #39
0
    def __init__(self):
        super().__init__()

        self.runaction = widget.OWAction("Write HDF5 File", self)
        self.runaction.triggered.connect(self.write_file)
        self.addAction(self.runaction)

        self.setFixedWidth(590)
        self.setFixedHeight(500)

        left_box_1 = oasysgui.widgetBox(self.controlArea,
                                        "HDF5 File Selection",
                                        addSpace=True,
                                        orientation="vertical",
                                        width=570,
                                        height=400)

        gui.checkBox(left_box_1, self, 'is_automatic_run',
                     'Automatic Execution')

        gui.separator(left_box_1, height=10)

        figure_box = oasysgui.widgetBox(left_box_1,
                                        "",
                                        addSpace=True,
                                        orientation="horizontal",
                                        width=550,
                                        height=50)

        #
        #
        #
        self.le_file_name = oasysgui.lineEdit(figure_box,
                                              self,
                                              "file_name",
                                              "Output File Name",
                                              labelWidth=120,
                                              valueType=str,
                                              orientation="horizontal")
        self.le_file_name.setFixedWidth(330)

        gui.button(figure_box, self, "...", callback=self.selectFile)

        gui.separator(left_box_1, height=10)

        #
        #
        #

        gui.comboBox(
            left_box_1,
            self,
            "TYPE_OF_OUTPUT",
            label=" Type of output file",
            labelWidth=260,
            items=[
                'COMSYL hdf5 with multi-mode', 'WOFRY hdf5 with multi-mode',
                'WOFRY multiple files'
            ],
            #callback=self.set_Propagator,
            sendSelectedValue=False,
            orientation="horizontal")

        self.le_index_format = oasysgui.lineEdit(
            left_box_1,
            self,
            "index_format",
            "index format [for individual files]",
            labelWidth=200,
            valueType=str,
            orientation="horizontal")
        gui.separator(left_box_1, height=10)

        #
        #
        #
        gui.comboBox(
            left_box_1,
            self,
            "ALL_MODES",
            label=" Modes to write",
            labelWidth=260,
            items=['Selected modes', 'All modes'],
            #callback=self.set_Propagator,
            sendSelectedValue=False,
            orientation="horizontal")

        oasysgui.lineEdit(left_box_1,
                          self,
                          "MODE_TO",
                          "To mode index:",
                          labelWidth=200,
                          valueType=int,
                          orientation="horizontal")

        gui.separator(left_box_1, height=10)
        #
        #
        #
        button = gui.button(self.controlArea,
                            self,
                            "Write File",
                            callback=self.write_file)
        button.setFixedHeight(45)
        self.le_index_format.setFixedWidth(330)

        gui.rubber(self.controlArea)