/usr/share/pyshared/PyQt4/uic/pykdeuic4.py is in python-kde4 4:4.8.2-0ubuntu1.
This file is owned by root:root, with mode 0o755.
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 | #!/usr/bin/env python
#
# Copyright (C) 2007-9 Simon Edwards <simon@simonzone.com>
# Copyright (C) 2011 Luca Beltrame <einar@heavensinferno.net>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Library General Public
# License as published by the Free Software Foundation; either
# version 2 of the License or (at your option) version 2.1 or
# version 3 or, at the discretion of KDE e.V. (which shall act as
# a proxy as in section 14 of the GPLv3), any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Library General Public License for more details.
#
# You should have received a copy of the GNU Library General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA
import sys
import time
import optparse
from PyQt4.uic.Compiler import indenter, compiler
from PyQt4.uic.Compiler import qtproxies
from PyQt4.uic.objcreator import MATCH,NO_MATCH
HEADER = """#!/usr/bin/env python
# coding=UTF-8
#
# Generated by pykdeuic4 from %s on %s
#
# WARNING! All changes to this file will be lost.
from PyKDE4 import kdecore
from PyKDE4 import kdeui
"""
DISPLAY_CODE = """
if __name__ == '__main__':
import sys
global app
class MainWin(kdeui.KMainWindow, %s):
def __init__ (self, *args):
kdeui.KMainWindow.__init__ (self)
rootWidget = QtGui.QWidget(self)
self.setupUi(rootWidget)
self.resize(640, 480)
self.setCentralWidget(rootWidget)
appName = "default"
catalog = ""
programName = kdecore.ki18n("default")
version = "1.0"
description = kdecore.ki18n("Default Example")
license = kdecore.KAboutData.License_GPL
copyright = kdecore.ki18n("unknown")
text = kdecore.ki18n("none")
homePage = ""
bugEmail = "email"
aboutData = kdecore.KAboutData(appName, catalog, programName, version, description,
license, copyright, text, homePage, bugEmail)
kdecore.KCmdLineArgs.init(sys.argv, aboutData)
app = kdeui.KApplication()
mainWindow = MainWin(None, "main window")
mainWindow.show()
app.lastWindowClosed.connect(app.quit)
app.exec_ ()
"""
# Override how messages are translated.
original_i18n_string = qtproxies.i18n_string
class kde_i18n_string(qtproxies.i18n_string):
"Wrapper around qtproxies.i18n_string to add support for kdecore's i18n."
def __init__(self, string, disambig=None):
original_i18n_string.__init__(self,string, disambig)
def __str__(self):
return "kdecore.i18n(%s)" % (qtproxies.as_string(self.string),)
qtproxies.i18n_string = kde_i18n_string
def processUI(uifile, output_filename=None, exe=False, indent=4):
"""Compile and process the UI file."""
if output_filename is not None:
output = open(output_filename,'w')
else:
output = sys.stdout
# Write out the header.
output.write(HEADER % (uifile, time.ctime()))
indenter.indentwidth = indent
comp = compiler.UICompiler()
winfo = comp.compileUi(uifile, output, None)
if exe:
output.write(DISPLAY_CODE % winfo["uiclass"])
if output_filename is not None:
output.close()
def main():
usage = "pykdeuic4 [-h] [-e] [-o output_file] ui_file"
parser = optparse.OptionParser(usage=usage)
parser.add_option("-e", action="store_true", dest="exe",
help="Generate extra code to display the UI",
default=False)
parser.add_option("-o", dest="output_filename",
metavar="file",
help="Write the output to file instead of stdout",
default=None)
options, arguments = parser.parse_args()
if len(arguments) != 1:
parser.error("Wrong number of arguments.")
source_ui = arguments[0]
exe = options.exe
output_filename = options.output_filename
processUI(source_ui, output_filename, exe)
if __name__ == '__main__':
main()
|