def __init__(self): QCoreApplication.setAttribute(Qt.AA_ShareOpenGLContexts) app = QApplication(sys.argv) app.setStyle(QStyleFactory.create('Fusion')) ui_file_name = '%s.ui' % Path(__file__).stem ui_file = QFile(ui_file_name) if not ui_file.open(QIODevice.ReadOnly): print('Cannot open %s: %s' % (ui_file_name, ui_file.errorString())) sys.exit(-1) loader = QUiLoader() self.window = loader.load(ui_file) ui_file.close() if not self.window: print(loader.errorString()) sys.exit(-1) self.connect() self.setting() self.window.show() sys.exit(app.exec())
if __name__ == '__main__': parser = ArgumentParser(description="contextinfo", formatter_class=RawTextHelpFormatter) parser.add_argument('--gles', '-g', action='store_true', help='Use OpenGL ES') parser.add_argument('--software', '-s', action='store_true', help='Use Software OpenGL') parser.add_argument('--desktop', '-d', action='store_true', help='Use Desktop OpenGL') options = parser.parse_args() if options.gles: QCoreApplication.setAttribute(Qt.AA_UseOpenGLES) elif options.software: QCoreApplication.setAttribute(Qt.AA_UseSoftwareOpenGL) elif options.desktop: QCoreApplication.setAttribute(Qt.AA_UseDesktopOpenGL) app = QApplication(sys.argv) mainWindow = MainWindow() mainWindow.show() mainWindow.updateDescription() sys.exit(app.exec_())
def main() -> int: logging.basicConfig() QCoreApplication.setAttribute(Qt.AA_ShareOpenGLContexts) app: QApplication = QApplication(sys.argv) _ = ui.MainWindow().inflate().bind(ui_model.MainWindowModel()).show() return app.exec_()
## LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ## A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ## OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ## DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ## THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ## (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ## OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." ## ## $QT_END_LICENSE$ ## ############################################################################# """PySide6 port of the widgets/gallery example from Qt v5.15""" import sys from PySide6.QtCore import QCoreApplication, Qt from PySide6.QtWidgets import QApplication from widgetgallery import WidgetGallery if __name__ == '__main__': QCoreApplication.setAttribute(Qt.AA_EnableHighDpiScaling) QCoreApplication.setAttribute(Qt.AA_UseHighDpiPixmaps) app = QApplication() gallery = WidgetGallery() gallery.show() sys.exit(app.exec_())
def initialize_qt(): sys.argv += ['--style', 'Material'] QGuiApplication.setAttribute(Qt.AA_EnableHighDpiScaling) QCoreApplication.setAttribute(Qt.AA_UseHighDpiPixmaps) QCoreApplication.setAttribute(Qt.AA_UseOpenGLES)