main.py 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. import section_profile_editor
  2. import section_play_melody
  3. import section_calendar
  4. from widgets import *
  5. import settings
  6. import notifier
  7. import sys
  8. def create_settings_widget() -> QWidget:
  9. frame = SectionFrame()
  10. QVBoxLayout(frame)
  11. return frame
  12. def create_timetable_widget() -> QWidget:
  13. global style
  14. frame = SectionFrame()
  15. layout = QVBoxLayout(frame)
  16. section_profile_editor.initialize(layout, style)
  17. return frame
  18. def create_base_layout() -> QHBoxLayout:
  19. global style
  20. timetable_widget = create_timetable_widget()
  21. calendar_section = section_calendar.create()
  22. settings_section = create_settings_widget()
  23. immediate_section = section_play_melody.create(style)
  24. bottom_layout = QHBoxLayout()
  25. bottom_layout.addWidget(immediate_section, 1)
  26. bottom_layout.addWidget(settings_section, 1)
  27. left_section = QVBoxLayout()
  28. left_section.addWidget(calendar_section)
  29. left_section.addLayout(bottom_layout)
  30. base_layout = QHBoxLayout()
  31. base_layout.addLayout(left_section, 2)
  32. base_layout.addWidget(timetable_widget, 1)
  33. return base_layout
  34. def initialize_app() -> None:
  35. global application, window, style
  36. application = QApplication(sys.argv)
  37. window = QWidget()
  38. style = window.style()
  39. settings.load_settings()
  40. base_layout = create_base_layout()
  41. window.setLayout(base_layout)
  42. window.resize(1920 // 2, 1080 // 2)
  43. rectangle = window.frameGeometry()
  44. center = application.primaryScreen().availableGeometry().center()
  45. rectangle.moveCenter(center)
  46. window.move(rectangle.topLeft())
  47. window.show()
  48. window.setWindowTitle('Звонилка')
  49. window.setWindowIcon(QIcon('icons/icon.png'))
  50. notifier.restart()
  51. application.exec()
  52. notifier.stop()
  53. if __name__ == '__main__':
  54. sys.exit(initialize_app())