0
朝の「Good Morning」、午後「Good Afternoon」、夕方「Good Evening」というKivyのボタンに表示されるバナーを作成しようとしています。 。私はこれを解決するのに苦労している。これまでのところ、これは私が私のコードのために持っているものです。Kivyのタイミングバナー挨拶
の.pyファイルで:.kvファイルで
class Personal_Assistant(BoxLayout):
time_stamp = 0
morning = 'Good Morning'
afternoon = 'Good Afternoon'
evening = 'Good even'
name = 'James'
def timer(self):
self.now = datetime.datetime.now()
if self.now > 5 and self.now <12:
return self.morning, 'James'
elif self.now > 12 and self.now < 5:
return self.afternoon, 'James'
elif self.now > 5 and self.now < 12:
return self.evening, 'James'
:
BoxLayout:
orientation: 'vertical'
padding: 20
spacing: 40
Button:
text: root.timer()
color: (255, 255, 255, 255)
text_size: self.size
font_size: 40
halign: 'center'
valign: 'middle'
background_color: (0, 0, 255, 0.6)
現在の時間を時間単位で取得する方法がわかりませんが、if文を使用して試してみましたが、 nd on the – Ajax1234