Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/pip/jupyterlab-gte-4.0.0-and-lt-4.4
Browse files Browse the repository at this point in the history
  • Loading branch information
Samuelopez-ansys authored Nov 6, 2024
2 parents 8d93277 + a24f7fc commit b569546
Show file tree
Hide file tree
Showing 14 changed files with 196 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci_cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion doc/source/examples/aedt_common/api_aedt_connect_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
#
Expand Down
4 changes: 3 additions & 1 deletion doc/source/examples/aedt_common/api_aedt_open_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
#
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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]
)

Expand All @@ -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(
Expand All @@ -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]
)

Expand All @@ -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]
)

Expand Down Expand Up @@ -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)
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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__(
Expand All @@ -41,6 +42,7 @@ def __init__(
bg_color="#333",
bg_color_active="#222",
context_color="#00ABE8",
font_size=12,
):
super().__init__()

Expand All @@ -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.
Expand All @@ -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(
Expand All @@ -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)
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down
21 changes: 21 additions & 0 deletions src/ansys/aedt/toolkits/common/ui/utils/widgets/py_tab/__init__.py
Original file line number Diff line number Diff line change
@@ -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.
29 changes: 29 additions & 0 deletions src/ansys/aedt/toolkits/common/ui/utils/widgets/py_tab/py_tab.py
Original file line number Diff line number Diff line change
@@ -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)
21 changes: 21 additions & 0 deletions src/ansys/aedt/toolkits/common/ui/utils/widgets/py_tab/styles.py
Original file line number Diff line number Diff line change
@@ -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;
}}
"""
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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):
"""
Expand Down

0 comments on commit b569546

Please sign in to comment.