Canvas 微调器不会出现在窗体上

Canvas 微调器不会出现在窗体上,canvas,colors,spinner,visible,Canvas,Colors,Spinner,Visible,嗨,伙计们,我发出了一声嘘声! 我做了一个旋转器并填充了它,然后想。。。我想把表格的颜色从黑色改为白色,所以我做了,但现在旋转器不在那里,我不知道我做了什么!嗯,我有点喜欢,我想我把代码放错地方了,但我不确定正确的地方在哪里。。。sooooo from bs4 import BeautifulSoup from urllib import request import sys, traceback import re import kivy from kivy.app import App fr

嗨,伙计们,我发出了一声嘘声! 我做了一个旋转器并填充了它,然后想。。。我想把表格的颜色从黑色改为白色,所以我做了,但现在旋转器不在那里,我不知道我做了什么!嗯,我有点喜欢,我想我把代码放错地方了,但我不确定正确的地方在哪里。。。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,并在微调器中选择电台。该按钮下将设置一个标签,用于发送详细信息,而不是打印 我希望在这个按钮下面有另一个按钮,只有当发现该站在网页中打开url时,这个按钮才会出现

我的问题是,我应该把旋转器的代码放在哪里才能看到

谢谢
Raif

我从表单的零开始,没有意识到必须将小部件添加到父小部件中

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

当我去掉代码的颜色部分时,微调器会出现,或者在那里,但一旦我将颜色更改为白色,它就消失了。我甚至尝试将颜色1定义为蓝色curses.init_pair1,curses.color_black,curses.color_blue stdscr.bkgd'',curses.color_pair1。。。请给我一些想法