/usr/share/pyshared/wxglade/configdialog.py is in python-wxglade 0.6.8-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 | """
Dialog for editing wxGlade preferences
@see: L{config.preferences}
@copyright: 2007 Alberto Griggio
@license: MIT (see license.txt) - THIS PROGRAM COMES WITH NO WARRANTY
"""
# import general python modules
import os
import wx
import misc
from configUI import wxGladePreferencesUI
class wxGladePreferences(wxGladePreferencesUI):
def __init__(self, preferences):
wxGladePreferencesUI.__init__(self, None, -1, "")
wx.EVT_BUTTON(self, self.choose_widget_path.GetId(),
self.on_widget_path)
self.preferences = preferences
self.set_values()
# disable CheckBox for selecting usage of KDE file dialogs
if wx.Platform != '__WXGTK__':
self.use_kde_dialogs.SetValue(False)
self.use_kde_dialogs.Enable(False)
def set_values(self):
try:
self.use_menu_icons.SetValue(self.preferences.use_menu_icons)
self.frame_tool_win.SetValue(self.preferences.frame_tool_win)
self.open_save_path.SetValue(self.preferences.open_save_path)
self.codegen_path.SetValue(self.preferences.codegen_path)
self.use_dialog_units.SetValue(
self.preferences.use_dialog_units)
self.number_history.SetValue(self.preferences.number_history)
self.show_progress.SetValue(self.preferences.show_progress)
self.wxg_backup.SetValue(self.preferences.wxg_backup)
self.codegen_backup.SetValue(self.preferences.codegen_backup)
self.default_border.SetValue(self.preferences.default_border)
self.default_border_size.SetValue(
self.preferences.default_border_size)
if self.preferences.backup_suffix == '.bak':
self.backup_suffix.SetSelection(1)
self.buttons_per_row.SetValue(self.preferences.buttons_per_row)
self.remember_geometry.SetValue(
self.preferences.remember_geometry)
self.local_widget_path.SetValue(
self.preferences.local_widget_path)
self.show_sizer_handle.SetValue(
self.preferences.show_sizer_handle)
self.allow_duplicate_names.SetValue(
self.preferences.allow_duplicate_names)
self.autosave.SetValue(self.preferences.autosave)
self.autosave_delay.SetValue(self.preferences.autosave_delay)
self.use_kde_dialogs.SetValue(self.preferences.use_kde_dialogs)
self.show_completion.SetValue(self.preferences.show_completion)
self.write_timestamp.SetValue(self.preferences.write_timestamp)
self.write_generated_from.SetValue(
self.preferences.write_generated_from)
self._fix_spin_ctrls()
except Exception, e:
wx.MessageBox(
_('Error reading config file:\n%s') % e,
_('Error'),
wx.OK | wx.CENTRE | wx.ICON_ERROR
)
def _fix_spin_ctrls(self):
"""\
Workaround to a wxGTK 2.8.4.2 bug in wx.SpinCtrl.GetValue
"""
done = {}
for name in ('buttons_per_row', 'autosave_delay', 'number_history',
'default_border_size'):
def fix(n):
done[n] = False
def update(e):
done[n] = True
e.Skip()
def get_val():
if not done[n]:
return getattr(self.preferences, n)
else:
return wx.SpinCtrl.GetValue(getattr(self, n))
return update, get_val
spin = getattr(self, name)
if spin.GetValue() != getattr(self.preferences, name):
update, get_val = fix(name)
spin.GetValue = get_val
spin.Bind(wx.EVT_SPINCTRL, update)
def set_preferences(self):
prefs = self.preferences
prefs['use_menu_icons'] = self.use_menu_icons.GetValue()
prefs['frame_tool_win'] = self.frame_tool_win.GetValue()
prefs['open_save_path'] = self.open_save_path.GetValue()
prefs['codegen_path'] = self.codegen_path.GetValue()
prefs['use_dialog_units'] = self.use_dialog_units.GetValue()
prefs['number_history'] = self.number_history.GetValue()
prefs['show_progress'] = self.show_progress.GetValue()
prefs['wxg_backup'] = self.wxg_backup.GetValue()
prefs['codegen_backup'] = self.codegen_backup.GetValue()
prefs['default_border'] = self.default_border.GetValue()
prefs['default_border_size'] = self.default_border_size.GetValue()
if self.backup_suffix.GetSelection():
prefs['backup_suffix'] = '.bak'
else:
prefs['backup_suffix'] = '~'
prefs['buttons_per_row'] = self.buttons_per_row.GetValue()
prefs['remember_geometry'] = self.remember_geometry.GetValue()
prefs['local_widget_path'] = self.local_widget_path.GetValue()
prefs['show_sizer_handle'] = self.show_sizer_handle.GetValue()
prefs['allow_duplicate_names'] = \
self.allow_duplicate_names.GetValue()
prefs['autosave'] = self.autosave.GetValue()
prefs['autosave_delay'] = self.autosave_delay.GetValue()
prefs['use_kde_dialogs'] = self.use_kde_dialogs.GetValue()
prefs['show_completion'] = self.show_completion.GetValue()
prefs['write_timestamp'] = self.write_timestamp.GetValue()
prefs['write_generated_from'] = self.write_generated_from.GetValue()
def on_widget_path(self, event):
"""\
Create a file choice dialog
"""
pth = misc.DirSelector(_("Choose a directory:"), os.getcwd(),
style=wx.DD_DEFAULT_STYLE |
wx.DD_NEW_DIR_BUTTON)
if pth:
self.local_widget_path.SetValue(pth)
# end of class wxGladePreferences
|