You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

84 lines
1.7 KiB

10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
  1. #!/usr/bin/env python2
  2. # -*- coding: utf-8 -*-
  3. """Youtubedlg __init__ file.
  4. Responsible on how the package looks from the outside.
  5. Example:
  6. In order to load the GUI from a python script.
  7. import youtube_dl_gui
  8. youtube_dl_gui.main()
  9. """
  10. from __future__ import unicode_literals
  11. import sys
  12. import gettext
  13. try:
  14. import wx
  15. except ImportError as error:
  16. print error
  17. sys.exit(1)
  18. __packagename__ = "youtube_dl_gui"
  19. # For package use
  20. from .version import __version__
  21. from .info import (
  22. __author__,
  23. __appname__,
  24. __contact__,
  25. __license__,
  26. __projecturl__,
  27. __licensefull__,
  28. __description__,
  29. __descriptionfull__,
  30. )
  31. gettext.install(__packagename__)
  32. from .formats import reload_strings
  33. from .logmanager import LogManager
  34. from .optionsmanager import OptionsManager
  35. from .utils import (
  36. get_config_path,
  37. get_locale_file
  38. )
  39. # Set config path and create options and log managers
  40. config_path = get_config_path()
  41. opt_manager = OptionsManager(config_path)
  42. log_manager = None
  43. if opt_manager.options['enable_log']:
  44. log_manager = LogManager(config_path, opt_manager.options['log_time'])
  45. # Set gettext before MainFrame import
  46. # because the GUI strings are class level attributes
  47. locale_dir = get_locale_file()
  48. try:
  49. gettext.translation(__packagename__, locale_dir, [opt_manager.options['locale_name']]).install(unicode=True)
  50. except IOError:
  51. opt_manager.options['locale_name'] = 'en_US'
  52. gettext.install(__packagename__)
  53. reload_strings()
  54. from .mainframe import MainFrame
  55. def main():
  56. """The real main. Creates and calls the main app windows. """
  57. app = wx.App()
  58. frame = MainFrame(opt_manager, log_manager)
  59. frame.Show()
  60. app.MainLoop()