/src/galleryforge/gui/guimain.py

https://github.com/numerodix/galleryforge · Python · 113 lines · 78 code · 24 blank · 11 comment · 5 complexity · 00f943fb2dcebc2a6999addb6e39f415 MD5 · raw file

  1. #!/usr/bin/python
  2. """
  3. Author: Martin Matusiak <numerodix@gmail.com>
  4. Program: Creates static HTML album pages and images pages recursively
  5. Date: Dec. 19, 2005
  6. This file is subject to the GNU General Public License (GPL)
  7. (http://www.gnu.org/copyleft/gpl.html)
  8. """
  9. import sys, inspect
  10. sys.path.append("..")
  11. import wx, glade_guimain
  12. import launch
  13. from config import config
  14. class GuiMainWindow(glade_guimain.MainFrame):
  15. def onStartBtn(self, event):
  16. self.onSaveSettingsBtn(event)
  17. basepath = self.gallery_path.GetValue()
  18. if basepath == None or basepath == "":
  19. wx.MessageDialog(self,
  20. "No gallery path given, cannot proceed without one.",
  21. "",
  22. wx.OK
  23. ).ShowModal()
  24. else:
  25. # self.exitBtn.Enable(enable=False)
  26. launch.main(basepath=basepath)
  27. # self.exitBtn.Enable()
  28. def onExitBtn(self, event):
  29. sys.exit(0)
  30. def onFileSelectorBtn(self, event):
  31. dlg = wx.DirDialog(self,
  32. defaultPath=self.gallery_path.GetValue()
  33. )
  34. if dlg.ShowModal():
  35. self.gallery_path.SetValue(dlg.GetPath())
  36. def initForms(self):
  37. settings = config.read()
  38. self.image_size_x.SetValue(int(settings['image_size_x']))
  39. self.image_size_y.SetValue(int(settings['image_size_y']))
  40. self.thumbnail_size_x.SetValue(int(settings['thumbnail_size_x']))
  41. self.thumbnail_size_y.SetValue(int(settings['thumbnail_size_y']))
  42. self.image_quality.SetValue(int(settings['image_quality']))
  43. self.thumbnail_quality.SetValue(int(settings['thumbnail_quality']))
  44. self.album_cols.SetValue(int(settings['album_cols']))
  45. self.album_rows.SetValue(int(settings['album_rows']))
  46. self.gallery_path.SetValue(settings['gallery_path'])
  47. self.image_extensions.SetValue(settings['image_extensions'])
  48. self.thumbnail_suffix.SetValue(settings['thumbnail_suffix'])
  49. self.tmp_first.SetValue(settings['tmp_first'])
  50. self.tmp_prev.SetValue(settings['tmp_prev'])
  51. self.tmp_index.SetValue(settings['tmp_index'])
  52. self.tmp_next.SetValue(settings['tmp_next'])
  53. self.tmp_last.SetValue(settings['tmp_last'])
  54. self.rebuild_thumbnails.SetValue(settings['rebuild_thumbnails'])
  55. def onSaveSettingsBtn(self, event):
  56. settings = {
  57. "image_size_x": self.image_size_x.GetValue(),
  58. "image_size_y": self.image_size_y.GetValue(),
  59. "thumbnail_size_x": self.thumbnail_size_x.GetValue(),
  60. "thumbnail_size_y": self.thumbnail_size_y.GetValue(),
  61. "image_quality": self.image_quality.GetValue(),
  62. "thumbnail_quality": self.thumbnail_quality.GetValue(),
  63. "album_cols": self.album_cols.GetValue(),
  64. "album_rows": self.album_rows.GetValue(),
  65. "gallery_path": self.gallery_path.GetValue(),
  66. "image_extensions": self.image_extensions.GetValue(),
  67. "thumbnail_suffix": self.thumbnail_suffix.GetValue(),
  68. "tmp_first": self.tmp_first.GetValue(),
  69. "tmp_prev": self.tmp_prev.GetValue(),
  70. "tmp_index": self.tmp_index.GetValue(),
  71. "tmp_next": self.tmp_next.GetValue(),
  72. "tmp_last": self.tmp_last.GetValue(),
  73. "rebuild_thumbnails": self.rebuild_thumbnails.GetValue(),
  74. }
  75. config.store(settings)
  76. class GuiApp(wx.App):
  77. def OnInit(self):
  78. wx.InitAllImageHandlers()
  79. frame = GuiMainWindow(None, -1, "")
  80. self.SetTopWindow(frame)
  81. frame.initForms()
  82. frame.Show()
  83. return 1
  84. def main():
  85. g = GuiApp(0)
  86. g.MainLoop()
  87. if __name__ == "__main__":
  88. main()