Example #1
0
    def on_login(self, instance):
        username = self.heybudlayout.username_textinput.text
        ip_addr = self.heybudlayout.password_textinput.text.split(":")

        chatlayout = ChatLayout(client, username)
        screenmanager.screens[1].add_widget(chatlayout)

        popup = Popup(title="Connection Status",
                      size_hint=(0.5, 0.25),
                      disabled=False,
                      auto_dismiss=False)
        popup.content = PopupBoxLayout(popup, self, "Connecting to server...")
        popup.open()

        try:
            client.connect((ip_addr[0], int(ip_addr[1])))
            thread1 = threading.Thread(target=reciever_thread,
                                       daemon=True,
                                       args=(
                                           client,
                                           chatlayout,
                                       ))
            thread1.start()
            #popup.content=PopupBoxLayout(popup,self,"Connection Successful")
            popup.dismiss()
            screenmanager.current = "chatlayout"
            Window.clearcolor = H("#66c2ff")
        except:
            popup.content = PopupBoxLayout(
                popup, self,
                "Couldnt connect to server\nPlease re-run the application")
Example #2
0
 def on_long_press(self):
     files = os.listdir(
         os.path.join(os.getcwd(),
                      load_config()["device_path"]))
     if any([x.endswith('tmp') for x in files]):
         print('COFAM')
         day = self.parent.parent.ids.date.dp.text.split(',')[1][1:]
         data = Data(filename=datename(day))
         with open(data.tmp_path, 'r') as f:
             lines = json.load(f)
         if len(lines) > 1:
             with open(data.tmp_path, 'w') as f:
                 json.dump(lines[:-1], f)
         else:
             os.remove(data.tmp_path)
         pop = Popup()
         pop.title = 'Komunikat'
         pop.separator_height = 0
         pop.size_hint = (.5, .4)
         pop.content = Button(text='Operacja cofnięta')
         pop.content.bind(on_press=pop.dismiss)
         pop.open()
     else:
         pop = Popup()
         pop.title = 'Komunikat'
         pop.separator_height = 0
         pop.size_hint = (.6, .2)
         pop.content = Button(text='Brak nowych wpisów')
         pop.content.bind(on_press=pop.dismiss)
         pop.open()
Example #3
0
 def suri(self, text):
     try:
         k = open("power.txt", "r")
         if text == str(k.read()):
             k.close()
             playout = GridLayout(rows=3)
             con = GridLayout(cols=2, size_hint=(1, 0.3))
             ser = Popup(title='Login',
                         size_hint=(0.7, 0.5),
                         background='E:\dcadc.jpg')
             h = Label(text="enter new passcode", text_color=(0, 1, 0, 0))
             lo = TextInput(size_hint=(0.7, 0.3))
             playout.add_widget(h)
             playout.add_widget(lo)
             btn = Button(text="cancle")
             btn2 = Button(text="confirm pass code")
             con.add_widget(btn)
             con.add_widget(btn2)
             playout.add_widget(con)
             ser.content = playout
             ser.open()
             btn.bind(on_press=ser.dismiss)
             btn2.bind(on_press=lambda l: self.loknath(lo.text))
             btn2.bind(on_press=ser.dismiss)
         else:
             if self.count1 != 1:
                 self.count1 = self.count1 - 1
                 return self.sonik()
             else:
                 print("hi")
     except:
         if text == "6532":
             playout = GridLayout(rows=3)
             con = GridLayout(cols=2, size_hint=(1, 0.3))
             ser = Popup(title='Login',
                         size_hint=(0.7, 0.5),
                         background='E:\dcadc.jpg')
             h = Label(text="enter new passcode")
             lo = TextInput(size_hint=(0.7, 0.3))
             playout.add_widget(h)
             playout.add_widget(lo)
             btn = Button(text="cancle")
             btn2 = Button(text="confirm pass code")
             con.add_widget(btn)
             con.add_widget(btn2)
             playout.add_widget(con)
             ser.content = playout
             ser.open()
             btn.bind(on_press=ser.dismiss)
             btn2.bind(on_press=lambda t: self.loknath(lo.text))
             btn2.bind(on_press=ser.dismiss)
         else:
             if self.count1 != 1:
                 self.count1 = self.count1 - 1
                 return self.sonik()
             else:
                 print("hi")
Example #4
0
    def add_popup(self, isUtil):
        if isUtil:
            popup = Popup(title='Ajouter un Utilisateur',
                          size_hint=(0.9, 0.9),
                          auto_dismiss=False)
            bl = BoxLayout(orientation='vertical')

            gl_inputs = GridLayout(cols=2)
            gl_inputs.som_name = TextInput(multiline=False)
            gl_inputs.add_widget(Label(text="Nom de l'utilisateur : "))
            gl_inputs.add_widget(gl_inputs.som_name)
            gl_inputs.add_widget(Label(text="Prenom de l'utilisateur"))
            gl_inputs.som_firstname = TextInput(multiline=False)
            gl_inputs.add_widget(gl_inputs.som_firstname)
            gl_inputs.add_widget(Label(text="Age de l'utilisateur"))
            gl_inputs.som_age = TextInput(multiline=False, input_filter='int')
            gl_inputs.add_widget(gl_inputs.som_age)

            bl.add_widget(gl_inputs)

            confirm_button = Button(text="Confirmer")
            confirm_button.bind(on_press=lambda a: self.add_sommet_popup(
                popup, "Utilisateur", gl_inputs.som_name.text, gl_inputs.
                som_firstname.text, gl_inputs.som_age.text))
            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()
        else:
            popup = Popup(title='Ajouter une Page',
                          size_hint=(0.9, 0.9),
                          auto_dismiss=False)
            bl = BoxLayout(orientation='vertical')

            gl_inputs = GridLayout(cols=2)
            gl_inputs.som_name = TextInput(multiline=False)
            gl_inputs.add_widget(Label(text="Nom de la page : "))
            gl_inputs.add_widget(gl_inputs.som_name)

            bl.add_widget(gl_inputs)

            confirm_button = Button(text="Confirmer")
            confirm_button.bind(on_press=lambda a: self.add_sommet_popup(
                popup, "Page", gl_inputs.som_name.text))
            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()
Example #5
0
 def get_date(self, p, q, w):
     try:
         if len(str(p)) != 2:
             p = str(0) + str(p)
         if len(str(q)) != 2:
             q = str(0) + str(q)
         popup = Popup(title='ATTANDANCE SHEET',
                       size_hint=(0.7, 0.7),
                       auto_dismiss=True,
                       background='E:\lkom.jpg')
         try:
             address = open("address.txt", "r")
         except:
             pass
         if len(str(self.ids.mokilali.text)) == 0:
             yt = address.read()
         else:
             address = open("address.txt", 'w')
             address.write(str(self.ids.mokilali.text))
             address.close()
             address = open("address.txt", "r")
             yt = address.read()
         book = pd.read_csv(str(yt))
         address.close()
         bookno = list(book['monk'])
         m2 = GridLayout(cols=2)
         layout = GridLayout(cols=2,
                             spacing=10,
                             size_hint_y=len(bookno) / 10)
         layout.bind(minimum_height=layout.setter('height'))
         for iuy in range(len(bookno)):
             m2.add_widget(Label(text=str(book["monk"][iuy])))
             m2.add_widget(
                 Label(text=str(book[str(w) + " " + str(q) + " " +
                                     str(p)][iuy])))
         layout.add_widget(m2)
         root = ScrollView(size_hint=(1, 1),
                           size=(popup.width, popup.height))
         root.add_widget(layout)
         popup.content = root
         popup.open()
     except:
         popup = Popup(title='ATTANDANCE SHEET',
                       size_hint=(0.5, 0.5),
                       auto_dismiss=True,
                       background='E:\lkom.jpg')
         popup.content = Label(text="no such data exist")
         popup.open()
Example #6
0
    def quit(self):
        confirm_popup = Popup(title='Confirmation Required',
                              title_color=[1, 0, 0, 1],
                              size_hint=(None, None),
                              size=(400, 200),
                              pos_hint={'center_x': .5, 'center_y:': .5},
                              background_color=[1, 0, 0, .3],
                              auto_dismiss=False)

        content = BoxLayout(orientation='vertical')

        confirm_label = Label(text='Are you sure you want to quit?')

        cancel_button = Button(text='No, I was wrong. Cancel.')
        cancel_button.bind(on_press=lambda x: confirm_popup.dismiss())

        confirm_button=Button(text="Yes, I’m sure. Quit.")
        confirm_button.bind(on_press=lambda x: self.stop())

        buttons = BoxLayout()
        buttons.add_widget(cancel_button)
        buttons.add_widget(confirm_button)

        content.add_widget(confirm_label)
        content.add_widget(buttons)

        confirm_popup.content = content
        confirm_popup.open()
    def unvailable_feature_popUp_creator(self):

        #I WILL MAKE THE FEATURES SIMPLE UNAVAILABLE FOR NOW

        myBox = BoxLayout()
        myBox.orientation = 'vertical'

        myLabel = Label()
        myLabel.text = 'This feature will be\navailable in future version'

        button = Button()
        button.text = 'Dismiss'
        button.size_hint_y = 0.3

        myBox.add_widget(myLabel)
        myBox.add_widget(button)

        popUp = Popup()
        popUp.title = 'Feature not yet available'
        popUp.content = myBox
        popUp.size_hint = (0.8, 0.5)

        button.bind(on_release=popUp.dismiss)

        return popUp
Example #8
0
 def on_enter(self):
     popup = Popup(title='Ingredients-List') #On entering this screen, a popup is made
     g_layout = GridLayout(rows=2)
     g_layout2 = GridLayout(cols=2, size_hint=(1,0.3))
     cont_btn = Button(text='Would you like to continue?',size_hint_y=None, font_size=20) #Size_hint_y is the horizontal size of the button, and i made it set such that it has no fixed value
     cont_btn.bind(on_press = popup.dismiss)
     cont_btn.bind(on_release = self.advance)
     back_btn = Button(text='Would you like to go back?', size_hint_y=None, font_size=20)
     back_btn.bind(on_press = self.back)
     back_btn.bind(on_release = popup.dismiss)
     ingredients_list = self.ingredients()
     ingredient_string = ''
     for ingredient in ingredients_list: # Add a ingredient into the ingredient_list
         if len(ingredient) > 70:
             ingredient = ingredient[:70] + '\n'+ ingredient[70:] # It makes sure that the ingredients length of each line does not exceed the allowed size of the border, by shortening it down
         ingredient_string += ingredient + '\n' # Add the string to the line 
     ingred_list = Label(text=ingredient_string, # Uses the ingredient_String line used as the text in the label
                              halign="center",
                              valign = "top")
     g_layout2.add_widget(back_btn)              
     g_layout2.add_widget(cont_btn)   
     g_layout.add_widget(ingred_list) 
     g_layout.add_widget(g_layout2)   
     popup.content = g_layout 
     popup.open()
    def generateJSON(self):
        
        ##### update the self.newData with customized command   ######

        for i in range(len(self.data['mapType']['resourceType'])):
            capability = self.data['mapType']['capability'][i][0]
            if (self.modf[i][0] == True) and ("valueMap" in self.data['mapData'][capability]):
                for j in range(len(self.checkbox[capability])) :
                    if self.checkbox[capability][j].active == True:
                        self.newData['mapData'][capability]["valueMap"][0]["OCFValue"][j] = self.updatedCommand[capability][j].text
        
        ###############################################################
        
    
        # adding popup
        popup = Popup(title='JSON file',size_hint=(.9, .9))
        popup.content = BoxLayout(orientation="vertical")
        popup.content.add_widget(Label(text="Click Download button to save the updated JSON file in the current folder"))
        
        #back button
        layout = FloatLayout(size_hint_y = .2)
        button = Button(text=' Close ', size_hint = (.2,.4) , pos_hint = {'x':.3 , 'y' : .4} )
        button.bind(on_press=popup.dismiss)
        layout.add_widget(button)
        
        #download button
        downld = Button(text = "Download" , size_hint = (.2,.4) , pos_hint = {'x':.5 , 'y' : .4})
        downld.bind(on_press = lambda x:self.downloadFile())
        layout.add_widget(downld)
        popup.content.add_widget(layout)
        popup.open()
Example #10
0
	def timesheet_pop(self):
		"""Popup to display the Timesheet"""

		popup = Popup(title='Timesheet')
		b=BoxLayout(orientation='vertical')
		s = ScrollView()
		global tslabel
		tslabel=Label(size_hint_y=None,line_height=1.5,valign="top",
					  text="|_ID_|______DATE______|___TIME_SPENT____|_____TASK_________|")
		tslabel.bind(texture_size=tslabel.setter('size'))
		btn1=Button(text='CLOSE',size_hint=(1,.06))
		s.add_widget(tslabel)
		b.add_widget(s)
		b.add_widget(btn1)
		popup.content=b
		popup.open()
		btn1.bind(on_press=popup.dismiss)

		con=lite.connect('TimeTracker.db')
		with con:
				cur=con.cursor()
				cur.execute("SELECT ID, TASK_DATE, TIME, TASK FROM Timesheet")
				rows = cur.fetchall()
				for row in rows:
				  tslabel.text=tslabel.text+"\n   "
				  tslabel.text+=str(row[0]).center(4)+"      "+str(row[1])
				  tslabel.text+="  "+str(row[2]).center(34)+"  "+str(row[3])
		if con:
				con.close()
Example #11
0
 def pressed(self):
     global query                    # I have had to use global variables as the kivy module does not allow classes to get parametres from one another, as that interferes with
     query = self.ids.dish.text      #the screens that are being used, as if i called one class in another, the classes layouts also get copied across which cannot be changed 
     query = "+".join(query.split())
     global toggle                   #As stated above regarding the use of global variables, toggle is the state of the BBC button (either down or normal)
     toggle = self.ids.BBC.state
     BBC = "https://www.bbc.co.uk/food/search?q=" + query #Gets the URL's of the specific query
     bakingMad = "https://www.bakingmad.com/search-results?searchtext=" + query
     if toggle == "down":
         content_list = self.list_of_dishes(query, BBC) #If the user clicks the BBC button, they get the list of BBC dishes
     else:
         content_list = self.list_of_dishes(query, bakingMad) #If the user clicks the BakingMad button, they get a list of BakingMad dishes
     #GoodFood = "https://www.bbcgoodfood.com/search/recipes?query=" + query
     global choices                              #Once again a global variable is used for the same reason as above
     choices = self.choices_list(content_list)
     
     if len(choices) == 0: #If there are no dishes for the user to choose from, it opens a popup that would tell the user there are no dishes available
         popup_alert = Popup(title = "No dishes")
         layout = GridLayout(rows = 2)
         label2 = Label(text="There are no dishes that match your criteria \n Please go back")
         btn2 = Button(text="Accept")
         btn2.bind(on_release = popup_alert.dismiss)
         layout.add_widget(label2)
         layout.add_widget(btn2)
         popup_alert.content = layout
         popup_alert.open()
     return choices
    def are_you_sure_exit(self):

        myBox = BoxLayout()
        myBox.orientation = 'vertical'

        myLabel = Label()
        myLabel.text = 'Are you sure\nyou wanna exit the game?'

        button = Button()
        button.text = 'No'
        button.size_hint_y = 0.2

        button1 = Button()
        button1.text = 'Yes'
        button1.size_hint_y = 0.2

        bar = Widget()
        bar.size_hint_y = 0.02

        myBox.add_widget(myLabel)
        myBox.add_widget(button1)
        myBox.add_widget(bar)
        myBox.add_widget(button)

        popUp = Popup()
        popUp.title = 'Exiting the game'
        popUp.content = myBox
        popUp.size_hint = (0.8, 0.8)

        button.bind(on_release=popUp.dismiss)
        button1.bind(on_release=self.exit_application)

        return popUp
Example #13
0
    def about(*args):
        '''Displays `about` page of the app and includes other credits.

        .. versionadded:: 0.1.0
        '''
        aboutdlg = Popup(title='About')
        text = ('Copyright (C) 2016, KeyWeeUsr(Peter Badida)\n'
                'License: GNU GPL v3.0\n'
                'Find me @ https://github.com/KeyWeeUsr\n\n'
                'Used Software:\n\n'
                'Python\n'
                'Copyright (C) 2001-2016 Python Software Foundation\n'
                'All rights reserved.\n\n'
                'Kivy\n'
                'Copyright (C) 2010-2016 Kivy Team and other contributors\n\n'
                'NumPy\n'
                'Copyright (C) 2005-2016, NumPy Developers.\n'
                'All rights reserved.\n\n'
                'SciPy\n'
                'Copyright (C) 2003-2013 SciPy Developers.\n'
                'All rights reserved.\n\n'
                'MatPlotLib\n'
                'Copyright (C) 2002-2016 John D. Hunter\n'
                'All Rights Reserved\n')

        aboutdlg.content = Label(text=text)
        aboutdlg.open()
Example #14
0
    def disrupt_game_popUp(self):

        myBox = BoxLayout()
        myBox.orientation = 'vertical'

        myLabel = Label()
        myLabel.text = 'This will quit the current game.\nAre you sure?'

        button1 = Button()
        button1.text = 'Yes'
        button1.size_hint_y = 0.2

        button2 = Button()
        button2.text = 'No'
        button2.size_hint_y = 0.2

        bar = Widget()
        bar.size_hint_y = 0.02

        myBox.add_widget(myLabel)
        myBox.add_widget(button1)
        myBox.add_widget(bar)
        myBox.add_widget(button2)

        popUp = Popup()
        popUp.title = 'Stop the game?'
        popUp.content = myBox
        popUp.size_hint = (0.9, 0.8)
        popUp.auto_dismiss = False

        #button.bind(on_release=popUp.dismiss)
        button1.bind(on_release=self.disrupt_yes)
        button2.bind(on_release=self.disrupt_no)

        return popUp
Example #15
0
 def create_inner_menu(self):
     popup = Popup(title="Choose the size of the cube", size_hint=(0.5, 0.5), auto_dismiss=False)
     layout = BoxLayout(orientation="vertical")
     label = Label(text="", font_size="20dp")
     layout.add_widget(label)
     
     textinput = TextInput(multiline=False, font_size="30dp")
     layout.add_widget(textinput)
     button = Button(text="Begin!", font_size="30dp")
     
     def _create_cube(inst):
         try:
             cube_size = int(textinput.text)
         except:
             label.text = "Error. Enter proper value."
             return
         if cube_size > 6 or cube_size < 2:
             label.text = "Cube size should be between 2 and 6"
             return
         self.create_cube(cube_size)
         textinput.focus = False
         popup.dismiss()
         
     button.bind(on_release=_create_cube)
     layout.add_widget(button)
     popup.content = layout
     popup.open()
     popup.pos = popup.pos[0], Window.height / 2.
Example #16
0
 def loadGraph(self, filePath):
     f = open(filePath)
     v = int(f.readline())
     e = int(f.readline())
     if (v + e) > 3000:
         print('Woah there! Pick a smaller graph!')
         Btn = Button(text="Okay", size_hint=(1,1))
         popup = Popup(size_hint=(None,None),size=(300,200),\
                   title='Woah there! Pick a smaller graph!')
         Btn.bind(on_press=popup.dismiss)
         popup.content=Btn
         popup.open()
         return False
     valid = self.newGraph(v)
     if valid == False:
         return
     #Read edge info
     for i in range(0, e):
         line = f.readline()
         arr = line.split()
         self.addEdge(int(arr[0]), int(arr[1]), float(arr[2]))
     #Read vertex info (optional)
     while True:
         line = f.readline()
         if line == "":
             return
         else:
             arr = line.split("|")
             vNo = int(arr[0].strip())
             if len(arr) == 2:
                 self.setVertexName(vNo, arr[1].strip())
             else:
                 self.setVertexNameInfo(vNo, arr[1].strip(), arr[2].strip())
Example #17
0
 def on_release(self):
     popup = Popup(title=str(self.info), size_hint=(.29, .5))
     popup.content = InfoLabel(text=config.descriptions[self.info],
                               pos_hint=({
                                   'center_y': .5
                               }))
     popup.open()
Example #18
0
    def on_press(self, instance):
        renew_timeout()
        global times, user, registration_fields
        if focused is not None:
            Clock.schedule_once(focused.refocus, 0.1)

        # logger.debug('Application: '+time.time() - times.get(instance.text, time.time() - 100))
        if time.time() - times.get(instance.text, time.time() - 100) > .05:
            times.update({instance.text: time.time()})
            # logger.debug('Application: '+instance.text)
            if focused is not None:
                if instance.text not in ('DEL', 'SPEICHERN'):
                    focused.insert_text(instance.text)
                elif instance.text == 'DEL':
                    focused.do_backspace()
                elif instance.text == 'SPEICHERN':
                    if '' in (RS.ids['firstname'].text,
                              RS.ids['lastname'].text, RS.ids['email'].text):
                        b = BoxLayout()
                        b.orientation = 'vertical'
                        b.add_widget(
                            Label(text='Bitte alle Felder ausfüllen!'))
                        btn = Button(text='Ok')
                        b.add_widget(btn)
                        p = Popup()
                        p.title = 'Fehler'
                        p.content = b
                        btn.bind(on_press=p.dismiss)
                        p.open()
                        return
                    # Create user
                    user = data.register_user(RS.ids['firstname'].text,
                                              RS.ids['lastname'].text,
                                              RS.ids['email'].text, badge_)
                    logout()
Example #19
0
    def parcours(self):
        popup = Popup(title='Ajouter un admin',
                      size_hint=(0.9, 0.9),
                      auto_dismiss=False)
        bl = BoxLayout(orientation='vertical')

        by_name = Button(text="Par nom")
        by_name.bind(on_press=lambda a: self.p_name(popup))

        by_degree = Button(text="Par degre")
        by_degree.bind(on_press=lambda a: self.p_degree(popup))

        search = Button(text="Rechercher...")
        search.bind(on_press=lambda a: self.p_find(popup))

        bl.add_widget(by_name)
        bl.add_widget(by_degree)
        bl.add_widget(search)

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

        popup.content = bl
        popup.open()
Example #20
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()
Example #21
0
    def p_display(self, som):
        bl = BoxLayout(orientation='vertical')

        if isinstance(som, Page):
            popup = Popup(title='Page :',
                          size_hint=(0.9, 0.9),
                          auto_dismiss=False)
            l = Label(text=som.__repr__())
            bl.add_widget(l)
        else:
            if isinstance(som, Utilisateur):
                popup = Popup(title='Utilisateur :',
                              size_hint=(0.9, 0.9),
                              auto_dismiss=False)
                l = Label(text=som.__repr__())
                bl.add_widget(l)
            else:
                popup = Popup(title='Impossible de trouver le sommet !')

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

        popup.content = bl
        popup.open()
Example #22
0
    def p_find(self, popup):
        popup.dismiss()

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

        confirmButton = Button(text="Confirmer")

        som_name = TextInput(multiline=False)

        confirmButton.bind(
            on_press=lambda a: self.p_display(self.g.find_name(som_name.text)))

        bl.add_widget(som_name)

        bl.add_widget(confirmButton)

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

        popup.content = bl
        popup.open()
    def run(self, instance):
        cv = []
        for child in self.drawing_space.children:
            cv.append(child)

        workflow = dict(cv=cv)

        jstr = json.dumps(dict(workflow=workflow), cls=KrakenJsonEncoder)

        p = subprocess.Popen([
            sys.executable,
            settings['kraken_path'] + '/kraken_backend/kraken.py'
        ],
                             stdin=subprocess.PIPE,
                             stdout=subprocess.PIPE)
        out, _ = p.communicate(jstr.encode())
        #print(out.decode())

        #print('out',settings['kraken_path'] + '/kraken_backend/kraken.py')
        status = eval(out)

        popup = Popup(title='Running Status',
                      size_hint=(None, None),
                      size=(400, 180))
        content = BoxLayout(orientation='vertical')
        content.add_widget(Label(text=status['status']))
        b = Button(text='Close')
        b.bind(on_press=popup.dismiss)
        content.add_widget(b)
        popup.content = content
        popup.open()
Example #24
0
def get_stock_data(row_text, dt):

    sym = row_text[9:-7]
    if not sym.isalpha():
        print('%s not a symbol' % sym)
        return

    nse = Nse()
    print('getting nse price for stock ', sym)
    q = nse.get_quote(sym)
    popup = Popup()
    popup.title = 'Live data for ' + sym
    popup.size_hint = (.7, .6)
    popup.pos_hint = {'center_x': .5, 'center_y': .5}

    if q is not None:
        ltp = q['lastPrice']
        low = q['dayLow']
        high = q['dayHigh']
        high52 = q['high52']
        low52 = q['low52']
        prevClose = q['previousClose']
        pChange = q['pChange']
        val = get_ltp_string(sym, ltp, prevClose, pChange)
        c1 = Label(text='Symbol')
        c2 = Label(text=sym)
        c3 = Label(text='PrevClose')
        c4 = Label(text=str(prevClose))
        c5 = Label(text='Last Price')
        c6 = Label(text=val, markup=True)
        c7 = Label(text='Day Low')
        c8 = Label(text=str(low))
        c9 = Label(text='Day High')
        c10 = Label(text=str(high))
        c11 = Label(text='52 week Low')
        c12 = Label(text=str(low52))
        c13 = Label(text='52 week High')
        c14 = Label(text=str(high52))
        # add the data
        gridlayout = GridLayout(cols=2)
        gridlayout.add_widget(c1)
        gridlayout.add_widget(c2)
        gridlayout.add_widget(c3)
        gridlayout.add_widget(c4)
        gridlayout.add_widget(c5)
        gridlayout.add_widget(c6)
        gridlayout.add_widget(c7)
        gridlayout.add_widget(c8)
        gridlayout.add_widget(c9)
        gridlayout.add_widget(c10)
        gridlayout.add_widget(c11)
        gridlayout.add_widget(c12)
        gridlayout.add_widget(c13)
        gridlayout.add_widget(c14)
        content = gridlayout
    else:
        content = Label(text='No data available for symbol ' + sym)
    popup.content = content
    popup.open()
    MDApp.get_running_app().stock_fetch = False
Example #25
0
    def btnMMGame_release(self, btn):

        if (self.game.isOver):

            self.set_all_button_disable(True)

            boxLayout = BoxLayout(orientation="vertical")

            dlgGameOver = Popup(title="Game Over",
                                size_hint=(None, None),
                                size=(500, 400),
                                auto_dismiss=False)

            lblWinner = Label(text="")
            lblWinner.font_size = 24

            btnMainMenu = Button(text="MainMenu")
            btnMainMenu.bind(on_press=self.btnMainMenu_press)
            btnMainMenu.bind(on_release=dlgGameOver.dismiss)

            if (self.player.isWin):
                lblWinner.text += "You won!"

            elif (self.enemy.isWin):
                lblWinner.text += "Yay!! I won"
            else:
                lblWinner.text = "Draw! You are tough to crack"

            boxLayout.add_widget(lblWinner)
            boxLayout.add_widget(btnMainMenu)

            dlgGameOver.content = boxLayout
            dlgGameOver.open()
Example #26
0
    def state_goal_popUp(self):

        myBox = BoxLayout()
        myBox.orientation = 'vertical'

        myLabel = Label()

        if ArtInfo.max_score[self.puzzle_index] != None:
            myLabel.text = 'Reach score of ' + str(
                self.goal) + '\nto unlock next stage.\n\
Maximum score: ' + str(ArtInfo.max_score[self.puzzle_index])
        else:
            myLabel.text = 'Reach score of ' + str(
                self.goal) + '\nto unlock next stage.\n\
Maximum score: unlimtied'

        button = Button()
        button.text = 'Ok!'
        button.size_hint_y = 0.3

        myBox.add_widget(myLabel)
        myBox.add_widget(button)

        popUp = Popup()
        popUp.title = 'Mission'
        popUp.content = myBox
        popUp.size_hint = (0.8, 0.5)
        popUp.auto_dismiss = False

        button.bind(on_release=self.start_timing_press)

        return popUp
Example #27
0
	def readme_pop(self):
		""" Readme """

		popup = Popup(title='README')
		b=BoxLayout(orientation='vertical')
		s = ScrollView()
		global tslabel
		tslabel=Label(size_hint_y=None,line_height=1.5,valign="top",
					  text= "Copyright (C) 2015 Revathy Narayanan\n" +
					  "The TimeTracker is a Python application \n that will keep"+
					  " track of time spent\n in day-to-day activities.\n\n"+
"The Application will have features \n"+
"* Start/Stop watch \n * Log Task\n * Add Comments\n"+
"* Generate & View Timesheet\n * Mail Timesheet\n\n "+
"The code is licensed under MIT License(MIT).\n "+
"Please see the file license in this distribution\n for license terms in the link below :\n"+
"https://github.com/rev20/Time-Tracker/blob/master/LICENSE \n\n"+
"Following is the link for the repository: \n"+
"https://github.com/rev20/Time-Tracker/")

		tslabel.bind(texture_size=tslabel.setter('size'))
		btn1=Button(text='CLOSE',size_hint=(1,.06))
		s.add_widget(tslabel)
		b.add_widget(s)
		b.add_widget(btn1)
		popup.content=b
		popup.open()
		btn1.bind(on_press=popup.dismiss)
Example #28
0
 def on_enter(self):
     popup = Popup(title='Dish Options', size_hint=(1,1))
     layout1 = StackLayout(orientation='lr-bt') #This time the options are layed out in a stack layout, so that I can have multiple options in a small space
     closebutton = Button(text='I want to make a different dish', size_hint=(0.9,0.05)) #This is a button that will make a different dish for the user
     closebutton.bind(on_press= popup.dismiss)                                           #The size_hint is the x and y co-ordinate score of how much percentage of the screen the button will have (with 1 being all the screen)
     closebutton.bind(on_release = self.change_page)
     scrlv = ScrollView(size_hint=(0.9,0.95)) #This adds a scrollable bar to the list of dishes, if there are lots of them
     slid = Slider(min=0, max=1, value=25, orientation='vertical', step=0.01, size_hint=(0.1, 0.95)) #The slid is the physical slider used, which calles the scrlv
     #step is the percentage of the screen it takes up, min and max are always 1 and 0 as they show the ful percentage of the screen covered by the bar
     scrlv.bind(scroll_y=partial(self.slider_change, slid))
     #what this does is, whenever the slider is dragged, it scrolls the previously added scrollview by the same amount the slider is dragged
     slid.bind(value=partial(self.scroll_change, scrlv))
     layout2 = GridLayout(cols=4, size_hint_y=None) #This is another grdi layout used within the popup
     layout2.bind(minimum_height=layout2.setter('height')) #Bind the height of the layout to the minimum height so that the scroll bar functions
     for txt in choices:
         btn = Button(text=txt, size_hint_y=None, height=80, valign='middle', font_size=12) # Add a button for each dish
         btn.text_size = (btn.size) #set the buttons so that their size changes depending on the screen size
         btn.bind(on_press = self.find_dish) #When the button is pressed, call the find_dish subroutine
         btn.bind(on_release = popup.dismiss) #Close the popup if they click the button
         layout2.add_widget(btn) # Add the buttons to the layout
     scrlv.add_widget(layout2)
     layout1.add_widget(closebutton) #Add the close button to the layout
     layout1.add_widget(scrlv) # Add the scroll bar to the layout
     layout1.add_widget(slid)  #Add the slider to the layout for the scroll bar
     popup.content = layout1
     popup.open()
     if len(choices) == 0:
         popup.dismiss()
         sm.current = "main" #This changes the screen back to the original "main" screen if there are no dishes, which allows the users to choose another dish
Example #29
0
    def game_over_popUp(self):

        myBox = BoxLayout()
        myBox.orientation = 'vertical'

        myLabel = Label()
        myLabel.text = 'Your score: ' + str(
            self.score) + '\nHighest score: ' + str(self.highest_score)
        if self.critical:
            myLabel.text = myLabel.text + '\nYou must score at least ' + str(
                self.goal) + '\nto unlock next level'

        button = Button()
        button.text = 'Ok'
        button.size_hint_y = 0.3

        myBox.add_widget(myLabel)
        myBox.add_widget(button)

        popUp = Popup()
        popUp.title = 'Result: Level ' + str(self.puzzle_index + 1)
        popUp.content = myBox
        popUp.size_hint = (0.8, 0.5)
        popUp.auto_dismiss = False

        button.bind(on_release=self.reset_timer)

        self.game_over_message_popUp = popUp
        self.game_over_message_popUp.open()
    def achievement_popUp(self):
        #MUST BE CALLED AFTER CALLING self.achievement_update() above

        myBox = BoxLayout()
        myBox.orientation = 'vertical'

        myLabel = Label()
        myLabel.text = self.achievement_update()
        myLabel.size_hint_y = len(ArtInfo.fanpage_url) * 0.07

        myScroll = ScrollView()
        myScroll.add_widget(myLabel)

        button = Button()
        button.text = 'Dismiss'
        button.size_hint_y = 0.15

        myBox.add_widget(myScroll)
        myBox.add_widget(button)

        popUp = Popup()
        popUp.title = 'Highest scores'
        popUp.content = myBox
        popUp.size_hint = (0.9, 0.8)

        button.bind(on_release=popUp.dismiss)

        popUp.open()
    def locked_pop_up(self):
        #A LOT OF LITERAL

        from kivy.uix.label import Label

        myBox=BoxLayout()
        myBox.orientation='vertical'
        
        myLabel=Label()
        myLabel.text='Clear previous stage\nto unlock this level'
        myLabel.valign='middle'
        myLabel.halign='center'

        button=Button()
        button.text='Dismiss'
        button.size_hint_y=0.3

        myBox.add_widget(myLabel)
        myBox.add_widget(button)
        
        popUp=Popup()
        popUp.title='Level locked'
        popUp.content=myBox
        popUp.size_hint=(0.7,0.5)

        button.bind(on_release=popUp.dismiss)
        
        return popUp
Example #32
0
 def open_not_implemented(self, log, pop_width, pop_height):
     pop = Popup(title=lang['Not_yet_implemented'])
     pop.size_hint = None, None
     pop.width = pop_width
     pop.height = pop_height
     pop.content = Label(text=logNot[log])
     pop.open()
Example #33
0
    def artist_unavailable_popUp(self):

        #MOVE THESE TO SOMEWHERE BETTER

        myBox = BoxLayout()
        myBox.orientation = 'vertical'

        myLabel = Label()
        myLabel.text = 'Artist fanpage is\nunavailable at this time'

        button = Button()
        button.text = 'Dismiss'
        button.size_hint_y = 0.3

        myBox.add_widget(myLabel)
        myBox.add_widget(button)

        popUp = Popup()
        popUp.title = 'Level locked'
        popUp.content = myBox
        popUp.size_hint = (0.5, 0.5)
        popUp.auto_dismiss = False

        button.bind(on_release=popUp.dismiss)

        popUp.open()
Example #34
0
    def _consolidate(self):
        """
        Performs consolidation
        """

        def consolidation_closure(index, clo_cl, clo_popup):
            def fn(*args):
                sel = clo_cl.pop(index)

                for rem in clo_cl:

                    old_typeid = rem.typeid
                    # Set all relevant fields
                    rem.value = sel.value
                    rem.manufacturer = sel.manufacturer
                    rem.manufacturer_pn = sel.manufacturer_pn
                    rem.supplier_pn = sel.supplier_pn
                    rem.supplier_url = sel.supplier_url
                    rem.supplier = sel.supplier

                    sel.extract_components(rem)
                    self.component_type_map.pop(old_typeid, None)

                self._update_data()
                clo_popup.dismiss()
            return fn

        uniq = {}
        dups = {}

        ctmap_keys = self.component_type_map.keys()

        # Find all duplicated components and put them into a dups map
        for ct in ctmap_keys:
            cthsh = ct.upper().replace(' ', '')

            if cthsh in uniq:
                if cthsh not in dups:
                    dups[cthsh] = [uniq[cthsh]]

                dups[cthsh].append(self.component_type_map[ct])
            else:
                uniq[cthsh] = self.component_type_map[ct]

        for d, cl in dups.items():

            _popup = Popup(title='Duplicate part value',
                           auto_dismiss=False,
                           size_hint=(0.9, 0.9))
            content = UniquePartSelectorDialog()
            for idx, c in enumerate(cl):
                content.top_box.add_widget(
                    Button(text=c.value,
                           on_release=consolidation_closure(idx,
                                                            cl,
                                                            _popup))
                )

            _popup.content = content
            _popup.open()
Example #35
0
 def show_color_picker(self, current_color):
     popup = Popup(title='Color Picker',
                   size_hint=(0.5, 0.5))
     color_picker = ColorPicker(color=current_color)
     color_picker.bind(color=self.on_paint_color)
     popup.content = color_picker
     popup.open()
Example #36
0
 def __init__(self, title):        
     p = Popup(title=title,size_hint=(None,None),size=(300,150))
     button = Button(text="okay", 
                     background_normal='kuvat/nappi_tausta.png',
                     background_down='kuvat/nappi_tausta_pressed.png',
                     on_release=p.dismiss)
     p.content = button
     p.open()          
Example #37
0
    def image_viewer(self):
        '''A quick and easy image viewer without leaving kivy'''
        image_viewer_button = Button(text = 'image viewer', size_hint_y = 0.2, background_color = [1, 1, 0, 1])
        
        # a popup window to display image
        image_viewer_popup = Popup(title = 'image viewer', size_hint = (1,1))
        image_viewer_exit_button = Button(text = 'exit image preview', size_hint_y = 0.1, font_size='20sp')
        self.image_object = Image(size_hint_y = 0.9)
        image_viewer_layout = BoxLayout(orientation = "vertical")
        image_viewer_layout.add_widget(self.image_object)
        image_viewer_layout.add_widget(image_viewer_exit_button)
        image_viewer_popup.content = image_viewer_layout
        # A count number for preview
        self.temp_file_number = 0

        def activate_folder_chooser(instance):
            if debug_mode is False:
            # When click the time_lapse_interval_input, stop the preview
                mc.camera_library('stop_preview')
            self.folder_chooser.path = self.folder
            self.folder_chooser_popup.open()

        def view_image(instance, value):
            # Callback function for FileChooser when select files
            # change from "['C:\\abc.jpg']" to "C:\\abc.jpg"
            filepath = str(value).replace('[','').replace(']','').replace('\'','')
            # check the file type
            filepath_split = filepath.split('.')

            if filepath_split[-1] in ['jpg', 'jpeg', 'png', 'tif', 'tiff']:
                # if the file is a image, then open the image_viewer
                # use pillow to create a thumbnail of the image, save memory
                size = (Window.width*0.9, Window.height*0.9)
                temp_file_location = "/home/pi/microscope/temp/{}.jpg".format(self.temp_file_number)   
                im = PIL_Image.open(filepath)
                im.thumbnail(size)
                # save as a temporary file
                im.save(temp_file_location, "JPEG")
                im.close()
                im = None
                # load the image again as a kivy object
                self.image_object.source = temp_file_location
                self.temp_file_number += 1
                # scatter_image_object = Scatter(size_hint_x = 0.5, size_hint_y = 0.5)
                # scatter_image_object.add_widget(image_object)
                # image_viewer_popup.content = scatter_image_object
                # add a layout with an exit button
                image_viewer_popup.open()
                os.remove(temp_file_location)

        def dismiss_image_viewer_popup(instance, *value):
            image_viewer_popup.dismiss()
            self.image_object.source = ''

        image_viewer_button.bind(on_release = activate_folder_chooser)
        image_viewer_exit_button.bind(on_release = dismiss_image_viewer_popup)
        # self.folder_chooser.bind(selection = view_image)
        return image_viewer_button
Example #38
0
File: main.py Project: mn22nw/IU
 def displayVictoryScreen(self):
     victoryScreen = Popup( title='EPIC WIN!', auto_dismiss=True,
                         attach_to=self,
                         size_hint=(None,None), pos_hint={'center_x': 0.5, 'center_y': .6} 
                         )
     layout = BoxLayout(orientation = 'vertical')
     image = Image(source='graphics/victory.png', pos_hint={'center_x': 0.5, 'center_y': 0.4})
     layout.add_widget(image)
     victoryScreen.content = layout
     victoryScreen.open()     
Example #39
0
File: main.py Project: mn22nw/IU
 def displayCollisionScreen(self):
     collisionScreen = Popup( title='Collision!', auto_dismiss=False,
                         attach_to=self,
                         size_hint=(None,None), pos_hint={'center_x': 0.5, 'center_y': .6} 
                         )
     layout = BoxLayout(orientation = 'vertical')
     image = Image(source='graphics/onCollision.png', pos_hint={'center_x': 0.5, 'center_y': 0.4})
     layout.add_widget(image)
     collisionScreen.content = layout
     collisionScreen.open()
     Clock.schedule_once(collisionScreen.dismiss, 2.5)     
    def receiverPopup(self,button,title):
		layout = BoxLayout(orientation='vertical')
		pop = Popup(attach_to=self,title=str(title),title_align = 'center',size_hint = (.5,.5))
		for r in self.tree.iter('receiver'):
			if (list(r)[0].text).upper() == 'F':
				btn = Button(text='%s' % str(list(r)[4].text), size_y = 5)
				btn.bind(on_press = lambda x: setattr(button, 'text', str(x.text)))
				btn.bind(on_release = pop.dismiss)
				layout.add_widget(btn)
		pop.content = layout
		pop.open()
Example #41
0
File: main.py Project: mn22nw/IU
 def displayLifeIsLostScreen(self):
     lifeIsLostScreen = Popup( title='Life is lost', auto_dismiss=False,
                         attach_to=self,
                         size_hint=(None,None), pos_hint={'center_x': 0.5, 'center_y': .6} 
                         )
     layout = BoxLayout(orientation = 'vertical')
     image = Image(source='graphics/lifeLost.png', pos_hint={'center_x': 0.5, 'center_y': 0.4})
     layout.add_widget(image)
     lifeIsLostScreen.content = layout
     lifeIsLostScreen.open()
     Clock.schedule_once(lifeIsLostScreen.dismiss, 2.5)
     Clock.schedule_once(self.removeLife, 2.6)
Example #42
0
def alert(msg, title=""):
    '''
    Alert function
    '''
    popup = Popup(title=title, size_hint=(None,None), size=(400,200) )
    content = BoxLayout(orientation="vertical")
    content.add_widget(Label(text=msg))
    content.add_widget(Button(text="Aceptar", on_press=popup.dismiss))
    popup.content=content
    popup.open()
    
    return popup
Example #43
0
 def __init__(self, title, text):
     popup = Popup(title=title, size_hint=(0.8, 0.8))
     scrollView = ScrollView(size_hint=(1, 1))
     label = Label(text=text, size_hint=(None,None), size=(1000,3000), text_size=(1000, 3000), valign='top')
     label.font_size=12
     #TODO: Bind texture size to size (Y dimension)
     scrollView.add_widget(label)
     closeButton = Button(text='Ok', on_press=popup.dismiss, size_hint_y = 0.1)
     vlayout = BoxLayout(orientation='vertical')
     vlayout.add_widget(scrollView)
     vlayout.add_widget(closeButton)
     popup.content = vlayout
     popup.open()
Example #44
0
def create_settings_button():
    # a button to call out settings panel
    settings_button = Button(text = 'settings')

    # configure a popup window to display settings and parameters
    settings_popup = Popup( title='Settings', size_hint=(0.8, 0.2))
    settings_popup.pos_hint =  {'x':0.5-settings_popup.size_hint[0]/2,
                               'y':0.9-settings_popup.size_hint[1]/2} # distance from popup.center
    settings_popup_content = GridLayout(cols=1) # a blank layout to put other widgets in
    settings_popup.content = settings_popup_content
    
    # when popup occurs, rezie the preview screen to prevent blockage?
    def fullscreen_preview(instance):
        """when popup get dismissed, revert camera preview window to normal"""
        mc.camera_library('stop_preview')
        mc.camera_library('fullscreen_preview')
    def reduced_size_preview(instance):
        """when popup get opened, reduce camera preview window size to prevent blocking"""
        mc.camera_library('stop_preview')
        reduced_size_window = (int(Window.width*0.2), int(Window.height*0.25), int(Window.width*0.6), int(Window.width*0.6/1.33))
        mc.camera_library('reduced_size_preview',reduced_size_window)
        
    settings_popup.bind(on_dismiss = fullscreen_preview)
    settings_popup.bind(on_open = reduced_size_preview)

    def switch_settings_popup_content(instance):
        """alter popup content when clicking buttons"""
        settings_popup_content.clear_widgets()
        settings_popup.open()
        if instance == settings_button:
            settings_popup_content.add_widget(settings_panel)
        elif instance == contrast_button:
            settings_popup_content.add_widget(contrast_controller)
        elif instance == brightness_button:
            settings_popup_content.add_widget(brightness_controller)
        elif instance == filepath_button:
            settings_popup_content.add_widget(filepath_controller)
            mc.camera_library('stop_preview') # the preview will block the keyboard
            filepath_input.text = format_filepath()

    
    # add buttons to call out popups
    # settings_panel with 3 buttons on it
    settings_panel, contrast_button, brightness_button, filepath_button = create_settings_panel()
    brightness_controller, contrast_controller = create_settings_controllers()
    filepath_controller = create_filepath_controller()

    for button in [settings_button, contrast_button, brightness_button, filepath_button]:
        button.bind(on_release= switch_settings_popup_content)

    return settings_button
 def submit(self,horizontal,vertical,gps_spacing,antennaHeight,phaseCenter):
     updateTolerance = False
     try:
         if self.verifyToleranceValues(float(horizontal),float(vertical),float(gps_spacing)):
             if vertical != list(self.tree.iter('vertical'))[0].text:
                 updateTolerance = True
                 list(self.tree.iter('vertical'))[0].text = vertical
             if horizontal != list(self.tree.iter('horizontal'))[0].text:
                 updateTolerance = True
                 list(self.tree.iter('horizontal'))[0].text = horizontal
             if gps_spacing != list(self.tree.iter('gps_spacing'))[0].text:
                 updateTolerance = True
                 list(self.tree.iter('gps_spacing'))[0].text = gps_spacing
             if antennaHeight != list(self.tree.iter('antennaHeight'))[0].text:
                 updateTolerance = True
                 list(self.tree.iter('antennaHeight'))[0].text = antennaHeight
             if phaseCenter != list(self.tree.iter('phaseCenter'))[0].text:
                 updateTolerance = True
                 list(self.tree.iter('phaseCenter'))[0].text = phaseCenter
             if updateTolerance:
                 self.root.settings_popup.dismiss()
                 self.tree.write(xmlFilePath)
                 popup_notif = Popup(attach_to=self,title='Settings', size_hint=(.3,.2))
                 content= Label(text ='Successfully submitted!')
                 content.bind(on_touch_up = popup_notif.dismiss)
                 popup_notif.content = content
                 popup_notif.open()
         popup_notesubmit = Popup(attach_to=self, title='Settings', size_hint=(.3,.2))
         content = Label(text='Submitted tolerances')
         content.bind(on_touch_up=popup_notesubmit.dismiss)
         popup_notesubmit.content = content
         popup_notesubmit.open()
     except ValueError:
         box = BoxLayout()
         box.add_widget(Label(text='There are fields in the settings menu that are empty.'))
         popup = Popup(title='Warning', content=box, size_hint = (None, None), size=(400,400))
         popup.open()
Example #46
0
    def select_color(self, instance, no_buts=True):
        '''
        The button click has fired the event, so show the popup.
        no_buts is  boolean and specifies whether to include buttons
        in the popup or not.
        '''
        popup = Popup(
            title="Select your colour",
            size_hint=(0.75, 0.75))

        # NOTE: the below properties can also be passed in to the Popup
        # constructor but we do them separately for clarity.
        if no_buts:
            colorPicker = ColorPicker()
            popup.bind(
                on_dismiss=lambda popup: \
                    self.popup_dismissed(popup, colorPicker.hex_color))
            popup.content = colorPicker
        else:
            # We prevent the default dismiss behaviour and roll our own in
            # the content.
            popup.auto_dismiss = False
            popup.content = self.get_ok_cancel_content(popup)
        popup.open()
Example #47
0
    def check_in(self):
        global tasks

        print tasks
        popup = Popup(title='Test popup',
            size_hint=(None, None), size=(400, 400))

        layout = GridLayout(cols=2)
        for task in tasks:
            b = Button(text=task.name)
            b.bind(on_press=popup.dismiss)
            b.bind(on_press=lambda x: self.did_task(task))

            layout.add_widget(b)
        popup.content = layout

        popup.open()
Example #48
0
File: main.py Project: mn22nw/IU
    def confirmClose(self):
        quitScreen = Popup( title='Quit Application', auto_dismiss=False,
                            attach_to=self,
                            size_hint=(None,None), pos_hint={'center_x': 0.5, 'center_y': .6}
                            )

        layout = BoxLayout(orientation = 'vertical')
        innerLayout = BoxLayout(size_hint_y = 0.2)
        l = Label(text='Are you sure you want to quit?',  size_hint_y = 0.8)
        layout.add_widget(l)
        btn = Button(text = 'Yes', on_press = self.close)
        btn2 = Button(text = 'No', on_press = quitScreen.dismiss)
        innerLayout.add_widget(btn)
        innerLayout.add_widget(btn2)
        layout.add_widget(innerLayout)

        quitScreen.content = layout
        quitScreen.open()
Example #49
0
def create_filepath_controller():
    global filepath_input # require to update in another function
    
    filepath_controller = BoxLayout(orientation = 'horizontal', size_hint_y = 0.1)
    folder_chooser_button = Button(text = 'File viewer \nto choose folder', size_hint_x = 0.2) # a button to popup filechooser
    filepath_input = TextInput(multiline = False, 
        size_hint_x = 1 - folder_chooser_button.size_hint_x)
    filepath = format_filepath() # use the default value which contains date and start from 001
    filepath_input.text = filepath
    for i in [filepath_input, folder_chooser_button]:
        filepath_controller.add_widget(i)

    folder_chooser = FileChooser()
    folder_chooser.add_widget(FileChooserIconLayout())
# a popup window to choose folder
    folder_chooser_popup = Popup(title = 'choose folder to save image', size_hint = (0.8, 0.8))
    folder_chooser_popup.pos_hint =  {'x':0.5-folder_chooser_popup.size_hint[0]/2,
                               'y':0.5-folder_chooser_popup.size_hint[1]/2} 
    folder_chooser_popup.content = folder_chooser
    folder_chooser_button.bind(on_release = folder_chooser_popup.open)
    
    def choose_folder(instance, value):
        global folder, folder_sign
        folder = str(value) + folder_sign
        filepath = format_filepath()
        filepath_input.text = filepath
    
    folder_chooser.bind(path = choose_folder)

    def update_filepath_input(instance):
        global folder, filename, folder_sign, filetype
        # seperate filepath_input elements
        filepath = filepath_input.text
        filepath_split = filepath.split(folder_sign)
        filename = filepath_split[-1] # last element after the folder sign 
        folder = folder_sign.join(filepath_split[0:-1]) + folder_sign 
        # format filepath and update filepath_input
        filepath = format_filepath()
        filepath_input.text = filepath

    filepath_input.bind(on_text_validate = update_filepath_input)

    return filepath_controller
	def btnGame_release(self, btn):

		if (self.game.isOver):

			self.set_all_button_disable(True)

			boxLayout = BoxLayout(orientation = "vertical")

			dlgGameOver = Popup(title = "GameOver",
					size_hint = (None, None),
					size = (400, 400),
					auto_dismiss = False)


			lblWinner = Label(text = "Winner : ")
			lblWinner.font_size = 24

			btnRestart = Button(text = "Restart")
			btnRestart.bind(on_press = self.btnRestart_press)
			btnRestart.bind(on_release = dlgGameOver.dismiss)


			btnMainMenu = Button(text = "MainMenu")
			btnMainMenu.bind(on_press = self.btnMainMenu_press)
			btnMainMenu.bind(on_release = dlgGameOver.dismiss)


			if (self.player1.isWin):
				lblWinner.text += self.player1.name + " (" + self.player1.marking + ")"

			elif (self.player2.isWin):
				lblWinner.text += self.player2.name + " (" + self.player2.marking + ")"

			else:
				lblWinner.text = "Tie"


			boxLayout.add_widget(lblWinner)
			boxLayout.add_widget(btnRestart)
			boxLayout.add_widget(btnMainMenu)

			dlgGameOver.content = boxLayout
			dlgGameOver.open()
Example #51
0
    def create_gallery(self):
        folder_chooser_button = Button(text = 'File viewer \nto choose folder', size_hint_x = 0.2) # a button to popup filechooser
        self.folder_chooser = FileChooser()
        self.folder_chooser.path = r'C:\Users\herbz\OneDrive - University Of Cambridge\Documents\GitHub\WaterScope-RPi\motor control'
        self.folder_chooser.add_widget(FileChooserIconLayout())
    # a popup window to choose folder
        folder_chooser_popup = Popup(title = 'choose folder to save image', size_hint = (0.9, 0.9))
        folder_chooser_popup.pos_hint =  {'x':0.5-folder_chooser_popup.size_hint[0]/2,
                                'y':0.5-folder_chooser_popup.size_hint[1]/2} 
        folder_chooser_popup.content = self.folder_chooser

        image_viewer_popup = Popup(title = 'image viewer', size_hint = (0.8, 0.8))
        self.number = 1
        def activate_folder_chooser(instance):
            folder_chooser_popup.open()
        def choose_image(instance, value):
            '''Callback function for FileChooser'''
            # change from "['C:\\abc.jpg']" to "C:\\abc.jpg"
            filepath = str(value).replace('[','').replace(']','').replace('\'','')
            print('file:' + filepath)
            # check the file type
            filepath_split = filepath.split('.')
            print('image: '+ filepath)
            
            if filepath_split[-1] in ['jpg', 'jpeg', 'png', 'tif', 'tiff']:
                im = PIL_Image.open(filepath)
                im.thumbnail((300,300))
                os.remove(self.thumbnail_location)
                self.thumbnail_location = r"C:\Users\herbz\OneDrive - University Of Cambridge\Documents\GitHub\WaterScope-RPi\motor control\exp\resources\thumbnail{}.jpg".format(self.number)
                im.save(self.thumbnail_location, "JPEG")
                im.close()
                self.image_object = Image(source = self.thumbnail_location, size_hint_x = 0.8, size_hint_y = 0.8)
                self.number = self.number*-1
                #self.image_object = Image(source = filepath)
                image_viewer_popup.content = self.image_object
                image_viewer_popup.open()
                os.remove(self.thumbnail_location)
            
            
        self.folder_chooser.bind(selection = choose_image)
        folder_chooser_button.bind(on_release = activate_folder_chooser)
        
        return folder_chooser_button
Example #52
0
	def button_release(self, btn):
		
		if (self.isGameOver):
			self.set_all_button_disable(True)
			
			boxLayout = BoxLayout(orientation = "vertical")

			dlgGameOver = Popup(title = "GameOver",
					size_hint = (None, None),
					size = (400, 400),
					auto_dismiss = False)


			lblWinner = Label(text = "Winner is : ")

			btnRestart = Button(text = "Restart")
			btnRestart.bind(on_press = self.restart_game)
			btnRestart.bind(on_release = dlgGameOver.dismiss)
			
			
			btnExit = Button(text = "Exit")
			btnExit.bind(on_release = App.get_running_app().stop)
			
			
			if (self.player.isWin):
				lblWinner.text += "Player."
				
			elif (self.enemy.isWin):
				lblWinner.text += "Computer."
				
			else:
				lblWinner.text = "This game is Tie."

			
			boxLayout.add_widget(lblWinner)
			boxLayout.add_widget(btnRestart)
			boxLayout.add_widget(btnExit)
			
			dlgGameOver.content = boxLayout
			dlgGameOver.open()
Example #53
0
    def attempt_part_lookup(self, *args):
        ct = self._current_type

        if ct is None:
            raise Exception("No component selected, this should not happen\n")

        if not ct.has_valid_key_fields:
            raise Exception("Missing key fields (value / footprint)!")

        up = self.ds.lookup(ct)

        if up is None:
            content = BoxLayout(orientation='vertical')
            content.add_widget(Label(text="Component does not exist in Datastore"))
            content.add_widget(Button(text='OK',
                                      size_hint_y=0.1,
                                      on_release=self.dismiss_popup))
            self._popup = Popup(title='No results found',
                                auto_dismiss=True,
                                content=content,
                                size_hint=(0.9, 0.9))
            self._popup.open()
            return

        if not up.manufacturer_pns.count():
            content = BoxLayout(orientation='vertical')
            content.add_widget(Label(text="No suitable parts found in Datastore"))
            content.add_widget(Button(text='OK',
                                      size_hint_y=0.1,
                                      on_release=self.dismiss_popup))
            
            self._popup = Popup(title='No results found',
                                auto_dismiss=True,
                                content=content,
                                size_hint=(0.9, 0.9))
            self._popup.open()
            return

        def lookup_closure(clo_mpn, clo_spn, clo_popup, *args):
            def fn (*args):
                if clo_mpn:
                    self.type_view.mfr_text.text = clo_mpn.manufacturer.name
                    self.type_view.mfr_pn_text.text = clo_mpn.pn
                if clo_spn:
                    self.type_view.sup_text.text = clo_spn.supplier.name
                    self.type_view.sup_pn_text.text = clo_spn.pn
                    self.type_view.sup_url_text.text = clo_spn.url

                if clo_popup:
                    clo_popup.dismiss()

            return fn

        cb_map = {}
        for pn in up.manufacturer_pns:
            if not len(pn.supplier_parts):
                btn_text = '{} (No Known Suppliers)'.format(
                    pn.pn
                )
                cb_map[btn_text] = (pn, None)
            else:
                for s_pn in pn.supplier_parts:
                    btn_text = '{} {} @ {}[{}]'.format(
                        pn.manufacturer.name,
                        pn.pn,
                        s_pn.supplier.name,
                        s_pn.pn
                    )
                    cb_map[btn_text] = (pn, s_pn)

        if len(cb_map) == 1:
            pn, s_pn = cb_map.values().pop()
            lookup_closure(pn, s_pn, None)()
        else:
            content = BoxLayout(orientation='vertical')
            _popup = Popup(title='No results found',
                           auto_dismiss=True,
                           size_hint=(0.9, 0.9))

            for btn_txt, pns in cb_map.items():
                cb = lookup_closure(pns[0], pns[1], _popup)
                content.add_widget(Button(text=btn_txt,
                                          size_hint_y=0.1,
                                          on_release=cb))
            _popup.content = content
            _popup.open()
Example #54
0
    def get_parameters(self):
        btn = self.set_param_btn_wid
        g = GridLayout(cols=2)
        param_temp = {}
        
        def only_if_callback(instance, value):
            value = value.strip()
            if value:
                param_temp['only_if'] = tuple(value.split(','))

        if self.action_type == 'say':
            g.add_widget(Label(text='message'))
            t = TextInput()
            if self.parameters:
                try:
                    t.text = self.parameters['message']
                except KeyError: 
                    pass
            t.bind(text=lambda _, value: param_temp.update({'message': value}))
            g.add_widget(t)

            g.add_widget(Label(text='only if'))
            t = TextInput()
            if self.parameters:
                try:
                    t.text = self.parameters['only_if']
                except KeyError: 
                    pass
            t.bind(text=only_if_callback)
            g.add_widget(t)
        elif self.action_type == 'listen':
            g.add_widget(Label(text='intent'))
            t = TextInput(multiline=False)
            if self.parameters:
                try:
                    t.text = self.parameters['intent']
                except KeyError:
                    pass
            t.bind(text=lambda _, value: param_temp.update({'intent': value}))
            g.add_widget(t)

            label_dict = {
                    'entity type': 'entity_type',
                    'maximum entities': 'n_entities',
                    'verify with context at': 'verify_with',
                    'update context at': 'context_key',
                    'failure message': 'fail_message',
                    'only if': 'only_if'}
            for k, v in label_dict.iteritems():
                g.add_widget(Label(text=k))
                t = TextInput()
                if k == 'failure message':
                    t.multiline = True
                if self.parameters:
                    try:
                        t.text = self.parameters[v]
                    except KeyError:
                        pass
                if k == 'maximum entities':
                    def int_callback(instance, value):
                        value = value.strip()
                        if value:
                            param_temp['n_entities'] = int(value)
                    t.bind(text=int_callback)
                elif k == 'only if':
                    t.bind(text=only_if_callback)
                else:
                    t.bind(text=lambda _, value: param_temp.update({v: value}))
                g.add_widget(t)
        elif self.action_type == 'play':
            g.add_widget(Label(text='source'))
            t = TextInput(multiline=False)
            if self.parameters:
                try:
                    t.text = self.parameters['source']
                except KeyError:
                    pass
            t.bind(text=lambda _, value: param_temp.update({'source': value}))
            g.add_widget(t)
            
            g.add_widget(Label(text='only if'))
            t = TextInput()
            if self.parameters:
                try:
                    t.text = self.parameters['only_if']
                except KeyError: 
                    pass
            t.bind(text=only_if_callback)
            g.add_widget(t)
        else:
            return

        p = Popup(title='Set parameters', size_hint=(.5, .8))
        # btn.bind(on_release=p.open)

        def submit_callback(button):
            self.parameters = param_temp
            p.dismiss()

        submit_btn = Button(text='Submit')
        submit_btn.bind(on_release=submit_callback)
        cancel_btn = Button(text='Cancel')
        cancel_btn.bind(on_release=lambda _: p.dismiss())
        g.add_widget(submit_btn)
        g.add_widget(cancel_btn)
        p.content = g
        p.open()
Example #55
0
 def AboutUs(self,*arg):
     content = AboutUs()
     popup = Popup(title='Common questions', content=content, auto_dismiss=False)
     popup.content = self.buildAboutUs(popup.dismiss)
     popup.open()
Example #56
0
    def show_help(self, *args):
        popup = Popup(size_hint=(.8, .8), auto_dismiss=True, title="Help")
        popup.content = BoxLayout(orientation="vertical", spacing=5, padding=5)
        scroll = ScrollView(pos_hint={'center_x': .5, 'center_y': .5}, do_scroll_x=False, size_hint=(1, 1))
        popup.content.add_widget(scroll)
        scrollbox = GridLayout(cols=1, padding=5, spacing=5, size_hint=(1, None))
        scrollbox.bind(minimum_height=scrollbox.setter('height'))
        scroll.add_widget(scrollbox)
        close = Button(on_press=hide_keyboard, text="Close", on_release=popup.dismiss, height="40dp", size_hint=(1, None))
        popup.content.add_widget(close)

        def on_ref(instance, value):
            if value == "email":
                open_url("mailto:[email protected]")
            elif value == "site":
                open_url("http://davideddu.altervista.org/software/")
            elif value == "gpl":
                open_url("http://gnu.org/licenses/gpl.html")
            elif value == "donate":
                open_url("http://davideddu.altervista.org/blog/donate/")

        label = Label(markup=True, size_hint_y=None, halign="center", on_ref_press=on_ref)

        label.height = int((215. * len(label.text)) / 600)# * (596. / self.label.width))
        def setsize(instance, value):
            #print len(instance.text), instance.text.split("\n", 1)[0], instance.width
            instance.text_size[0] = value[0]
            instance.texture_size[1] = value[1]
            instance.height = int((215. * len(label.text)) / 600 * (596. / instance.width))
        label.bind(size=setsize)  #self.label.setter("texture_size"))

        oses = {"linux":    "Linux",
                "android":  "Android",
                "macosx":   "Mac OS X",
                "win":      "Windows (use this program on Linux for best performance)"}

        label.text = """[size=24dp][b]AFS USA Student Finder[/b] {version}[/size]
by [ref=email][color=#32A4CE]Davide Depau[/color][/ref] - [ref=site][color=#32A4CE]Homepage[/color][/ref]
Running on {0}

AFS USA Student Finder is Free Software, but its development takes precious time.
You can [ref=donate][color=#32A4CE]donate[/color][/ref] to help its development.

[size=20dp][b]How to use the application[/b][/size]
Use this application as you would with any touch app: to scroll, don't use the mouse wheel, just drag the items, like you would do with your phone.

[size=16dp][b]Normal search[/b][/size]
It is like in the AFS website: just write a zip code in the first box, and tap the "search" button (the one with the lens).
Wait a few seconds, and it will show a list of students going near to the ZIP you put. You can filter them using the menus on the bottom, or using the "Name" box. Tapping the "Show more" button will show a lot of information, most of which is not available in AFS website.

[size=16dp][b]Automatic search[/b][/size]
When you click the "Autosearch" button, the program will check one by one all the ZIP codes. This might be useful if you are going to go the USA with AFS and you want to find your profile.
Please note that:
- this operation requires a lot of time (if you are lucky, about ten hours...)
- once started the operation cannot be stopped/paused unless you close the application
- slow PCs or phones may become very slow while running this software
- your carrier may charge you if you use it with mobile broadband
- the application cannot manage very big amounts of data, so you should enable some filters (like the country, the gender and the name) before starting the operation

If you are running this application on a mobile phone/tablet, please also note that if you do something else while the app is working, the Android OS might close the app to free some resources needed by the other applications.

[size=16dp][b]Persistence[/b][/size]
«Automatic search is very slow and takes a lot of hours! Can I close the application and make it start where it had finished?»
Of course you can! When you open the app, [b]before searching anything[/b], click on the "persistence" button (the floppy). Choose a file; you can create a new one or choose an existing one. Then click "Load". If you previously used the same file, the program will automatically load the old student list. You can then start autosearch: it will continue from the point it has been stopped.
If you want to create a new list on the same file, enable "Reset file content" before clicking "Load".

Pros:
- You don't have to keep the PC turned on to parse the entire list of ZIPs
- You don't lose your list if the app crashes for any reason

Cons:
- It doesn't work on Android
- The persistence may become very big

[size=12dp]I am not in any way related to AFS, AFS USA or other associations/companies. Every trademark is of his respective owner. I decline every responsibility due to the use of this program to the user.
Copyright © Davide Depau 2013.  This program is licensed under a GNU GPL version 3 license or later [ref=gpl]<[color=#32A4CE]http://gnu.org/licenses/gpl.html[/color]>\[/ref].
This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.[/size]""".format(oses[opsys], version=__version__)

        scrollbox.add_widget(label)

        global container
        container.popup = popup
        def onopen(*args, **kwargs):
            global container
            container.shown = True
        def ondismiss(*args, **kwargs):
            global container
            container.shown = False
        self.bind(on_open=onopen, on_dismiss=ondismiss)
        popup.open()
    def make_calendar(self):
        popup = Popup()
        popup.title = 'Calendar'
        layout = BoxLayout(orientation='vertical')
        inner_layout_1 = BoxLayout(size_hint=(1, 0.9),
                                   orientation='vertical')
        calendar_selection = GridLayout(cols=4,
                                        rows=1,
                                        size_hint=(1, 0.1))
        prev_month = Button(markup=True,
                            text="<",
                            font_size="30sp",
                            on_release=self.prev_month)
        next_month = Button(markup=True,
                            text=">",
                            font_size="30sp",
                            on_release=self.next_month)
        select_month = Factory.SelectMonth()
        self.month_button = Button(text='{}'.format(vars.month_by_number(self.month)),
                                   on_release=select_month.open)
        for index in range(12):
            month_options = Button(text='{}'.format(vars.month_by_number(index)),
                                   size_hint_y=None,
                                   height=40,
                                   on_release=partial(self.select_calendar_month, index))
            month_options.on_press = select_month.select(self.month_button.text)
            select_month.add_widget(month_options)

        select_month.on_select = lambda instance, x: setattr(self.month_button, 'text', x)
        select_year = Factory.SelectMonth()

        self.year_button = Button(text="{}".format(self.year),
                                  on_release=select_year.open)
        for index in range(10):
            year_options = Button(text='{}'.format(int(self.year) + index),
                                  size_hint_y=None,
                                  height=40,
                                  on_release=partial(self.select_calendar_year, index))
            year_options.on_press = select_year.select(self.year_button.text)

        select_month.bind(on_select=lambda instance, x: setattr(self.month_button, 'text', x))
        calendar_selection.add_widget(prev_month)
        calendar_selection.add_widget(self.month_button)
        calendar_selection.add_widget(self.year_button)
        calendar_selection.add_widget(next_month)
        self.calendar_layout = GridLayout(cols=7,
                                          rows=8,
                                          size_hint=(1, 0.9))
        self.create_calendar_table()

        inner_layout_1.add_widget(calendar_selection)
        inner_layout_1.add_widget(self.calendar_layout)
        inner_layout_2 = BoxLayout(size_hint=(1, 0.1),
                                   orientation='horizontal')
        inner_layout_2.add_widget(Button(markup=True,
                                         text="cancel",
                                         on_release=popup.dismiss))

        layout.add_widget(inner_layout_1)
        layout.add_widget(inner_layout_2)
        popup.content = layout
        popup.open()
Example #58
0
    def create_settings_button(self):
        '''setting button will trigger popup with different settings'''
        # a button to call out settings panel
        settings_button = Button(text = 'settings', size_hint_y = 0.2)

        # configure a popup window to display settings and parameters
        settings_popup = Popup( title='Settings', size_hint=(0.8, 0.2))
        settings_popup.pos_hint =  {'x':0.5-settings_popup.size_hint[0]/2,
                                'y':0.9-settings_popup.size_hint[1]/2} # distance from popup.center
        settings_popup_content = GridLayout(cols=1) # a blank layout to put other widgets in
        settings_popup.content = settings_popup_content

        def preview_window_resize(argv, instance):
            ''' resize the window when popup oppens to prevent camera preview blocks the option
            
            Using partial() makes first argument argv rather than intance'''

            if debug_mode is True:
                if argv == 'fullscreen':
                    print('full screen preview')
                if argv == 'resized':
                    print('resized preview')
            if debug_mode is False:
                if argv == 'fullscreen':
                    mc.camera_library('stop_preview')
                    mc.camera_library('fullscreen_preview')
                if argv == 'resized':
                    mc.camera_library('stop_preview')
                    reduced_size_window = (
                        int(Window.width*0.2), int(Window.height*0.25),
                        int(Window.width*0.6), int(Window.width*0.6/1.33))
                    mc.camera_library('reduced_size_preview', reduced_size_window)
            
        settings_popup.bind(on_dismiss = partial(preview_window_resize, 'fullscreen'))
        settings_popup.bind(on_open = partial(preview_window_resize, 'resized') )
        
        def switch_settings_popup_content(instance):
            """ Callback for different options buttons
            
            alter popup content when clicking buttons"""

            settings_popup_content.clear_widgets()
            settings_popup.open()
            if instance == settings_button:
                settings_popup_content.add_widget(settings_panel)
            elif instance == contrast_button:
                settings_popup_content.add_widget(contrast_controller)
            elif instance == brightness_button:
                settings_popup_content.add_widget(brightness_controller)
            elif instance == white_balance_button:
                settings_popup_content.add_widget(white_balance_controller)
            elif instance == filepath_button:
                if debug_mode is False:
                    mc.camera_library('stop_preview') # the preview will block the keyboard
                settings_popup_content.add_widget(filepath_controller)
                # Update the filepath_input and folder_chooser (after taking images, possibly)
                self.filepath_input.text = self.format_filepath(update = True)
                # go to different folder to refresh the folder_chooser
                self.folder_chooser.path = self.folder

        # add buttons to call out popups
        # settings_panel with 3 buttons on it
        settings_panel, contrast_button, brightness_button, white_balance_button, filepath_button = self.create_settings_panel()
        brightness_controller, contrast_controller, white_balance_controller = self.create_settings_controllers()
        filepath_controller = self.create_filepath_controller()
        for button in [settings_button, contrast_button, brightness_button, white_balance_button, filepath_button]:
            button.bind(on_release= switch_settings_popup_content)
        return settings_button