def __init__(self,
                 left_items,
                 right_items,
                 connector,
                 take_left=True,
                 take_right=True):
        '''
    plain constructor
    '''

        super().__init__()
        self.ui = Ui_Dialog()
        self.ui.setupUi(self)
        self.show()
        self.left_items = left_items
        self.right_items = right_items
        self.take_left = take_left
        self.take_right = take_right
        try:
            roundButton(self.ui.pushButtonExit, "exit", "exit")
        except:
            pass
        self.selected_left = False
        self.selected_right = False
        self.populateLists(left_items, right_items)
        self.selection.connect(connector)
    def __init__(self):
        '''
    plain constructor
    '''

        super().__init__()
        self.ui = Ui_Dialog()
        self.ui.setupUi(self)
        self.show()
        roundButton(self.ui.pushButtonExit, "exit", "exit")
示例#3
0
    def __init__(
            self,
            left_nw: str,
            left_list: list,
            right_nw: str,
            right_list: list,
            equation_list:
        list,  # list of triples (left_var_ID, right_var_ID, equ_ID)
            variables):
        '''
    plain constructor
    '''

        super().__init__()
        self.ui = Ui_SourceSinkLinking()
        self.ui.setupUi(self)
        self.show()
        roundButton(self.ui.pushAccept, "accept", "accept")
        roundButton(self.ui.pushReset, "update", "reset lists")
        roundButton(self.ui.pushExit, "exit", "exit")
        roundButton(self.ui.pushDelete, "delete", "delete selected equation")
        self.left_list = left_list
        self.right_list = right_list
        self.equation_list = equation_list
        self.variables = variables

        self.selectedSource = None
        self.selectedSink = None

        self.on_pushReset_pressed()
        self.ui.labelLeft.setText(left_nw)
        self.ui.labelRight.setText(right_nw)
    def __init__(self, indices):
        '''
    Constructor
    '''
        QtWidgets.QWidget.__init__(self)
        self.indices = indices
        self.languages = LANGUAGES['aliasing']
        self.ui = Ui_AliasTable()
        self.ui.setupUi(self)
        self.setup()
        self.setWindowTitle("indices aliases")
        self.ui.tableWidget.itemChanged.connect(self.rename)

        roundButton(self.ui.pushFinished, "back", tooltip="go back")
        roundButton(self.ui.pushInfo, "info", tooltip="information")
  def __init__(self, variables, current_network):
    '''
    Constructor
    '''
    QtWidgets.QWidget.__init__(self)
    self.variables = variables  # all
    self.current_network = current_network
    self.variables_ID_list = self.variables.index_definition_networks_for_variable[self.current_network]
    self.languages = LANGUAGES['aliasing_modify']
    self.ui = Ui_AliasTable()
    self.ui.setupUi(self)
    self.setup()
    self.setWindowTitle("variable aliases")
    self.ui.tableWidget.itemChanged.connect(self.rename)
    self.show()

    roundButton(self.ui.pushFinished, "back", tooltip="go back")
    roundButton(self.ui.pushInfo, "info", tooltip="information")
  def __init__(self, prompt, placeholdertext="", limiting_list=[], fokus=True):
    """
    Serves the purpose of defining a string allowing for accepting or rejecting the result
    :param prompt: displayed in the window title
    :param placeholdertext: place holder shown in the line edit
    :param accept: method/function reference
    :param reject: method/function reference
    """
    # TODO: add validator
    QtWidgets.QDialog.__init__(self)
    self.ui = Ui_Dialog()
    self.ui.setupUi(self)
    # print(" <<<< show me")
    self.hide()
    self.placeholdertext = placeholdertext
    self.limiting_list = limiting_list
    self.setWindowTitle(prompt)
    self.text = None


    roundButton(self.ui.pushAccept, "accept", tooltip="accept")
    roundButton(self.ui.pushReject, "reject", tooltip="reject")
    self.ui.pushAccept.hide()

    self.ui.pushAccept.clicked.connect(self.__accept)
    self.ui.pushReject.clicked.connect(self.close)
    self.ui.lineEdit.textEdited.connect(self.__changedText)

    self.ui.lineEdit.textChanged.connect(self.newText)
    self.ui.pushReject.setFocus()
    self.ui.lineEdit.setPlaceholderText(placeholdertext)

    self.palette_red = QtGui.QPalette()
    self.palette_red.setColor(QtGui.QPalette.Text, QtCore.Qt.red)

    self.palette_black = QtGui.QPalette()
    self.palette_black.setColor(QtGui.QPalette.Text, QtCore.Qt.black)

    if fokus:
      self.ui.lineEdit.setFocus()
    def __init__(self,
                 thelist,
                 selected=None,
                 myparent=None,
                 left_icon="reject",
                 left_tooltip="reject",
                 right_icon="accept",
                 right_tooltip="accept"):
        '''
    Constructor
    Behaviour
     -- double click assumes also right button pressed
     -- single click requires acceptance -- default right button
     -- left button is default reject
     -- returns selection and state (left | right | selected)
    '''
        self.thelist = thelist
        self.selection = None
        QtWidgets.QDialog.__init__(self, parent=myparent)
        self.ui = Ui_Dialog()
        self.ui.setupUi(self)

        roundButton(self.ui.pushLeft, left_icon, left_tooltip)
        roundButton(self.ui.pushRight, right_icon, right_tooltip)

        self.ui.listWidget.addItems(thelist)

        self.selection = None
        self.state = None  # left | right | selected

        max_width = 0
        height = 20
        for i in thelist:
            label = QtWidgets.QLabel(i)
            width = label.fontMetrics().boundingRect(label.text()).width()
            height = height + label.fontMetrics().boundingRect(
                label.text()).height()
            if width > max_width:
                max_width = width
        self.__resizeMe(height, max_width + 20)
示例#8
0
    def __init__(self):
        QtWidgets.QMainWindow.__init__(self)
        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)

        self.ontology_name = getOntologyName(task="task_entity_generation")
        self.ontology_dir = DIRECTORIES[
            "ontology_location"] % self.ontology_name
        self.ontology_file = FILES["ontology_file"] % self.ontology_name

        roundButton(self.ui.pushInfo, "info", tooltip="information")
        roundButton(self.ui.pushSave,
                    "save",
                    tooltip="save ProMo base ontology")
        roundButton(self.ui.pushGraphNode, "dot_graph", tooltip="show graph")

        checkAndFixResources(self.ontology_name, stage="ontology_stage_2")

        self.ontology_container = OntologyContainer(self.ontology_name)
        self.incidence_dictionary, self.inv_incidence_dictionary = makeIncidenceDictionaries(
            self.ontology_container.variables)

        self.reduced_network_node_list = self.ontology_container.list_reduced_network_node_objects  #__makeNodeLists()
        self.reduced_arc_list = self.ontology_container.list_reduced_network_arc_objects  # self.__makeArcLists()

        self.radio_selectors = {}
        self.__makeCombosNetworks()

        self.current_equation_IDs = {
        }  # hash: radio button index     value: equation_ID_str
        self.ui.tabWidget.setCurrentIndex(0)
        self.current_tab = 0
        self.tabs = ["node", "arc", "intra", "inter"]

        self.selected_node = None
        self.selected_arc = None
        self.selected_intra = None
        self.selected_inter = None
        self.selected_arc_network = None
        self.selected_node_network = None

        self.assignments = {}

        self.__makeEquationList()
示例#9
0
    def __init__(self):
        QtWidgets.QMainWindow.__init__(self)
        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)

        roundButton(self.ui.pushSave, "save", tooltip="save to file")
        roundButton(self.ui.pushAddTypedToken,
                    "plus",
                    tooltip="add typed token")
        roundButton(self.ui.pushSaveAndExit, "exit", tooltip="exit")

        # attach ontology
        ontology_name = getOntologyName(task="task_typed_tokens")
        ontology = OntologyContainer(
            ontology_name)  # DIRECTORIES["ontology_location"] % ontology_name)
        self.networks = ontology.list_leave_networks

        self.typed_token_file_spec = FILES["typed_token_file"] % ontology_name

        self.DATA = TypedTokenData()

        typed_tokens = []
        self.instances = {}
        for nw in self.networks:
            for token in ontology.token_typedtoken_on_networks[nw]:
                for typed_token in ontology.token_typedtoken_on_networks[nw][
                        token]:
                    typed_tokens.append(typed_token)
                    # self.instances[typed_token] = INSTANCES

        self.DATA.initialise(typed_tokens)
        self.__interfaceLogics("start")
        self.new = False
        self.selected_typed_token_class = None
        gotten = self.load()
        if gotten:
            self.__interfaceLogics("loaded")
        else:
            self.__interfaceLogics("start")
            typed_tokens_class = self.__makeTokenWithTypedTokensCombo()
            self.new = True
            self.__interfaceLogics("new")
示例#10
0
  def __init__(self,
               title,
               variables,
               indices,
               network,
               enabled_types=['ALL'],
               hide_vars=[],
               hide_columns=[],
               info_file=None,
               hidden=[]
               ):
    """
    constructs a dialog window based on QDialog for picking variables
    @param title:     title string: indicates the tree's nature
    @param variables: physical variable.
    @network:      network type
    @my_types:      type of variables being processed

    control is done through the interface and additional functions:
    - enable_pick_contents : true or false
    - enable_seclection : rows and columns

    signals:
    - picked : returns selected item text
    - completed : button finished has been pressed
    -
    """

    VariableTable.__init__(self,
                           title,
                           "variable_picking",
                           variables,
                           indices,
                           network,
                           # variables.index_accessible_variables_on_networks,
                           enabled_types,
                           hide_vars,
                           hide_columns,
                           info_file=info_file
                           )
    buttons = {}
    buttons["back"] = self.ui.pushFinished
    buttons["info"] = self.ui.pushInfo
    buttons["new"] = self.ui.pushNew
    buttons["port"] = self.ui.pushPort
    buttons["dot"] = self.ui.pushDot
    buttons["tex"] = self.ui.pushLaTex

    hidden = ["new", "port", "info", "dot", "tex"]

    roundButton(buttons["back"], "back", tooltip="go back")
    # roundButton(buttons["info"], "info", tooltip="information")

    # roundButton(buttons["new"], "new", tooltip="new variable")
    # roundButton(buttons["port"], "port", tooltip="new port variable")
    for b in hidden:
      buttons[b].hide()
    self.variable_list = []
    self.hide_columns = hide_columns

    self.setToolTips('pick')
    self.ui.tableVariable.setToolTip("click on row to copy variable to expression")
    self.ui.tableVariable.setSortingEnabled(True)
示例#11
0
    def __init__(self, icon_f):

        super().__init__()
        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)

        roundButton(self.ui.pushButtonInformation,
                    "info",
                    tooltip="information")
        roundButton(self.ui.pushButtonSave,
                    "save",
                    tooltip="save entity behaviour")
        roundButton(self.ui.pushButtonCancel,
                    "exit",
                    tooltip="cancel and exit")
        roundButton(self.ui.pushButtonDelete,
                    "delete",
                    tooltip="delete current var/eq tree")
        roundButton(self.ui.pushButtonMakeLatex,
                    "LaTex",
                    tooltip="make latex files for all objects")
        roundButton(self.ui.pushButtonViewLatex,
                    "variable_show",
                    tooltip="show latex")
        roundButton(self.ui.pushButtonUpdate, "update", tooltip="update tree")

        self.ui.groupBoxControls.hide()
        self.ui.pushButtonLeft.hide()
        self.ui.pushButtonRight.hide()
        self.ui.pushButtonMakeLatex.hide()
        self.ui.pushButtonViewLatex.hide()

        # output streaming
        REDIRECT_STDOUT = True
        REDIRECT_ERROR = True

        stdOut = Redirect(self.ui.msgTextBoxStandardOut)
        stdOut.home()
        stdError = Redirect(self.ui.msgTextBoxErrorOut)
        stdError.home()
        if REDIRECT_STDOUT:
            sys.stdout = Stream(newText=stdOut.update)
        if REDIRECT_ERROR:
            sys.stderr = Stream(newText=stdError.update)

        # first get ontology
        self.ontology_name = getOntologyName(task=icon_f)

        # check for infrastructure
        checkAndFixResources(self.ontology_name, stage="ontology_stage_2")

        # attach ontology
        self.ontology_container = OntologyContainer(self.ontology_name)
        self.location = DIRECTORIES["latex_doc_location"] % self.ontology_name

        self.ontology_location = DIRECTORIES["ontology_location"] % str(
            self.ontology_name)

        self.reduced_network_node_list = self.ontology_container.list_reduced_network_node_objects
        self.reduced_arc_list = self.ontology_container.list_reduced_network_arc_objects

        # instantiate entity behaviours
        networks = self.ontology_container.list_inter_branches
        # entities_list = self.reduced_network_node_list

        self.arc_objects = self.ontology_container.list_arc_objects_on_networks
        self.node_objects = self.ontology_container.list_inter_node_objects_tokens  # list_node_objects_on_networks_with_tokens
        entities_list = []
        for nw in self.node_objects:
            for o in self.node_objects[nw]:
                obj = TEMPLATE_ENTITY_OBJECT % (nw, "node", o, "base")
                entities_list.append(obj)
        for nw in self.arc_objects:
            for o in self.arc_objects[nw]:
                obj = TEMPLATE_ENTITY_OBJECT % (
                    nw, "arc", o, "base"
                )  # RULE: "base" is used for the base bipartite graph
                entities_list.append(obj)

        self.entity_behaviours = EntityBehaviour(entities_list)

        self.list_linked_equations = self.__getFilteredEquationList(
            "interface_link_equation")
        # print("debugging")

        equations_label_list, \
        self.equation_information, \
        self.equation_inverse_index = self.__makeEquationAndIndexLists()
        self.rules = {}

        # get existing data
        self.__readVariableAssignmentToEntity()

        # interface components
        self.layout_InterNetworks = QtWidgets.QVBoxLayout(
        )  # Vertical Box with horizontal boxes of radio buttons & labels
        self.ui.scrollAreaWidgetContentsInterNetworks.setLayout(
            self.layout_InterNetworks)

        # initialisations
        # network selector
        self.radio_InterNetworks = Selector("InterNetworks",
                                            self.radioReceiverState, networks,
                                            self.layout_InterNetworks)

        self.selected_InterNetwork_ID = None
        self.selected_Entity_ID = None
        self.selected_variant_ID = None
        self.selected_variant_str_ID = "base"
        self.radio_index = None
        self.selected_base_variable = None
        self.rightListEquationIDs = []
        self.rightListEquationIDs_radio_ID = []

        self.match_equations_label_list = []
        self.match_equation_ID = {}
        # self.node_arc = "nodes"
        self.node_arc = self.ui.tabWidgetNodesArcs.tabText(
            self.ui.tabWidgetNodesArcs.currentIndex())

        # controls
        self.actions = [
            "show", "duplicates", "new_variant", "edit_variant",
            "instantiate_variant"
        ]

        # prepare lists
        self.current_base_var_ID = None

        # start process

        self.status_report = self.statusBar().showMessage
        self.status_report("getting started")
        self.entity_layout_clean = True
        self.variant_layout_clean = True
        self.equation_left_clean = True
        self.equation_right_clean = True
        self.selected_variant = None
        self.state = "start"
示例#12
0
    def __init__(self,
                 title,
                 variables,
                 indices,
                 tokens_on_networks,
                 variable_types_on_networks,
                 network,
                 network_expression,
                 choice,
                 disabled_variables=[],
                 hide_vars=[],
                 hide_columns=[],
                 info_file=None,
                 hidden=[]):
        """
    constructs a dialog window based on QDialog
    @param title:     title string: indicates the tree's nature
    @param variables: physical variable.
    @network:      network type
    @my_types:      type of variables being processed

    control is done through the interface and additional functions:
    - enable_pick_contents : true or false
    - enable_selection : rows and columns

    signals:
    - picked : returns selected item text
    - completed : button finished has been pressed
    -
    """

        enabled_variable_types = [choice]
        self.variable_types_on_networks = variable_types_on_networks
        self.selected_variable_type = choice
        self.tokens_on_networks = tokens_on_networks

        VariableTable.__init__(
            self,
            title,
            "variables_definition",
            variables,
            indices,
            network,
            # variables.index_networks_for_variable,       # defines variable space
            enabled_variable_types,
            hide_vars,
            hide_columns,
            info_file=info_file)

        buttons = {
            "back": self.ui.pushFinished,
            "info": self.ui.pushInfo,
            "new": self.ui.pushNew,
            "port": self.ui.pushPort,
            "LaTex": self.ui.pushLaTex,
            "dot": self.ui.pushDot
        }

        roundButton(buttons["back"], "back", tooltip="go back")
        roundButton(buttons["info"], "info", tooltip="information")
        roundButton(buttons["new"],
                    "dependent_variable",
                    tooltip="new dependent variable")
        roundButton(buttons["port"], "port", tooltip="new port variable")

        for b in hidden:
            buttons[b].hide()

        # version_change : hide token column
        self.hideColumn(3)

        self.network_expression = network_expression
        self.variable_list = []
        self.disabled_variables = disabled_variables
        self.variables_in_table = []
        self.label_ID_dict = {}  # for changing / choosing index set
        self.reset_table()

        self.enabled_columns = None
        self.selected_variable_symbol = None

        self.ui_symbol = UI_SymbolDialog()
        self.ui_symbol.finished.connect(self.reset_table)
        self.ui_units = UI_PhysUnitsDialog("new physical units")
        self.ui_units.finished.connect(self.reset_table)