コード例 #1
0
    def initUI(self):
        central_widget = makeWidget.make_vbox()
        central_widget.setLayout(central_widget.layout)

        text_area = makeWidget.make_vbox()
        # todo: demander une confirmation de la traduction
        description = """
        <html>
        <h1>RDRP Database Tools - Help</h1>
        <p>This GUI is meant to help manipulating a standardized format for chemical reactions.</p>

        <h3>Read</h3>
        <p>This application have two main tabs: "Read" and "Write". The first one allows you to read datas from a JSON file, while the second let you create your own JSON file by filling forms. To add a file to read, use one of these two buttons:</p>
        <br/><img src="ressources/addFiles.png"></img><br/>
        <p>You can drop files on the left part to open them or you can click on the right button to open a new window in which you can choose some files to open.</p>
        <br/><img src="ressources/addMultpleFiles.png"></img><br/>
        <p><div style="color: #FF0000;text-decoration: underline;">Tips:</div> you can hold ctrl and click on as many files as you want to open them all.</p>
        <p>Once files are opened, you can see what is inside by click on the corresponding tab. The corresponding informations will be printed on the left.</p>
        <br/><img src="ressources/infosOnFiles.png"></img><br/>
        <p>If you click on one of the coefficient buttons, the graphs on the right will be updated with the values inside the opened files. For instance, if you click on "Diffusion", the program will search every "diffusion" part in every opened file and will plot it in the graph.</p>
        <br/><img src="ressources/drawCoefficients.png"></img><br/>
        <br/><img src="ressources/drawnCoefficients.png"></img><br/>
        <p>You can modify the graph with the below buttons:</p>
        <br/><img src="ressources/modifyGraph.png"></img><br/>
        <li>
            <ul>You can move in the graph by clicking on the arrows and then by clicking on the graph, holding the mouse button pressed and dragging the mouse.</ul>
            <ul>After a click on the magnifying glass, you can zoom in the graph.</ul>
            <ul>The third button let you modify the height and the weight of the graph.</ul>
            <ul>The fourth button let you add a title to the graph, edit its axis, change the legend... It can be usefull to get a better looking graph.
            <br/>
            <div style="color: #FF0000;text-decoration: underline;">Be careful:</div> if you draw a graph using one of the coefficient buttons (on the left of the graph), these changes will be lost. Be sure to export your graph before drawing another one.</ul>
            <ul>The floppy icon let you export the graph into an image (ie: save it on your computer)</ul>
        </li>

        <h3>Write</h3>
        <p></p>
        <br/>
        </html>"""
        desc_label = QLabel(description)
        desc_label.setTextInteractionFlags(Qt.LinksAccessibleByMouse)
        desc_label.setOpenExternalLinks(True)
        desc_label.setWordWrap(True)
        scroll = makeWidget.make_scroll(desc_label)
        scroll.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        central_widget.layout.addWidget(scroll)
        p = central_widget.palette()
        p.setColor(central_widget.backgroundRole(), QColor(0, 0, 0))
        central_widget.setPalette(p)
        self.setCentralWidget(central_widget)
コード例 #2
0
    def initUI(self):
        """
            Create the GUI of the window.
        """
        central_widget = QWidget()

        central_widget.layout = QHBoxLayout()
        central_widget.setLayout(central_widget.layout)
        logo = makeWidget.make_pixmap("ressources/logo2.png")
        central_widget.layout.addWidget(logo)

        text_area = makeWidget.make_vbox()
        # todo: demander une confirmation de la traduction
        description = """
        <html>
        <h1>RDRP Database Tools</h1>
        <h3>"Reaction-Diffusion modelling for Retention and Permation Database Tools"</h3>
        <p><b>Version 1.0</b></p>
        <br/>
        <p> A Graphical User Interface made by the <a href="www.lspm.cnrs.fr/">LSPM</a> (Laboratory of Sciences of Processes and Materials).</p>
        </html>"""
        desc_label = QLabel(description)
        desc_label.setTextInteractionFlags(Qt.LinksAccessibleByMouse)
        desc_label.setOpenExternalLinks(True)
        text_area.layout.addWidget(desc_label)
        central_widget.layout.addWidget(text_area)
        p = central_widget.palette()
        p.setColor(central_widget.backgroundRole(), QColor(0, 0, 0))
        central_widget.setPalette(p)
        self.setCentralWidget(central_widget)
コード例 #3
0
    def __init__(self):
        super().__init__()
        self.layout = QHBoxLayout()
        self.setLayout(self.layout)
        self.names_of_curves = ["temperature", "int+sum", "int", "sum", "mini_int"]
        self.data_onglets = []

        self.doublelist = DoubleThumbListWidget()
        trigger_click = partial(self.on_click_open_files, self.doublelist)
        
        def todo(*args):
            pass
        
        bt_draw = QPushButton("Draw")
        bt_draw.clicked.connect(self.draw)

        draw_bts = make_vbox()
        draw_bts.layout.addWidget(QLabel("Draw"))
        draw_bts.layout.addWidget(bt_draw)
        self.checkboxes = Checkboxes("Select your data", self.names_of_curves)
        
        self.layout.addWidget(
            make_hbox(
                make_vbox(
                    self.doublelist,
                    AddFiles(todo, trigger_click)  # todo
                ),
                make_vbox(
                    self.checkboxes,
                    draw_bts
                )
            )
        )

        self.pltwindows = [PltWindowProfile() for _ in range(4)]
        tab_right = QTabWidget()
        tab_right.setFocusPolicy(Qt.NoFocus)
        tab_right.addTab(self.pltwindows[0], "Log - Natural")
        tab_right.addTab(self.pltwindows[1], "Log - 1/T")
        tab_right.addTab(self.pltwindows[2], "Natural - Natural")
        tab_right.addTab(self.pltwindows[3], "Log - Log")
        tab_right.setCurrentIndex(3)
        self.layout.addWidget(tab_right)
コード例 #4
0
ファイル: ShowNewFile.py プロジェクト: mougenj/RD4F-Tool
        def fillVboxWithAnything(equations_container, name, coef1, coef2, comment_content, is_in_the_file=True):
            """
                Create a QGroupBox, fill it with the informations contained in
                'name', 'coef1' and 'coef2'.
                Then, add this widget to equations_container.
            """
            coef2kJmol = "None" if coef2 == "None" else "{:.2e}".format(float(coef2)/0.0104)
            equation_container = QGroupBox()
            unit2 = ("(eV)", "(kJ/mol)")
            if name == "D":
                unit1 = "(m²/s)"
                # latex_equation = makeWidget.make_pixmap("ressources/latex_equation_diffusivity_resized.png")
                latex_equation_text = \
                    r"$D = D_0 \cdot e^{-\frac{E_D}{k_B \cdot T}}$"
                latex_equation = mathTex_to_QPixmap(latex_equation_text, 16)
                title = "For interstitial diffusivity"
                objectName = "diffusivity"
                coef1_name = "D_0"
                coef2_name = "E_D"
            elif name == "S":
                unit1 = "(adatome/(m³*Pa½))"  # todo: update it (like JS)
                # latex_equation = makeWidget.make_pixmap("ressources/latex_equation_solubility_resized.png")
                latex_equation_text = \
                    r"$S = S_0 \cdot e^{-\frac{E_S}{k_B \cdot T}}$"
                latex_equation = mathTex_to_QPixmap(latex_equation_text, 16)
                title = "For solubility"
                objectName = "solubility"
                coef1_name = "S_0"
                coef2_name = "E_S"
            elif name == "Kr":
                unit1 = "(m⁴/s)"
                # latex_equation = makeWidget.make_pixmap("ressources/latex_equation_combination_resized.png")
                latex_equation_text = \
                    r"$K_r = K_{r_0} \cdot e^{-\frac{E_r}{k_B \cdot T}}$"
                latex_equation = mathTex_to_QPixmap(latex_equation_text, 16)
                title = "For combination"  # todo: check translation
                objectName = "combination"
                coef1_name = "Kr_0"
                coef2_name = "E_r"
            equation_container.setTitle(title)
            equation_container.setObjectName(objectName)

            grid_data_coef = QWidget()
            grid_data_coef.layout = QGridLayout()
            grid_data_coef.setLayout(grid_data_coef.layout)

            grid_data_coef.layout.addWidget(latex_equation, 0, 0)
            grid_data_coef.layout.addWidget(QLabel(coef1_name), 1, 0)
            grid_data_coef.layout.addWidget(QLineEditWidthed(coef1, self.editable, "--------------"), 1, 1)
            grid_data_coef.layout.addWidget(QLabel(unit1), 1, 2)
            if self.editable:
                checkbox = QCheckBox("Take it into account")
                checkbox.setChecked(is_in_the_file)
                grid_data_coef.layout.addWidget(checkbox, 1, 4)
            grid_data_coef.layout.addWidget(QLabel(coef2_name), 2, 0)

            # eV
            coef2_line = QLineEditWidthed(coef2, self.editable, "--------------")
            grid_data_coef.layout.addWidget(coef2_line, 2, 1)
            grid_data_coef.layout.addWidget(QLabel(unit2[0]), 2, 2)

            # kJ/mol
            coef2kJmol_line = QLineEditWidthed(coef2kJmol, self.editable, "--------------")
            grid_data_coef.layout.addWidget(coef2kJmol_line, 2, 3)
            grid_data_coef.layout.addWidget(QLabel(unit2[1]), 2, 4)

            # automatic update
            coef2_line.setAutoUpdate(coef2kJmol_line, 1/0.0104)
            coef2kJmol_line.setAutoUpdate(coef2_line, 0.0104)

            textedit = QTextEdit(comment_content)
            textedit.setReadOnly(not self.editable)
            vbox = makeWidget.make_vbox(grid_data_coef, textedit)
            equation_container.setLayout(vbox.layout)
            equations_container.layout.addWidget(equation_container)
コード例 #5
0
ファイル: ShowNewFile.py プロジェクト: mougenj/RD4F-Tool
    def make_vbox_from_data_equation(self, list_data_equation):
        """
            Display equation in a widget.
        """
        equations_container = makeWidget.make_vbox()
        equations_container.setObjectName("equation")
        list_equation_already_written = []

        def fillVboxWithAnything(equations_container, name, coef1, coef2, comment_content, is_in_the_file=True):
            """
                Create a QGroupBox, fill it with the informations contained in
                'name', 'coef1' and 'coef2'.
                Then, add this widget to equations_container.
            """
            coef2kJmol = "None" if coef2 == "None" else "{:.2e}".format(float(coef2)/0.0104)
            equation_container = QGroupBox()
            unit2 = ("(eV)", "(kJ/mol)")
            if name == "D":
                unit1 = "(m²/s)"
                # latex_equation = makeWidget.make_pixmap("ressources/latex_equation_diffusivity_resized.png")
                latex_equation_text = \
                    r"$D = D_0 \cdot e^{-\frac{E_D}{k_B \cdot T}}$"
                latex_equation = mathTex_to_QPixmap(latex_equation_text, 16)
                title = "For interstitial diffusivity"
                objectName = "diffusivity"
                coef1_name = "D_0"
                coef2_name = "E_D"
            elif name == "S":
                unit1 = "(adatome/(m³*Pa½))"  # todo: update it (like JS)
                # latex_equation = makeWidget.make_pixmap("ressources/latex_equation_solubility_resized.png")
                latex_equation_text = \
                    r"$S = S_0 \cdot e^{-\frac{E_S}{k_B \cdot T}}$"
                latex_equation = mathTex_to_QPixmap(latex_equation_text, 16)
                title = "For solubility"
                objectName = "solubility"
                coef1_name = "S_0"
                coef2_name = "E_S"
            elif name == "Kr":
                unit1 = "(m⁴/s)"
                # latex_equation = makeWidget.make_pixmap("ressources/latex_equation_combination_resized.png")
                latex_equation_text = \
                    r"$K_r = K_{r_0} \cdot e^{-\frac{E_r}{k_B \cdot T}}$"
                latex_equation = mathTex_to_QPixmap(latex_equation_text, 16)
                title = "For combination"  # todo: check translation
                objectName = "combination"
                coef1_name = "Kr_0"
                coef2_name = "E_r"
            equation_container.setTitle(title)
            equation_container.setObjectName(objectName)

            grid_data_coef = QWidget()
            grid_data_coef.layout = QGridLayout()
            grid_data_coef.setLayout(grid_data_coef.layout)

            grid_data_coef.layout.addWidget(latex_equation, 0, 0)
            grid_data_coef.layout.addWidget(QLabel(coef1_name), 1, 0)
            grid_data_coef.layout.addWidget(QLineEditWidthed(coef1, self.editable, "--------------"), 1, 1)
            grid_data_coef.layout.addWidget(QLabel(unit1), 1, 2)
            if self.editable:
                checkbox = QCheckBox("Take it into account")
                checkbox.setChecked(is_in_the_file)
                grid_data_coef.layout.addWidget(checkbox, 1, 4)
            grid_data_coef.layout.addWidget(QLabel(coef2_name), 2, 0)

            # eV
            coef2_line = QLineEditWidthed(coef2, self.editable, "--------------")
            grid_data_coef.layout.addWidget(coef2_line, 2, 1)
            grid_data_coef.layout.addWidget(QLabel(unit2[0]), 2, 2)

            # kJ/mol
            coef2kJmol_line = QLineEditWidthed(coef2kJmol, self.editable, "--------------")
            grid_data_coef.layout.addWidget(coef2kJmol_line, 2, 3)
            grid_data_coef.layout.addWidget(QLabel(unit2[1]), 2, 4)

            # automatic update
            coef2_line.setAutoUpdate(coef2kJmol_line, 1/0.0104)
            coef2kJmol_line.setAutoUpdate(coef2_line, 0.0104)

            textedit = QTextEdit(comment_content)
            textedit.setReadOnly(not self.editable)
            vbox = makeWidget.make_vbox(grid_data_coef, textedit)
            equation_container.setLayout(vbox.layout)
            equations_container.layout.addWidget(equation_container)

        for name, c1, c2, comment in list_data_equation:
            coef1 = "None" if c1[1] is None else "{:.2e}".format(float(c1[1]))
            coef2 = "None" if c2[1] is None else "{:.2e}".format(float(c2[1]))
            comment_content = comment[1]
            equation_container = QGroupBox()
            if name == "D" or name == "S" or name == "Kr":
                fillVboxWithAnything(equations_container, name, coef1, coef2, comment_content)
                list_equation_already_written.append(name)
            else:
                print("WARNING : I can't show the equation named", name, "because it is not in ['D', 'S', 'Kr'].")
        # if this ShowNewFile is editable and if some informations is lacking,
        # we must display an empty section so that the user will be able to
        # fill it anyway
        # (if we don't, the section will be missing and the user won't be able
        # to add the lacking infos)
        if self.editable:
            for name in ("D", "S", "Kr"):
                if name not in list_equation_already_written:
                    print("WARNING:", name, "not found in the JSON. I'll add it myself.")
                    fillVboxWithAnything(equations_container, name, "None", "None", "", is_in_the_file=False)

        return equations_container
コード例 #6
0
ファイル: ShowNewFile.py プロジェクト: mougenj/RD4F-Tool
    def __init__(self, parameters, color, editable=False):
        """
            Init the ShowNewFile.
        """
        super().__init__()
        print(parameters)
        self.editable = editable
        """
            Here is a little hack: in the QTreeWidget (see below), we will add
            some QTreeWidgetItem. Each one of them will be removable. But each
            time we remove a QTreeWidgetItem, the index of the QTreeWidgetItem
            below it will be reindexed. So, we need to remember how many
            QTreeWidgetItem were deleted to calculate the old index.
            This is done throught a list. Each time we add a node, we add its
            id to the list. This way, when we delete the node, we search the
            position of its id in the list, and we delete the node at this
            position.
            The same process is used later for the node of other nodes.
        """
        self.nb_created = 0
        self.correspondence_index_position = []

        self.setMinimumSize(690, 500)
        tabs = QTabWidget()
        tabs.setFocusPolicy(Qt.NoFocus)  # prevent the "horrible orange box effect" on Ubuntu
        # set the style
        tabs.setStyleSheet(tabs.styleSheet() + """
        QTabBar::tab:!selected {
            color: rgb(242, 241, 240);
            background-color: rgb(0, 126, 148);
        }

        QTabBar::tab:selected {
            color: rgb(0, 126, 148);
        }
        """)

        # change the background color
        p = self.palette()
        red, green, blue, alpha = color
        p.setColor(self.backgroundRole(), QColor(red, green, blue, alpha))
        self.setPalette(p)

        # get the equation from the file
        list_data_equation = []
        for key in parameters["equation"]:
            if key == "D":
                first_coef_type = "D_0"
                second_coef_type = "E_D"
            elif key == "S":
                first_coef_type = "S_0"
                second_coef_type = "E_S"
            elif key == "Kr":
                first_coef_type = "Kr_0"
                second_coef_type = "E_r"
            

            sorted_coefficients = []
            sorted_coefficients.append(key)
            sorted_coefficients.append((first_coef_type, parameters["equation"][key][first_coef_type]))
            sorted_coefficients.append((second_coef_type, parameters["equation"][key][second_coef_type]))
            comment = parameters["equation"][key].get("comment", "")
            sorted_coefficients.append(("comment", comment))
            list_data_equation.append(sorted_coefficients)

        self.list_data_equation = list_data_equation
        # create a tab based on this informations
        tabs.addTab(makeWidget.make_scroll(self.make_vbox_from_data_equation(list_data_equation)), "Coefficients values")

        """
        # display a nice name for the area
        adatome_name = parameters["material"]["adatome"]
        adatome_name = str(adatome_name) if adatome_name is not None else "None"
        material_name = parameters["material"]["name"]
        material_name = str(material_name) if material_name is not None else "None"
        name_of_area = QLabel("diffusion of " + adatome_name + " in " + material_name)
        myFont=QFont()
        myFont.setBold(True)
        name_of_area.setFont(myFont)
        """

        material_container = makeWidget.make_vbox()
        material_container.setObjectName("material")
        gb_material = QGroupBox()
        gb_material.setTitle("material")
        gb_material.setObjectName("gb_material")
        grid_material = QGridLayout()
        grid_material.setObjectName("grid_material")
        gb_material.layout = grid_material
        gb_material.setLayout(gb_material.layout)

        gb_adatome = QGroupBox()
        gb_adatome.setTitle("adatome")
        gb_adatome.setObjectName("gb_adatome")
        grid_adatome = QGridLayout()
        grid_adatome.setObjectName("grid_adatome")
        gb_adatome.layout = grid_adatome
        gb_adatome.setLayout(gb_adatome.layout)

        material_container.layout.addWidget(gb_adatome)
        material_container.layout.addWidget(gb_material)

        adatome_counter = 0
        for key in ["adatome", "adatome_atomic_number", "adatome_atomic_symbol"]:
            value = ""
            try:
                value = str(parameters["material"][key])
            except KeyError:
                print("There is no key named", key, "in the file loaded, thus it is not possible to diplay this information.")
                if self.editable:
                    value = "None"
            if value:
                line = QLineEditWidthed(value, editable, "--------------")
                grid_adatome.addWidget(QLabel(key), adatome_counter, 0)
                grid_adatome.addWidget(line, adatome_counter, 1);
                adatome_counter += 1

        
        material_counter = 0
                # "name" : None,
        # "atomic_symbol" : None,
        # "lattice_type" : None,
        # "melting_point" : None,
        # "atomic_number" : None,
        # "mean_lattice_constant" : None,
        # "density" : None,

        # "adatome" : None,
        # "adatome_atomic_number" : None,
        # "adatome_atomic_symbol" : None

        keys = ("name", "atomic_symbol", "lattice_type", "melting_point", "atomic_number", "mean_lattice_constant", "density")
        units = ("", "", "", "K", "", "m", "atoms/m³")
        for key, unit in zip(keys, units):
            value = ""
            try:
                value = str(parameters["material"][key])
            except KeyError:
                print("There is no key named", key, "in the file loaded, thus it is not possible to diplay this information.")
                if self.editable:
                    value = "None"
            if value:
                line = QLineEditWidthed(value, editable, "--------------")
                grid_material.addWidget(QLabel(key), material_counter, 0)
                grid_material.addWidget(QLabel("     "), material_counter, 1)  # todo: find a better way to align Qlabels inside the grid
                grid_material.addWidget(line, material_counter, 2)

                if unit:
                    grid_material.addWidget(QLabel("("+unit+")"), material_counter, 3)
                    if key == "density":
                        eq_density = makeWidget.make_pixmap("ressources/latex_equation_density_resized.png")
                        grid_material.addWidget(eq_density, material_counter, 4)
                    else:
                        grid_material.addWidget(QLabel(""), material_counter, 4)
                material_counter += 1

        tabs.addTab(makeWidget.make_scroll(material_container), "Material")

        gridSource = QWidget()
        gridSource.layout = QGridLayout()
        gridSource.setLayout(gridSource.layout)
        gridSource.setObjectName("source")
        i = 0

        self.list_data_source = parameters["source"]
        # last edit
        prop = "last_edit"
        gridSource.layout.addWidget(QLabel(prop), i, 0)
        value = parameters["source"].get("last_edit", get_today_date())
        gridSource.layout.addWidget(QLineEditWidthed(value, False, "2019-07-01 10:56:89"), i, 1)
        i += 1

        # author_name
        prop = "author_name"
        gridSource.layout.addWidget(QLabel(prop), i, 0)
        value = parameters["source"][prop]
        if value is None:
            value = "None"
        elif type(value) is not str:
            value = "{:.2e}".format(float(value))
        gridSource.layout.addWidget(QLineEditWidthed(value, editable, "-------------------------------"), i, 1)
        i += 1

        # DOI
        prop = "doi"
        gridSource.layout.addWidget(QLabel(prop), i, 0)
        doi_api_success = False
        to_insert = None
        if not self.editable:
            try:
                import signal
                from crossref.restful import Works

                class TimeoutException(Exception):
                    pass

                def deadline(timeout, *args):
                    """
                        "decorator of a decorator" that allow the decorator
                        to accept an argument. If the decorated function didn't
                        finish before 'timeout' seconds, then a
                        TimeoutException is raised.
                    """
                    def decorate(f):
                        """ the decorator creation """
                        def handler(signum, frame):
                            """ the handler for the timeout """
                            raise TimeoutException()
                
                        def new_f(*args):
                            """ the initiation of the handler, 
                            the lauch of the function and the end of it"""
                            signal.signal(signal.SIGALRM, handler)
                            signal.alarm(timeout)
                            res = f(*args)
                            signal.alarm(0)
                            return res
                    
                        new_f.__name__ = f.__name__
                        return new_f
                    return decorate

                @deadline(3)
                def request_doi_api():
                    works = Works()
                    address = parameters["source"][prop]
                    data = works.doi(address)
                    if data:
                        value = data["URL"]
                        to_insert = QLabel("<html><a href=\"" + value + "\">" + value + "</a></html>")
                    else:
                        to_insert = None
                    return to_insert
                
                try:
                    # to_insert = request_doi_api()
                    if to_insert:
                        doi_api_success = True
                except TimeoutException:
                    print("time out")
            except Exception as e:
                print(e)
        if not doi_api_success:
            value = parameters["source"][prop]
            if value is None:
                value = "None"
            elif type(value) is not str:
                value = "{:.2e}".format(float(value))
            to_insert = QLineEditWidthed(value, editable, "https://doi.org/10.1016/j.nme.2018.11.020-------------")
        gridSource.layout.addWidget(to_insert, i, 1)
        i += 1
        # YEAR
        prop = "year"
        gridSource.layout.addWidget(QLabel(prop), i, 0)
        value = parameters["source"][prop]
        if value is None:
            value = "None"
        elif type(value) is not str:
            value = str(int(value))
        gridSource.layout.addWidget(QLineEditWidthed(value, editable, "------"), i, 1)
        i += 1

        tabs.addTab(makeWidget.make_scroll(gridSource), "Source")
        
        tree = QTreeWidget()
        tree.setItemsExpandable(False)
        tabs.setStyleSheet(tabs.styleSheet() + """
        QTreeWidget::item {
            margin: 3px 0;
        }
        """)
        if self.editable:
            tree.setColumnCount(4)
            tree.setHeaderLabels([
                "Density",
                "",
                "energy",
                "",
                "frequence",
                "",
                "Delete this trap",
                "Add data to this trap"
            ])
        else:
            tree.setColumnCount(2)
            tree.setHeaderLabels([
                "Density",
                "",
                "energy",
                "",
                "frequence",
                ""
            ])
        tree.header().resizeSection(0, 120)
        tree.header().resizeSection(1, 50)
        tree.header().resizeSection(2, 100)
        tree.header().resizeSection(3, 35)
        tree.header().resizeSection(4, 100)
        tree.header().resizeSection(5, 35)

        tree.header().resizeSection(6, 115)
        tree.header().resizeSection(7, 145)
        tree.header().setStretchLastSection(False)
        tree.setObjectName("traps")
        
        for trap in parameters["traps"]:
            tree_item_for_this_trap = self.create_subtree_for_a_trap(tree, trap)
            for data in trap["data"]:
                self.addEnergyToATrap(tree, tree_item_for_this_trap, data)
        vbox = makeWidget.make_vbox()
        vbox.layout.addWidget(tree)

        if self.editable:
            bt_add_new_trap = QPushButton("Add a trap")
            vbox.layout.addWidget(bt_add_new_trap)
            empty_trap = {"density":None, "angular_frequency":None, "energy":[]}
            bt_add_new_trap.clicked.connect(partial(self.create_subtree_for_a_trap, tree, empty_trap))
        comment = parameters.get("traps-comment", "")
        textedit = QTextEdit(comment)
        textedit.setReadOnly(not self.editable)
        textedit.setObjectName("traps-comment")
        tabs.addTab(makeWidget.make_vbox(vbox, textedit), "Traps")
        
        layout = QVBoxLayout()  # contient les tabs
        layout.addWidget(tabs)
        self.setLayout(layout)
        self.tabs = tabs
コード例 #7
0
ファイル: ReadingPart.py プロジェクト: mougenj/RD4F-Tool
    def __init__(self):
        """
            Init the ReadingPart.Create the UI (the three part) and init the
            validity range.
        """
        super().__init__()
        self.layout = QHBoxLayout()
        self.setLayout(self.layout)

        self.data_onglets = []
        self.data_sources = []
        self.start_validity_range = 300  # K
        self.end_validity_ranges = []  # K
        self.template_validity_range = "validity range : [300; {}]"
        self.validity_range = ""
        self.qlabel_validity_range = QLabel()
        # sauvegarde de la couleur du fond
        color = self.palette().color(QPalette.Background)
        rgba = color.red(), color.green(), color.blue(), color.alpha()
        self.background = rgba

        # LEFT
        tab_left = QTabWidget(tabsClosable=True)

        def CloseTab(i):
            tab_left.removeTab(i)
            self.data_onglets.pop(i)
            self.data_sources.pop(i)
            self.end_validity_ranges.pop(i)
            self.majValidityRange()

        tab_left.tabCloseRequested.connect(CloseTab)
        tab_left.setTabPosition(QTabWidget.West)
        tab_left.setFocusPolicy(Qt.NoFocus)
        tab_left.setObjectName("tab_left")

        trigger_drag = partial(self.open_new_file, tab_left)
        trigger_click = partial(self.on_click_open_files, tab_left)

        # with open("json.txt") as fichier:
        #     self.open_new_file(tab_left, "json.txt", json.loads(fichier.read()))

        self.layout.addWidget(
            make_vbox(tab_left, AddFiles(trigger_drag, trigger_click)))

        bt_d = QPushButton("Diffusion")
        bt_d.clicked.connect(partial(self.on_click_tracer, "D"))
        bt_s = QPushButton("Solubility")
        bt_s.clicked.connect(partial(self.on_click_tracer, "S"))
        bt_kr = QPushButton(
            "Combination coefficients")  # todo: demander pour la traduction
        bt_kr.clicked.connect(partial(self.on_click_tracer, "Kr"))

        hbox = make_vbox()
        for _ in range(10):  # todo: find another way to place the widget down
            hbox.layout.addWidget(QLabel(" "))
            self.majValidityRange()

        button_convert = QPushButton("Convert the file into TMAP")
        button_convert.clicked.connect(
            partial(self.convert_to_other_format, tab_left.currentIndex))
        hbox.layout.addWidget(button_convert)

        button_save = QPushButton("Save into txt file")
        button_save.clicked.connect(self.save_into_txt_file)
        hbox.layout.addWidget(button_save)

        self.qlabel_validity_range.setText(self.validity_range)
        hbox.layout.addWidget(self.qlabel_validity_range)
        hbox.layout.addWidget(QLabel("Coefficients"))
        hbox.layout.addWidget(bt_d)
        hbox.layout.addWidget(bt_s)
        hbox.layout.addWidget(bt_kr)
        self.layout.addWidget(hbox)

        # RIGHT

        # let's add tabs on the right
        self.pltwindows = [PltWindowReading() for _ in range(4)]
        tab_right = QTabWidget()
        tab_right.setFocusPolicy(Qt.NoFocus)
        tab_right.addTab(self.pltwindows[0], "Log - Natural")
        tab_right.addTab(self.pltwindows[1], "Log - 1/T")
        tab_right.addTab(self.pltwindows[2], "Natural - Natural")
        tab_right.addTab(self.pltwindows[3], "Log - Log")
        tab_right.setCurrentIndex(3)
        self.layout.addWidget(tab_right)
コード例 #8
0
ファイル: ReadingPart.py プロジェクト: mougenj/RD4F-Tool
 def make_tab(self):
     return make_vbox()