将子流程Python模块与Raspbian上的Kivy一起使用

将子流程Python模块与Raspbian上的Kivy一起使用,python,raspberry-pi,kivy,Python,Raspberry Pi,Kivy,我尝试在linux Raspbian上使用python kivy调用可执行文件。 我的代码工作不正常,按下按钮我的应用程序冻结,无法打开可执行文件。 我试过python解释器: >> from subprocess import call >> call("7w.sh") 工作正常,在python中kivy可执行文件未打开 为什么不打开? 我的代码: Main.py from kivy.uix.floatlayout import FloatLayout from ki

我尝试在linux Raspbian上使用python kivy调用可执行文件。 我的代码工作不正常,按下按钮我的应用程序冻结,无法打开可执行文件。 我试过python解释器:

>> from subprocess import call
>> call("7w.sh")
工作正常,在python中kivy可执行文件未打开

为什么不打开? 我的代码:

Main.py

from kivy.uix.floatlayout import FloatLayout
from kivy.app import App
from kivy.config import Config
Config.set('graphics', 'width', '800')
Config.set('graphics', 'height', '480')
from subprocess import call



class SmAgro(FloatLayout):
    def __init__(self, **kwargs):
        super(SmAgro, self).__init__(**kwargs)
        self.screen_list = []

    def call_External_Pog(self):
        call(['7w.sh'])

    def changeScreen(self, next_screen):

        if next_screen == "configuracoes":
            self.ids.kivy_screen_manager.current = "configuracoes_screen"

        if next_screen == "equipamentos":
            self.ids.kivy_screen_manager.current = "equipamento_screen"

        if next_screen == "sobre":
            self.ids.kivy_screen_manager.current = "about_screen"

        if next_screen == "voltar":
            self.ids.kivy_screen_manager.current = "start_screen"


class SMAgroApp(App):
    def __init__(self, **kwargs):
        super(SMAgroApp, self).__init__(**kwargs)
    def build(self):
        return SmAgro()


if __name__ == '__main__':
    SMAgroApp().run()
我的smagro.kv

<SMAgro>:
    ScreenManager:
        id: kivy_screen_manager
        StartScreen:
            name: "start_screen"

        EquipamentoScreen:
            id: equipamento_screen
            name: "equipamento_screen"

        ConfiguracoesScreen:
            id: configuracoes_screen
            name: "configuracoes_screen"

        AboutScreen:
            id: about_screen
            name: "about_screen"

<StartScreen@Screen>:
    canvas:
        Color:
            rgb: [1,1,1,1]
        Rectangle:
            pos: self.pos
            size: self.size
    FloatLayout:
        pos_hint: {'center_y': 0.5, 'center_x': 0.5}
        size_hint: 0.45, 0.48
        Label:
            id: lbl_start_home
            text: 'SMAgro '
            color: [0,0,0,.200]
            font_size: root.height / 6
            font_name: '../data/fonts/Segoe_UI.ttf'
            size_hint_x:0.3
            size_hint_y:1.6
            pos_hint: {'y': .5, 'x': .35}
        Button:
            on_release: app.root.changeScreen(self.text.lower())
            background_color: [.4,1,.1,1]
            pos_hint: {'x': 0, 'y': 0.375}
            size_hint: 1, 0.625
            text: "Equipamentos"
            text_size: self.size
            padding: 8, 8
            font_name: '../data/fonts/Segoe_UI.ttf'
            Image:
                source: '../data/img/Truck-96.png'
                color: [1,1,1,1]
                y: self.parent.y + self.parent.height - 120
                x: self.parent.x + self.parent.height + 70

        Button:
            on_release: app.root.changeScreen(self.text.lower())
            background_color: [.4,1,.1,1]
            pos_hint: {'x': 0, 'y': 0}
            size_hint: .5, 0.375
            text: 'Configuracoes'
            text_size: self.size
            padding: 8, 8
            font_name: '../data/fonts/Segoe_UI.ttf'
            Image:
                source: '../data/img/Settings-64.png'
                color: [1,1,1,1]
                y: self.parent.y + self.parent.height - 90
                x: self.parent.x + self.parent.height - 15
        Button:
            on_release: app.root.call_External_Pog()
            background_color: [.4,1,.1,1]
            pos_hint: {'x': .5, 'y': 0}
            size_hint: .5, 0.375
            text: 'Routerizador'
            text_size: self.size
            padding: 8, 8
            font_name: '../data/fonts/Segoe_UI.ttf'
            Image:
                source: '../data/img/GPS Device-64.png'
                color: [1,1,1,1]
                y: self.parent.y + self.parent.height - 90
                x: self.parent.x + self.parent.height - 15

<EquipamentoScreen@Screen>:
    canvas:
        Color:
            rgb: [1,1,1,1]
        Rectangle:
            pos: self.pos
            size: self.size

    FloatLayout:
        Label:
            id: lbl_equip
            text: 'Equipamento: '
            color: [0, 0, 0, 1]
            font_size: root.height / 20
            font_name: '../data/fonts/Segoe_UI.ttf'
            size_hint_x:0.3
            size_hint_y:1.8
        BoxLayout:
            pos: (220,410)
            size_hint_x: 0.621
            size_hint_y: 0.11
            TextInput:
                id: txt_equip
                font_size: '36sp'
                padding_y: (self.height - self.line_height) / 2
                border: 30, 30, 30, 30
                background_normal: '../data/img/AO734.png'
        Label:
            id: lbl_operador
            text: 'Operador: '
            color: [0, 0, 0, 1]
            font_size: root.height / 20
            font_name: '../data/fonts/Segoe_UI.ttf'
            size_hint_x:0.3
            size_hint_y:1.6
        BoxLayout:
            pos: (220,356)
            size_hint_x: 0.2
            size_hint_y: 0.11
            TextInput:
                id: txt_operador
                font_size: '36sp'
                padding_y: (self.height - self.line_height) / 2
                border: 30, 30, 30, 30
                background_normal: '../data/img/AO734.png'
            Button:
                id: btn_search
                background_normal: '../data/img/AO734.png'
                border: 30, 30, 30, 30
                Image:
                    source: '../data/img/Search-64.png'
                    y: self.parent.y - 28
                    x: self.parent.x- 10
        BoxLayout:
            pos: (400,356)
            size_hint_x: 0.4
            size_hint_y: 0.11
            TextInput:
                id: txt_search
                border: 30, 30, 30, 30
                background_normal: '../data/img/AO734.png'

        Label:
            id: lbl_medicao
            text: 'Medicao inicial: '
            color: [0, 0, 0, 1]
            font_size: root.height / 20
            font_name: '../data/fonts/Segoe_UI.ttf'
            size_hint_x:0.3
            size_hint_y:1.35

        BoxLayout:
            pos: (220,300)
            size_hint_x: 0.2
            size_hint_y: 0.11
            TextInput:
                id: txt_medicao
                font_size: '36sp'
                padding_y: (self.height - self.line_height) / 2
                border: 30, 30, 30, 30
                background_normal: '../data/img/AO734.png'

        BoxLayout:
            Label:
                id: lbl_turma
                text: 'Turma: '
                color: [0, 0, 0, 1]
                font_size: root.height / 20
                font_name: '../data/fonts/Segoe_UI.ttf'

            Label:
                text: 'Diurno:'
                color: [0, 0, 0, 1]
            CheckBox:
                group: 'turma'
                on_release: True

            Label:
                text: 'Noturno:'
                color: [0, 0, 0, 1]
            CheckBox:
                group: 'turma'

            Label:
                text: 'Vespertino:'
                color: [0, 0, 0, 1]
            CheckBox:
                group: 'turma'

        BoxLayout:
            pos: (10,10)
            size_hint_x: 0.2
            size_hint_y: 0.12
            Button:
                on_release: root.manager.current = root.manager.previous()
                id: btn_previous
                background_normal: '../data/img/Circled Left 2-64.png'
            Label:
                id: lbl_previous
                text: 'Voltar'
                color: [0, 0, 0, 1]
                font_size: root.height / 20
                font_name: '../data/fonts/Segoe_UI.ttf'

        BoxLayout:
            pos: (630,10)
            size_hint_x: 0.2
            size_hint_y: 0.12
            Label:
                id: lbl_next
                text: 'Avancar'
                color: [0, 0, 0, 1]
                font_size: root.height / 20
                font_name: '../data/fonts/Segoe_UI.ttf'
            Button:
                id: btn_next
                background_normal: '../data/img/Circled Right 2-64.png'

<ConfiguracoesScreen@Screen>:
    canvas:
        Color:
            rgb: [1,1,1,1]
        Rectangle:
            pos: self.pos
            size: self.size

    FloatLayout:
        Label:
            id: lbl_cod_equipamento
            text: 'Cod. equipamento: '
            color: [0, 0, 0, 1]
            font_size: root.height / 20
            font_name: '../data/fonts/Segoe_UI.ttf'
            size_hint_x:0.3
            size_hint_y:1.75
        BoxLayout:
            pos: (220,410)
            size_hint_x: 0.2
            size_hint_y: 0.11
            TextInput:
                id: txt_cod_equipamento
                font_size: '36sp'
                padding_y: (self.height - self.line_height) / 2
                border: 30, 30, 30, 30
                background_normal: '../data/img/AO734.png'
            Button:
                id: btn_search
                background_normal: '../data/img/AO734.png'
                border: 30, 30, 30, 30
                Image:
                    source: '../data/img/Search-64.png'
                    y: self.parent.y - 28
                    x: self.parent.x- 10
        BoxLayout:
            pos: (400,410)
            size_hint_x: 0.4
            size_hint_y: 0.11
            TextInput:
                id: txt_search
                border: 30, 30, 30, 30
                background_normal: '../data/img/AO734.png'

        BoxLayout:
            orientation: 'vertical'
            pos_hint: {'center_y': 0.5, 'center_x': 0.5}
            size_hint_x: .5
            size_hint_y: .5
            Button:
                id: btn_update
                text: 'Atualizar dados'
                font_name: '../data/fonts/Segoe_UI.ttf'
                Image:
                    source: '../data/img/Available Updates-64.png'
                    y: self.parent.y - 22
                    x: self.parent.x- 10
            Button:
                id: btn_clear
                text: 'Limpar dados'
                font_name: '../data/fonts/Segoe_UI.ttf'
                Image:
                    source: '../data/img/Broom-64.png'
                    y: self.parent.y - 22
                    x: self.parent.x- 10
            Button:
                id: btn_senddata
                text: 'Enviar dados'
                font_name: '../data/fonts/Segoe_UI.ttf'
                Image:
                    source: '../data/img/Sent-64.png'
                    y: self.parent.y - 22
                    x: self.parent.x- 10
            Button:
                id: btn_save
                text: 'Gravar'
                font_name: '../data/fonts/Segoe_UI.ttf'
                Image:
                    source: '../data/img/Save-64.png'
                    y: self.parent.y - 22
                    x: self.parent.x- 10
        BoxLayout:
            pos: (10,10)
            size_hint_x: 0.2
            size_hint_y: 0.12
            Button:
                on_release: root.manager.current = root.manager.previous()
                id: btn_previous
                background_normal: '../data/img/Circled Left 2-64.png'
            Label:
                id: lbl_previous
                text: 'Voltar'
                color: [0, 0, 0, 1]
                font_size: root.height / 20
                font_name: '../data/fonts/Segoe_UI.ttf'

        BoxLayout:
            pos: (630,10)
            size_hint_x: 0.2
            size_hint_y: 0.12
            Label:
                id: lbl_next
                text: 'Avancar'
                color: [0, 0, 0, 1]
                font_size: root.height / 20
                font_name: '../data/fonts/Segoe_UI.ttf'
            Button:
                id: btn_next
                background_normal: '../data/img/Circled Right 2-64.png'

<AboutScreen@Screen>:
    canvas:
        Color:
            rgb: [1,1,1,1]
        Rectangle:
            pos: self.pos
            size: self.size
    BoxLayout:
        padding: root.width * .02, root.height * .02
        Label:
#            text: app.getText()
            color: [.4,1,.1,1]
            halign: "center"
            markup: True
            font_size: root.height / 20
            text_size: self.width, None
            center_y: .5
            on_ref_press: app.on_ref_press(*args)
            font_name: '../data/fonts/Segoe_UI.ttf'

    BoxLayout:
        pos: (10,10)
        size_hint_x: 0.1
        size_hint_y: 0.11
        Button:
            on_release: root.manager.current = root.manager.next()
            id: btn_previous
            background_normal: '../data/img/Circled Left 2-64.png'
        Label:
            id: lbl_previous
            text: 'Voltar'
            color: [0, 0, 0, 1]
            font_size: root.height / 20
            font_name: '../data/fonts/Segoe_UI.ttf'

    BoxLayout:
        pos: (630,10)
        size_hint_x: 0.1
        size_hint_y: 0.11
        Label:
            id: lbl_next
            text: 'Avancar'
            color: [0, 0, 0, 1]
            font_size: root.height / 20
            font_name: '../data/fonts/Segoe_UI.ttf'
        Button:
            id: btn_next
            background_normal: '../data/img/Circled Right 2-64.png'
:
屏幕管理器:
id:kivy_屏幕_经理
StartScreen:
名称:“启动屏幕”
设备屏幕:
id:Equipmento_屏幕
名称:“设备屏幕”
配置屏幕:
id:configuracoes_屏幕
名称:“配置屏幕”
关于屏幕:
id:about_屏幕
名称:“关于屏幕”
:
画布:
颜色:
rgb:[1,1,1,1]
矩形:
pos:self.pos
大小:self.size
浮动布局:
位置提示:{'center_y':0.5,'center_x':0.5}
尺寸提示:0.45,0.48
标签:
id:lbl\u开始\u回家
文字:“SMAgro”
颜色:[0,0,0,200]
字体大小:root.height/6
字体名称:“../data/fonts/Segoe_UI.ttf”
大小提示:0.3
尺寸:1.6
位置提示:{'y':.5,'x':.35}
按钮:
发布时:app.root.changeScreen(self.text.lower())
背景颜色:[.4,1,1]
位置提示:{'x':0,'y':0.375}
尺寸提示:1,0.625
案文:“装备”
文本大小:self.size
填充:8,8
字体名称:“../data/fonts/Segoe_UI.ttf”
图片:
来源:“../data/img/Truck-96.png”
颜色:[1,1,1,1]
y:self.parent.y+self.parent.height-120
x:self.parent.x+self.parent.height+70
按钮:
发布时:app.root.changeScreen(self.text.lower())
背景颜色:[.4,1,1]
位置提示:{'x':0,'y':0}
尺寸提示:.5,0.375
文本:“配置”
文本大小:self.size
填充:8,8
字体名称:“../data/fonts/Segoe_UI.ttf”
图片:
来源:“../data/img/Settings-64.png”
颜色:[1,1,1,1]
y:self.parent.y+self.parent.height-90
x:self.parent.x+self.parent.height-15
按钮:
发布时:app.root.call\u External\u Pog()
背景颜色:[.4,1,1]
pos_提示:{'x':.5'y':0}
尺寸提示:.5,0.375
文字:“Routerizador”
文本大小:self.size
填充:8,8
字体名称:“../data/fonts/Segoe_UI.ttf”
图片:
来源:“../data/img/GPS-Device-64.png”
颜色:[1,1,1,1]
y:self.parent.y+self.parent.height-90
x:self.parent.x+self.parent.height-15
:
画布:
颜色:
rgb:[1,1,1,1]
矩形:
pos:self.pos
大小:self.size
浮动布局:
标签:
id:lbl\U设备
文字:“设备:”
颜色:[0,0,0,1]
字体大小:root.height/20
字体名称:“../data/fonts/Segoe_UI.ttf”
大小提示:0.3
尺寸:1.8
盒子布局:
职位:(220410)
尺寸:0.621
尺寸:0.11
文本输入:
id:txt\U设备
字体大小:“36sp”
填充y:(自高度-自线条高度)/2
边界:30,30,30,30
背景:正常:“../data/img/AO734.png”
标签:
id:lbl_operador
文字:“歌剧演员:”
颜色:[0,0,0,1]
字体大小:root.height/20
字体名称:“../data/fonts/Segoe_UI.ttf”
大小提示:0.3
尺寸:1.6
盒子布局:
职位:(220356)
大小提示:0.2
尺寸:0.11
文本输入:
id:txt_operador
字体大小:“36sp”
填充y:(自高度-自线条高度)/2
边界:30,30,30,30
背景:正常:“../data/img/AO734.png”
按钮:
id:btn\U搜索
背景:正常:“../data/img/AO734.png”
边界:30,30,30,30
图片:
来源:“../data/img/Search-64.png”
y:self.parent.y-28
x:self.parent.x-10
盒子布局:
位置:(400356)
大小提示:0.4
尺寸:0.11
文本输入:
id:txt\u搜索
边界:30,30,30,30
背景:正常:“../data/img/AO734.png”
标签:
id:lbl_medicao
文字:“医疗专用:”
颜色:[0,0,0,1]
字体大小:root.height/20
字体名称:“../data/fonts/Segoe_UI.ttf”
大小提示:0.3
尺寸:1.35
盒子布局:
职位:(220300)
大小提示:0.2
尺寸:0.11
文本输入:
id:txt_medicao
字体大小:“36sp”
填充y:(自高度-自线条高度)/2
边界:30,30,30,30
背景:正常:“../data/img/AO734.png”
盒子布局:
标签:
id:lbl_turma
文字:“图尔玛:”
颜色:[0,0,0,1]
字体大小:root.height/20
字体名称:“../data/fonts/Segoe_UI.ttf”
标签:
文本:“否:”
颜色:[0,0,0,1]
复选框:
组别:图尔玛
发布时:正确
标签:
文本:“Noturno:”
>>>import subprocess
>>>p = subprocess.Popen(["bash", "7w.sh", ""])
>>>p.communicate()