{
  "cells": [
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "%matplotlib inline"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\n# QML Basic Example\nBasic Qt tutorial.\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "import os\nimport sys\n\nfrom qtpy import QtCore\nfrom qtpy import QtWidgets\nfrom qtpy import QtQml\n\napp = QtWidgets.QApplication([])\n\nos.environ[\"QT_QUICK_CONTROLS_STYLE\"] = \"Material\"\nos.environ[\"QT_QUICK_CONTROLS_MATERIAL_THEME\"] = \"Dark\""
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "Create a widget, populate it with a layout, then add a label with some text:\n\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "qml = b\"\"\"\nimport QtQuick 2.15\nimport QtQuick.Controls 2.15\n\nApplicationWindow {\n    id: root\n    visible: true\n    width: 640\n    height: 480\n    title: qsTr(\"QtGallery\")\n\n    Button {\n        text: qsTr(\"Qt is awesome!!!\")\n        anchors.centerIn: parent\n    }\n}\n\"\"\""
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "Show the widget so it'll render right after this text:\n\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "engine = QtQml.QQmlApplicationEngine()\nengine.loadData(qml)"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "If you have a ``QApplication.exec_()`` call at the end of your example script\n(so it can be run as-is from the command line), ``qtgallery`` disables\nthe Qt event loop execution to prevent an indefinite loop.\n\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "if __name__ == \"__main__\":\n    app.exec_()"
      ]
    }
  ],
  "metadata": {
    "kernelspec": {
      "display_name": "Python 3",
      "language": "python",
      "name": "python3"
    },
    "language_info": {
      "codemirror_mode": {
        "name": "ipython",
        "version": 3
      },
      "file_extension": ".py",
      "mimetype": "text/x-python",
      "name": "python",
      "nbconvert_exporter": "python",
      "pygments_lexer": "ipython3",
      "version": "3.7.9"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}