home *** CD-ROM | disk | FTP | other *** search
- # Source Generated with Decompyle++
- # File: in.pyc (Python 2.6)
-
- import sys
- import re
- from PyQt4.uic.Compiler.indenter import write_code
- from PyQt4.uic.Compiler.misc import Literal, moduleMember
- if sys.hexversion >= 50331648:
- from PyQt4.uic.port_v3.proxy_base import ProxyBase
- from PyQt4.uic.port_v3.encode_utf8 import encode_utf8
- else:
- from PyQt4.uic.port_v2.proxy_base import ProxyBase
- from PyQt4.uic.port_v2.encode_utf8 import encode_utf8
- i18n_strings = []
- i18n_context = ''
-
- def i18n_print(string):
- i18n_strings.append(string)
-
-
- def obj_to_argument(obj):
- if isinstance(obj, str):
- arg = '"' + escape(obj) + '"'
- else:
- arg = str(obj)
- return arg
-
-
- def i18n_void_func(name):
-
- def _printer(self, *args):
- i18n_print('%s.%s(%s)' % (self, name, ', '.join(map(obj_to_argument, args))))
-
- return _printer
-
-
- def i18n_func(name):
-
- def _printer(self, rname, *args):
- i18n_print('%s = %s.%s(%s)' % (rname, self, name, ', '.join(map(obj_to_argument, args))))
- return Literal(rname)
-
- return _printer
-
-
- def strict_getattr(module, clsname):
- cls = getattr(module, clsname)
- if issubclass(cls, LiteralProxyClass):
- raise AttributeError(cls)
- issubclass(cls, LiteralProxyClass)
- return cls
-
- _esc_regex = re.compile('(\\"|\\\'|\\\\)')
-
- def escape(text):
- x = _esc_regex.sub('\\\\\\1', text)
- return re.sub('\\n', '\\\\n"\\n"', x)
-
-
- class i18n_string(object):
-
- def __init__(self, string):
- self.string = string
-
-
- def __str__(self):
- return 'QtGui.QApplication.translate("%s", "%s", None, QtGui.QApplication.UnicodeUTF8)' % (i18n_context, escape(encode_utf8(self.string)))
-
-
- AS_ARGUMENT = 2
-
- class ProxyClassMember(object):
-
- def __init__(self, proxy, function_name, flags):
- self.proxy = proxy
- self.function_name = function_name
- self.flags = flags
-
-
- def __str__(self):
- return '%s.%s' % (self.proxy, self.function_name)
-
-
- def __call__(self, *args):
- func_call = '%s.%s(%s)' % (self.proxy, self.function_name, ', '.join(map(obj_to_argument, args)))
- if self.flags & AS_ARGUMENT:
- self.proxy._uic_name = func_call
- return self.proxy
- needs_translation = False
- for arg in args:
- if isinstance(arg, i18n_string):
- needs_translation = True
- continue
- self.flags & AS_ARGUMENT
-
- if needs_translation:
- i18n_print(func_call)
- else:
- write_code(func_call)
-
-
-
- class ProxyClass(ProxyBase):
- flags = 0
-
- def __init__(self, objectname, is_attribute, args = (), noInstantiation = False):
- if objectname:
- if is_attribute:
- objectname = 'self.' + objectname
-
- self._uic_name = objectname
- else:
- self._uic_name = 'Unnamed'
- if not noInstantiation:
- funcall = '%s(%s)' % (moduleMember(self.module, self.__class__.__name__), ', '.join(map(str, args)))
- if objectname:
- funcall = '%s = %s' % (objectname, funcall)
-
- write_code(funcall)
-
-
-
- def __str__(self):
- return self._uic_name
-
-
- def __getattribute__(self, attribute):
-
- try:
- return object.__getattribute__(self, attribute)
- except AttributeError:
- return ProxyClassMember(self, attribute, self.flags)
-
-
-
-
- class LiteralProxyClass(ProxyClass):
- flags = AS_ARGUMENT
-
- def __init__(self, *args):
- self._uic_name = '%s(%s)' % (moduleMember(self.module, self.__class__.__name__), ', '.join(map(obj_to_argument, args)))
-
-
-
- class ProxyNamespace(ProxyBase):
- pass
-
-
- class QtCore(ProxyNamespace):
-
- class Qt(ProxyNamespace):
- pass
-
-
- class QMetaObject(ProxyClass):
-
- def connectSlotsByName(cls, *args):
- ProxyClassMember(cls, 'connectSlotsByName', 0)(*args)
-
- connectSlotsByName = classmethod(connectSlotsByName)
-
-
- class QObject(ProxyClass):
-
- def metaObject(self):
-
- class _FakeMetaObject((object,)):
-
- def className(*args):
- return self.__class__.__name__
-
-
- return _FakeMetaObject()
-
-
- def objectName(self):
- return self._uic_name.split('.')[-1]
-
-
- def connect(cls, *args):
- slot_name = str(args[-1])
- if slot_name.endswith('.raise'):
- args = list(args[:-1])
- args.append(Literal(slot_name + '_'))
-
- ProxyClassMember(cls, 'connect', 0)(*args)
-
- connect = classmethod(connect)
-
-
- _qwidgets = ('QAbstractItemView', 'QCalendarWidget', 'QColumnView', 'QCommandLinkButton', 'QDateEdit', 'QDateTimeEdit', 'QDial', 'QDialog', 'QDialogButtonBox', 'QDockWidget', 'QDoubleSpinBox', 'QFrame', 'QGraphicsView', 'QGroupBox', 'QLabel', 'QLCDNumber', 'QLineEdit', 'QListView', 'QMainWindow', 'QMdiArea', 'QMenuBar', 'QPlainTextEdit', 'QProgressBar', 'QScrollArea', 'QScrollBar', 'QSlider', 'QSpinBox', 'QSplitter', 'QStackedWidget', 'QStatusBar', 'QTextBrowser', 'QTextEdit', 'QTimeEdit', 'QToolBar', 'QWizard', 'QWizardPage')
-
- class QtGui(ProxyNamespace):
-
- class QApplication(QtCore.QObject):
-
- def translate(uiname, text, context, encoding):
- if not text:
- pass
- return i18n_string('')
-
- translate = staticmethod(translate)
-
-
- class QIcon(ProxyClass):
- pass
-
-
- class QConicalGradient(ProxyClass):
- pass
-
-
- class QLinearGradient(ProxyClass):
- pass
-
-
- class QRadialGradient(ProxyClass):
- pass
-
-
- class QBrush(ProxyClass):
- pass
-
-
- class QPalette(ProxyClass):
- pass
-
-
- class QFont(ProxyClass):
- pass
-
-
- class QSpacerItem(ProxyClass):
- pass
-
-
- class QSizePolicy(ProxyClass):
- pass
-
-
- class QAction(QtCore.QObject):
- pass
-
-
- class QActionGroup(QtCore.QObject):
- pass
-
-
- class QButtonGroup(QtCore.QObject):
- pass
-
-
- class QLayout(QtCore.QObject):
- pass
-
-
- class QGridLayout(QLayout):
- pass
-
-
- class QBoxLayout(QLayout):
- pass
-
-
- class QHBoxLayout(QBoxLayout):
- pass
-
-
- class QVBoxLayout(QBoxLayout):
- pass
-
-
- class QFormLayout(QLayout):
- pass
-
-
- class QWidget(QtCore.QObject):
-
- def font(self):
- return Literal('%s.font()' % self)
-
-
- def minimumSizeHint(self):
- return Literal('%s.minimumSizeHint()' % self)
-
-
- def sizePolicy(self):
- sp = LiteralProxyClass()
- sp._uic_name = '%s.sizePolicy()' % self
- return sp
-
-
-
- class QHeaderView(ProxyClass):
- pass
-
-
- class QListWidgetItem(ProxyClass):
- pass
-
-
- class QListWidget(QWidget):
- isSortingEnabled = i18n_func('isSortingEnabled')
- setSortingEnabled = i18n_void_func('setSortingEnabled')
-
- def item(self, row):
- return QtGui.QListWidgetItem('%s.item(%i)' % (self, row), False, (), noInstantiation = True)
-
-
-
- class QTreeView(QWidget):
-
- def header(self):
- return QtGui.QHeaderView('%s.header()' % self, False, (), noInstantiation = True)
-
-
-
- class QTreeWidgetItem(ProxyClass):
-
- def child(self, index):
- return QtGui.QTreeWidgetItem('%s.child(%i)' % (self, index), False, (), noInstantiation = True)
-
-
-
- class QTreeWidget(QTreeView):
- isSortingEnabled = i18n_func('isSortingEnabled')
- setSortingEnabled = i18n_void_func('setSortingEnabled')
-
- def headerItem(self):
- return QtGui.QWidget('%s.headerItem()' % self, False, (), noInstantiation = True)
-
-
- def topLevelItem(self, index):
- return QtGui.QTreeWidgetItem('%s.topLevelItem(%i)' % (self, index), False, (), noInstantiation = True)
-
-
-
- class QTableView(QWidget):
-
- def horizontalHeader(self):
- return QtGui.QHeaderView('%s.horizontalHeader()' % self, False, (), noInstantiation = True)
-
-
- def verticalHeader(self):
- return QtGui.QHeaderView('%s.verticalHeader()' % self, False, (), noInstantiation = True)
-
-
-
- class QTableWidgetItem(ProxyClass):
- pass
-
-
- class QTableWidget(QTableView):
- isSortingEnabled = i18n_func('isSortingEnabled')
- setSortingEnabled = i18n_void_func('setSortingEnabled')
-
- def item(self, row, col):
- return QtGui.QTableWidgetItem('%s.item(%i, %i)' % (self, row, col), False, (), noInstantiation = True)
-
-
- def horizontalHeaderItem(self, col):
- return QtGui.QTableWidgetItem('%s.horizontalHeaderItem(%i)' % (self, col), False, (), noInstantiation = True)
-
-
- def verticalHeaderItem(self, row):
- return QtGui.QTableWidgetItem('%s.verticalHeaderItem(%i)' % (self, row), False, (), noInstantiation = True)
-
-
-
- class QMenu(QWidget):
-
- def menuAction(self):
- return Literal('%s.menuAction()' % self)
-
-
-
- class QTabWidget(QWidget):
-
- def addTab(self, *args):
- i18n_print('%s.setTabText(%s.indexOf(%s), %s)' % (self._uic_name, self._uic_name, args[0], args[-1]))
- pargs = args[:-1] + ('',)
- ProxyClassMember(self, 'addTab', 0)(*pargs)
-
-
- def indexOf(self, page):
- return Literal('%s.indexOf(%s)' % (self, page))
-
-
-
- class QToolBox(QWidget):
-
- def addItem(self, *args):
- i18n_print('%s.setItemText(%s.indexOf(%s), %s)' % (self._uic_name, self._uic_name, args[0], args[-1]))
- pargs = args[:-1] + ('',)
- ProxyClassMember(self, 'addItem', 0)(*pargs)
-
-
- def indexOf(self, page):
- return Literal('%s.indexOf(%s)' % (self, page))
-
-
-
- class QComboBox(QWidget):
- pass
-
-
- class QFontComboBox(QComboBox):
- pass
-
-
- class QAbstractButton(QWidget):
- pass
-
-
- class QCheckBox(QAbstractButton):
- pass
-
-
- class QPushButton(QAbstractButton):
- pass
-
-
- class QRadioButton(QAbstractButton):
- pass
-
-
- class QToolButton(QAbstractButton):
- pass
-
- for _class in _qwidgets:
- if _class not in locals():
- locals()[_class] = type(_class, (QWidget,), { })
- continue
-
-
-