runeoptimizer_gui.py 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. #!/usr/bin/env python
  2. """
  3. This file is part of RuneOptimizer.
  4. RuneOptimizer is free software: you can redistribute it and/or modify it
  5. under the terms of the GNU General Public License as published by the Free
  6. Software Foundation, either version 3 of the License, or (at your option)
  7. any later version.
  8. RuneOptimizer is distributed in the hope that it will be useful, but WITHOUT
  9. ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  10. FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  11. more details.
  12. You should have received a copy of the GNU General Public License along with
  13. RuneOptimizer. If not, see <https://www.gnu.org/licenses/>.
  14. """
  15. import sqlite3
  16. import json
  17. import os
  18. import signal
  19. import pipes
  20. import appdirs
  21. import subprocess
  22. from types import SimpleNamespace
  23. from time import sleep
  24. import wx
  25. import wx.grid
  26. import wx.adv
  27. import data.data as data
  28. import runeoptimizer.runeoptimizer as runeoptimizer
  29. import values.values as values
  30. import database.database as database
  31. from gui.RuneOptimizerFrame import RuneOptimizerFrame
  32. # The path to the RuneOptimizer executable. Different in Windows.
  33. executable_path = \
  34. os.path.dirname(os.path.realpath(__file__)) + '/../runeoptimizer'
  35. if os.name == 'nt':
  36. executable_path = \
  37. os.path.dirname(os.path.realpath(__file__)) + '\\..\\runeoptimizer.exe'
  38. if __name__ == '__main__':
  39. """
  40. Main function.
  41. Conects to the database and shows the initial frame.
  42. """
  43. #Get CLI app version
  44. # TODO: Change executable name for windows
  45. #if os.name == 'nt':
  46. values.APP_INFO["app_version"] = subprocess.check_output(
  47. ['runeoptimizer', 'version']
  48. )
  49. # TODO: Test for executable to exist
  50. # TODO: Test for database to exist
  51. # Open the database
  52. print(appdirs.user_data_dir("RuneOptimizer", "", roaming=True))
  53. database.CONNECTION = sqlite3.connect(
  54. appdirs.user_data_dir("RuneOptimizer", "", roaming=True) + "/data.sqlite"
  55. )
  56. database.CONNECTION.isolation_level = None
  57. # This makes sure that the executable has connection to the database.
  58. runeoptimizer.run(["init"])
  59. data.reload_units()
  60. data.reload_teams()
  61. # Start the GUI
  62. app = wx.App()
  63. frm = RuneOptimizerFrame(
  64. parent=None, title='Rune Optimizer', pos=(100, 100), size=(1000, 650)
  65. )
  66. frm.Show()
  67. app.MainLoop()