Server IP : 127.0.0.2 / Your IP : 18.117.227.191 Web Server : Apache/2.4.18 (Ubuntu) System : User : www-data ( ) PHP Version : 7.0.33-0ubuntu0.16.04.16 Disable Function : disk_free_space,disk_total_space,diskfreespace,dl,exec,fpaththru,getmyuid,getmypid,highlight_file,ignore_user_abord,leak,listen,link,opcache_get_configuration,opcache_get_status,passthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,php_uname,phpinfo,posix_ctermid,posix_getcwd,posix_getegid,posix_geteuid,posix_getgid,posix_getgrgid,posix_getgrnam,posix_getgroups,posix_getlogin,posix_getpgid,posix_getpgrp,posix_getpid,posix,_getppid,posix_getpwnam,posix_getpwuid,posix_getrlimit,posix_getsid,posix_getuid,posix_isatty,posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid,posix_setpgid,posix_setsid,posix_setuid,posix_times,posix_ttyname,posix_uname,pclose,popen,proc_open,proc_close,proc_get_status,proc_nice,proc_terminate,shell_exec,source,show_source,system,virtual MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /usr/lib/python2.7/dist-packages/PyQt4/uic/ |
Upload File : |
############################################################################# ## ## Copyright (c) 2015 Riverbank Computing Limited <info@riverbankcomputing.com> ## ## This file is part of PyQt4. ## ## This file may be used under the terms of the GNU General Public License ## version 3.0 as published by the Free Software Foundation and appearing in ## the file LICENSE included in the packaging of this file. Please review the ## following information to ensure the GNU General Public License version 3.0 ## requirements will be met: http://www.gnu.org/copyleft/gpl.html. ## ## If you do not wish to use this file under the terms of the GPL version 3.0 ## then you may purchase a commercial license. For more information contact ## info@riverbankcomputing.com. ## ## This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ## WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ## ############################################################################# import sys import logging from PyQt4.uic import compileUi, loadUi class Driver(object): """ This encapsulates access to the pyuic functionality so that it can be called by code that is Python v2/v3 specific. """ LOGGER_NAME = 'PyQt4.uic' def __init__(self, opts, ui_file): """ Initialise the object. opts is the parsed options. ui_file is the name of the .ui file. """ if opts.debug: logger = logging.getLogger(self.LOGGER_NAME) handler = logging.StreamHandler() handler.setFormatter(logging.Formatter("%(name)s: %(message)s")) logger.addHandler(handler) logger.setLevel(logging.DEBUG) self._opts = opts self._ui_file = ui_file def invoke(self): """ Invoke the action as specified by the parsed options. Returns 0 if there was no error. """ if self._opts.preview: return self._preview() self._generate() return 0 def _preview(self): """ Preview the .ui file. Return the exit status to be passed back to the parent process. """ from PyQt4 import QtGui app = QtGui.QApplication([self._ui_file]) widget = loadUi(self._ui_file) widget.show() return app.exec_() def _generate(self): """ Generate the Python code. """ needs_close = False if sys.hexversion >= 0x03000000: if self._opts.output == '-': from io import TextIOWrapper pyfile = TextIOWrapper(sys.stdout.buffer, encoding='utf8') else: pyfile = open(self._opts.output, 'wt', encoding='utf8') needs_close = True else: if self._opts.output == '-': pyfile = sys.stdout else: pyfile = open(self._opts.output, 'wt') needs_close = True compileUi(self._ui_file, pyfile, self._opts.execute, self._opts.indent, self._opts.pyqt3_wrapper, self._opts.from_imports, self._opts.resource_suffix) if needs_close: pyfile.close() def on_IOError(self, e): """ Handle an IOError exception. """ sys.stderr.write("Error: %s: \"%s\"\n" % (e.strerror, e.filename)) def on_SyntaxError(self, e): """ Handle a SyntaxError exception. """ sys.stderr.write("Error in input file: %s\n" % e) def on_NoSuchWidgetError(self, e): """ Handle a NoSuchWidgetError exception. """ if e.args[0].startswith("Q3"): sys.stderr.write("Error: Q3Support widgets are not supported by PyQt4.\n") else: sys.stderr.write(str(e) + "\n") def on_Exception(self, e): """ Handle a generic exception. """ if logging.getLogger(self.LOGGER_NAME).level == logging.DEBUG: import traceback traceback.print_exception(*sys.exc_info()) else: from PyQt4 import QtCore sys.stderr.write("""An unexpected error occurred. Check that you are using the latest version of PyQt and send an error report to support@riverbankcomputing.com, including the following information: * your version of PyQt (%s) * the UI file that caused this error * the debug output of pyuic4 (use the -d flag when calling pyuic4) """ % QtCore.PYQT_VERSION_STR)