Пример #1
0
        else:
            print("Network '{}' is loaded "
                  "and is composed of the following files:".format(
                      self.pickle_file_name))
            for file in self.gel_net.Gellish_files:
                print('- {}'.format(file.path_and_name))

    def load_pickle_db(self, fname):
        try:
            infile = open(fname, "br")
        except FileNotFoundError:
            print("Input pickle file could not be found: {}".format(fname))
            return ()
        try:
            self.gel_net = pickle.load(infile)
        except EOFError:
            print("Input pickle file could not be read: {}".format(fname))
        else:
            infile.close()


if __name__ == "__main__":
    sys.setrecursionlimit(100000)

    # Initialize user_db and start up

    user_db = SU.UserDb()
    comm = Communicator()
    comm.start_up(user_db)
    comm.start_net()
Пример #2
0
    def main(self):
        """ Define a main_window with select options and GUI language choice.
        """
        main_menu = ['Main Menu', 'Hoofdmenu']
        login = ['Login/Register', 'Login/Registreer']
        read_file = ['Read file', 'Lees file']
        search = ['Search', 'Zoek']
        query = ['Query', 'Vraag']
        admin = ['DB Admin', 'DB Admin']
        new_net = ['New network', 'Nieuw netwerk']
        save_as = ['Save net', 'Opslaan']
        manual = ['User manual', 'Handleiding']
        wiki = ['Gellish wiki', 'Gellish wiki']

        # Initialize user_db and start up
        user_db = SU.UserDb()
        self.start_up(user_db)
        self.start_net()

        # Set GUI language default = English: GUI_lang_names[0]
        self.Set_GUI_language(self.GUI_lang_names[0])

        # Define main GUI window
        self.container = gui.Widget(margin='2px',
                                    style='background-color:#eeffdd')
        self.container.set_size('100%', '100%')
        self.container.attributes['title'] = 'Communicator'

        # Menu bar
        self.menubar = gui.MenuBar(height=20, width='100%')
        self.container.append(self.menubar)

        import_text = [
            'Import one or more Gellish files',
            'Lees een of meer Gellish files'
        ]
        self.read_file_tag = gui.MenuItem(read_file[self.GUI_lang_index],
                                          width=100,
                                          height=20)
        self.read_file_tag.attributes['title'] = import_text[
            self.GUI_lang_index]
        self.read_file_tag.onclick.connect(self.read_verify_and_merge_files)
        self.menubar.append(self.read_file_tag)

        self.search_tag = gui.MenuItem(search[self.GUI_lang_index],
                                       width=100,
                                       height=20)
        self.search_tag.attributes['title'] = 'Open a search window'
        self.search_tag.onclick.connect(self.search_net)
        self.menubar.append(self.search_tag)

        self.manual_tag = gui.MenuItem(manual[self.GUI_lang_index],
                                       width=100,
                                       height=20)
        self.manual_tag.attributes[
            'title'] = 'Open the Communicator user manual'
        self.manual_tag.onclick.connect(self.user_manual)
        self.menubar.append(self.manual_tag)

        self.wiki_tag = gui.MenuItem(wiki[self.GUI_lang_index],
                                     width=100,
                                     height=20)
        self.wiki_tag.attributes['title'] = 'Open the Gellish languages wiki'
        self.wiki_tag.onclick.connect(self.open_wiki)
        self.menubar.append(self.wiki_tag)

        self.admin_tag = gui.MenuItem(admin[self.GUI_lang_index],
                                      width=100,
                                      height=20)
        self.admin_tag.attributes[
            'title'] = 'Save network on file or delete old and create new network'
        self.menubar.append(self.admin_tag)

        self.save_as_tag = gui.MenuItem(save_as[self.GUI_lang_index],
                                        width=100,
                                        height=20)
        self.save_as_tag.attributes[
            'title'] = 'Save semantic network on binary file'
        self.save_as_tag.onclick.connect(self.gel_net.save_pickle_db)
        self.admin_tag.append(self.save_as_tag)

        self.new_net_tag = gui.MenuItem(new_net[self.GUI_lang_index],
                                        width=100,
                                        height=20)
        self.new_net_tag.attributes[
            'title'] = 'Delete old and create new semantic network'
        self.new_net_tag.onclick.connect(self.gel_net.reset_and_build_network)
        self.admin_tag.append(self.new_net_tag)

        # Define language selector
        self.lang_container = gui.HBox(width=180,
                                       height=20,
                                       style='margin-left:200px')

        lang_text = ['Language:', 'Taal:']
        self.lang_label = gui.Label(lang_text[self.GUI_lang_index],
                                    width=80,
                                    height=20,
                                    style='background-color:#eeffdd')
        self.lang_label.attributes[
            'title'] = 'Select a language for specification of a search'

        self.lang_container.append(
            self.lang_label)  #self.main_frame, width=10)
        # Set default language: GUI_lang_names[0] = English, [1] = Nederlands
        self.lang_default = self.GUI_lang_names[0]
        self.lang_select = gui.DropDown(
            self.GUI_lang_names,
            width=100,
            height=20,
            style='background-color:#ffffc0')  #margin='10px'
        self.lang_select.attributes[
            'title'] = 'The language used for specification of a search'
        self.lang_container.append(self.lang_select)
        self.menubar.append(self.lang_container)

        # Binding GUI language choice
        self.lang_select.onchange.connect(self.Determine_GUI_language)

        # Main Frame
        self.main_frame = gui.VBox(width='100%', height='100%')
        self.container.append(self.main_frame)
        self.main_frame.attributes['color'] = 'green'

        self.query = None
        self.unknown = ['unknown', 'onbekend']
        self.unknown_quid = 0  # start UID for unknowns in queries

        # Create display views object
        self.views = Display_views(self.gel_net, self)

        # Define a notebook in window
        self.Define_notebook()

        return self.container