【发布时间】:2018-07-24 12:50:49
【问题描述】:
我正在使用python-2.7 和 kivy。当我点击cross.png 然后日历打开。当我点击日历时,如何获得选定的日期?实际上我需要选择日期放入TextInput。谁能告诉我如何使它成为可能?
test.py
from kivy.app import App
from kivy.uix.boxlayout import BoxLayout
from KivyCalendar import DatePicker
from kivy.core.window import Window
Window.clearcolor = (0.5, 0.5, 0.5, 1)
class Calendar(BoxLayout):
def __init__(self):
super(Calendar, self).__init__()
def show_calendar(self):
datePicker = DatePicker()
datePicker.show_popup(1,.3)
class Test(App):
def build(self):
return Calendar()
if __name__ == '__main__':
Test().run()
test.kv
<Calendar>:
BoxLayout:
orientation: "vertical"
padding : 20, 20
size_hint_y: .5
Button:
on_press: root.show_calendar()
Image:
y: self.parent.y
center_x: self.parent.center_x
allow_stretch: True
source: 'cross.png'
TextInput:
text:""
<DatePicker>:
pHint: .3, .3
【问题讨论】:
标签: python python-2.7 kivy kivy-language