Skip to content

Commit

Permalink
Merge branch 'main' into release/0.5
Browse files Browse the repository at this point in the history
# Conflicts:
#	src/ansys/aedt/toolkits/common/__init__.py
  • Loading branch information
Samuelopez-ansys committed Jul 8, 2024
2 parents 77a7e6a + 279126f commit 1a66980
Show file tree
Hide file tree
Showing 6 changed files with 235 additions and 2 deletions.
8 changes: 8 additions & 0 deletions examples/toolkit/pyaedt_toolkit/ui/frontend_properties.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@ btn_tooltip= "Design"
show_top= true
is_active= false

[[defaults.add_left_menus]]
btn_icon= "help.svg"
btn_id= "help_menu"
btn_text= "Help"
btn_tooltip= "Help"
show_top= false
is_active= false

[[defaults.add_left_menus]]
btn_icon= "icon_log.svg"
btn_id= "progress_menu"
Expand Down
24 changes: 24 additions & 0 deletions examples/toolkit/pyaedt_toolkit/ui/run_frontend.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
# New windows
from windows.create_geometry.geometry_menu import GeometryMenu
from windows.plot_design.plot_design_menu import PlotDesignMenu
from windows.help.help_menu import HelpMenu

# Common windows
from ansys.aedt.toolkits.common.ui.main_window.main_window_layout import MainWindowLayout
Expand Down Expand Up @@ -102,6 +103,11 @@ def __init__(self):
self.plot_design_menu.setup()
self.ui.left_menu.clicked.connect(self.plot_design_menu_clicked)

# Help menu
self.plot_design_menu = HelpMenu(self)
self.plot_design_menu.setup()
self.ui.left_menu.clicked.connect(self.help_menu_clicked)

# Home page as first page
self.ui.set_page(self.ui.load_pages.home_page)

Expand Down Expand Up @@ -142,6 +148,24 @@ def plot_design_menu_clicked(self):
if not is_left_visible:
self.ui.toggle_left_column()

def help_menu_clicked(self):
selected_menu = self.ui.get_selected_menu()
menu_name = selected_menu.objectName()

if menu_name == "help_menu":
selected_menu.set_active(True)
self.ui.set_page(self.plot_design_menu.plot_design_menu_widget)

self.ui.set_left_column_menu(
menu=self.plot_design_menu.plot_design_column_widget,
title="Help",
icon_path=self.ui.images_load.icon_path("help.svg"),
)

is_left_visible = self.ui.is_left_column_visible()
if not is_left_visible:
self.ui.toggle_left_column()


if __name__ == "__main__":
app = QApplication(sys.argv)
Expand Down
Empty file.
125 changes: 125 additions & 0 deletions examples/toolkit/pyaedt_toolkit/ui/windows/help/help_menu.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
from PySide6 import QtCore, QtGui, QtWidgets
from PySide6.QtWidgets import QLabel
from PySide6.QtWidgets import QGridLayout
from PySide6.QtWidgets import QWidget
from windows.plot_design.plot_design_column import Ui_LeftColumn
from windows.plot_design.plot_design_page import Ui_Plot_Design

import tempfile
from ansys.aedt.toolkits.common import __version__

ABOUT_TEXT = f"""<h2>PyAEDT Common Toolkit {__version__}</h2>
<p>Project using <a href='https://wiki.qt.io/Qt_for_Python'> PySide6</a>.</p>
<p>If you have any questions or issues, please open an issue in <a href='https://github.com/ansys/pyaedt-toolkits-common/issues'>pyaedt-toolkits-common Issues</a> page.</p>
<p>Alternatively, you can contact us at <a href='mailto:[email protected]'>[email protected]</a>.</p>
<p>Your use of this software is governed by the MIT License. In addition, this package allows you to access a software that is licensed under separate terms ("Separately Licensed Software"). If you chose to install such Separately Licensed Software, you acknowledge that you are responsible for complying with any associated terms and conditions.</p>
<p>Copyright 2023 - 2024 ANSYS, Inc. All rights reserved.</p>
"""
DOCUMENTATION_URL = "https://aedt.common.toolkit.docs.pyansys.com/"
ISSUE_TRACKER_URL = "https://github.com/ansys/pyaedt-toolkits-common/issues"


class HelpMenu(object):
def __init__(self, main_window):
# General properties
self.main_window = main_window
self.ui = main_window.ui
self.temp_folder = tempfile.mkdtemp()

# Add page
plot_design_menu_index = self.ui.add_page(Ui_Plot_Design)
self.ui.load_pages.pages.setCurrentIndex(plot_design_menu_index)
self.plot_design_menu_widget = self.ui.load_pages.pages.currentWidget()

# Add left column
new_column_widget = QWidget()
new_ui = Ui_LeftColumn()
new_ui.setupUi(new_column_widget)
self.ui.left_column.menus.menus.addWidget(new_column_widget)
self.plot_design_column_widget = new_column_widget
self.plot_design_column_vertical_layout = new_ui.plot_design_vertical_layout

# Specific properties
self.plot_design_label = self.plot_design_menu_widget.findChild(QLabel, "plot_design_label")
self.plot_design_grid = self.plot_design_menu_widget.findChild(QGridLayout, "plot_design_grid")

self.plot_design_button_layout = None
self.plot_design_button = None
self.online_documentation_button = None
self.issue_tracker_button = None

def setup(self):
# Modify theme
app_color = self.main_window.ui.themes["app_color"]
text_color = app_color["text_active"]
background = app_color["dark_three"]

# Label button
plot_design_label_style = """
QLabel {{
color: {_color};
font-size: {_font_size}pt;
font-weight: bold;
}}
"""
custom_style = plot_design_label_style.format(
_color=text_color, _bg_color=background, _font_size=self.main_window.properties.font["title_size"]
)
self.plot_design_label.setStyleSheet(custom_style)

# Set column

# About button
row_returns = self.ui.add_n_buttons(
self.plot_design_column_vertical_layout, num_buttons=1,
height=40,
width=[200],
text=["About"],
font_size=self.main_window.properties.font["title_size"]
)
self.plot_design_button_layout = row_returns[0]
self.plot_design_button = row_returns[1]
self.plot_design_button_layout.addWidget(self.plot_design_button)
self.plot_design_button.clicked.connect(self.about_button_clicked)

# Documentation button
row_returns = self.ui.add_n_buttons(
self.plot_design_column_vertical_layout, num_buttons=1,
height=40,
width=[200],
text=["Documentation website"],
font_size=self.main_window.properties.font["title_size"]
)
self.plot_design_button_layout = row_returns[0]
self.online_documentation_button = row_returns[1]
self.plot_design_button_layout.addWidget(self.online_documentation_button)
self.online_documentation_button.clicked.connect(self.visit_website)

# Issue tracker button
row_returns = self.ui.add_n_buttons(
self.plot_design_column_vertical_layout, num_buttons=1,
height=40,
width=[200],
text=["Issue tracker"],
font_size=self.main_window.properties.font["title_size"]
)

self.plot_design_button_layout = row_returns[0]
self.issue_tracker_button = row_returns[1]
self.plot_design_button_layout.addWidget(self.issue_tracker_button)
self.issue_tracker_button.clicked.connect(self.report_issue)

def about_button_clicked(self):
"""Display the PyAEDT Common Toolkit 'About' information."""

mbox = QtWidgets.QMessageBox.about(self.main_window, "About", ABOUT_TEXT)

def visit_website(self):
"""Access the PyAEDT Common Toolkit documentation."""
url = QtCore.QUrl(DOCUMENTATION_URL)
QtGui.QDesktopServices.openUrl(url)

def report_issue(self):
"""Access the PyAEDT Common Toolkit issues tracker."""
url = QtCore.QUrl(ISSUE_TRACKER_URL)
QtGui.QDesktopServices.openUrl(url)
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ classifiers = [
]
dependencies = [
"build==1.2.1",
"twine==5.1.0",
"twine==5.1.1",
"pyaedt>=0.8.0,<0.10",
"pydantic",
"tomli; python_version < '3.12'",
Expand Down Expand Up @@ -59,7 +59,7 @@ doc = [
"nbsphinx>=0.9.0,<0.10",
"sphinx_design",
"jupytext",
"ipython>=8.13.0,<8.26",
"ipython>=8.13.0,<8.27",
"jupyterlab>=4.0.0,<4.3",
"pypandoc>=1.10.0,<1.14",
]
Expand Down
76 changes: 76 additions & 0 deletions src/ansys/aedt/toolkits/common/ui/utils/images/icons/help.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 1a66980

Please sign in to comment.