1.1 --- a/XSLForms/Resources/PyQtResources.py Wed Oct 26 00:07:09 2005 +0000
1.2 +++ b/XSLForms/Resources/PyQtResources.py Wed Oct 26 00:37:36 2005 +0000
1.3 @@ -1,42 +1,44 @@
1.4 #!/usr/bin/env python
1.5
1.6 +"""
1.7 +Resources for use with PyQt.
1.8 +
1.9 +Copyright (C) 2005 Paul Boddie <paul@boddie.org.uk>
1.10 +
1.11 +This library is free software; you can redistribute it and/or
1.12 +modify it under the terms of the GNU Lesser General Public
1.13 +License as published by the Free Software Foundation; either
1.14 +version 2.1 of the License, or (at your option) any later version.
1.15 +
1.16 +This library is distributed in the hope that it will be useful,
1.17 +but WITHOUT ANY WARRANTY; without even the implied warranty of
1.18 +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1.19 +Lesser General Public License for more details.
1.20 +
1.21 +You should have received a copy of the GNU Lesser General Public
1.22 +License along with this library; if not, write to the Free Software
1.23 +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
1.24 +"""
1.25 +
1.26 import XSLForms.Prepare
1.27 -import qt
1.28 -import qtui
1.29 -import qtxmldom
1.30 +import XSLForms.Resources.Common
1.31 +import qt, qtui, qtxmldom
1.32 import os
1.33
1.34 -class XSLFormsResource:
1.35 +class XSLFormsResource(XSLForms.Resources.Common.PyQtCommonResource):
1.36
1.37 "An XSLForms resource for use with PyQt."
1.38
1.39 - template_resources = {}
1.40 widget_resources = {}
1.41 - document_resources = {}
1.42 -
1.43 - # Helper methods.
1.44 - # NOTE: Should be moved to a superclass.
1.45 -
1.46 - def prepare_document(self, document_identifier):
1.47 - filename = self.document_resources[document_identifier]
1.48 - return os.path.abspath(os.path.join(self.resource_dir, filename))
1.49
1.50 def get_document(self, document_identifier):
1.51 return qtxmldom.parse(self.prepare_document(document_identifier))
1.52
1.53 - def get_elements(self, document_identifier):
1.54 - doc = self.get_document(document_identifier)
1.55 - return doc.getElementsByTagName(document_identifier + "-enum")
1.56 -
1.57 - def prepare_template(self, template_identifier):
1.58 - filename = self.template_resources[template_identifier]
1.59 - return os.path.abspath(os.path.join(self.resource_dir, filename))
1.60 -
1.61 - def prepare_widget(self, template_identifier, widget_identifier, parent=None):
1.62 - template_path = self.prepare_template(template_identifier)
1.63 + def prepare_widget(self, design_identifier, widget_identifier, parent=None):
1.64 + design_path = self.prepare_design(design_identifier)
1.65 fragment_name, widget_name = self.widget_resources[widget_identifier]
1.66 fragment_path = os.path.abspath(os.path.join(self.resource_dir, fragment_name))
1.67 - XSLForms.Prepare.ensure_qt_fragment(template_path, fragment_path, widget_name)
1.68 + XSLForms.Prepare.ensure_qt_fragment(design_path, fragment_path, widget_name)
1.69 return qtui.QWidgetFactory.create(fragment_path, None, parent)
1.70
1.71 def populate_list(self, field, elements):