U
U
uvv992022-01-26 21:53:40
Python
uvv99, 2022-01-26 21:53:40

How to solve AttributeError: 'NoneType' object has no attribute 'reshape' error?

Shows error: AttributeError: 'NoneType' object has no attribute 'reshape'
can't figure out why? Opens the application, turns on the camera, then turns it off for some reason, it seems to work, but shows an error, why?

from kivy.app import App
from kivy.lang import Builder
from kivy.uix.screenmanager import ScreenManager, Screen
from kivy.core.window import Window
from kivy.clock import Clock
from requests import get
from kivy.uix.button import Button
import requests


Window.size = (360, 480)
Window.clearcolor = (0, .17, .55, 1)


notice_list = []
department = 'kmd'


Builder.load_string("""
<MenuScreen>:
    BoxLayout:
        orientation: 'vertical'
        padding: 5, 10
        spacing: 10

        Button:
            text: 'УВЕДОМЛЕНИЯ'
            background_color: 0, .12, .52, 1
        Button:
            text: 'ЗАКАЗЫ В РАБОТЕ'
            background_color: 0, .12, .52, 1
        Button:
            text: 'АРХИВ ЗАКАЗОВ'
            background_color: 0, .12, .52, 1
        Button:
            text: 'СКАНИРОВАНИЕ QR'
            background_color: 0, .12, .52, 1
            on_press: root.manager.current = 'settings'

<ScanScreen>:
    BoxLayout:
    #:import ZBarCam kivy_garden.zbarcam.ZBarCam
        orientation: 'vertical'
        padding: 5, 10
        spacing: 10

        ZBarCam:
            id: qrcodecam
        Label:
            size_hint: None, None
            size: self.texture_size[0], 50
            text: ' , '.join([str(symbol.data) for symbol in qrcodecam.symbols])

        Button:
            text: 'РАБОТА НАЧАТА'
            background_color: 0, .12, .52, 1
            on_press: root.manager.current = 'start'
        Button:
            text: 'РАБОТА ПРИОСТАНОВЛЕНА'
            background_color: 0, .12, .52, 1
        Button:
            text: 'РАБОТА ЗАКОНЧЕНА'
            background_color: 0, .12, .52, 1
            on_press: root.manager.current = 'menu'
""")

class MenuScreen(Screen):
    pass

class ScanScreen(Screen):
    def __init__(self, **kwargs):
        super(ScanScreen, self).__init__(**kwargs)
        self.start = kwargs.get('start')

    def start(self, *args, **kwargs):
        response = requests.post(f'http://127.0.0.1:8000/api/notice/{department}', data = {'user': department, 'id': notice_list})



def get_notice(_):
    for i in get(f'http://127.0.0.1:8000/api/notice/{department}').text.split(','):
        if i != '':
            notice_list.append(i)
    print(notice_list)


class MainApp(App):
    def build(self):
        sm = ScreenManager()
        sm.add_widget(MenuScreen(name='menu'))
        sm.add_widget(ScanScreen(name='settings'))
        sm.add_widget(ScanScreen(name='start'))
        return sm


if __name__=='__main__':
    Clock.schedule_interval(get_notice, 1)

    MainApp().run()

Answer the question

In order to leave comments, you need to log in

2 answer(s)
U
uvv99, 2022-01-27
@uvv99

Barely figured out, found a way out:

from kivy.app import App
from kivy.lang import Builder
from kivy.uix.screenmanager import ScreenManager, Screen
from kivy.core.window import Window
from kivy.clock import Clock
from requests import get, post
from kivy.uix.camera import Camera

Window.size = (360, 480)
Window.clearcolor = (0, .17, .55, 1)


notice_list = []
department = 'kmd'


Builder.load_string("""
<MenuScreen>:
    BoxLayout:
        orientation: 'vertical'
        padding: 5, 10
        spacing: 10

        Button:
            text: 'УВЕДОМЛЕНИЯ'
            background_color: 0, .12, .52, 1
        Button:
            text: 'ЗАКАЗЫ В РАБОТЕ'
            background_color: 0, .12, .52, 1
        Button:
            text: 'АРХИВ ЗАКАЗОВ'
            background_color: 0, .12, .52, 1
        Button:
            text: 'СКАНИРОВАНИЕ QR'
            background_color: 0, .12, .52, 1
            on_press: root.manager.current = 'settings'

<ScanScreen>:
    BoxLayout:
    #:import ZBarCam kivy_garden.zbarcam.ZBarCam
        orientation: 'vertical'
        padding: 5, 10
        spacing: 10

        ZBarCam:
            id: qrcodecam
        Label:
            size_hint: None, None
            size: self.texture_size[0], 50
            text: ' , '.join([str(symbol.data) for symbol in qrcodecam.symbols])

        Button:
            text: 'РАБОТА НАЧАТА'
            background_color: 0, .12, .52, 1
            on_press: app.start()
        Button:
            text: 'РАБОТА ПРИОСТАНОВЛЕНА'
            background_color: 0, .12, .52, 1
        Button:
            text: 'РАБОТА ЗАКОНЧЕНА'
            background_color: 0, .12, .52, 1
            on_press: root.manager.current = 'menu'
""")

class MenuScreen(Screen):
    pass

class ScanScreen(Screen):
    pass


def get_notice(_):
    for i in get(f'http://127.0.0.1:8000/api/notice/{department}').text.split(','):
        if i != '':
            notice_list.append(i)


class MainApp(App):
    def build(self):
        sm = ScreenManager()
        sm.add_widget(MenuScreen(name='menu'))
        sm.add_widget(ScanScreen(name='settings'))
        return sm

    def start(self):
        r = get(f'http://127.0.0.1:8000/api/give_csrf')
        csrf = r.text.split('=')[-1][1:-2]
        cookies = r.cookies.get_dict()

        post(f'http://127.0.0.1:8000/api/qr_start/{department}',
              data = {'id': notice_list, 'csrfmiddlewaretoken': csrf},
              cookies = cookies)


if __name__=='__main__':
    Clock.schedule_interval(get_notice, 3)

    MainApp().run()

L
Leonid, 2022-01-27
@bravebug

Need full traceback

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question