Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
3.4k views
in Technique[技术] by (71.8m points)

python - why does my map screen not work, can someone help me

imports:

from kivy.app import App
from kivy.uix.widget import Widget
from kivy.properties import StringProperty
from kivy.properties import ObjectProperty
from kivy.uix.label import Label
from kivy.core.window import Window
from kivy.uix.screenmanager import ScreenManager, Screen
from kivy.uix.boxlayout import BoxLayout
from kivy_garden.mapview import MapView, MapMarker
kv = '''
<Login>
    name:'Login'
    ben: benName.text
    pw: passwort.text
    knopf: btn
    knopff: btnn
 
    GridLayout:
        cols: 1
        size: root.width,root.height
        GridLayout:
            cols: 2
            Label:
                text: "Username"
                font_size: 25
            TextInput:
                id: benName
                multiline: False
                font_size: 30
            Label:
                text: "Password"
                font_size: 25
                bold: True
            TextInput:
                password: True
                id: passwort
                multiline: False
                font_size: 40
        Button:
            size_hint: (1.,1.10)
            text:" Start "
            id: btn
            font_size: 40
            on_release:
                root.manager.current = "Map" if passwort.text == "1" and benName.text == "1" else "Login"
                root.manager.transition.direction = "down"
        Button:
            size_hint: (1.,1.10)
            text: " Exit "
            id: btnn
            font_size: 40
            on_release: app.stop()


<Map>:
    #:import MapSource kivy_garden.mapview.MapSource
    <Toolbar@BoxLayout>:
        size_hint_y: None
        height: '48dp'
        padding: '4dp'
        spacing: '4dp'
        canvas:
            Color:
                rgba: .2, .2, .2, .6
            Rectangle:
                pos: self.pos
                size: self.size
    <ShadedLabel@Label>:
        size: self.texture_size
        canvas.before:
            Color:
                rgba: .2, .2, .2, .6
            Rectangle:
                pos: self.pos
                size: self.size
    RelativeLayout:
        MapView:
            id: mapview
            lat: 50.6394
            lon: 3.057
            zoom: 8
            #size_hint: .5, .5
            #pos_hint: {"x": .25, "y": .25}
            #on_map_relocated: mapview2.sync_to(self)
            #on_map_relocated: mapview3.sync_to(self)
            MapMarker:
                lat: 50.6394
                lon: 3.057
            MapMarker
                lat: -33.867
                lon: 151.206
        Toolbar:
            Label:
                text: "Lon: {}".format(mapview.lon)
            Label:
                text: "Lat: {}".format(mapview.lat)


'''

MyApp class:

class Login(Screen):
    ben = StringProperty()
    pw = StringProperty()
    knopf = ObjectProperty()


class MyApp(App):
    Builder.load_string(kv)
 
    def build(self):
        ms = ScreenManager()
        ms.add_widget(Login(name='Login'))
        ms.add_widget(Map(name='Map'))
        self.title = "MyApp"
        return ms



class Map(Screen):
    pass



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

Error:

     ERORR   raise ParserException(self, ln,
     kivy.lang.parser.ParserException: Parser: File "<inline>", line 50:
     ...
          48:<Map>:
          49:    #:import MapSource kivy_garden.mapview.MapSource
     >>   50:    <Toolbar@BoxLayout>:
          51:        size_hint_y: None
          52:        height: '48dp'
     ...
     Invalid property name
    [Finished in 2.0s with exit code 1]


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...