main.py 1.0 KB

1234567891011121314151617181920212223242526272829303132
  1. import os
  2. from easygui import enterbox
  3. import sys
  4. from easygui.boxes.derived_boxes import msgbox
  5. from images import get_verse_image
  6. from parser import get_full_verse
  7. msg ="Введите номер стиха. Например sb 1.1.1 или bg 1.1"
  8. title = "Ввод стиха"
  9. while True:
  10. try: # читаем последний веденный стих
  11. with open("lastverse", "r") as f:
  12. last_verse = f.read()
  13. except Exception:
  14. last_verse = "bg 4.34"
  15. verse = enterbox(msg, title, last_verse)
  16. if verse is None:
  17. sys.exit(0)
  18. verses_data = get_full_verse(verse)
  19. if 'error' not in verses_data:
  20. f_img = ''
  21. for i, v in enumerate(verses_data['verses']):
  22. image = get_verse_image(v)
  23. if i == 0:
  24. f_img = image
  25. os.system(f"eom {f_img}") # для открытия картинки используем програму eom (eye of mate).
  26. else:
  27. msgbox(title="Ошибка", msg=verses_data['error'])