Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/300.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中自动加载用户信息吗_Python_Save_Load_Kivy_Textinput - Fatal编程技术网

Python 你能在kivy中自动加载用户信息吗

Python 你能在kivy中自动加载用户信息吗,python,save,load,kivy,textinput,Python,Save,Load,Kivy,Textinput,我正在制作一个应用程序,其中有一个配置文件屏幕,您可以使用文本输入框输入通用配置文件信息(姓名、身高、体重等)。我知道有一种方法可以在每个文本输入框旁边放置一个按钮来保存信息,另一个按钮用来加载信息。我想知道是否有一种方法可以在用户打开应用程序时自动加载此信息,而不是通过点击按钮手动加载信息 <Phone>: result: _result h: _h w: _w AnchorLayout: anchor_x: 'center' anchor_y: 'top'

我正在制作一个应用程序,其中有一个配置文件屏幕,您可以使用文本输入框输入通用配置文件信息(姓名、身高、体重等)。我知道有一种方法可以在每个文本输入框旁边放置一个按钮来保存信息,另一个按钮用来加载信息。我想知道是否有一种方法可以在用户打开应用程序时自动加载此信息,而不是通过点击按钮手动加载信息

<Phone>:
result: _result
h: _h
w: _w


AnchorLayout:
    anchor_x: 'center'
    anchor_y: 'top'

    ScreenManager:
        size_hint: 1, .9
        id: _screen_manager
        Screen:
            name: 'home'
            canvas.before:
                Rectangle:
                    pos: self.pos
                    size: self.size
                    source: "/home/aaron/Desktop/main.png"
            Label:
                markup: True
                text: '[size=100][color=ff3333]Welcome to [color=ff3333]Diabetes Manager[/color][/size]'
        Screen:
            name: 'menu'
            GridLayout: 
                cols: 2
                padding: 50
                canvas.before:
                    Rectangle:
                        pos: self.pos
                        size: self.size
                        source: "/home/aaron/Desktop/main.png"

                Button:
                    text: 'My Profile'
                    on_press: _screen_manager.current = 'profile' 
                Button:
                    text: 'History'
                    on_press: _screen_manager.current = 'history'     

                Button:
                    text: 'New Entry'
                    on_press: _screen_manager.current = 'new_entry' 
                Button:
                    text: 'Graph'
                    on_press: _screen_manager.current = 'graph' 
                Button:
                    text: 'Diet'
                    on_press: _screen_manager.current = 'diet' 
                Button:
                    text: 'Settings'
                    on_press: _screen_manager.current = 'settings' 

        Screen:
            name: 'profile'
            GridLayout: 
                cols: 1
                BoxLayout:
                    Label:
                        size_hint_x: 0.22
                        bold: True
                        markup: True
                        text: '[size=40][color=0000ff]Name[/color][/size]'
                    TextInput:
                        id: _name
                        hint_text: 'Name'

                BoxLayout:
                    Label:  
                        size_hint_x: 0.22
                        bold: True
                        markup: True
                        text: '[size=40][color=0000ff]Gender[/color][/size]'
                    TextInput:
                        id: _gender1
                        hint_text: 'Gender'

                BoxLayout:
                    Label:
                        size_hint_x: 0.22
                        bold: True
                        markup: True
                        text: '[size=34][color=0000ff]Type of Diabetes[/color][/size]'
                    TextInput:
                        id: _type
                        hint_text: 'Type of Diabetes'

                BoxLayout:
                    Label:
                        size_hint_x: 0.22
                        bold: True
                        markup: True
                        text: '[size=40][color=0000ff]Height (in)[/color][/size]'
                    TextInput:
                        id: _h
                        hint_text: 'Height in inches'

                BoxLayout:
                    Label:
                        size_hint_x: 0.22
                        bold: True
                        markup: True
                        text: '[size=40][color=0000ff]Weight (lb)[/color][/size]'
                    TextInput:
                        id: _w
                        hint_text: 'Weight in pounds'

                BoxLayout:
                    Button:
                        text: 'Calculate BMI'
                        on_press: root.product(*args)

                    Label:
                        size_hint_x: 4.5
                        id:_result
                        bold: True
                        markup: True
                        text: '[size=40][color=0000ff]BMI[/color][/size]'

                BoxLayout:
                    Label:
                        size_hint_x: 0.22
                        bold: True
                        markup: True
                        text: '[size=30][color=0000ff]List of Medications[/color][/size]'
                    TextInput:
                        id: _meds
                        hint_text: 'List of Medications'

                BoxLayout:
                    Label:
                        size_hint_x: 0.22
                        bold: True
                        markup: True
                        text: '[size=38][color=0000ff]Insulin Times[/color][/size]'
                    TextInput:
                        id: _times
                        hint_text: 'Please Enter Times to Take Insulin'


        Screen:
            name: 'history'
            GridLayout: 
                cols:1

        Screen:
            name: 'new_entry'
            GridLayout:
                cols:1

                BoxLayout:
                    Label:
                        size_hint_x: 0.22
                        bold: True
                        markup: True
                        text: '[size=40][color=0000ff]Time[/color][/size]'
                    TextInput:
                        id: _time
                        hint_text: 'Current Time'

                BoxLayout:
                    Label:
                        size_hint_x: 0.22
                        bold: True
                        markup: True
                        text: '[size=28][color=0000ff]Blood Sugar (mg/dL)[/color][/size]'
                    TextInput:
                        id: _glucose_reading
                        hint_text: 'Current Blood Sugar'

                BoxLayout:
                    Label:
                        size_hint_x: 0.22
                        bold: True
                        markup: True
                        text: '[size=40][color=0000ff]Carbs[/color][/size]'
                    TextInput:
                        id: _food
                        hint_text: 'Total Carbs for meal'

                BoxLayout:
                    Label:
                        size_hint_x: 0.22
                        bold: True
                        markup: True
                        text: '[size=30][color=0000ff]Medications Taken[/color][/size]'
                    TextInput:
                        id: _meds_taken
                        hint_text: 'Please Enter Any Medications Taken'


        Screen:
            name: 'graph'
            GridLayout: 
                cols: 3
                padding: 50
            Label: 
                markup: True
                text: '[size=24][color=dd88ff]Your Graph[/color][/size]'

        Screen:
            name: 'diet'
            GridLayout: 
                cols: 3
                padding: 50
            Label: 
                markup: True
                text: '[size=24][color=dd88ff]Reccomended Diet[/color][/size]'


        Screen:
            name: 'settings'
            GridLayout: 
                cols: 3
                padding: 50
            Label: 
                markup: True
                text: '[size=24][color=dd88ff]Settings[/color][/size]'


AnchorLayout:
    anchor_x: 'center'
    anchor_y: 'bottom'
    BoxLayout:
        orientation: 'horizontal'
        size_hint: 1, .1
        Button:
            id: btnExit
            text: 'Exit'
            on_press: app.stop() 
        Button:
            text: 'Menu'
            on_press: _screen_manager.current = 'menu'
:
结果:\u结果
h:_h
w:_w
主持人安排:
主播:中锋
主播:托普
屏幕管理器:
尺寸提示:1.9
id:\u屏幕\u管理器
屏幕:
姓名:“家”
在以下情况之前:
矩形:
pos:self.pos
大小:self.size
来源:“/home/aron/Desktop/main.png”
标签:
标记:正确
文本:'[size=100][color=ff3333]欢迎来到[color=ff3333]糖尿病管理器[/color][/size]'
屏幕:
名称:“菜单”
网格布局:
科尔斯:2
填充:50
在以下情况之前:
矩形:
pos:self.pos
大小:self.size
来源:“/home/aron/Desktop/main.png”
按钮:
文本:“我的个人资料”
按以下按钮:\屏幕\管理器.current='配置文件'
按钮:
文字:“历史”
按以下按钮:\屏幕\管理器。当前='历史'
按钮:
文本:“新条目”
按以下按钮:\屏幕\管理器.current='新建\条目'
按钮:
文本:“图形”
按下时:\屏幕\管理器.current='图形'
按钮:
文字:“饮食”
按以下按钮:\屏幕\管理器.current='diet'
按钮:
文本:“设置”
按时:\屏幕\管理器.current='设置'
屏幕:
名称:“个人资料”
网格布局:
科尔斯:1
盒子布局:
标签:
尺寸:0.22
黑体字:对
标记:正确
文本:'[size=40][color=0000ff]名称[/color][/size]'
文本输入:
id:\u名称
提示文字:“名称”
盒子布局:
标签:
尺寸:0.22
黑体字:对
标记:正确
文本:'[size=40][color=0000ff]性别[/color][/size]'
文本输入:
id:_gender1
提示文字:“性别”
盒子布局:
标签:
尺寸:0.22
黑体字:对
标记:正确
文本:“[size=34][color=0000ff]糖尿病类型”
文本输入:
id:\u类型
提示文字:“糖尿病类型”
盒子布局:
标签:
尺寸:0.22
黑体字:对
标记:正确
文本:'[size=40][color=0000ff]高度(英寸)[/color][/size]'
文本输入:
id:_h
提示文字:“以英寸为单位的高度”
盒子布局:
标签:
尺寸:0.22
黑体字:对
标记:正确
文本:'[size=40][color=0000ff]重量(磅)[/color][/size]'
文本输入:
id:_w
提示文字:“以磅为单位的重量”
盒子布局:
按钮:
文本:“计算体重指数”
按:root.product(*args)
标签:
尺寸:4.5
id:\u结果
黑体字:对
标记:正确
文本:“[size=40][color=0000ff]BMI][color][/size]”
盒子布局:
标签:
尺寸:0.22
黑体字:对
标记:正确
文本:“[size=30][color=0000ff]药物列表[/color][/size]”
文本输入:
id:(美国)
提示文字:“药物列表”
盒子布局:
标签:
尺寸:0.22
黑体字:对
标记:正确
文本:“[size=38][color=0000ff]胰岛素倍”
文本输入:
id:_次
提示文字:“请输入服用胰岛素的时间”
屏幕:
名称:“历史”
网格布局:
科尔斯:1
屏幕:
名称:'new_entry'
网格布局:
科尔斯:1
盒子布局:
标签:
尺寸:0.22
黑体字:对
标记:正确
文本:'[size=40][color=0000ff]时间[/color][/size]'
文本输入:
id:_时间
提示文字:“当前时间”
盒子布局:
标签:
尺寸:0.22
黑体字:对
标记:正确
文本:'[size=28][color=0000ff]Blood Suga
class TestApp(App):
    def build_config(self, config):
        config.setdefaults('section1', {
            'key1': 'value1',
            'key2': '42'
        })

    def build(self):
        config = self.config
        return Label(text='key1 is %s and key2 is %d' % (
            config.get('section1', 'key1'),
            config.getint('section1', 'key2')))