diff --git a/.github/workflows/ci_cd.yml b/.github/workflows/ci_cd.yml index 65fd773e..1355140d 100644 --- a/.github/workflows/ci_cd.yml +++ b/.github/workflows/ci_cd.yml @@ -49,7 +49,7 @@ jobs: name: "Build documentation" runs-on: [self-hosted, pyaedt, toolkits, Windows] needs: [ doc-style ] - timeout-minutes: 10 + timeout-minutes: 20 steps: - name: Build documentation uses: ansys/actions/doc-build@v8 diff --git a/doc/source/examples/aedt_common/api_aedt_connect_session.py b/doc/source/examples/aedt_common/api_aedt_connect_session.py index 2063c1c1..9e2af782 100644 --- a/doc/source/examples/aedt_common/api_aedt_connect_session.py +++ b/doc/source/examples/aedt_common/api_aedt_connect_session.py @@ -8,6 +8,7 @@ # # Perform the required imports. +import os import sys from ansys.aedt.toolkits.common.backend.api import AEDTCommon import ansys.aedt.core @@ -85,7 +86,10 @@ # Create a waveguide in the design. wg = toolkit.aedtapp.modeler.create_waveguide([0, 0, 0], 1) -toolkit.aedtapp.plot() +model = toolkit.aedtapp.plot(show=False) +model.show_grid = False +model.plot(os.path.join(toolkit.aedtapp.working_directory, "Image.jpg")) + # ## Save and release AEDT # diff --git a/doc/source/examples/aedt_common/api_aedt_open_project.py b/doc/source/examples/aedt_common/api_aedt_open_project.py index fc9c1f24..1c557493 100644 --- a/doc/source/examples/aedt_common/api_aedt_open_project.py +++ b/doc/source/examples/aedt_common/api_aedt_open_project.py @@ -79,7 +79,9 @@ toolkit.logger.info("Create Box") box = toolkit.aedtapp.modeler.create_box([10, 10, 10], [20, 20, 20]) -box.plot() +model = box.plot(show=False) +model.show_grid = False +model.plot(os.path.join(toolkit.aedtapp.working_directory, "Image.jpg")) # ## Save and release AEDT # diff --git a/pyproject.toml b/pyproject.toml index 707950be..f2355d5b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -50,7 +50,7 @@ doc = [ "pyaedt[all]>=0.10.0,<0.12", "recommonmark>=0.7.0,<0.8", "pyside6==6.7.3", - "ansys-sphinx-theme>=0.10.0,<1.2", + "ansys-sphinx-theme>=0.10.0,<1.3", "numpydoc>=1.5.0,<1.9", "Sphinx>=7.1.0,<8.2", "sphinx-copybutton>=0.5.0,<0.6", diff --git a/src/ansys/aedt/toolkits/common/ui/common_windows/settings_column.py b/src/ansys/aedt/toolkits/common/ui/common_windows/settings_column.py index 244aa716..9c28fd55 100644 --- a/src/ansys/aedt/toolkits/common/ui/common_windows/settings_column.py +++ b/src/ansys/aedt/toolkits/common/ui/common_windows/settings_column.py @@ -71,6 +71,11 @@ def __init__(self, main_window): self.aedt_thread = None + self.line1 = None + self.line2 = None + self.line3 = None + self.line4 = None + def setup(self): font_size = self.main_window.properties.font["title_size"] # Version row @@ -92,7 +97,7 @@ def setup(self): self.aedt_version.currentTextChanged.connect(lambda: self.process_id()) # Add line - self.ui.add_vertical_line( + self.line1 = self.ui.add_vertical_line( self.ui.right_column.menus.settings_vertical_layout, top_spacer=[0, 10], bot_spacer=[0, 10] ) @@ -111,7 +116,7 @@ def setup(self): self.aedt_session = row_returns[2] # Add line - self.ui.add_vertical_line(self.ui.right_column.menus.settings_vertical_layout, [0, 10], [0, 20]) + self.line2 = self.ui.add_vertical_line(self.ui.right_column.menus.settings_vertical_layout, [0, 10], [0, 20]) # Non-graphical row_returns = self.ui.add_toggle( @@ -128,7 +133,7 @@ def setup(self): self.non_graphical_label = row_returns[3] # Add line - self.ui.add_vertical_line( + self.line3 = self.ui.add_vertical_line( self.ui.right_column.menus.settings_vertical_layout, top_spacer=[0, 10], bot_spacer=[0, 10] ) @@ -148,7 +153,7 @@ def setup(self): self.browse.clicked.connect(lambda: self.browse_file()) # Add line - self.ui.add_vertical_line( + self.line4 = self.ui.add_vertical_line( self.ui.right_column.menus.settings_vertical_layout, top_spacer=[0, 10], bot_spacer=[0, 10] ) @@ -249,3 +254,37 @@ def browse_file(self): ) if file != "": self.file.setText(file) + + def hide_widgets(self): + self.aedt_session.setVisible(False) + self.aedt_session_label.setVisible(False) + self.aedt_version.setVisible(False) + self.aedt_version_label.setVisible(False) + self.browse.setVisible(False) + self.connect_aedt.setVisible(False) + self.file.setVisible(False) + self.graphical_label.setVisible(False) + self.non_graphical_label.setVisible(False) + self.graphical_mode.setVisible(False) + + self.line1.setVisible(False) + self.line2.setVisible(False) + self.line3.setVisible(False) + self.line4.setVisible(False) + + def show_widgets(self): + self.aedt_session.setVisible(True) + self.aedt_session_label.setVisible(True) + self.aedt_version.setVisible(True) + self.aedt_version_label.setVisible(True) + self.browse.setVisible(True) + self.connect_aedt.setVisible(True) + self.file.setVisible(True) + self.graphical_label.setVisible(True) + self.non_graphical_label.setVisible(True) + self.graphical_mode.setVisible(True) + + self.line1.setVisible(True) + self.line2.setVisible(True) + self.line3.setVisible(True) + self.line4.setVisible(True) diff --git a/src/ansys/aedt/toolkits/common/ui/main_window/main_window_layout.py b/src/ansys/aedt/toolkits/common/ui/main_window/main_window_layout.py index 83d98fa8..b381fd05 100644 --- a/src/ansys/aedt/toolkits/common/ui/main_window/main_window_layout.py +++ b/src/ansys/aedt/toolkits/common/ui/main_window/main_window_layout.py @@ -436,6 +436,7 @@ def main_clicked(self): self.toggle_left_column() elif selected_menu.objectName() == "top_settings" and not is_right_visible: + self.app.settings_menu.show_widgets() if is_left_visible: self.toggle_left_column() self.toggle_right_column() diff --git a/src/ansys/aedt/toolkits/common/ui/utils/widgets/__init__.py b/src/ansys/aedt/toolkits/common/ui/utils/widgets/__init__.py index 41bebfd6..5b7f1dc8 100644 --- a/src/ansys/aedt/toolkits/common/ui/utils/widgets/__init__.py +++ b/src/ansys/aedt/toolkits/common/ui/utils/widgets/__init__.py @@ -35,6 +35,7 @@ from ansys.aedt.toolkits.common.ui.utils.widgets.py_push_button.py_push_button import PyPushButton from ansys.aedt.toolkits.common.ui.utils.widgets.py_right_column.py_right_column import PyRightColumn from ansys.aedt.toolkits.common.ui.utils.widgets.py_slider.py_slider import PySlider +from ansys.aedt.toolkits.common.ui.utils.widgets.py_tab.py_tab import PyTab from ansys.aedt.toolkits.common.ui.utils.widgets.py_title_bar.py_title_bar import PyTitleBar from ansys.aedt.toolkits.common.ui.utils.widgets.py_toggle.py_toggle import PyToggle from ansys.aedt.toolkits.common.ui.utils.widgets.py_window.py_window import PyWindow diff --git a/src/ansys/aedt/toolkits/common/ui/utils/widgets/py_combo_box/py_combo_box.py b/src/ansys/aedt/toolkits/common/ui/utils/widgets/py_combo_box/py_combo_box.py index 819dbddd..2758def1 100644 --- a/src/ansys/aedt/toolkits/common/ui/utils/widgets/py_combo_box/py_combo_box.py +++ b/src/ansys/aedt/toolkits/common/ui/utils/widgets/py_combo_box/py_combo_box.py @@ -23,7 +23,7 @@ class PyComboBox(QComboBox): Background color when mouse hovers over the combo box. The default is ``"#FFFFFF"``. text_color : str, optional Text color in the combo box. The default is ``"#000000"``. - font_size : int + font_size : int, optional The font size of the text on the button. Examples diff --git a/src/ansys/aedt/toolkits/common/ui/utils/widgets/py_line_edit/py_line_edit.py b/src/ansys/aedt/toolkits/common/ui/utils/widgets/py_line_edit/py_line_edit.py index ca4c0814..afab1826 100644 --- a/src/ansys/aedt/toolkits/common/ui/utils/widgets/py_line_edit/py_line_edit.py +++ b/src/ansys/aedt/toolkits/common/ui/utils/widgets/py_line_edit/py_line_edit.py @@ -27,7 +27,8 @@ class PyLineEdit(QLineEdit): The background color of the line edit when active. Default is "#222" (darker gray). context_color : str, optional The color representing a context or active state. Default is "#00ABE8" (blue). - + font_size : int, optional + The font size of the text on the button. """ def __init__( @@ -41,6 +42,7 @@ def __init__( bg_color="#333", bg_color_active="#222", context_color="#00ABE8", + font_size=12, ): super().__init__() @@ -49,9 +51,13 @@ def __init__( if place_holder_text: self.setPlaceholderText(place_holder_text) - self.set_stylesheet(radius, border_size, color, selection_color, bg_color, bg_color_active, context_color) + self.set_stylesheet( + radius, border_size, color, selection_color, bg_color, bg_color_active, context_color, font_size + ) - def set_stylesheet(self, radius, border_size, color, selection_color, bg_color, bg_color_active, context_color): + def set_stylesheet( + self, radius, border_size, color, selection_color, bg_color, bg_color_active, context_color, font_size + ): """ Set the stylesheet for the PyLineEdit. @@ -71,6 +77,8 @@ def set_stylesheet(self, radius, border_size, color, selection_color, bg_color, Background color when the line edit is active. context_color : str Color representing a context or active state. + font_size : int + The font size of the text on the button. """ style_format = Styles.style.format( @@ -81,5 +89,6 @@ def set_stylesheet(self, radius, border_size, color, selection_color, bg_color, _bg_color=bg_color, _bg_color_active=bg_color_active, _context_color=context_color, + _font_size=font_size, ) self.setStyleSheet(style_format) diff --git a/src/ansys/aedt/toolkits/common/ui/utils/widgets/py_line_edit/styles.py b/src/ansys/aedt/toolkits/common/ui/utils/widgets/py_line_edit/styles.py index a2dcf0a5..1c7e9b7d 100644 --- a/src/ansys/aedt/toolkits/common/ui/utils/widgets/py_line_edit/styles.py +++ b/src/ansys/aedt/toolkits/common/ui/utils/widgets/py_line_edit/styles.py @@ -9,6 +9,7 @@ class Styles(object): selection-color: {_selection_color}; selection-background-color: {_context_color}; color: {_color}; + font-size: {_font_size}pt; }} QLineEdit:focus {{ border: {_border_size}px solid {_context_color}; diff --git a/src/ansys/aedt/toolkits/common/ui/utils/widgets/py_tab/__init__.py b/src/ansys/aedt/toolkits/common/ui/utils/widgets/py_tab/__init__.py new file mode 100644 index 00000000..3bc3c8e5 --- /dev/null +++ b/src/ansys/aedt/toolkits/common/ui/utils/widgets/py_tab/__init__.py @@ -0,0 +1,21 @@ +# Copyright (C) 2023 - 2024 ANSYS, Inc. and/or its affiliates. +# SPDX-License-Identifier: MIT +# +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. diff --git a/src/ansys/aedt/toolkits/common/ui/utils/widgets/py_tab/py_tab.py b/src/ansys/aedt/toolkits/common/ui/utils/widgets/py_tab/py_tab.py new file mode 100644 index 00000000..82b78588 --- /dev/null +++ b/src/ansys/aedt/toolkits/common/ui/utils/widgets/py_tab/py_tab.py @@ -0,0 +1,29 @@ +from PySide6.QtWidgets import QTabWidget + +from ansys.aedt.toolkits.common.ui.utils.widgets.py_tab.styles import Styles + + +class PyTab(QTabWidget): + """ + Initialize the PyTab. + + Parameters + ---------- + color : str + The pane color. + text_color : str + The text color. + selected_color : int + The color of the selected tab. + unselected_color : str + The color of the unselected tab. + """ + + def __init__(self, color, text_color, selected_color, unselected_color): + super().__init__() + + # SET STYLESHEET + custom_style = Styles.style.format( + _color=color, _unselected_color=unselected_color, _selected_color=selected_color, _text_color=text_color + ) + self.setStyleSheet(custom_style) diff --git a/src/ansys/aedt/toolkits/common/ui/utils/widgets/py_tab/styles.py b/src/ansys/aedt/toolkits/common/ui/utils/widgets/py_tab/styles.py new file mode 100644 index 00000000..4816bfc5 --- /dev/null +++ b/src/ansys/aedt/toolkits/common/ui/utils/widgets/py_tab/styles.py @@ -0,0 +1,21 @@ +class Styles(object): + style = """ + QTabWidget::pane {{ + border: 1px solid #21252d; + top:-1px; + background: {_color}; + }} + QTabBar::tab {{ + background: {_unselected_color}; + border: 1px solid #21252d; + border-top-left-radius: 7px; + border-top-right-radius: 7px; + padding: 5px; + color: {_text_color}; + }} + + QTabBar::tab:selected {{ + background: {_selected_color}; + margin-bottom: -1px; + }} + """ diff --git a/src/ansys/aedt/toolkits/common/ui/utils/windows/common_window_utils.py b/src/ansys/aedt/toolkits/common/ui/utils/windows/common_window_utils.py index 8bf6071a..2a0f7e21 100644 --- a/src/ansys/aedt/toolkits/common/ui/utils/windows/common_window_utils.py +++ b/src/ansys/aedt/toolkits/common/ui/utils/windows/common_window_utils.py @@ -215,6 +215,61 @@ def add_combobox(self, layout, height=40, width=None, label="label1", combobox_l return [layout_row, label_widget, combobox_widget] + def add_textbox(self, layout, height=40, width=None, label="label1", initial_text=None, font_size=12): + """ + Adds a label and textbox to a layout. + + Parameters + ---------- + layout: QLayout + The layout object to which the label and combobox will be added. + height: int, optional + The height of the label and combobox widgets. Default is 40. + width: list, optional + The width of the label and combobox widgets. If not provided, a default width of [100, 100] will be used. + label: str, optional + The text to be displayed on the label widget. Default is '"label1"'. + initial_text: str, optional + Text to be displayed in the textbox. + font_size: int, optional + The font size of the label widget. Default is 12. + + Returns + ------- + list + A list containing the layout row object, label object, and combobox object. + """ + initial_text = initial_text or " " + width = width or [100, 100] + + app_color = self.themes["app_color"] + text_foreground = app_color["text_foreground"] + bg_color = app_color["combo_color"] + + layout_row = QHBoxLayout() + layout.addLayout(layout_row) + + label_widget = PyLabel(text=label, font_size=font_size, color=text_foreground) + label_widget.setMinimumHeight(height) + label_widget.setFixedWidth(width[0]) + layout_row.addWidget(label_widget) + + linebox_widget = PyLineEdit( + text=initial_text, + radius=8, + bg_color=bg_color, + color=text_foreground, + selection_color=app_color["white"], + bg_color_active=app_color["dark_three"], + context_color=app_color["context_color"], + font_size=font_size, + ) + linebox_widget.setMinimumHeight(height) + linebox_widget.setFixedWidth(width[1]) + layout_row.addWidget(linebox_widget) + + return [layout_row, label_widget, linebox_widget] + def add_toggle(self, layout, height=40, width=None, label=None, font_size=12): """ Add a label and a toggle button to a specified layout. @@ -407,7 +462,7 @@ def add_vertical_line(self, layout, top_spacer=None, bot_spacer=None): spacer = QSpacerItem(bot_spacer[0], bot_spacer[1], QSizePolicy.Minimum, QSizePolicy.Minimum) layout.addItem(spacer) - return True + return line def toggle_left_column(self): """