U
U
uvv992022-01-22 21:27:41
Kivy
uvv99, 2022-01-22 21:27:41

I do not understand why the program does not start? What's wrong with me?

Good afternoon. I do not understand why the program does not start? What's wrong with me?

from kivy.app import App
from kivy.lang import Builder
from kivy.uix.screenmanager import ScreenManager, Screen
from kivy.core.window import Window

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


Builder.load_string("""
<PushScreen>:
    BoxLayout:
    #:import ZBarCam kivy_garden.zbarcam.ZBarCam

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

<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:
        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
            on_press: root.manager.current = 'menu'
""")


class MenuScreen(Screen):
    pass


class ScanScreen(Screen):
    pass

class PushScreen(Screen):
    pass


class MainApp(App):
    def build(self):
        sm = ScreenManager()
        sm.add_widget(MenuScreen(name='menu'))  # 1 tablo
        sm.add_widget(PushScreen(name='settings')) # 2 tablo
        sm.add_widget(ScanScreen(neme='total')) # 3 tablo
        return sm


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

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
Oksana ..., 2022-01-22
@uvv99

one.

sm.add_widget(ScanScreen(name='total')) # 3 tablo

Must be, but you have "neme"
2. Label cannot have on_press: root.manager.current = 'total' , only buttons.
In general, I would like to see the error log ...
I have your code running like this:
from kivy.app import App
from kivy.lang import Builder
from kivy.uix.screenmanager import ScreenManager, Screen
from kivy.core.window import Window

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


Builder.load_string("""

<PushScreen>:
    #:import ZBarCam kivy_garden.zbarcam.ZBarCam
    BoxLayout:
        ZBarCam:
            id: qrcodecam
        Label:
            size_hint: None, None
            size: self.texture_size[0], 50
            text: ' , '.join([str(symbol.data) for symbol in qrcodecam.symbols])
      
<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:
        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
            on_press: root.manager.current = 'menu'
""")


class MenuScreen(Screen):
    pass


class ScanScreen(Screen):
    pass

class PushScreen(Screen):
    pass


sm = ScreenManager()
sm.add_widget(MenuScreen(name='menu'))  # 1 tablo
sm.add_widget(PushScreen(name='settings'))  # 2 tablo
sm.add_widget(ScanScreen(name='total'))  # 3 tablo


class MainApp(App):
    def __init__(self):
        super(MainApp, self).__init__()

    def build(self):

        return sm


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

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question