diff --git a/MANIFEST.in b/MANIFEST.in index ce996f6c4ffcc6a70d095c24ed296ec3b69e5f43..96b265fd04394abbdbf033028b46c98619817869 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,4 +1,5 @@ include README.md include LICENSE include CMakeLists.txt +include b_asic/GUI/operation_icons/* recursive-include src *.cpp *.h diff --git a/b_asic/GUI/__init__.py b/b_asic/GUI/__init__.py index 16dd0253b1690cef57efa5a25f5adf28f53646f7..0b0902af19e41d0855dd13d5cea45ceb950a082b 100644 --- a/b_asic/GUI/__init__.py +++ b/b_asic/GUI/__init__.py @@ -1,4 +1,15 @@ -"""TODO""" -from drag_button import * -from improved_main_window import * -from gui_interface import * +""" +Better ASIC Toolbox GUI. +TODO: More info. +""" +from b_asic.GUI.main_window import * +from b_asic.GUI.about_window import * +from b_asic.GUI.arrow import * +from b_asic.GUI.drag_button import * +from b_asic.GUI.gui_interface import * +from b_asic.GUI.port_button import * +from b_asic.GUI.properties_window import * +from b_asic.GUI.select_sfg_window import * +from b_asic.GUI.show_pc_window import * +from b_asic.GUI.simulate_sfg_window import * +from b_asic.GUI.utils import * diff --git a/b_asic/GUI/arrow.py b/b_asic/GUI/arrow.py index badb1f0b80e11d86b73a26757d9554d3c01c4b54..7df52d052a209921b6592d3dd581a8fe3cefd83e 100644 --- a/b_asic/GUI/arrow.py +++ b/b_asic/GUI/arrow.py @@ -5,7 +5,7 @@ QGraphicsLineItem, QGraphicsWidget from PySide2.QtCore import Qt, QSize, QLineF, QPoint, QRectF from PySide2.QtGui import QIcon, QFont, QPainter, QPen -from b_asic import Signal +from b_asic.signal import Signal class Arrow(QGraphicsLineItem): diff --git a/b_asic/GUI/drag_button.py b/b_asic/GUI/drag_button.py index 6d5c47c39adb5c06147abf505bea17e04808b4a9..d300315f0217f203bf1c849ce04d614fddfc87e1 100644 --- a/b_asic/GUI/drag_button.py +++ b/b_asic/GUI/drag_button.py @@ -5,14 +5,13 @@ This class creates a dragbutton which can be clicked, dragged and dropped. import os.path -from properties_window import PropertiesWindow +from b_asic.GUI.properties_window import PropertiesWindow +from b_asic.GUI.utils import decorate_class, handle_error from PySide2.QtWidgets import QPushButton, QMenu, QAction from PySide2.QtCore import Qt, QSize, Signal from PySide2.QtGui import QIcon -from utils import decorate_class, handle_error - @decorate_class(handle_error) class DragButton(QPushButton): @@ -93,7 +92,7 @@ class DragButton(QPushButton): self.pressed = not pressed self.setStyleSheet(f"background-color: {'white' if not self.pressed else 'grey'}; border-style: solid;\ border-color: black; border-width: 2px") - path_to_image = os.path.join('operation_icons', f"{self.operation_path_name}{'_grey.png' if self.pressed else '.png'}") + path_to_image = os.path.join(os.path.dirname(__file__), 'operation_icons', f"{self.operation_path_name}{'_grey.png' if self.pressed else '.png'}") self.setIcon(QIcon(path_to_image)) self.setIconSize(QSize(55, 55)) diff --git a/b_asic/GUI/main_window.py b/b_asic/GUI/main_window.py index 239bbbec80bd0e8d96af6d1606702748db8a7ccd..5c78e69d8ba78ec43f417af2f6b106c06909f194 100644 --- a/b_asic/GUI/main_window.py +++ b/b_asic/GUI/main_window.py @@ -7,23 +7,26 @@ from pprint import pprint from os import getcwd, path import importlib import logging -logging.basicConfig(level=logging.INFO) import sys -from about_window import AboutWindow, FaqWindow, KeybindsWindow -from drag_button import DragButton -from gui_interface import Ui_main_window -from arrow import Arrow -from port_button import PortButton -from show_pc_window import ShowPCWindow - +from b_asic.GUI.about_window import AboutWindow, FaqWindow, KeybindsWindow +from b_asic.GUI.drag_button import DragButton +from b_asic.GUI.gui_interface import Ui_main_window +from b_asic.GUI.arrow import Arrow +from b_asic.GUI.port_button import PortButton +from b_asic.GUI.show_pc_window import ShowPCWindow +from b_asic.GUI.utils import decorate_class, handle_error +from b_asic.GUI.simulate_sfg_window import SimulateSFGWindow, Plot +from b_asic.GUI.select_sfg_window import SelectSFGWindow + +from b_asic import FastSimulation from b_asic.simulation import Simulation -from b_asic import Operation, SFG, InputPort, OutputPort, Input, Output, FastSimulation +from b_asic.operation import Operation +from b_asic.port import InputPort, OutputPort +from b_asic.signal_flow_graph import SFG +from b_asic.special_operations import Input, Output import b_asic.core_operations as c_oper import b_asic.special_operations as s_oper -from utils import decorate_class, handle_error -from simulate_sfg_window import SimulateSFGWindow, Plot -from select_sfg_window import SelectSFGWindow from b_asic.save_load_structure import * from numpy import linspace @@ -36,12 +39,11 @@ QGraphicsProxyWidget, QInputDialog, QTextEdit, QFileDialog from PySide2.QtCore import Qt, QSize, QFileInfo from PySide2.QtGui import QIcon, QFont, QPainter, QPen, QBrush, QKeySequence -from tkinter import Tk -from tkinter.filedialog import askopenfilename, askopenfile - MIN_WIDTH_SCENE = 600 MIN_HEIGHT_SCENE = 520 +logging.basicConfig(level=logging.INFO) + @decorate_class(handle_error) class MainWindow(QMainWindow): @@ -387,9 +389,9 @@ class MainWindow(QMainWindow): border-color: black; border-width: 2px") self.add_ports(attr_button) - icon_path = path.join("operation_icons", f"{op.type_name().lower()}.png") + icon_path = path.join(path.dirname(__file__), "operation_icons", f"{op.type_name().lower()}.png") if not path.exists(icon_path): - icon_path = path.join("operation_icons", f"custom_operation.png") + icon_path = path.join(path.dirname(__file__), "operation_icons", f"custom_operation.png") attr_button.setIcon(QIcon(icon_path)) attr_button.setIconSize(QSize(55, 55)) attr_button.setToolTip("No sfg") @@ -532,8 +534,13 @@ class MainWindow(QMainWindow): self.keybinds_page.show() -if __name__ == "__main__": +def start_gui(): app = QApplication(sys.argv) window = MainWindow() window.show() sys.exit(app.exec_()) + + +if __name__ == "__main__": + start_gui() + diff --git a/b_asic/GUI/port_button.py b/b_asic/GUI/port_button.py index 06e1ee455a8ab0b7ad7552e18bf0bec6733a83aa..a856b618578c6e271c8717a7e9d6e2bb78a62b67 100644 --- a/b_asic/GUI/port_button.py +++ b/b_asic/GUI/port_button.py @@ -4,6 +4,7 @@ import sys from PySide2.QtWidgets import QPushButton, QMenu from PySide2.QtCore import Qt, Signal + class PortButton(QPushButton): connectionRequested = Signal(QPushButton) moved = Signal() diff --git a/b_asic/GUI/properties_window.py b/b_asic/GUI/properties_window.py index 580ce409bbe30ec2ec74ddcda542168dc4d7985c..3c690517d446b9131df63d06413698e25e13820e 100644 --- a/b_asic/GUI/properties_window.py +++ b/b_asic/GUI/properties_window.py @@ -3,6 +3,7 @@ QLabel, QCheckBox, QGridLayout from PySide2.QtCore import Qt from PySide2.QtGui import QDoubleValidator + class PropertiesWindow(QDialog): def __init__(self, operation, main_window): super(PropertiesWindow, self).__init__() diff --git a/b_asic/GUI/show_pc_window.py b/b_asic/GUI/show_pc_window.py index 5952ca991c70a4a466183900adab6f0fb39610a1..1cc879397f726c343350ea33483e5850404b851b 100644 --- a/b_asic/GUI/show_pc_window.py +++ b/b_asic/GUI/show_pc_window.py @@ -1,8 +1,9 @@ +from b_asic.signal_flow_graph import SFG + from PySide2.QtWidgets import QDialog, QPushButton, QVBoxLayout, QCheckBox,\ QFrame, QFormLayout from PySide2.QtCore import Qt, Signal -from b_asic import SFG class ShowPCWindow(QDialog): pc = Signal() @@ -45,4 +46,4 @@ class ShowPCWindow(QDialog): self._window.sfg_dict[sfg].show_precedence_graph() self.accept() - self.pc.emit() \ No newline at end of file + self.pc.emit() diff --git a/b_asic/save_load_structure.py b/b_asic/save_load_structure.py index 8c416b8643a127c2b07754934050a3eb54f8dfc0..165461236beb47cdba624bcb01eb5ba6609f5ef3 100644 --- a/b_asic/save_load_structure.py +++ b/b_asic/save_load_structure.py @@ -4,7 +4,8 @@ Given a structure try to serialize it and save it to a file. Given a serialized file try to deserialize it and load it to the library. """ -from b_asic import SFG, GraphComponent +from b_asic.signal_flow_graph import SFG +from b_asic.graph_component import GraphComponent from datetime import datetime from inspect import signature @@ -76,4 +77,4 @@ def python_to_sfg(path: str) -> SFG: code = compile(f.read(), path, 'exec') exec(code, globals(), locals()) - return locals()["prop"]["name"], locals()["positions"] if "positions" in locals() else {} \ No newline at end of file + return locals()["prop"]["name"], locals()["positions"] if "positions" in locals() else {} diff --git a/setup.py b/setup.py index 0568514756180c02b81a7b323789fb72a6e5bf26..37a143a1ccdf4de1fd8b35d31c2d67e6cb1f78b3 100644 --- a/setup.py +++ b/setup.py @@ -76,8 +76,9 @@ setuptools.setup( "graphviz", "matplotlib" ], - packages = ["b_asic"], + packages = ["b_asic", "b_asic/GUI"], ext_modules = [CMakeExtension("b_asic")], cmdclass = {"build_ext": CMakeBuild}, - zip_safe = False + zip_safe = False, + include_package_data = True )