Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/280.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Kivy标签文本不';t更新_Python_Kivy - Fatal编程技术网

Python Kivy标签文本不';t更新

Python Kivy标签文本不';t更新,python,kivy,Python,Kivy,我正在和Kivy一起做一个日历程序。我的问题是打印到标签功能。我在函数末尾编写了appointment\u label.text=appointment\u name\u file\u内容,但标签只有在重新启动程序时才会更新。 如果您想知道label_id_file_content代表“1jal”,即标签id 谢谢你的帮助 朱利叶斯 Python: # diable multitouch from kivy.config import Config Config.set('input', 'mo

我正在和Kivy一起做一个日历程序。我的问题是打印到标签功能。我在函数末尾编写了appointment\u label.text=appointment\u name\u file\u内容,但标签只有在重新启动程序时才会更新。 如果您想知道label_id_file_content代表“1jal”,即标签id

谢谢你的帮助 朱利叶斯

Python:

# diable multitouch
from kivy.config import Config
Config.set('input', 'mouse', 'mouse,multitouch_on_demand')
from kivy.app import App
from kivy.uix.screenmanager import Screen,ScreenManager
from kivy.lang.builder import Builder
from kivy.uix.popup import Popup
from kivy.uix.floatlayout import FloatLayout
from kivy.clock import Clock




class screenmanager(ScreenManager):
    pass

class PopupContent(FloatLayout):
    def store_appointment_name(self):
        appointment_name = self.ids.appointment_name.text
        with open("appointment_name_file","w") as appointment_name_file:
            appointment_name_file.write(appointment_name)
        with open("label_id_file","r") as label_id_file:
            label_id_file_content = label_id_file.read()

        #check month
        if "ja" in label_id_file_content:
            Ja = JanuaryWindow()
            Ja.__init__()



class MonthWindow(Screen):
    pass


class JanuaryWindow(Screen):
    def __init__(self, **kwargs):
        super(JanuaryWindow, self).__init__(**kwargs)
        Clock.schedule_once(self.print_appointment_to_label)

    def print_appointment_to_label(self,dt):
        with open("appointment_name_file", "r") as appointment_name_file:
            appointment_name_file_content = appointment_name_file.read()
        with open("label_id_file", "r") as label_id_file:
            label_id_file_content = label_id_file.read()

        appointment_label = self.ids[label_id_file_content]
        appointment_label.text = appointment_name_file_content


        # Label Text is not showing up only when restart program









kv = Builder.load_file("Calendar-KIVY.kv")

class Calendar(App):
    def create_popup_and_convert_button_id_in_label_id(self,button_id):
        with open("button_id_file","w") as button_id_file:
            button_id_file.write(button_id)


        pcontent = PopupContent()
        new_appointment_p = Popup(title="Make new appointment",content=pcontent,size_hint=(None,None),size=(1500,1000))
        new_appointment_p.open()

        #make label id
        with open("button_id_file", "r") as button_id_file:
            button_id_file_content = button_id_file.read()

        label_id = button_id_file_content.replace("b", "l")

        with open("label_id_file", "w") as label_id_file:
            label_id_file.write(label_id)


    def build(self):
        return kv

Calendar().run()
千伏:

屏幕管理器:
蒙特文杜:
一月窗:
:
标签:
文本:“输入您的约会名称”
尺寸提示:0.4,0.1
pos_提示:{“x”:0.1,“y”:0.6}
文本输入:
id:约会名称
尺寸提示:0.4,0.06
pos_提示:{“x”:0.478,“y”:0.615}
多行:False
按钮:
文本:“创建”
尺寸提示:0.8,0.2
pos_提示:{“x”:0.1,“y”:0.09}
发布时:
root.store\u约会\u name()
:
姓名:“MoW”
网格布局:
科尔斯:4
按钮:
案文:“1月”
发布时:
app.root.current=“下巴”
按钮:
案文:“2月”
发布时:
app.root.current=“很少”
按钮:
正文:“三月”
按钮:
案文:“4月”
按钮:
案文:“五月”
按钮:
案文:“6月”
按钮:
案文:“7月”
按钮:
案文:“8月”
按钮:
案文:“9月”
按钮:
案文:“10月”
按钮:
案文:“11月”
按钮:
案文:“12月”
:
姓名:“下巴”
浮动布局:
标签:
案文:“1月”
字体大小:“30sp”
pos_提示:{“x”:-0.426,“y”:0.429}
盒子布局:
方向:“垂直”
pos_提示:{“x”:-0.4,“y”:-0.0015}
尺寸提示:0.9,0.89
标签:
案文:“1”
标签:
案文:“2”
标签:
案文:“3”
标签:
案文:“4”
标签:
案文:“5”
标签:
案文:“6”
标签:
案文:“7”
标签:
案文:“8”
标签:
案文:“9”
标签:
案文:“10”
标签:
案文:“11”
标签:
案文:“12”
标签:
案文:“13”
标签:
案文:“14”
标签:
案文:“15”
标签:
案文:“”
盒子布局:
方向:“垂直”
pos_提示:{“x”:0,y:-0.0015}
尺寸提示:0.9,0.89
标签:
案文:“16”
标签:
案文:“17”
标签:
案文:“18”
标签:
案文:“19”
标签:
案文:“20”
标签:
案文:“21”
标签:
案文:“22”
标签:
案文:“23”
标签:
案文:“24”
标签:
案文:“25”
标签:
案文:“26”
标签:
案文:“27”
标签:
案文:“28”
标签:
案文:“29”
标签:
案文:“30”
标签:
案文:“”
盒子布局:
方向:“垂直”
pos_提示:{“x”:0.32,“y”:-0.0015}
尺寸提示:0.9,0.89
标签:
案文:“31”
标签:
案文:“”
标签:
案文:“”
标签:
案文:“”
标签:
案文:“”
标签:
案文:“”
标签:
案文:“”
标签:
案文:“”
标签:
案文:“”
标签:
案文:“”
标签:
案文:“”
标签:
案文:“”
标签:
案文:“”
标签:
案文:“”
标签:
案文:“”
标签:
案文:“”
浮动布局:
按钮:
pos_提示:{“x”:0.38,“y”:0.843}
尺寸提示:0.02,0.03
正文:“+”
发布时:
在标签id(“1jab”)中创建应用程序弹出窗口和转换按钮id
浮动布局:
按钮:
pos_提示:{“x”:0.38,“y”:0.7885}
尺寸提示:0.02,0.03
正文:“+”
浮动布局:
按钮:
pos_提示:{“x”:0.38,“y”:0.734}
尺寸提示:0.02,0.03
正文:“+”
浮动布局:
按钮:
pos_提示:{“x”:0.38,“y”:0.6795}
尺寸提示:0.02,0.03
正文:“+”
浮动布局:
按钮:
pos_提示:{“x”:0.38,“y”:0.6795}
尺寸提示:0.02,0.03
正文:“+”
浮动布局:
按钮:
pos_提示:{“x”:0.38,“y”:0.625}
尺寸提示:0.02,0.03
正文:“+”
浮动布局:
按钮:
pos_提示:{“x”:0.38,“y”:0.5705}
尺寸提示:0.02,0.03
正文:“+”
浮动布局:
按钮:
pos_提示:{“x”:0.38,“y”:0.516}
尺寸提示:0.02,0.03
正文:“+”
浮动布局:
按钮:
pos_提示:{“x”:0.38,“y”:0.4615}
尺寸提示:0.02,0.03
正文:“+”
浮动布局:
按钮:
pos_提示:{“x”:0.38,“y”:0.4615}
尺寸提示:0.02,0.03
正文:“+”
浮动布局:
按钮:
pos_提示:{“x”:0.38,“y”:0.407}
尺寸提示:0.02,0.03
正文:“+”
浮动布局:
按钮:
pos_提示:{“x”:0.38,“y”:0.3525}
尺寸提示:0.02,0.03
正文:“+”
浮动布局:
按钮:
pos_提示:{“x”:0.38,“y”:0.298}
尺寸提示:0.02,0.03
正文:“+”
浮动布局:
按钮:
pos_提示:{“x”:0.38,“y”:0.2435}
尺寸提示:0.02,0.03
正文:“+”
浮动布局:
按钮:
pos_提示:{“x”:0.38,“y”:0.2435}
尺寸提示:0.02,0.03
正文:“+”
浮动布局:
按钮:
pos_提示:{“x”:0.38,“y”:0.188}
大小
screenmanager:
    MonthWindow:
    JanuaryWindow:




<PopupContent>:
    Label:
        text: "Enter your appointment name"
        size_hint: 0.4,0.1
        pos_hint:{"x":0.1,"y":0.6}
    TextInput:
        id: appointment_name
        size_hint: 0.4,0.06
        pos_hint: {"x":0.478,"y":0.615}
        multiline: False
    Button:
        text: "Create"
        size_hint: 0.8,0.2
        pos_hint: {"x":0.1,"y":0.09}
        on_release:
            root.store_appointment_name()




<MonthWindow>:
    name : "MoW"
    GridLayout:
        cols:4
        Button:
            text:"January"
            on_release:
                app.root.current = "JaW"
        Button:
            text:"February"
            on_release:
                app.root.current = "FeW"
        Button:
            text:"March"
        Button:
            text:"April"
        Button:
            text:"May"
        Button:
            text:"June"
        Button:
            text:"July"
        Button:
            text:"August"
        Button:
            text:"September"
        Button:
            text:"October"
        Button:
            text:"November"
        Button:
            text:"December"




<JanuaryWindow>:
    name : "JaW"
    FloatLayout:
        Label:
            text:"January"
            font_size: "30sp"
            pos_hint: {"x":-0.426,"y":0.429}
    BoxLayout:
        orientation: "vertical"
        pos_hint: {"x":-0.4,"y":-0.0015}
        size_hint: 0.9,0.89
        Label:
            text:"1"
        Label:
            text:"2"
        Label:
            text:"3"
        Label:
            text:"4"
        Label:
            text:"5"
        Label:
            text:"6"
        Label:
            text:"7"
        Label:
            text:"8"
        Label:
            text:"9"
        Label:
            text:"10"
        Label:
            text:"11"
        Label:
            text:"12"
        Label:
            text:"13"
        Label:
            text:"14"
        Label:
            text:"15"
        Label:
            text:""
    BoxLayout:
        orientation: "vertical"
        pos_hint: {"x":0,"y":-0.0015}
        size_hint: 0.9,0.89
        Label:
            text:"16"
        Label:
            text:"17"
        Label:
            text:"18"
        Label:
            text:"19"
        Label:
            text:"20"
        Label:
            text:"21"
        Label:
            text:"22"
        Label:
            text:"23"
        Label:
            text:"24"
        Label:
            text:"25"
        Label:
            text:"26"
        Label:
            text:"27"
        Label:
            text:"28"
        Label:
            text:"29"
        Label:
            text:"30"
        Label:
            text:""
    BoxLayout:
        orientation: "vertical"
        pos_hint: {"x":0.32,"y":-0.0015}
        size_hint: 0.9,0.89
        Label:
            text:"31"
        Label:
            text:""
        Label:
            text:""
        Label:
            text:""
        Label:
            text:""
        Label:
            text:""
        Label:
            text:""
        Label:
            text:""
        Label:
            text:""
        Label:
            text:""
        Label:
            text:""
        Label:
            text:""
        Label:
            text:""
        Label:
            text:""
        Label:
            text:""
        Label:
            text:""
    FloatLayout:
        Button:
            pos_hint: {"x":0.38,"y":0.843}
            size_hint: 0.02,0.03
            text: "+"
            on_release:
                app.create_popup_and_convert_button_id_in_label_id("1jab")
    FloatLayout:
        Button:
            pos_hint: {"x":0.38,"y":0.7885}
            size_hint: 0.02,0.03
            text: "+"
    FloatLayout:
        Button:
            pos_hint: {"x":0.38,"y":0.734}
            size_hint: 0.02,0.03
            text: "+"
    FloatLayout:
        Button:
            pos_hint: {"x":0.38,"y":0.6795}
            size_hint: 0.02,0.03
            text: "+"
    FloatLayout:
        Button:
            pos_hint: {"x":0.38,"y":0.6795}
            size_hint: 0.02,0.03
            text: "+"
    FloatLayout:
        Button:
            pos_hint: {"x":0.38,"y":0.625}
            size_hint: 0.02,0.03
            text: "+"
    FloatLayout:
        Button:
            pos_hint: {"x":0.38,"y":0.5705}
            size_hint: 0.02,0.03
            text: "+"
    FloatLayout:
        Button:
            pos_hint: {"x":0.38,"y":0.516}
            size_hint: 0.02,0.03
            text: "+"
    FloatLayout:
        Button:
            pos_hint: {"x":0.38,"y":0.4615}
            size_hint: 0.02,0.03
            text: "+"
    FloatLayout:
        Button:
            pos_hint: {"x":0.38,"y":0.4615}
            size_hint: 0.02,0.03
            text: "+"
    FloatLayout:
        Button:
            pos_hint: {"x":0.38,"y":0.407}
            size_hint: 0.02,0.03
            text: "+"
    FloatLayout:
        Button:
            pos_hint: {"x":0.38,"y":0.3525}
            size_hint: 0.02,0.03
            text: "+"
    FloatLayout:
        Button:
            pos_hint: {"x":0.38,"y":0.298}
            size_hint: 0.02,0.03
            text: "+"
    FloatLayout:
        Button:
            pos_hint: {"x":0.38,"y":0.2435}
            size_hint: 0.02,0.03
            text: "+"
    FloatLayout:
        Button:
            pos_hint: {"x":0.38,"y":0.2435}
            size_hint: 0.02,0.03
            text: "+"
    FloatLayout:
        Button:
            pos_hint: {"x":0.38,"y":0.188}
            size_hint: 0.02,0.03
            text: "+"
    FloatLayout:
        Button:
            pos_hint: {"x":0.38,"y":0.1235}
            size_hint: 0.02,0.03
            text: "+"
    FloatLayout:
        Button:
            pos_hint: {"x":0.38,"y":0.07}
            size_hint: 0.02,0.03
            text: "+"
    FloatLayout:
        Button:
            pos_hint: {"x":0.7174,"y":0.843}
            size_hint: 0.02,0.03
            text: "+"
    FloatLayout:
        Button:
            pos_hint: {"x":0.7174,"y":0.7885}
            size_hint: 0.02,0.03
            text: "+"
    FloatLayout:
        Button:
            pos_hint: {"x":0.7174,"y":0.734}
            size_hint: 0.02,0.03
            text: "+"
    FloatLayout:
        Button:
            pos_hint: {"x":0.7174,"y":0.6795}
            size_hint: 0.02,0.03
            text: "+"
    FloatLayout:
        Button:
            pos_hint: {"x":0.7174,"y":0.6795}
            size_hint: 0.02,0.03
            text: "+"
    FloatLayout:
        Button:
            pos_hint: {"x":0.7174,"y":0.625}
            size_hint: 0.02,0.03
            text: "+"
    FloatLayout:
        Button:
            pos_hint: {"x":0.7174,"y":0.5705}
            size_hint: 0.02,0.03
            text: "+"
    FloatLayout:
        Button:
            pos_hint: {"x":0.7174,"y":0.516}
            size_hint: 0.02,0.03
            text: "+"
    FloatLayout:
        Button:
            pos_hint: {"x":0.7174,"y":0.4615}
            size_hint: 0.02,0.03
            text: "+"
    FloatLayout:
        Button:
            pos_hint: {"x":0.7174,"y":0.4615}
            size_hint: 0.02,0.03
            text: "+"
    FloatLayout:
        Button:
            pos_hint: {"x":0.7174,"y":0.407}
            size_hint: 0.02,0.03
            text: "+"
    FloatLayout:
        Button:
            pos_hint: {"x":0.7174,"y":0.3525}
            size_hint: 0.02,0.03
            text: "+"
    FloatLayout:
        Button:
            pos_hint: {"x":0.7174,"y":0.298}
            size_hint: 0.02,0.03
            text: "+"
    FloatLayout:
        Button:
            pos_hint: {"x":0.7174,"y":0.2435}
            size_hint: 0.02,0.03
            text: "+"
    FloatLayout:
        Button:
            pos_hint: {"x":0.7174,"y":0.2435}
            size_hint: 0.02,0.03
            text: "+"
    FloatLayout:
        Button:
            pos_hint: {"x":0.7174,"y":0.188}
            size_hint: 0.02,0.03
            text: "+"
    FloatLayout:
        Button:
            pos_hint: {"x":0.7174,"y":0.1235}
            size_hint: 0.02,0.03
            text: "+"
    FloatLayout:
        Button:
            pos_hint: {"x":0.7174,"y":0.07}
            size_hint: 0.02,0.03
            text: "+"
    BoxLayout:
        orientation: "vertical"
        pos_hint: {"x":-0.36,"y":-0.0015}
        size_hint: 0.9,0.89
        Label:
            id:1jal
            text: ""
        Label:
            id:2jal
            text:""
        Label:
            id:3jal
            text:""
        Label:
            id:4jal
            text:""
        Label:
            id:5jal
            text:""
        Label:
            id:6jal
            text:""
        Label:
            id:7jal
            text:""
        Label:
            id:8jal
            text:""
        Label:
            id:9jal
            text:""
        Label:
            id:10jal
            text:""
        Label:
            id:11jal
            text:""
        Label:
            id:12jal
            text:""
        Label:
            id:13jal
            text:""
        Label:
            id:14jal
            text:""
        Label:
            id:15jal
            text:""
        Label:
            text:""
    BoxLayout:
        orientation: "vertical"
        pos_hint: {"x":0,"y":-0.0015}
        size_hint: 0.9,0.89
        Label:
            id:16jal
            text:""
        Label:
            id:17jal
            text:""
        Label:
            id:18jal
            text:""
        Label:
            id:19jal
            text:""
        Label:
            id:20jal
            text:""
        Label:
            id:21jal
            text:""
        Label:
            id:22jal
            text:""
        Label:
            id:23jal
            text:""
        Label:
            id:24jal
            text:""
        Label:
            id:25jal
            text:""
        Label:
            id:26jal
            text:""
        Label:
            id:27jal
            text:""
        Label:
            id:28jal
            text:""
        Label:
            id:29jal
            text:""
        Label:
            id:30jal
            text:""
        Label:
            text:""
    BoxLayout:
        orientation: "vertical"
        pos_hint: {"x":0.32,"y":-0.0015}
        size_hint: 0.9,0.89
        Label:
            id:31jal
            text:""
        Label:
            text:""
        Label:
            text:""
        Label:
            text:""
        Label:
            text:""
        Label:
            text:""
        Label:
            text:""
        Label:
            text:""
        Label:
            text:""
        Label:
            text:""
        Label:
            text:""
        Label:
            text:""
        Label:
            text:""
        Label:
            text:""
        Label:
            text:""
        Label:
            text:""