/usr/share/pyshared/pyface/xrc_dialog.py is in python-pyface 4.1.0-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 | #-----------------------------------------------------------------------------
#
# Copyright (c) 2005, Enthought, Inc.
# All rights reserved.
#
# Author: Scott Swarts <swarts@enthought.com>
#
#-----------------------------------------------------------------------------
"""A dialog that is loaded from an XRC resource file.
"""
from __future__ import absolute_import
# Standard library imports.
import os.path
# Major packages.
import wx
import wx.xrc
# Enthought library imports
from traits.api import Instance, Str
import traits.util.resource
# Local imports.
from .dialog import Dialog
##############################################################################
# class 'XrcDialog'
##############################################################################
class XrcDialog(Dialog):
"""A dialog that is loaded from an XRC resource file.
"""
##########################################################################
# Traits
##########################################################################
### 'XrcDialog' interface ############################################
# Path to the xrc file relative to the class's module
xrc_file = Str
# The ID of the dialog in the file
id = Str("dialog")
# The resource object
resource = Instance(wx.xrc.XmlResource)
##########################################################################
# 'Dialog' interface
##########################################################################
def _create_control(self, parent):
"""
Creates the dialog and loads it in from the resource file.
"""
classpath = traits.util.resource.get_path( self )
path = os.path.join( classpath, self.xrc_file )
self.resource = wx.xrc.XmlResource( path )
return self.resource.LoadDialog(parent, self.id)
def _create_contents(self, dialog):
"""
Calls add_handlers. The actual content is created
in _create_control by loading a resource file.
"""
# Wire up the standard buttons
# We change the ID on OK and CANCEL to the standard ids
# so we get the default behavior
okbutton = self.XRCCTRL("OK")
if okbutton is not None:
# Change the ID and set the handler
okbutton.SetId(wx.ID_OK)
wx.EVT_BUTTON(self.control, okbutton.GetId(), self._on_ok)
cancelbutton = self.XRCCTRL("CANCEL")
if cancelbutton is not None:
# Change the ID and set the handler
cancelbutton.SetId(wx.ID_CANCEL)
wx.EVT_BUTTON(self.control, cancelbutton.GetId(), self._on_cancel)
helpbutton = self.XRCCTRL("HELP")
if helpbutton is not None:
wx.EVT_BUTTON(self.control, helpbutton.GetId(), self._on_help)
self._add_handlers()
##########################################################################
# 'XrcDialog' interface
##########################################################################
def XRCID(self, name):
"""
Returns the numeric widget id for the given name.
"""
return wx.xrc.XRCID(name)
def XRCCTRL(self, name):
"""
Returns the control with the given name.
"""
return self.control.FindWindowById(self.XRCID(name))
def set_validator(self, name, validator):
"""
Sets the validator on the named control.
"""
self.XRCCTRL(name).SetValidator(validator)
##########################################################################
# 'XrcDialog' protected interface
##########################################################################
def _add_handlers(self):
"""
Override to add event handlers.
"""
return
#### EOF ######################################################################
|