KivyMD 0.103.0 вызывает ошибки с 'NavigationDrawerSubheader' - PullRequest
0 голосов
/ 08 января 2020

Я недавно обновил kivyMD со 0.102.1 до 0.103.0 и получаю следующую ошибку:

повышение FactoryException ('Неизвестно класс <% s> '% name) kivy.factory.FactoryException: неизвестный класс

Но когда go возвращается к версии 0.102.1 , все работает просто отлично. Я выложу код ниже, но я просто хотел узнать, хочу ли я обновить до 0.103.0 , что мне нужно изменить? Я пытался провести некоторое исследование, но не смог найти то, что решит проблему.

.py

#imported from kivy framework
from kivy.app import App

from kivymd.app import MDApp
from kivy.app import App
from datetime import datetime
from datetime import timedelta
from kivy.clock import Clock
from kivy.lang import Builder
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.floatlayout import FloatLayout
from kivy.uix.screenmanager import ScreenManager, Screen
from kivy.uix.image import Image
import weatherGrab
from weatherGrab import weatherCheck
import os

#1st screen
class Login_Screen(Screen):

    #Takes user input from the .KV file, converts it to string and verifies if its a saved login
    def verify_credentials(self):
        Username = self.ids.Username_userInput
        Password = self.ids.Password_userInput

        Username_string = Username.text
        Password_string = Password.text

        #Allows the variable to be used in another class and method
        Login_Screen.verify_credentials.GGG = Username.text

        #checks if user input is equal to temp database
        if self.ids["Username_userInput"].text == "Username" and self.ids["Password_userInput"].text == "Password":
            self.manager.current = "Homepage_Screen"
            print("USER LOGIN DATA: " + Username_string +" "+Password_string)
            weatherGrab.weatherCheck()
            #print('CURRENT WEATHER - London','\n',weatherCheck.currentWeather,'\n' ,weatherCheck.temp)
            #print('HERE',var1)
            #x = dir(platform) prints all function from that lib

    #after log in, sets user input to empty so the next user can login
    def clean(self):
        self.ids["Username_userInput"].text = ""
        self.ids["Password_userInput"].text = ""

    #saving user inputs to a text file (temp database)
    def save_data(self): 
        Username = self.ids.Username_userInput
        Password = self.ids.Password_userInput

        Username_string = Username.text
        Password_string = Password.text

        TextDoc = open("UserLogin.txt", "a")
        username = Username_string
        password = Password_string
        if username == '' and password == '':
            pass
        else:
            TextDoc.write("\n"+username+","+password)
            TextDoc.close()

    #loads data from the file (debugging/testing)
    def load_data(self):
        f = open("UserLogin.txt", "r")
        print("FROM TEXT FILE:"+ f.read())

#2nd screen
class Homepage_Screen(Screen):

    #Event dispatcher to load data when user enters the second screen
    def on_enter(self):
        self.load_info()
        self.weather()

    def weather(self):
        self.ids["temp"].text = weatherCheck.temp
        self.ids["date"].text = weatherCheck.currentDate

    #Text prints in termial for testing/debugging
    def load_info(self):
        print("PASSING USERNAME TO HOMEPAGE: "+Login_Screen.verify_credentials.GGG)
        self.ids["USERNAME"].text = "Welcome"+" "+Login_Screen.verify_credentials.GGG


    #Saves User input from the notes textinput
    def save_notes(self):
        UserNotes = self.ids.UserInput_notes
        UserNote = UserNotes.text
        TextDoc = open("UserLogin.txt", "a")
        TextDoc.write("," + UserNote)
        TextDoc.close()

#3rd screen
class Application_Screen(Screen):
    pass


#4th screen
class Logout_Screen(Screen):

    def newline(self):
        TextDoc = open("UserLogin.txt", "a")
        TextDoc.write("\n")
        TextDoc.close()

    def forcequit(self):
        exit()

#class for all screens
class ScreenManagement(ScreenManager):
   pass

class MainApp(MDApp):

    def build(self):
        #declaring time from python, and making it refresh every second
        self.now = datetime.now()
        Clock.schedule_interval(self.update_clock, 1)

    def update_clock(self, *args):
        self.now = self.now + timedelta(seconds=1)
        #Allows for time to be shown on all screens
        self.root.get_screen("Homepage_Screen").ids["CurrentTime"].text = self.now.strftime("%H:%M:%S")
        self.root.get_screen("Logout_Screen").ids["CurrentTime"].text = self.now.strftime("%H:%M:%S")
        self.root.get_screen("Login_Screen").ids["CurrentTime"].text = self.now.strftime("%H:%M:%S")
        #print(self.now.strftime("%H:%M:%S"))

MainApp().run()

.kv

#:kivy 1.0
#:import hex kivy.utils.get_color_from_hex
#styles that will apply to all intences for each tag
<MDRaisedButton>:
    font_size:18
<Label>:
    color: 0,0,0,1
#declaring screen managers and printing them in this order
ScreenManagement:
    Login_Screen:
        name:"Login_Screen"
        id: woow
    Homepage_Screen:
        name:"Homepage_Screen"
    Application_Screen:
        name:"Application_Screen"
    Logout_Screen:
        name:"Logout_Screen"
#style for login screen
<Login_Screen>:
    #background color
    FloatLayout:
        spacing: 10
        canvas.before:
            Color:
                rgba: hex('#eff3fa')
            Rectangle:
                size: self.size
                pos: self.pos
        #Navbar
        MDToolbar:
            id: fb
            pos_hint: {'center_x': 0.5, 'top':1.0}
            size_hint_y:None
            height: 50
            title: "Virtual Assistant"
            md_bg_color: hex('#132843')
            Label:
                id: CurrentTime
                font_size:18
                size_hint_x: .1
                color: (1,1,1,1)
        #login container
        #background color/positioning
        BoxLayout:
            spacing: 10
            orientation: 'vertical'
            padding: 50
            canvas.before:
                Color:
                    rgba: hex('#000')
                Rectangle:
                    size: self.size
                    pos: self.pos
            pos_hint: {'center_x': 0.5, 'center_y': 0.5}
            size_hint: 0.33, None
            size_hint_min_x: 200
            height: self.minimum_height
            #LOGIN CONTENT
            #logo
            Image:
                source: 'Logo.png'
                size_hint: None, None
                size: 100, 100
                pos_hint: {'center_x': 0.5, 'center_y': 0.0}
            MDTextField:
                id: Username_userInput
                hint_text:"Username"
                text:"Username"
                line_color_normal: 0,0,0,1
            MDTextField:
                id: Password_userInput
                hint_text:"Password"
                text:"Password"
                password: True
                line_color_normal: 0,0,0,1
                #color_mode:'accent'
            Button:
                text:"Login"
                size_hint_y: None
                height: 60
                padding: 10,10
                background_color: (2.08, 2.40, 1.92,1)
                size_hint: 0.40, None
                pos_hint: {'center_x': 0.5, 'center_y': 0.0}
                on_press: root.verify_credentials() , root.save_data(), root.clean(), root.load_data()
#style for Homepage screen
<Homepage_Screen>:
    #SIDEBAR BUTTONS
    NavigationLayout:
        id: nav_layout
        MDNavigationDrawer:
            drawer_logo:'Logo.png'
            NavigationDrawerSubheader:
                id: USERNAME
            NavigationDrawerIconButton:
                icon:"home"
                text:"Homepage"
                theme_text_color: 'Custom'
                on_release:
                    screen_manager.current = "Homepage"
            NavigationDrawerIconButton:
                icon:'application'
                text: "Application"
                on_release:
                    screen_manager.current = "Application"
            NavigationDrawerIconButton:
                icon: 'dictionary'
                text: "Dictionary"
                on_release:
                    screen_manager.current = "Dictionary"
            MDRectangleFlatIconButton:
                icon:'logout'
                text: "Logout"
                #on_press: root.clean()
                on_release: app.root.current = "Logout_Screen"
                size_hint: 1, None
                font_size:20
                text_color: 0,0,0,1
        #BACKGROUND
        FloatLayout:
            spacing: 10
            canvas.before:
                Color:
                    rgba: hex('#eff3fa')
                Rectangle:
                    size: self.size
                    pos: self.pos
            #NAVBAR
            MDToolbar:
                id: fb
                pos_hint: {'center_x': 0.5, 'top':1.0}
                size_hint_y:None
                height: 50
                title: "Virtual Assistant"
                md_bg_color: hex('#132843')
                left_action_items: [['menu', lambda x: root.ids.nav_layout.toggle_nav_drawer()]]
                Label:
                    id: CurrentTime
                    size_hint_x: .1
                    font_size:18
                    color: (1,1,1,1)   
            #SIDEBAR SCREEN STYLE  
            ScreenManager:
                id: screen_manager
                #HOMEPAGE SCREEN STYLE
                Screen:
                    name: "Homepage"
                    BoxLayout:
                        spacing: 10
                        orientation: 'vertical'
                        padding: 10
                        canvas.before:
                            Color:
                                rgba: (1,1,1,.8)
                            Rectangle:
                                size: self.size
                                pos: self.pos
                        pos_hint: {'center_x': 0.5, 'top': (root.height - fb.height)/root.height}
                        size_hint: 0.3, None
                        height: 35
                        GridLayout:
                            rows: 3
                            cols: 3
                            padding: 10
                            spacing: 15
                            #pos_hint: {"center_x":0.6, "center_y":0.0}
                            Label:
                                id:date
                                color: (0,0,0,1)
                                size_hint_x: 2
                            Label:
                                id:temp
                                color: (0,0,0,1)
                                size_hint_x: 2
                            Label:
                                text:'icon'
                                color: (0,0,0,1)
                                size_hint_x: 2
                    BoxLayout:
                        orientation: 'horizontal'
                        spacing: 10
                        padding: 10
                        canvas.before:
                            Color:
                                rgba: (1,1,1,1)
                            Rectangle:
                                size: self.size
                                pos: self.pos
                        size_hint: 0.8, None
                        height: 60
                        pos_hint: {'center_x': .5, 'center_y':.5}
                        TextInput:
                            height:60
                            size_hint: 5, None
                            focus: True
                            multiline: False
                            font_size: 25
                            padding_y:15
                            background_color: 1,1,1,0
                            foreground_color: 0,0,0,1
                            pos_hint:{'center_x':0, 'center_y':0.5}
                        MDRectangleFlatIconButton:
                            icon:'search-web'
                            height:45
                            text_color: 0,0,0,1
                            md_bg_color: hex("#D0F0C0")
                            pos_hint: {'center_x': 0.5, 'center_y': 0.5}
                            Label:
                                text:'Search'
                                font_size:18


...