home *** CD-ROM | disk | FTP | other *** search
/ Freelog 116 / FreelogNo116-JuilletSeptembre2013.iso / GestionFichiers / metamorphose / metamorphose2_0.8.2_setup.exe / metamorphose2.exe / preferences / dialog.pyo (.txt) < prev    next >
Python Compiled Bytecode  |  2011-01-12  |  7KB  |  153 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyo (Python 2.6)
  3.  
  4. from __future__ import print_function
  5. import logging
  6. import automation
  7. import colors
  8. import display
  9. import errorCheck
  10. import general
  11. import app
  12. import utils
  13. import wx
  14.  
  15. class Notebook(wx.Toolbook):
  16.     
  17.     def __init__(self, parent, id, name):
  18.         wx.Toolbook.__init__(self, parent, id, name = name, style = wx.BK_TOP)
  19.         il = wx.ImageList(22, 22)
  20.         imgGeneral = il.Add(wx.Bitmap(utils.icon_path(u'22/general.png'), wx.BITMAP_TYPE_PNG))
  21.         imgDisplay = il.Add(wx.Bitmap(utils.icon_path(u'22/display.png'), wx.BITMAP_TYPE_PNG))
  22.         imgColors = il.Add(wx.Bitmap(utils.icon_path(u'22/colors.png'), wx.BITMAP_TYPE_PNG))
  23.         imgAuto = il.Add(wx.Bitmap(utils.icon_path(u'22/auto.png'), wx.BITMAP_TYPE_PNG))
  24.         imgLog = il.Add(wx.Bitmap(utils.icon_path(u'22/log.png'), wx.BITMAP_TYPE_PNG))
  25.         imgError = il.Add(wx.Bitmap(utils.icon_path(u'22/error.png'), wx.BITMAP_TYPE_PNG))
  26.         self.AssignImageList(il)
  27.         panels = ((general, _(u'General'), imgGeneral), (display, _(u'Display'), imgDisplay), (colors, _(u'Colors'), imgColors), (automation, _(u'Automate'), imgAuto), (logging, _(u'Logging'), imgLog), (errorCheck, _(u'Error Checks'), imgError))
  28.         i = 0
  29.         for pane in panels:
  30.             page = getattr(pane[0], 'Panel')
  31.             page = page(self)
  32.             self.AddPage(page, pane[1], imageId = pane[2])
  33.             notebookPage = self.GetPage(i)
  34.             if not parent.initial:
  35.                 parent.load_prefs(notebookPage)
  36.             
  37.             if hasattr(notebookPage, 'init_enabled'):
  38.                 notebookPage.init_enabled()
  39.             
  40.             i += 1
  41.         
  42.  
  43.  
  44.  
  45. class Dialog(wx.Dialog):
  46.     
  47.     def __init_mainsizer_items(self, parent):
  48.         parent.AddWindow(self.notebook, 1, border = 5, flag = wx.ALL | wx.EXPAND)
  49.         parent.AddSizer(self.buttons, 0, border = 5, flag = wx.ALL | wx.EXPAND)
  50.  
  51.     
  52.     def __init_buttons_items(self, parent):
  53.         parent.AddSpacer((110, -1), 0, border = 0, flag = 0)
  54.         parent.AddWindow(self.apply, 0, border = 25, flag = wx.RIGHT)
  55.         parent.AddWindow(self.ok, 0, border = 108, flag = wx.RIGHT)
  56.         parent.AddSpacer((10, -1), 1, border = 0, flag = 0)
  57.         parent.AddWindow(self.close, 0, border = 0, flag = 0)
  58.  
  59.     
  60.     def __init_sizers(self):
  61.         self.mainSizer = wx.BoxSizer(orient = wx.VERTICAL)
  62.         self.buttons = wx.BoxSizer(orient = wx.HORIZONTAL)
  63.         self._Dialog__init_mainsizer_items(self.mainSizer)
  64.         self._Dialog__init_buttons_items(self.buttons)
  65.         utils.set_min_size(self, ignoreClasses = (wx.TextCtrl, wx.Button, wx.Choice, wx.SpinCtrl, wx.FilePickerCtrl, wx.DirPickerCtrl, wx.ColourPickerCtrl))
  66.         self.SetSizerAndFit(self.mainSizer)
  67.  
  68.     
  69.     def __init_ctrls(self, parent):
  70.         wx.Dialog.__init__(self, name = u'dialog', parent = parent, style = wx.CAPTION, title = u'Preferences')
  71.         self.SetIcon(wx.Icon(utils.icon_path(u'preferences.ico'), wx.BITMAP_TYPE_ICO))
  72.         self.notebook = Notebook(id = -1, name = u'notebook', parent = self)
  73.         self.apply = wx.Button(id = wx.ID_APPLY, name = u'apply', parent = self, style = 0)
  74.         self.apply.Bind(wx.EVT_BUTTON, self._Dialog__on_apply_button)
  75.         self.ok = wx.Button(id = wx.ID_OK, name = u'ok', parent = self, style = 0)
  76.         self.ok.Bind(wx.EVT_BUTTON, self._Dialog__on_ok_button)
  77.         self.close = wx.Button(id = wx.ID_CANCEL, name = u'close', parent = self, style = 0)
  78.         self.close.Bind(wx.EVT_BUTTON, self._Dialog__close_diag)
  79.         self._Dialog__init_sizers()
  80.  
  81.     
  82.     def __init__(self, parent, prefs, initial):
  83.         global main
  84.         main = parent
  85.         self.initial = initial
  86.         self.prefs = prefs
  87.         self._Dialog__init_ctrls(parent)
  88.         if initial:
  89.             self.close.Enable(False)
  90.             self.apply.Enable(False)
  91.         
  92.         self.CentreOnScreen()
  93.         if not initial:
  94.             self.oldDirTree = self.prefs.get(u'useDirTree')
  95.             self.oldSHowHiddenDirs = self.prefs.get(u'showHiddenDirs')
  96.         
  97.  
  98.     
  99.     def __on_apply_button(self, event):
  100.         self.prefs.set_prefs(self)
  101.         prefs = app.prefs = self.prefs
  102.         if not self.initial:
  103.             if prefs.get(u'useDirTree') != self.oldDirTree:
  104.                 main.picker.set_tree()
  105.             
  106.             if prefs.get(u'showHiddenDirs') != self.oldSHowHiddenDirs:
  107.                 main.picker.dirPicker.ShowHidden(prefs.get(u'showHiddenDirs'))
  108.             
  109.             self.oldDirTree = prefs.get(u'useDirTree')
  110.             self.oldSHowHiddenDirs = prefs.get(u'showHiddenDirs')
  111.             main.bottomWindow.display.set_preferences()
  112.             main.show_preview(True)
  113.         
  114.  
  115.     
  116.     def load_prefs(self, panel):
  117.         app.debug_print('Loading %s preferences ...' % panel.GetName())
  118.         for child in panel.GetChildren():
  119.             
  120.             try:
  121.                 v = self.prefs.get(child.GetName(), False)
  122.             except KeyError:
  123.                 continue
  124.  
  125.             app.debug_print('   %s = %s' % (child.GetName(), v))
  126.             if isinstance(child, wx.CheckBox) and isinstance(child, wx.RadioButton) or isinstance(child, wx.SpinCtrl):
  127.                 child.SetValue(v)
  128.                 continue
  129.             if isinstance(child, wx.ComboBox) or isinstance(child, wx.TextCtrl):
  130.                 child.SetValue(unicode(v))
  131.                 continue
  132.             if isinstance(child, wx.Choice):
  133.                 child.SetSelection(v)
  134.                 continue
  135.             if isinstance(child, wx.DirPickerCtrl) or isinstance(child, wx.FilePickerCtrl):
  136.                 child.SetPath(unicode(v))
  137.                 continue
  138.             if isinstance(child, wx.ColourPickerCtrl):
  139.                 child.SetColour(v)
  140.                 continue
  141.         
  142.  
  143.     
  144.     def __close_diag(self, event):
  145.         self.Close()
  146.  
  147.     
  148.     def __on_ok_button(self, event):
  149.         self._Dialog__on_apply_button(event)
  150.         self.Close()
  151.  
  152.  
  153.