Как вы можете сказать, мне нужно многому научиться.Я, кажется, не зацикливаюсь, поэтому эта проблема очень похожа на мою последнюю, которую я только что опубликовал.Я хочу, чтобы щелчок моей кнопки уведомлял меня, что он уже был нажат, но я получаю две ошибки.KeyError: 'calendar_butt'
и AttributeError: 'super' object has no attribute '__getattr__'
.Я хотел бы, чтобы функция CalendarButt использовалась при каждом открытии всплывающего окна и нажатии кнопки set_event
Main .py File
from kivy.config import Config
Config.set('graphics', 'resizable', False)
Config.set('graphics', 'width', '800')
Config.set('graphics', 'height', '600')
from datetime import datetime, date, time, timedelta
from kivy.app import App
from kivy.clock import Clock
from kivy.uix.screenmanager import Screen, ScreenManager, NoTransition
from kivy.uix.button import ButtonBehavior, Button
from kivy.uix.popup import Popup
class CalendarButt(Button):
def button_clicked(self):
if self.ids.calendar_butt.state == 'down':
print('Hello')
class ScheduledPopup(Popup):
pass
class ButtonPopup(Popup):
def schedule_event(self, *args):
if self.ids.set_event.state == 'down':
CalendarButt(text=self.ids.scheduled_event.text)
print(self.ids.scheduled_event.text)
class CalendarLayout(Screen):
pass
class January(Screen):
pass
class ManageScreens(ScreenManager):
pass
class Calendar(App):
def build(self):
return ManageScreens()
if __name__ == '__main__':
Calendar().run()
Основной файл KV
#: import main calendar
#: import NoTransition kivy.uix.screenmanager.NoTransition
#:import Factory kivy.factory.Factory
#: include january.kv
<ScheduledPopup@Popup>:
title: 'Event Scheduled'
id: scheduled_popup
BoxLayout:
Label:
text: 'Event Scheduled.'
Button:
text: 'Close.'
on_release: root.dismiss()
<ButtonPopup>:
title: 'Set Events'
title_align: 'center'
auto_dismiss: False
size_hint: None, None
size: 400, 200
GridLayout:
cols: 1
TextInput:
multiline: True
id: scheduled_event
hint_text: "Something scheduled for this day..."
BoxLayout:
Button:
id: set_event
text: "Schedule"
on_press: root.schedule_event()
on_release: root.dismiss()
Button:
id: cancel
text: "Cancel"
on_release: root.dismiss()
<CustButton@Button>:
size: 1, 1
<CalendarButt>:
on_press: root.button_clicked()
background_color: 12, 12, 12, 0.1
font_name: 'Roboto-Thin'
font_size: 20
background_down: 'background_pressed.png'
on_release: Factory.ButtonPopup().open()
Январь.kv
<ManageScreens>:
transition: NoTransition()
January:
name: 'january'
id: january
canvas.before:
Color:
rgba: 0, 0, 0, 1
Rectangle:
size: self.size
pos: self.pos
RelativeLayout:
Label:
text: "January"
font_size: 20
pos_hint: {'center_x': 0.5, 'center_y': 0.88}
GridLayout:
pos_hint: {'top': 0.85}
row_default_height: 75
row_force_default: True
cols: 7
rows: 5
spacing: 10
padding: 10
CalendarButt:
text: ''
CalendarButt:
text: ''
CalendarButt:
text: '1'
CalendarButt:
text: '2'