Exemplo n.º 1
0
    def disconnect_popup(self):
        popup = Popup(title='Choisissez un premier sommet',
                      size_hint=(0.9, 0.9),
                      auto_dismiss=False)
        bl = BoxLayout(orientation='vertical')

        confirm_button = Button(text="Confirmer")
        confirm_button.disabled = True

        list_adapter1 = ListAdapter(data=[
            str(i + 1) + "- " + self.g.get_sommets()[i].nom
            for i in range(len(self.g.get_sommets()))
        ],
                                    cls=ListItemButton,
                                    sorted_keys=[])
        list_adapter1.bind(
            on_selection_change=lambda a: self.selection_change_disco(
                list_adapter1, 0, confirm_button))
        list_view1 = ListView(adapter=list_adapter1)

        bl.add_widget(list_view1)

        confirm_button.bind(on_press=lambda a: self.disconnect_popup2(popup))
        cancel_button = Button(text="Annuler")
        cancel_button.bind(on_press=lambda a: popup.dismiss())
        bl.add_widget(confirm_button)
        bl.add_widget(cancel_button)

        popup.content = bl
        popup.open()
Exemplo n.º 2
0
    def p_degree(self, popup):
        popup.dismiss()

        popup = Popup(title='Sommets par degre',
                      size_hint=(0.9, 0.9),
                      auto_dismiss=False)
        bl = BoxLayout(orientation='vertical')

        list_adapter1 = ListAdapter(data=[
            str(i + 1) + "- " + self.g.get_sommets_by_degree()[i].nom
            for i in range(len(self.g.get_sommets()))
        ],
                                    cls=ListItemButton,
                                    sorted_keys=[])
        list_adapter1.bind(on_selection_change=lambda a: self.selected(
            list_adapter1, "degre"))
        list_view1 = ListView(adapter=list_adapter1)

        bl.add_widget(list_view1)

        cancel_button = Button(text="Fermer")
        cancel_button.bind(on_press=lambda a: popup.dismiss())
        bl.add_widget(cancel_button)

        popup.content = bl
        popup.open()
Exemplo n.º 3
0
    def __init__(self, **kwargs):
        kwargs['cols'] = 2
        super(MainView, self).__init__(**kwargs)
        self.orientation = 'vertical'

        self.list_adapter = ListAdapter(data=["Item #{0}".format(i) for i in range(10)], cls=ListItemButton, sorted_keys=[])
        self.list_adapter.bind(on_selection_change=self.selection_change)
        list_view = ListView(adapter=self.list_adapter)
        self.add_widget(list_view)
        self.add_widget(Button(text="select random item", on_press=self.callback))
Exemplo n.º 4
0
    def popup_pagerank(self, popup):
        popup.dismiss()

        popup = Popup(title='PageRank',
                      size_hint=(0.9, 0.9),
                      auto_dismiss=False)
        bl = BoxLayout(orientation='vertical')

        pr = self.g.page_rank()

        list_adapter1 = ListAdapter(data=[
            keySom.nom + " : " + str(pr[keySom]) for keySom in pr.keys()
        ],
                                    cls=ListItemButton,
                                    sorted_keys=[])
        list_view1 = ListView(adapter=list_adapter1)

        bl.add_widget(list_view1)

        cancel_button = Button(text="Annuler")
        cancel_button.bind(on_press=lambda a: popup.dismiss())
        bl.add_widget(cancel_button)

        popup.content = bl
        popup.open()
Exemplo n.º 5
0
 def recomend(self):
     project = ProjectGenerator()
     lista = project.getRecomendations(project.encriptPassword(self.user))
     for node in lista:
         print(node)
     toShow = []
     for i in range(0, 20):
         toShow.append(lista[i])
     self.ids.project_list.adapter = ListAdapter(data=toShow,
                                                 cls=ListItemButton)
Exemplo n.º 6
0
 def showAll(self):
     project = ProjectGenerator()
     result = project.showNodes()
     result = result.values()  #Convert to a list
     projects = []
     for node in result:  #Print nodes in the result
         projects.append(
             node[0]["title"]
         )  #The name of the atribute is setted in the second []
     self.ids.project_list.adapter = ListAdapter(data=projects,
                                                 cls=ListItemButton)
Exemplo n.º 7
0
  def __init__(self, **kwargs):
      kwargs['cols'] = 2
      super(MainView, self).__init__(**kwargs)
 # def build(self):
     # global store
      project_store = JsonStore('projectlist.json')
      self.list_adapter = ListAdapter(data=[("Project " + r + ' ' + project_store[r]['profile']['projecttitle'])
                                            for r in project_store.keys()],
                                      cls=ListItemButton,
                                      sorted_keys=[])
      self.list_adapter.bind(on_selection_change=self.callback)
      list_view = ListView(adapter=self.list_adapter)
      self.add_widget(list_view)
Exemplo n.º 8
0
class MainView(BoxLayout):
    def __init__(self, **kwargs):
        kwargs['cols'] = 2
        super(MainView, self).__init__(**kwargs)
   # def build(self):
       # global store
        project_store = JsonStore('projectlist.json')
        self.list_adapter = ListAdapter(data=[("Project " + r + ' ' + project_store[r]['profile']['projecttitle'])
                                              for r in project_store.keys()],
                                        cls=ListItemButton,
                                        sorted_keys=[])
        self.list_adapter.bind(on_selection_change=self.callback)
        list_view = ListView(adapter=self.list_adapter)
        self.add_widget(list_view)

    def callback(self, instance):
        global PROJECT
        p_num= instance.selection[0].text.split(' ')[1]
        PROJECT = p_num
        print p_num
        print 'project'
        return PROJECT
Exemplo n.º 9
0
    def __init__(self, **kwargs):
        kwargs['cols'] = 2
        super(MainView, self).__init__(**kwargs)
        self.orientation = 'vertical'
        
        self.network = Network()
        listUser = self.network.getAllUsers()
	
	
        self.myListAdapter = ListAdapter(data=[str(listUser[i]) for i in range(len(listUser))], 
					cls=ListItemButton, 
					selection_mode='single', 
					sorted_keys=[])
        self.myListAdapter.bind(on_selection_change=self.selectionChange)
        myListView = ListView(adapter=self.myListAdapter)
        
        self.add_widget(myListView)
      
	self.layout = BoxLayout(orientation='vertical')
	lbl = Label(text = 'SELECT USER FROM LIST')
	
	btn1 = Button(text='Friends', background_color = (0.988, 0.53, 0.70, 1.0))
	btn1.bind(on_press=self.clickFriends)
	
	btn2 = Button(text='Friends of friends', background_color = (0.988, 0.53, 0.70, 1.0))
	btn2.bind(on_press=self.clickFriendsOfFriends)
	
	btn3 = Button(text='Suggested friend', background_color = (0.988, 0.53, 0.70, 1.0))
	btn3.bind(on_press=self.clickSuggestedFriends)
	
	self.layout.add_widget(lbl)
	self.layout.add_widget(btn1)
	self.layout.add_widget(btn2)
	self.layout.add_widget(btn3)
	
	people = ""
  
	self.add_widget(self.layout)
Exemplo n.º 10
0
    def connect_popup(self):
        popup = Popup(title='Connecter deux sommets',
                      size_hint=(0.9, 0.9),
                      auto_dismiss=False)
        bl = BoxLayout(orientation='vertical')

        confirm_button = Button(text="Confirmer")
        confirm_button.disabled = True

        gl_inputs = GridLayout(cols=2)

        gl_inputs.add_widget(Label(text="Sommet 1"))
        gl_inputs.add_widget(Label(text="Sommet 2"))

        list_adapter1 = ListAdapter(data=[
            str(i + 1) + "- " + self.g.get_sommets()[i].nom
            for i in range(len(self.g.get_sommets()))
        ],
                                    cls=ListItemButton,
                                    sorted_keys=[])
        list_adapter1.bind(on_selection_change=lambda a: self.selection_change(
            list_adapter1, 0, list_adapter2, confirm_button))
        list_view1 = ListView(adapter=list_adapter1)

        gl_inputs.add_widget(list_view1)

        list_adapter2 = ListAdapter(data=[
            str(i + 1) + "- " + self.g.get_sommets()[i].nom
            for i in range(len(self.g.get_sommets()))
        ],
                                    cls=ListItemButton,
                                    sorted_keys=[])
        list_adapter2.bind(on_selection_change=lambda a: self.selection_change(
            list_adapter2, 1, list_adapter1, confirm_button))
        list_view2 = ListView(adapter=list_adapter2)

        gl_inputs.add_widget(list_view2)

        bl.add_widget(gl_inputs)

        confirm_button.bind(on_press=lambda a: self.connect(popup))
        cancel_button = Button(text="Annuler")
        cancel_button.bind(on_press=lambda a: popup.dismiss())
        bl.add_widget(confirm_button)
        bl.add_widget(cancel_button)

        popup.content = bl
        popup.open()
Exemplo n.º 11
0
    def aff_list_succ(self):
        popup = Popup(title='Liste de successeurs',
                      size_hint=(0.9, 0.9),
                      auto_dismiss=False)
        bl = BoxLayout(orientation="vertical")

        list_adapter1 = ListAdapter(data=[
            str(i + 1) + "- " + self.g.get_sommets()[i].__repr__()
            for i in range(len(self.g.get_sommets()))
        ],
                                    cls=ListItemButton,
                                    sorted_keys=[])
        list_adapter1.bind(on_selection_change=lambda a: self.selected(
            list_adapter1, "no_filter"))
        list_view1 = ListView(adapter=list_adapter1)

        bl.add_widget(list_view1)

        bt = Button(text="Fermer")
        bt.bind(on_press=lambda a: popup.dismiss())
        bl.add_widget(bt)
        popup.content = bl
        popup.open()
Exemplo n.º 12
0
class MainView(BoxLayout):
    def __init__(self, **kwargs):
        kwargs['cols'] = 2
        super(MainView, self).__init__(**kwargs)
        self.orientation = 'vertical'

        self.list_adapter = ListAdapter(data=["Item #{0}".format(i) for i in range(10)], cls=ListItemButton, sorted_keys=[])
        self.list_adapter.bind(on_selection_change=self.selection_change)
        list_view = ListView(adapter=self.list_adapter)
        self.add_widget(list_view)
        self.add_widget(Button(text="select random item", on_press=self.callback))

    def callback(self, instance):
        index = randint(0, 9)
        self.change_from_code = True
        if not self.list_adapter.get_view(index).is_selected:
            self.list_adapter.get_view(index).trigger_action(duration=0)
        self.change_from_code = False

    def selection_change(self, adapter, *args):
        if self.change_from_code:
            print("selection change from code")
        else:
            print("selection changed by click")
Exemplo n.º 13
0
    def disp_pcd(self, som):
        popup = Popup(title='Plus courtes distances',
                      size_hint=(0.9, 0.9),
                      auto_dismiss=False)
        bl = BoxLayout(orientation='vertical')

        pcd = self.g.plus_courte_distance(som)

        list_adapter1 = ListAdapter(data=[
            keySom.nom + " : " + str(pcd[keySom]) for keySom in pcd.keys()
        ],
                                    cls=ListItemButton,
                                    sorted_keys=[])
        list_view1 = ListView(adapter=list_adapter1)

        bl.add_widget(list_view1)

        cancel_button = Button(text="Annuler")
        cancel_button.bind(on_press=lambda a: popup.dismiss())
        bl.add_widget(cancel_button)

        popup.content = bl
        popup.open()
Exemplo n.º 14
0
class MainView(GridLayout):
    def __init__(self, **kwargs):
        kwargs['cols'] = 2
        super(MainView, self).__init__(**kwargs)
        self.orientation = 'vertical'
        
        self.network = Network()
        listUser = self.network.getAllUsers()
	
	
        self.myListAdapter = ListAdapter(data=[str(listUser[i]) for i in range(len(listUser))], 
					cls=ListItemButton, 
					selection_mode='single', 
					sorted_keys=[])
        self.myListAdapter.bind(on_selection_change=self.selectionChange)
        myListView = ListView(adapter=self.myListAdapter)
        
        self.add_widget(myListView)
      
	self.layout = BoxLayout(orientation='vertical')
	lbl = Label(text = 'SELECT USER FROM LIST')
	
	btn1 = Button(text='Friends', background_color = (0.988, 0.53, 0.70, 1.0))
	btn1.bind(on_press=self.clickFriends)
	
	btn2 = Button(text='Friends of friends', background_color = (0.988, 0.53, 0.70, 1.0))
	btn2.bind(on_press=self.clickFriendsOfFriends)
	
	btn3 = Button(text='Suggested friend', background_color = (0.988, 0.53, 0.70, 1.0))
	btn3.bind(on_press=self.clickSuggestedFriends)
	
	self.layout.add_widget(lbl)
	self.layout.add_widget(btn1)
	self.layout.add_widget(btn2)
	self.layout.add_widget(btn3)
	
	people = ""
  
	self.add_widget(self.layout)

    
    def selectionChange(self, adapter, *args):
        if (adapter.selection):
	    self.layout.disabled = False
	    self.people = str(adapter.selection[0].text)
	
    def clickFriends(self, adapter):
	
	listUser1 = self.network.getFriends(self.people)
	lvAdapter = SimpleListAdapter(data=[str(listUser1[i]) for i in range(len(listUser1))],cls=Label)
        lv = ListView(adapter=lvAdapter)
	
	myTitle = str(self.people)
	myTitle += "\nFriends: ";
	
	popup = Popup(title=myTitle, content=lv, size_hint = (None, None), size=(400,400))
	popup.open()


    def clickFriendsOfFriends(self, adapter):

	listUser1 = self.network.getFriendOfFriends(self.people)
	lvAdapter = SimpleListAdapter(data=[str(listUser1[i]) for i in range(len(listUser1))],cls=Label)
        lv = ListView(adapter=lvAdapter)
        
        
	myTitle = str(self.people)
	myTitle += "\nFriends of Friends: ";
	
	popup = Popup(title=myTitle, content=lv, size_hint = (None, None), size=(400,400))
	popup.open()

    def clickSuggestedFriends(self, adapter):
	
	listUser1 = self.network.getSuggestedFriend(self.people)
	lvAdapter = SimpleListAdapter(data=[str(listUser1[i]) for i in range(len(listUser1))],cls=Label)
        lv = ListView(adapter=lvAdapter)
	
	myTitle = str(self.people)
	myTitle += "\nSuggested Friends: ";
	
	popup = Popup(title=myTitle, content=lv, size_hint = (None, None), size=(400,400))
	popup.open()
Exemplo n.º 15
0
class Connected(Screen):

    user = ""
    project = ProjectGenerator()
    result = project.showNodes()
    result = result.values()  #Convert to a list
    projects = []
    for node in result:  #Print nodes in the result
        projects.append(
            node[0]
            ["title"])  #The name of the atribute is setted in the second []
    adapter = ListAdapter(data=projects, cls=ListItemButton)

    def showAll(self):
        project = ProjectGenerator()
        result = project.showNodes()
        result = result.values()  #Convert to a list
        projects = []
        for node in result:  #Print nodes in the result
            projects.append(
                node[0]["title"]
            )  #The name of the atribute is setted in the second []
        self.ids.project_list.adapter = ListAdapter(data=projects,
                                                    cls=ListItemButton)

    def select(self):
        try:
            self.ids.name.text = self.ids.project_list.adapter.selection[
                0].text
            project = ProjectGenerator()
            result = project.getProject(
                "title", self.ids.project_list.adapter.selection[0].text)
            result = result.values()  #Convert to a list
            for node in result:
                self.ids.description.text = node[0]["description"]
                self.ids.time.text = "Time in hours: " + str(node[0]["time"])
                self.ids.complexity.text = "Complexity: " + node[0][
                    "complexity"]
                self.ids.integrants.text = "Integrants required: " + str(
                    node[0]["integrants"])
            project.db.link("User", "Project", "name",
                            project.encriptPassword(self.user), "title",
                            self.ids.project_list.adapter.selection[0].text,
                            "HAS_VIEWED")
        except:
            self.ids.name.text = "PROJECT GENERATOR"
            self.ids.description.text = "SELECT ONE PROJECT"
            self.ids.time.text = ""
            self.ids.complexity.text = ""
            self.ids.integrants.text = ""

    def recomend(self):
        project = ProjectGenerator()
        lista = project.getRecomendations(project.encriptPassword(self.user))
        for node in lista:
            print(node)
        toShow = []
        for i in range(0, 20):
            toShow.append(lista[i])
        self.ids.project_list.adapter = ListAdapter(data=toShow,
                                                    cls=ListItemButton)

    def delete(self):
        project = ProjectGenerator()
        try:
            self.ids.name.text = self.ids.project_list.adapter.selection[
                0].text
            project.db.delete("Project", "title",
                              self.ids.project_list.adapter.selection[0].text)
            self.showAll()
        except:
            self.ids.name.text = "PROJECT GENERATOR"
            self.ids.description.text = "SELECT ONE PROJECT"

    def add(self):
        app = App.get_running_app()
        self.manager.transition = SlideTransition(direction="right")
        self.manager.current = 'add'
        app.config.read(app.get_application_config())
        app.config.write()

    def SignOut(self):
        app = App.get_running_app()
        self.manager.transition = SlideTransition(direction="left")
        self.manager.current = 'login'
        app.config.read(app.get_application_config())
        app.config.write()

    pass