2017-03-05 10 views
0

これは1「NoneType」オブジェクトには、属性「アダプター」、「NoneType」オブジェクトが属性「テキスト」

エラー#1で3つの質問ですがありませんがありません

エラー#2:「NoneType」オブジェクトが、私は時間

  1. 私は、[追加]ボタンをクリックすると、私はエラー#1
  2. を得るためにこれをデバッグしようとしている何の属性「アダプター」

    を持っていません

  3. 削除ボタンをクリックするとエラー#2が発生する
  4. Kivy ListItemButtonとSpinnerをスタイルする方法。私はドキュメントを読みましたが、理解できませんでした!

ご質問がお送りいただければ申し訳ありません。ここ

はgithubのリポジトリである:nairamanager.kv

<ViewEditProducts>: 

BoxLayout: 
    product_name: product_name 
    product_list: product_list 
    orientation: "vertical" 
    size: root.size 
    BoxLayout: 
     orientation: "horizontal" 
     size_hint: (1,None) 
     height: root.height*.1 
     BackButton: 
      id: back_button 
      markup: True 
      align: "center" 
      font_size: "50sp" 
      size_hint: (.1,1) 
      on_press: 
       root.manager.current = "news_feed_screen" 
       root.manager.transition.direction = "left" 
     TopLabel: 
      text: "[b]View Edit Products[/b]" 
      halign: "left" 
      markup: True 
      font_size: "15sp" 
      font_name: "Arimo" 
    BoxLayout: 
     orientation: "horizontal" 
     size_hint: (1,None) 
     height: (root.height*.07)+self.padding[1]+self.padding[3] 
     spacing: 10 
     padding: (root.width*.25,root.height*.1,root.width*.25,root.height*.03) 
     UniTextInput: 
      id: product_name 
      hint_text: "Product Name" 
     GreenButton: 
      text: "Add" 
      size_hint: (.3,1) 
      on_press: root.add_product() 
     GreenButton: 
      id: delete_green_button 
      text: "Delete" 
      size_hint: (.3,1) 
      on_press: root.delete_product() 
    BoxLayout: 
     orientation: "vertical" 
     size_hint: (1,root.height*.3) 
     padding: (root.width*.25,0,root.width*.25,root.height*.1) 
     ListView: 
      id: product_list 
      adapter: 
       ListAdapter(data=[str(i) for i in range(1,32)], selection_mode="multiple", cls=ListItemButton) 

は、これが実際のコードです:

# -*- coding: utf-8 -*- 

# import kivy configuration file 
from kivy.config import Config 
# Config.set("graphics", "resizable", 0) 

import kivy 

# kivy version in use 
kivy.require("1.9.1") 

# importing needed classes 
from kivy.app import App 
from kivy.uix.gridlayout import GridLayout 
from kivy.uix.scrollview import ScrollView 
from kivy.uix.boxlayout import BoxLayout 
from kivy.uix.anchorlayout import AnchorLayout 
from kivy.uix.label import Label 
from kivy.core.text import LabelBase 
from kivy.uix.button import Button 
from kivy.uix.widget import Widget 
from kivy.core.window import Window 
from kivy.core.window import WindowBase 
from kivy.uix.image import Image 
from kivy.properties import ObjectProperty,ListProperty,StringProperty 
from kivy.uix.image import Image 
from kivy.uix.listview import ListItemButton 
from kivy.adapters.listadapter import ListAdapter 
from kivy.uix.screenmanager import    ScreenManager,Screen,FadeTransition,FallOutTransition,WipeTransition,NoTransition,SlideTransition,RiseInTransition,SwapTransition 

# Change the background color of window 
Window.clearcolor = (1,1,1,1) 


class LoginSignUp(Screen): 
    pass 

class Login(Screen): 
    pass 

class SignUp(Screen): 
    pass 

class SignUpTerms(Screen): 
    pass 

class NewsFeed(Screen): 
    pass 

class ViewEditProfile(Screen): 
    pass 

class ViewEditProducts(Screen): 
    product_name = ObjectProperty() 
    product_list = ObjectProperty() 

    def add_product(self): 
     # Get product name 
     product_name = self.product_name.text 

     # Add to list 
     self.product_list.data.extend([product_name]) 

     # Refresh list 
     self.product_list._trigger_reset_populate() 

    def delete_product(self,*args): 

     # If item selected 
     if self.product_list.adapter.selection: 

      # Get the text from selected 
      selection = self.product_list.adapter.selection[0].text 

      # Remove the item 
      self.product_list.remove(selection) 

      # Refresh list 
      self.product_list._trigger_reset_populate() 

class ProductList(ListItemButton): 
    pass 


class ViewEditExpenditures(Screen): 
    pass 

class ViewEditAssetsLiabilities(Screen): 
    pass 

class GetLoan(Screen): 
    pass 

class FinancialStatement(Screen): 
    pass 

class ProfitLossStatement(Screen): 
    pass 

class BalanceSheet(Screen): 
    pass 

class SalesForecast(Screen): 
    pass 

class About(Screen): 
    pass 

# Screen management 
class ScreenManagement(ScreenManager): 

    # Set property for screens 
    transition = NoTransition() 
    login_signup = ObjectProperty(None) 
    login = ObjectProperty(None) 
    signup = ObjectProperty(None) 
    signup_terms = ObjectProperty(None) 
    view_edit_profile = ObjectProperty(None) 
    view_edit_products = ObjectProperty(None) 
    view_edit_expenditures = ObjectProperty(None) 
    view_edit_assets_liabilities = ObjectProperty(None) 
    get_loan = ObjectProperty(None) 
    financial_statement = ObjectProperty(None) 
    profit_loss_statement = ObjectProperty(None) 
    balance_sheet = ObjectProperty(None) 
    sales_forecast = ObjectProperty(None) 
    news_feed = ObjectProperty(None) 
    about = ObjectProperty(None) 

class NairaManagerRegister(Screen): 
    pass 


class NairaManagerApp(App): 
    icon = "images/favicon_32.png" 
    title = "Naira Manager" 

    def build(self): 
     return ScreenManagement() 

if __name__ == "__main__": 
    LabelBase.register(name="Roboto",  fn_regular="fonts/roboto_regular.ttf", fn_bold="fonts/roboto_bold.ttf") 
    LabelBase.register(name="Arimo", fn_regular="fonts/arimo_regular.ttf", fn_bold="fonts/arimo_bold.ttf") 
    LabelBase.register(name="Webdings", fn_regular="fonts/webdings.ttf") 
    NairaManagerApp().run() 
+2

ようこそ。単にリンクを投稿するのではなく、Qコードと関連するコードのスニペットを編集してください。チェックアウトhttp://stackoverflow.com/help/how-to-ask – xlm

+1

コードの[mcve]で編集してください。リンク先を教えてください。 –

+0

これを試してみましたが、動作しませんでした。私のコードが正しくインデントされていないことを私に伝えます。 –

答えて

-1

https://github.com/CoreElites/nairamanager

はここ

がkivyファイルですありがとう今はとても遅いですが、同様の問題がありました。このコードをproduct_name: product_name product_list: product_listに入れてBoxLayout:の外に置くことで、このコードを動作させることができます。私は問題がproduct_listの範囲にあると思う。

関連する問題