2014-10-28 4 views
0

안녕 얘들 아 내가 부랑자를 만들었 어! 나는 스피너를 만들었고, 그것을 채웠다, 그리고 생각했다 ... 나는 검은 색에서 흰색으로 형태의 색을 바꾸고 싶다. 그래서 나는 그랬다. 그러나 이제는 스피너가 거기에 있지 않다. 물론 나는 가지, 나는 메신저는 엉덩이 것, 지금까지 모든 일 그게 전부 sooooo는 ... 내가 잘못된 장소에 코드를 가지고 있지만 바로 이곳이 어디 있는지 잘 모르겠어요회 전자는 양식에 나타나지 않을 것입니다.

from bs4 import BeautifulSoup 
from urllib import request 
import sys, traceback 
import re 
import kivy 
from kivy.app import App 
from kivy.uix.button import Button 
from kivy.uix.label import Label 
from kivy.uix.spinner import Spinner 
from kivy.base import runTouchApp 
from kivy.uix.image import Image 
from kivy.uix.widget import Widget 
from kivy.lang import Builder 
root = Builder.load_string(''' 
FloatLayout: 
    canvas.before: 
     Color: 
      rgba: 1, 1, 1, 1 
     Rectangle: 
     # self here refers to the widget i.e FloatLayout 
      pos: self.pos 
      size: self.size''') 
class MainApp(App): 

    def build(self): 

#add drop down box filled with stations 
     spinner = Spinner(
# default value shown 
     text='Pick a Station', 
     values=('Appledore','Axminster','Bampton','Barnstaple','Bere Alston','Bideford','Bovey Tracey','Braunton','Bridgwater','Brixham','Buckfastleigh','Budleigh Salterton','Burnham on sea','Camels Head','Castle Cary','Chagford','Chard','Cheddar','Chulmleigh','Colyton','Combe Martin','Crediton','Crewkerne','Crownhill','Cullompton','Dartmouth','Dawlish','Exeter Danes Castle','Exeter Middlemoor','Exmouth','Frome','Glastonbury','Greenbank','Hartland','Hatherleigh','Holsworthy','Honiton','Ilfracombe','Ilminster','Ivybridge','Kingsbridge','Kingston','Lundy Island','Lynton','Martock','Minehead','Modbury','Moretonhampstead','Nether Stowey','Newton Abbot','North Tawton','Okehampton','Ottery St Mary','Paignton','Plympton','Plymstock','Porlock','Princetown','Salcombe','Seaton','Shepton Mallet','Sidmouth','Somerton','South Molton','Street','Taunton','Tavistock','Teignmouth','Tiverton','Topsham','Torquay','Torrington','Totnes','USAR','Wellington','Wells','Williton','Wincanton','Witheridge','Wiveliscombe','Woolacombe','Yelverton','Yeovil'), 
# just for positioning in our example 
     size_hint=(None, None), 
     size=(100, 44), 
     pos_hint={'center_y': 0.8}) 
     def show_selected_value(spinner, text): 
      print('The spinner', spinner, 'have text', text) 
      spinner.bind(text=show_selected_value) 
      runTouchApp(spinner) 
     return root 
########################### 
#load stations into a list 
StationsString = "Appledore,Axminster,Bampton,Barnstaple,Bere Alston,Bideford,Bovey Tracey,Braunton,Bridgwater,Brixham,Buckfastleigh,Budleigh Salterton,Burnham on sea,Camels Head,Castle Cary,Chagford,Chard,Cheddar,Chulmleigh,Colyton,Combe Martin,Crediton,Crewkerne,Crownhill,Cullompton,Dartmouth,Dawlish,Exeter Danes Castle,Exeter Middlemoor,Exmouth,Frome,Glastonbury,Greenbank,Hartland,Hatherleigh,Holsworthy,Honiton,Ilfracombe,Ilminster,Ivybridge,Kingsbridge,Kingston,Lundy Island,Lynton,Martock,Minehead,Modbury,Moretonhampstead,Nether Stowey,Newton Abbot,North Tawton,Okehampton,Ottery St Mary,Paignton,Plympton,Plymstock,Porlock,Princetown,Salcombe,Seaton,Shepton Mallet,Sidmouth,Somerton,South Molton,Street,Taunton,Tavistock,Teignmouth,Tiverton,Topsham,Torquay,Torrington,Totnes,USAR,Wellington,Wells,Williton,Wincanton,Witheridge,Wiveliscombe,Woolacombe,Yelverton,Yeovil" 
TheStation = StationsString.split(',') 

if __name__ == '__main__': 
    MainApp().run() 



########################### 
#get info for incident 
def FindIncident(sStation): 
    webpage = request.urlopen("http://www.dsfire.gov.uk/News/Newsdesk/IncidentsPast7days.cfm?siteCategoryId=3&T1ID=26&T2ID=35")#main page 
    soup = BeautifulSoup(webpage) 
    incidents = soup.find(id="CollapsiblePanel1") #gets todays incidents panel 
    Links = [] #create list call Links 

    for line in incidents.find_all('a'): #get all hyperlinks 
     Links.append("http://www.dsfire.gov.uk/News/Newsdesk/"+line.get('href')) #loads links into Links list while making them full links 
    n = 0 
    e = len(Links) 
    if e == n: #if no links available no need to continue 
     print("No Incidents Found Please Try Later") 
     sys.exit(0) 

    sFound = False 
    while n < e: #loop through links to find station 
     if sFound: #if the station has been found stop looking 
      sys.exit(0) 
     webpage = request.urlopen(Links[n]) #opens link in list) 
     soup = BeautifulSoup(webpage) #loads webpage 
     if soup.find_all('p', text=re.compile(r'{}'.format(sStation))) == []:#check if returned value is found 
      #do nothing leaving blank gave error 
      a = "1" #this is pointless but stops the error 
     else: 
      print(soup.find_all('p', text=re.compile(r'{}'.format(sStation)))) #output result 
      WebLink = Links[n] 
      sFound = True # to avoid un needed goes through the loop process 
     n=n+1 # moves counter to next in list 
    if not sFound: #after looping process if nothing has been found output nothing found 
     print("nothing found please try again later") 
    return; 
########################### 

을 생각합니까 버튼 아래 스피너에서 선택한 스테이션과 함께 FindIncident를 호출하는 회 전자 아래의 버튼은 인쇄물 대신 (인쇄 대신) 을 보내는 레이블이 될 것입니다. im은 해당 버튼 아래에 다른 버튼이 있기를 원합니다. 방송국에서 웹 페이지의 URL을 열었습니다.

그 모든 것이 분명해졌습니다. LOL 제 질문은 스피너를 표시 할 코드를 어디에 두어야합니까?

감사 Raif

내가 양식에 처음부터 시작
+0

에 위젯을 추가 할 필요가 실현하지 않았다 회 전자 나타납니다, 또는 거기에 있지만 즉시 내가 사라진 흰색으로 색을 변경합니다. 나는 심지어 파란색에 검정색 #을 정의하려고 시도했다. curses.init_pair (1, curses.COLOR_BLACK, curses.COLOR_BLUE) stdscr.bkgd ('', curses.color_pair (1)) ... ideas please –

답변

0

, 당신은 내가 코드의 색상 측면을 제거 부모 위젯

class 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='Pick a Station', 
values=('Appledore','Axminster','Bampton','Barnstaple','Bere Alston','Bideford','Bovey Tracey','Braunton','Bridgwater','Brixham','Buckfastleigh','Budleigh Salterton','Burnham on sea','Camels Head','Castle Cary','Chagford','Chard','Cheddar','Chulmleigh','Colyton','Combe Martin','Crediton','Crewkerne','Crownhill','Cullompton','Dartmouth','Dawlish','Exeter Danes Castle','Exeter Middlemoor','Exmouth','Frome','Glastonbury','Greenbank','Hartland','Hatherleigh','Holsworthy','Honiton','Ilfracombe','Ilminster','Ivybridge','Kingsbridge','Kingston','Lundy Island','Lynton','Martock','Minehead','Modbury','Moretonhampstead','Nether Stowey','Newton Abbot','North Tawton','Okehampton','Ottery St Mary','Paignton','Plympton','Plymstock','Porlock','Princetown','Salcombe','Seaton','Shepton Mallet','Sidmouth','Somerton','South Molton','Street','Taunton','Tavistock','Teignmouth','Tiverton','Topsham','Torquay','Torrington','Totnes','USAR','Wellington','Wells','Williton','Wincanton','Witheridge','Wiveliscombe','Woolacombe','Yelverton','Yeovil'), 
size_hint=(None, None), 
size=(150, 44), 
pos_hint = ({'center_x':0.5, 'y': 0.35})) 
     b = Button(text="Search For Incidents",size_hint=(None, None), 
        pos_hint =({'center_x':0.5, 'y': 0.25}), 
        size=(150, 44)) 
     LblRes = Label(text="Results will display here", 
         pos_hint =({'center_x':0.5, 'y': 0.15}), 
         size_hint=(600,100),color=(1,1,1,1),font_size=35) 
     b.bind(on_press=FindIncident(Spinner.text)) 
     self.root.add_widget(spinner) 
     self.root.add_widget(LblRes) 
     self.root.add_widget(i) 
     self.root.add_widget(b) 
     return 
관련 문제