Пример #1
0
    def __init__(self):
        QDialog.__init__(self)

        layout = QFormLayout(self)
        self.setLayout(layout)
        layout.addRow("Python version:", QLabel("%s.%s.%s (%s)" % 
                        (sys.version_info[0], 
                         sys.version_info[1], 
                         sys.version_info[2], 
                         sys.version_info[3])))

        layout.addRow("Qt version:", QLabel( qVersion()))
Пример #2
0
    def __init__(self):

        # QMainWindow.__init__(self)
        super().__init__()      # use super() to avoid explicit dependency on the base class name
                                # Note: must not pass the self reference to __init__ in this case!
        self.resize(800, 600)

        # Create the main content widget
        mainWidget = QWidget(self)
        self.setCentralWidget(mainWidget)

        # Create a text component at the top area of the main widget
        self.output = QTextEdit(mainWidget)
        self.output.setReadOnly(True)
        self.output.setLineWrapMode(QTextEdit.NoWrap);

        # set the font
        font = self.output.font()
        font.setFamily("Courier")
        font.setPointSize(10)
        self.output.setFont(font)

        # Set the background color
        # self.output.setTextBackgroundColor(Qt.red) # Only sets the background color for the text itself, not for the whole widget
        pal = self.output.palette()
        pal.setColor(QPalette.Base, Qt.black)
        self.output.setPalette(pal)

        mainLayout = QVBoxLayout(mainWidget)
        mainLayout.addWidget(self.output)

        # Create buttons in a grid layout below the top area
        buttonWidget = QWidget(mainWidget)
        self.buttonLayout = QGridLayout(buttonWidget)
        mainLayout.addWidget(buttonWidget)

        # Add some buttons to execute python code
        self.row = 0
        self.column = 0
        self.addButton("Clear console", lambda : self.output.clear())
        self.newRow()

        # Add buttons for all the examples - attention: do not make "examples"
        # a local variable - otherwise, the Examples object would be destroyed
        # at the end of __init__ !!!
        self.examples = samplePackage.SampleModule.Examples(self)
        for example in self.examples.getExamples():
            if example is None:
                self.newRow()
            else:
                self.addButton(example.label, example.function)

        # In a Python program, sys.excepthook is called just before the program exits.
        # So we can catch all fatal, uncaught exceptions and log them.
        # NOTE: we must be sure not to set the excepthook BEFORE we an actually
        # log something!! 
        sys.excepthook = self.logException

        self.writelnColor(Qt.magenta, 
                          "Python version: {0}.{1}.{2} ({3})".format(
                              sys.version_info[0], 
                              sys.version_info[1], 
                              sys.version_info[2], 
                              sys.version_info[3]))
        self.writelnColor(Qt.magenta, 
                          "Qt version    : {0}".format(qVersion()))
Пример #3
0
# native
# from PyQt4.QtCore import QT_VERSION, QT_VERSION_STR, PYQT_VERSION, PYQT_VERSION_STR
# from sip import SIP_VERSION, SIP_VERSION_STR
#
# if __name__ == '__main__':
#     print(f"PyQt Version Number is: {PYQT_VERSION_STR} ({PYQT_VERSION})")
#     print(f"Qt Version is: {QT_VERSION_STR} ({QT_VERSION})")
#     print(f"Sip Version Number is: {SIP_VERSION_STR} ({SIP_VERSION})")

from PySide.QtCore import __version__, __version_info__, qVersion

if __name__ == '__main__':
    print(__version__)
    print(__version_info__)
    print(qVersion())

# import sys
# import os
# os.environ['QT_API'] = 'PyQt4'
# from qtpy.QtCore import *
# from qtpy.QtGui import *
# from qtpy.QtWidgets import *
# from sip import SIP_VERSION
#
# if __name__ == '__main__':
#     # I think I should to see the source code of qtpy
#     print(f"PyQt Version Number is: {PYQT_VERSION})")
#     print(f"Qt Version is: {QT_VERSION})")
#     print(f"Sip Version Number is: {SIP_VERSION}")