简体   繁体   English

我的代码有什么问题。 它继续显示此错误消息

[英]what is the problem with my code. it keeps on displaying this error message

i am trying to make a software that records microphone data in realtime but it keeps on coming up with an error.我正在尝试制作一个实时记录麦克风数据的软件,但它不断出现错误。 " TypeError: init () got an unexpected keyword argument '__no_builder'" i have looked through the code but cant seem to find any problems. “ TypeError: init () got an unexpected keyword argument '__no_builder'” 我查看了代码,但似乎找不到任何问题。 i am using atom to code.我正在使用 atom 进行编码。 there is a .kv and .py file有一个 .kv 和 .py 文件

python file
from kivy.app import App
from kivy.uix.boxlayout import BoxLayout
from kivy.garden.graph import MeshLinePlot
from kivy.clock import Clock
from threading import Thread
import audioop
import pyaudio
from kivy.core.window import Window
from kivy.lang import Builder

Window.borderless = True

def capture_mic_data():
    chunk = 1024
    FORMAT = pyaudio.paInt16
    CHANNELS = 1
    RATE : 44100
    p = pyaudio.PyAudio()
    s =  p.open(format = FORMAT, channels = CHANNELS, rate = RATE, input = True,frames_per_buffer =chunk)

    global levels
    while True:
        data =  s.read(chunk)
        mx = audio.rms(data,2)
        if len(levels) >= 100:
            levels = []
        levels.append(mx)



class Logic(BoxLayout):

    def __init__(self,):
        super(Logic,self).__init__()
        self.plot = MeshLinePlot(color=[1,0,0,1])

    def start(self):
        self.ids.graph.add_plot(self.plot)
        Clock.schedule_interval(self.get_value,0.0001)

    def stop(self):
        Clock.unschedule(self.get_value)

    def get_value(self,dt):
        self.plot.points =[(i,j/5) for i,j in enumerate(levels)]


class MainApp(App):
    def build(self):
        return Builder.load_file("main.kv")

levels =[]
capture_mic_data_thread = Thread(target =  capture_mic_data)
capture_mic_data_thread.daemon = True
capture_mic_data_thread.start()
MainApp().run()

kivy file基维文件

Logic:
    BoxLayout:
        orientation: "vertical"
        BoxLayout:
            size_hint: [1,.8]
            Graph:
                id: graph
                xlabel: "Amplitude"
                ylabel: "Sample"
                x_grid_label : True
                y_grid_label : True
                background_color : 0.429,0.3,0.423,1
                x_ticks_minor : 10
                x_ticks_major :5
                color : 1,1,0,1
                ymax: 500
                ymin: 0
                xmax: 100
                border_color : 1,1,0,1

            BoxLayout:
                size_hint: [1,.1]
                orientation : "horizontal"
                Button:
                    size_hint:[0.2,1]
                    text: "START"
                    bold : True
                    on_press: root.start()

                Button:
                    text: "STOP"
                    size_hint_x:0.2
                    bold :True
                    on_press: root.stop()

You must handle keyword arguments when you extend a class.扩展类时必须处理关键字参数。 Just add that to your Logic class:只需将其添加到您的Logic类中:

class Logic(BoxLayout):

    def __init__(self, **kwargs):
        super(Logic,self).__init__(**kwargs)
        self.plot = MeshLinePlot(color=[1,0,0,1])

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我的 Python 代码有问题。 有错误,“未解决的参考” - Having a problem with my Python Code. Has the error, “unresolved reference” 初学者问题,编写我的第一个代码。 不确定这个问题 - Beginner problem, writing my first code. Not sure about this problem 多次抓取:代码中的问题。 我究竟做错了什么? - Multiple scraping: problem in the code. What am I doing wrong? 无法杀死我的python代码。 怎么了? - Can't kill my python code. What's wrong? 以下代码中的错误是什么? 应该使用列表制作矩阵 - What is the error in the following code. It is supposed to make a matrix using lists 代码中的模块错误。 无法弄清楚出了什么问题 - module error in code. Cannot figure out what is wrong 我的不和谐机器人代码有问题,它一直显示相同的错误 - I have a problem with my code for a discord bot, it keeps showing the same error 如何从 python 代码执行 pylint 命令。 此外,pylint 中的哪些参数可以根据我的需要生成日志消息 - How can I execute pylint command from python code. Also what argument in pylint can make log message as per my need 关于改进我的代码的建议。 - Suggestions on improving my code. 重复掷硬币代码异常。 找不到问题出在我的代码还是 Python 本身 - Anomaly in repeated coin flipping code. Can't find whether the problem is in my code or Python itself
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM