Last active
March 13, 2019 11:50
-
-
Save a-andreyev/feff8d672a713d278d144c16744aac26 to your computer and use it in GitHub Desktop.
Qt_for_Python_Tutorial_HelloQML
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from PySide2.QtWidgets import QApplication | |
from PySide2.QtQuick import QQuickView | |
from PySide2.QtCore import QUrl | |
import resources | |
app = QApplication([]) | |
view = QQuickView() | |
url = QUrl("qrc:///view.qml") | |
view.setSource(url) | |
view.show() | |
app.exec_() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE RCC><RCC version="1.0"> | |
<qresource prefix="/"> | |
<file>view.qml</file> | |
<file>silicaview.qml</file> | |
</qresource> | |
</RCC> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from cx_Freeze import setup, Executable | |
import sys | |
PROGRAM_NAME = "Qt_for_Python_Tutorial_HelloQML" | |
VERSION = "0.0.1" | |
MAIN_SCRIPT_NAME = "main.py" | |
bin_includes = [] | |
includefiles = [] | |
if sys.platform == 'linux': | |
bin_includes.extend(['libpyside2.cpython-34m.so', 'libshiboken2.cpython-34m.so']) | |
includefiles.extend(['/usr/lib/libshiboken2.cpython-34m.so', '/usr/lib/libpyside2.cpython-34m.so']) | |
options = { | |
'build_exe': { | |
'bin_includes': bin_includes, | |
# 'bin_path_includes':'/usr/lib', | |
'include_files': includefiles, | |
} | |
} | |
setup( name = PROGRAM_NAME, | |
version = VERSION, options=options, | |
requires=['PySide2', 'shiboken'], | |
executables = [Executable(MAIN_SCRIPT_NAME)]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import QtQuick 2.0 | |
import Sailfish.Silica 1.0 | |
ApplicationWindow | |
{ | |
initialPage: sailCalcComponent | |
Component { | |
id: sailCalcComponent | |
Page { | |
Rectangle { | |
id: myRect | |
anchors.fill: parent | |
color: "transparent" | |
Button { | |
id: myButton | |
anchors.centerIn: parent | |
text: "Press me" | |
onClicked: { | |
myRect.color = Qt.hsla(Math.random(), 0.5, 0.4, 0.4) | |
} | |
} | |
} | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import QtQuick 2.0 | |
Rectangle { | |
id: myRect | |
anchors.fill: parent | |
color: "lightgreen" | |
Text { | |
id: myText | |
anchors.centerIn: parent | |
text: "Hello, world" | |
font.bold: true | |
Rectangle { | |
anchors.fill: parent | |
anchors.margins: -parent.height/3 | |
color: "white" | |
radius: height | |
opacity: 0.5 | |
} | |
} | |
Timer { | |
interval: 500; running: true; repeat: true | |
onTriggered: { | |
myRect.color = Qt.hsla(Math.random(), 0.5, 0.4, 1) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment