def run(self, panel):
        xdotWidget = XDotWidget()
        panel.add(xdotWidget)
        if self.controller.symbol is None:
            return
        # We retrieve all the fields and there associated variables
        fields = dict()
        for field in self.controller.symbol.getExtendedFields():
            var = field.getVariable()
            if var is not None:
                fields["F{0}".format(field.getIndex())] = var

        dotCode = ["digraph G {"]
        dotCode.extend(self.addDotCodeForFields(fields))
        dotCode.append("}")
        xdotWidget.drawDotCode('\n'.join(dotCode))
        xdotWidget.show_all()

        if self.controller.allowMaximize:
            panel.connect("button_press_event", self.doubleClick_cb)
Beispiel #2
0
    def createInferringStatusView(self):
        self.dialog = Gtk.Dialog(title=_("Execution of the inferring process"),
                                 flags=0,
                                 buttons=None)

        mainTable = Gtk.Table(rows=5, columns=4, homogeneous=False)

        # Insert the current Hypothesis of the automata
        self.xdotWidget = XDotWidget()
        self.xdotWidget.show_all()
        self.xdotWidget.set_size_request(500, 500)
        mainTable.attach(self.xdotWidget,
                         0,
                         2,
                         0,
                         4,
                         xoptions=Gtk.AttachOptions.FILL,
                         yoptions=0,
                         xpadding=5,
                         ypadding=5)

        # Insert the updated list of requests and associated responses
        scroll_requests = Gtk.ScrolledWindow()
        self.treestore_queries = Gtk.TreeStore(
            str, str, str)  # queries, responses, color
        treeview_queries = Gtk.TreeView(self.treestore_queries)
        treeview_queries.get_selection().set_mode(Gtk.SelectionMode.SINGLE)
        treeview_queries.set_size_request(500, 500)
        #        treeview_queries.connect('button-press-event', self.button_press_on_transitions)
        cell = Gtk.CellRendererText()
        # col : membership queries
        col_queries_querie = Gtk.TreeViewColumn(_("Membership queries"))
        col_queries_querie.pack_start(cell, True)
        col_queries_querie.add_attribute(cell, "text", 0)
        treeview_queries.append_column(col_queries_querie)
        # col : responses to queries
        column_queries_responses = Gtk.TreeViewColumn(_("Responses"))
        column_queries_responses.pack_start(cell, True)
        column_queries_responses.add_attribute(cell, "text", 1)
        treeview_queries.append_column(column_queries_responses)
        scroll_requests.add(treeview_queries)
        scroll_requests.set_policy(Gtk.PolicyType.AUTOMATIC,
                                   Gtk.PolicyType.AUTOMATIC)
        scroll_requests.show()
        mainTable.attach(scroll_requests,
                         2,
                         4,
                         0,
                         4,
                         xoptions=Gtk.AttachOptions.FILL,
                         yoptions=0,
                         xpadding=5,
                         ypadding=5)

        # Progress bar
        self.progressbar = Gtk.ProgressBar()
        self.progressbar.show()
        #        # Insert the status message
        #        self.statusLabel = Gtk.Label(label="A number of X states has been created - Current turn contains N MQ")
        #        self.statusLabel.show()
        mainTable.attach(self.progressbar,
                         0,
                         2,
                         4,
                         5,
                         xoptions=Gtk.AttachOptions.FILL,
                         yoptions=0,
                         xpadding=5,
                         ypadding=5)

        # Insert the stop button
        self.stopButton = Gtk.Button(_("Stop"))
        self.stopButton.show()
        self.stopButton.connect("clicked", self.stopInference)
        mainTable.attach(self.stopButton,
                         2,
                         3,
                         4,
                         5,
                         xoptions=Gtk.AttachOptions.FILL,
                         yoptions=0,
                         xpadding=5,
                         ypadding=5)

        # Insert the Save button
        self.saveButton = Gtk.Button(_("Save as Grammar"))
        self.saveButton.show()
        self.saveButton.connect("clicked", self.saveGrammar)
        mainTable.attach(self.saveButton,
                         3,
                         4,
                         4,
                         5,
                         xoptions=Gtk.AttachOptions.FILL,
                         yoptions=0,
                         xpadding=5,
                         ypadding=5)

        self.dialog.vbox.pack_end(mainTable, True, True, 0)
        self.dialog.show_all()