/pyfpdb/HUD_run_me.py

https://github.com/forrestdg/fpdb
Python | 69 lines | 38 code | 14 blank | 17 comment | 2 complexity | 7090eb52661debfb6e7c053d45ee034e MD5 | raw file
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. #Copyright 2009-2011 Eric Blade
  4. #This program is free software: you can redistribute it and/or modify
  5. #it under the terms of the GNU Affero General Public License as published by
  6. #the Free Software Foundation, version 3 of the License.
  7. #
  8. #This program is distributed in the hope that it will be useful,
  9. #but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. #GNU General Public License for more details.
  12. #
  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. #In the "official" distribution you can find the license in agpl-3.0.txt.
  16. import sys
  17. import os
  18. import thread
  19. import time
  20. import string
  21. import re
  22. errorfile = open('HUD-error.txt', 'w', 0)
  23. sys.stderr = errorfile
  24. # pyGTK modules
  25. import pygtk
  26. import gtk
  27. import gobject
  28. # FreePokerTools modules
  29. import Configuration
  30. import Database
  31. import Tables
  32. import Hud
  33. import HUD_main
  34. def destroy(*args): # call back for terminating the main eventloop
  35. gtk.main_quit()
  36. if __name__== "__main__":
  37. sys.stderr.write(_("HUD_main starting"))
  38. try:
  39. HUD_main.db_name = sys.argv[1]
  40. except:
  41. HUD_main.db_name = 'fpdb'
  42. sys.stderr.write(_("Using db name = %s") % (HUD_main.db_name))
  43. HUD_main.config = Configuration.Config()
  44. gobject.threads_init() # this is required
  45. hud = HUD_main.HUD_main()
  46. thread.start_new_thread(hud.read_stdin, ()) # starts the thread
  47. HUD_main.main_window = gtk.Window()
  48. HUD_main.main_window.connect("destroy", destroy)
  49. HUD_main.eb = gtk.VBox()
  50. label = gtk.Label(_('Closing this window will exit from the HUD.'))
  51. HUD_main.eb.add(label)
  52. HUD_main.main_window.add(HUD_main.eb)
  53. HUD_main.main_window.set_title(_("HUD Main Window"))
  54. HUD_main.main_window.show_all()
  55. gtk.main()