position - calling a procedure when a button is pressed -


I thought it would be easy, but I'm here!

I say a process button is pressed and the results display results on the label

DSFRSapp (app): Def build (self): self.root = FloatLayout () i = Image (source = 'DSFRSLogo.png', Allow_stretch = true, pos_hint = ({ 'center_x': 0.5, 'y': .25})) = spinner spinner (text = "Choose a station, Value = ('Applied', 'Exmster', 'Bampton', 'Bernstein', 'Bayer Alston', 'Buddyford', 'Bouvey Tracy', 'Bournton', 'Bridgewater', 'Brewham', 'Bakfastal', ' Badley Salterton ',' 'Carnation', 'Cormon', 'Coulton', 'Crohn Corner', 'Crawford', 'Chord', 'Shader', 'Chooted', 'Colton', 'Combe Martin', 'Crohnen', 'Crownhill' ',' Clompton ',' Dartmouth ',' Desalish ',' Exeter Dan's Castle ',' Exeter Midnight ',' Exmouth ',' From ',' Glostonbury ',' Greenbank ',' Heartland ',' Hadleeu ',' Holswarthy 'Honiton,' Ilfracombe 'Ilminster' Ivybridge 'King' Newton Abbot ',' North Tavtn 'Okhampton' London Island ',' Lin 'Martin', 'Martin', 'Modb', 'Mortar', 'Morton Hampstead', 'Swarar Steve', 'Otteri Saint Mary', 'Pigtton', 'Pleaton', 'Playstock', 'Porlococ', 'Princetown' 'Salcombe', 'Seaton', 'Shapton Malllet', 'Sidmouth', 'Somartan', 'South Molton', 'Street', 'Tanton', 'Tavistock', 'Teignmouth', 'Tiverton', 'Topsham' 'Torquay' Torrington 'Totnes' USAR 'Wellington', 'Wales' size = Hint = (no, no), size = (150, 44), pos_hint = ({0} , 'Whitid', 'Vincentton', 'Writij', 'Vivelscombe', 'Vulkomb Sector ',' Yelvrton '' Center_x ': 0.5,' y ': 0.35})) b = button (text = "Search for the events", Akar_hnt = (no, no), pos_hint = ({' center_x ' : 0.5, 'y': 0.25}), size = (150, 44)) LblRes = label (text = "results will appear here", pos_hint = ({'center_x': 0.5, 'y': 0.15}), Akar_hent = (600 100), color = (1,1,1,1), font_size = 35) b.bind (on_press = FindIncident (spinner Text)) Selfkrootkadd_widget (spinner) Selfkrootkadd_widget (LblRes) Self.root.add_widget (i) self.rot.ed_visitate (b) Return Df SearchInstant (sstation): webpage = request.rollopen ("http: //www.dsfire.gov.uk/News/Newsdesk/IncidentsPast7days.cfm? siteCategoryId = 3 and TlID = 26 and T2ID = 35 ") # Home Soup = Beautiful Soup (webpage) events = Supkfild (id =" CollapsiblePanel1 ") #gets today Events panel link = [] #create list call incidents. Link to the line in find_all ('a'): # All hyperlinks LINK.append ("http://www.dsfire.gov.uk/news/newsdayc/" + line.get ('href')) # While linking loads links, when making them full links, n = 0 e = lane (link) e == n: # If there is no link available then there is no need to continue. ("No events were found please try later") sys.exit (0) sFound = False while n & lt; E: via the link to the station #loop if to find sFound station: #if get station Soup = beautiful soup (webpage) #loads webpage if sows.exit (0) webpage = request.urlopen (link [n]) #opens link in the list soup.find_all ('p', text = recompile (R '{}'. Format (sStation)) == []: # Check that if returned value returned, no spaces will not leave error = "1" #. Useless but prevents error Print (Supkfnd_l ( 'P', text = re Compackej ( ''}}. Format (sstation))) # Output result goes through the required loop process to avoid WebLink = Links [N] sFound = true # n = n + 1 # moves in the next list in the list, if not SFound: #after the looping process if nothing has been found out of the output nothing got print ("please try not to get anything again"); If __name__ == "__ main__": DSFRSapp (). Run ()

So when the button is pressed to call FindIncident using spinner text as a string. In this way, it can search for the station and instead of print, I will put the results in the label, possibly with a link to the website.

Any help would be great!

rif

B.Bind (on_press = FindIncident (spinner. Text))

You have to pass the function as the argument of the bound . You are not passing FindIncident, you are calling and are passing the results ... which is none.

Try

  from functools idiot partial b.bind (on_press = partial (findIncident, spinner.text))  

its Also declare FindIncident as the def FindIncident (sStation, * args): , as the bind will automatically give additional logic. You can do the same with the lambda function.

Be careful with the matters of your code - At this time you use Spinner.text , when you probably mean Spinner.text , As you have created a variable spinner


Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -