anontwigtk.py 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. #!/usr/bin/python
  2. # -*- coding: utf8 -*-
  3. """
  4. Copyright (C) 2012 Jhonny5 <jhonny5@riseup.net>
  5. This program is free software: you can redistribute it and/or modify
  6. it under the terms of the GNU Affero General Public License as published by
  7. the Free Software Foundation, either version 3 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU Affero General Public License for more details.
  13. You should have received a copy of the GNU Affero General Public License
  14. along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. """
  16. #import os, sys
  17. #import shutil #for remove directory tree
  18. import logging
  19. #from optparse import OptionParser
  20. from core.gtk.main import GuiWelcome, GuiUtils, GuiStarter
  21. from core.wrapper import WrapperAnontwi
  22. from core.gtk.config_gtk import *
  23. """
  24. for windows:
  25. if sys.platform == 'win32':
  26. os.environ['PATH'] += ";lib;"
  27. else:
  28. """
  29. #gtk libraries import
  30. try:
  31. import pygtk
  32. pygtk.require("2.0")
  33. except:
  34. print ("PyGkt not found.")
  35. try:
  36. import gtk, gtk.glade
  37. except:
  38. print ("Gkt / Glade not found")
  39. #sys.exit(1)
  40. #print ("Gtk / GLade found.")
  41. #LOG_LEVEL = logging.DEBUG
  42. LOG_LEVEL = logging.INFO
  43. class AnontwiGTK():
  44. @staticmethod
  45. def run():
  46. logging.basicConfig(level=LOG_LEVEL)
  47. logging.debug('Running Program')
  48. log = logging.getLogger('GTK')
  49. wrapper = WrapperAnontwi()
  50. # is first time that program runs ? show assistant : run MainWindow
  51. if not wrapper.get_consumer_tokens() \
  52. or not wrapper.get_access_tokens():
  53. log.debug('Running Assistant')
  54. GuiWelcome()
  55. gtk.main()
  56. log.debug('Running Starter GUI')
  57. GuiStarter()
  58. gtk.main()