本文整理汇总了Python中PyQt4.QtDeclarative.QDeclarativeView.rootObject方法的典型用法代码示例。如果您正苦于以下问题:Python QDeclarativeView.rootObject方法的具体用法?Python QDeclarativeView.rootObject怎么用?Python QDeclarativeView.rootObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt4.QtDeclarative.QDeclarativeView
的用法示例。
在下文中一共展示了QDeclarativeView.rootObject方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run
# 需要导入模块: from PyQt4.QtDeclarative import QDeclarativeView [as 别名]
# 或者: from PyQt4.QtDeclarative.QDeclarativeView import rootObject [as 别名]
def run(self):
app = QApplication(sys.argv)
imageProvider = ImageProvider()
# Create the QML user interface.
view = QDeclarativeView()
view.setResizeMode(QDeclarativeView.SizeRootObjectToView)
engine = view.engine()
engine.addImageProvider("mazakodron", imageProvider)
view.setSource(QUrl('symulator/mazakodron.qml'))
rootObject = view.rootObject()
if not rootObject:
view.setSource(QUrl('mazakodron.qml'))
rootObject = view.rootObject()
rootObject.requestDraw.connect(imageProvider.draw)
self.rootObject = rootObject
view.setGeometry(0, 0, 800, 600)
view.show()
timer = QTimer()
timer.start(1000/60) # 60FPS
timer.timeout.connect(self.process)
sys.exit(app.exec_());
示例2: main
# 需要导入模块: from PyQt4.QtDeclarative import QDeclarativeView [as 别名]
# 或者: from PyQt4.QtDeclarative.QDeclarativeView import rootObject [as 别名]
def main():
app = QApplication(sys.argv)
now = Now()
# Create the QML user interface.
view = QDeclarativeView()
view.setSource(QUrl('meet.qml'))
view.setResizeMode(QDeclarativeView.SizeRootObjectToView)
view.setWindowTitle(u'属于你我的时间')
# Get the root object of the user interface. It defines a
# 'messageRequired' signal and JavaScript 'updateMessage' function. Both
# can be accessed transparently from Python.
rootObject = view.rootObject()
# Provide the current date and time when requested by the user interface.
rootObject.messageRequired.connect(now.emit_now)
# Update the user interface with the current date and time.
now.now.connect(rootObject.updateMessage)
timer = QTimer()
timer.timeout.connect(now.emit_now)
timer.start(500)
# Provide an initial message as a prompt.
rootObject.updateMessage(u"转眼间,你我已相遇...")
# Display the user interface and allow the user to interact with it.
view.setGeometry(80, 80, 960, 580)
view.show()
app.exec_()
示例3: main
# 需要导入模块: from PyQt4.QtDeclarative import QDeclarativeView [as 别名]
# 或者: from PyQt4.QtDeclarative.QDeclarativeView import rootObject [as 别名]
def main():
app = QApplication(sys.argv)
stack = Stack()
# Create the QML user interface.
view = QDeclarativeView()
view.setSource(QUrl('stack.qml'))
view.setResizeMode(QDeclarativeView.SizeRootObjectToView)
view.setWindowTitle(u'栈')
# Get the root object of the user interface. It defines a
# 'messageRequired' signal and JavaScript 'updateMessage' function. Both
# can be accessed transparently from Python.
rootObject = view.rootObject()
# Provide the current date and time when requested by the user interface.
rootObject.button_clicked.connect(stack.push)
# Update the user interface with the current date and time.
stack.push_element.connect(rootObject.first_clicked)
# Provide an initial message as a prompt.
#rootObject.updateMessage(u"转眼间,你我已相遇...")
stack.push(2)
# Display the user interface and allow the user to interact with it.
view.setGeometry(80, 80, 960, 580)
view.show()
app.exec_()
示例4: main
# 需要导入模块: from PyQt4.QtDeclarative import QDeclarativeView [as 别名]
# 或者: from PyQt4.QtDeclarative.QDeclarativeView import rootObject [as 别名]
def main():
# Main function to be executed while running the program
# Generate QML View
app = QApplication(sys.argv)
view = QDeclarativeView()
view.setSource(QUrl('Fingers.qml'))
view.setResizeMode(QDeclarativeView.SizeRootObjectToView)
# Get Root Object for communication
global rootObject
rootObject = view.rootObject()
# Connect to start Leap signal
rootObject.qmlStarted.connect(startLeap)
# Connect to stop Leap signal
rootObject.qmlStop.connect(stopLeap)
# Display the component
import subprocess
output = subprocess.Popen('xrandr | grep "\*" | cut -d" " -f4',shell=True, stdout=subprocess.PIPE).communicate()[0]
output = output[:-1]
screenX = output[:output.index('x')]
screenY = output[output.index('x')+1:]
view.setGeometry(100, 100, int(screenX), int(screenY))
view.show()
app.exec_()
示例5: __init__
# 需要导入模块: from PyQt4.QtDeclarative import QDeclarativeView [as 别名]
# 或者: from PyQt4.QtDeclarative.QDeclarativeView import rootObject [as 别名]
def __init__(self):
super(StartPage, self).__init__()
vbox = QVBoxLayout(self)
vbox.setContentsMargins(0, 0, 0, 0)
view = QDeclarativeView()
qml = os.path.join(os.path.dirname(__file__), "StartPage.qml")
path = QDir.fromNativeSeparators(qml)
view.setSource(QUrl.fromLocalFile(path))
view.setResizeMode(QDeclarativeView.SizeRootObjectToView)
self._root = view.rootObject()
vbox.addWidget(view)
示例6: create_dv
# 需要导入模块: from PyQt4.QtDeclarative import QDeclarativeView [as 别名]
# 或者: from PyQt4.QtDeclarative.QDeclarativeView import rootObject [as 别名]
def create_dv():
# Create the QML user interface.
view = QDeclarativeView()
view.setSource(QUrl('qml/leonbmain.qml'))
view.setResizeMode(QDeclarativeView.SizeRootObjectToView)
# Display the user interface and allow the user to interact with it.
view.setGeometry(100, 100, 400, 240)
view.show()
rootObject = view.rootObject()
return view
示例7: __init__
# 需要导入模块: from PyQt4.QtDeclarative import QDeclarativeView [as 别名]
# 或者: from PyQt4.QtDeclarative.QDeclarativeView import rootObject [as 别名]
def __init__(self, parent=None):
super(SplitOrientation, self).__init__(parent,
Qt.Dialog | Qt.FramelessWindowHint)
self.setModal(True)
self.setAttribute(Qt.WA_TranslucentBackground)
self.setStyleSheet("background:transparent;")
self.setFixedHeight(150)
self.setFixedWidth(310)
# Create the QML user interface.
view = QDeclarativeView()
view.setResizeMode(QDeclarativeView.SizeRootObjectToView)
view.setSource(ui_tools.get_qml_resource("SplitOrientation.qml"))
self._root = view.rootObject()
vbox = QVBoxLayout(self)
vbox.addWidget(view)
示例8: __init__
# 需要导入模块: from PyQt4.QtDeclarative import QDeclarativeView [as 别名]
# 或者: from PyQt4.QtDeclarative.QDeclarativeView import rootObject [as 别名]
def __init__(self, parent=None):
super(MainSelector, self).__init__(parent)
# Create the QML user interface.
view = QDeclarativeView()
view.setResizeMode(QDeclarativeView.SizeRootObjectToView)
view.setSource(ui_tools.get_qml_resource("MainSelector.qml"))
self._root = view.rootObject()
vbox = QVBoxLayout(self)
vbox.setContentsMargins(0, 0, 0, 0)
vbox.setSpacing(0)
vbox.addWidget(view)
self.connect(self._root, SIGNAL("open(int)"),
lambda i: self.emit(SIGNAL("changeCurrent(int)"), i))
self.connect(self._root, SIGNAL("ready()"),
lambda: self.emit(SIGNAL("ready()")))
示例9: __init__
# 需要导入模块: from PyQt4.QtDeclarative import QDeclarativeView [as 别名]
# 或者: from PyQt4.QtDeclarative.QDeclarativeView import rootObject [as 别名]
def __init__(self, parent=None):
super(Notification, self).__init__(None, Qt.ToolTip)
self._parent = parent
self._duration = 3000
self.setAttribute(Qt.WA_TranslucentBackground)
self.setAttribute(Qt.WA_TransparentForMouseEvents)
self.setAttribute(Qt.WA_ShowWithoutActivating)
self.setStyleSheet("background:transparent;")
self.setWindowFlags(Qt.FramelessWindowHint | Qt.WindowStaysOnTopHint)
self.setFixedHeight(30)
# Create the QML user interface.
view = QDeclarativeView()
view.setResizeMode(QDeclarativeView.SizeRootObjectToView)
view.setSource(ui_tools.get_qml_resource("Notification.qml"))
self._root = view.rootObject()
vbox = QVBoxLayout(self)
vbox.addWidget(view)
self.connect(self._root, SIGNAL("close()"), self.close)
示例10: __init__
# 需要导入模块: from PyQt4.QtDeclarative import QDeclarativeView [as 别名]
# 或者: from PyQt4.QtDeclarative.QDeclarativeView import rootObject [as 别名]
def __init__(self, parent=None):
super(SplitOrientation, self).__init__(parent, Qt.Dialog | Qt.FramelessWindowHint)
self._operations = {"row": False, "col": True}
self.setModal(True)
self.setAttribute(Qt.WA_TranslucentBackground)
self.setStyleSheet("background:transparent;")
self.setFixedHeight(130)
self.setFixedWidth(290)
# Create the QML user interface.
view = QDeclarativeView()
view.setResizeMode(QDeclarativeView.SizeRootObjectToView)
view.setSource(ui_tools.get_qml_resource("SplitOrientation.qml"))
self._root = view.rootObject()
vbox = QVBoxLayout(self)
vbox.setContentsMargins(0, 0, 0, 0)
vbox.setSpacing(0)
vbox.addWidget(view)
self.connect(self._root, SIGNAL("selected(QString)"), self._split_operation)
示例11: __init__
# 需要导入模块: from PyQt4.QtDeclarative import QDeclarativeView [as 别名]
# 或者: from PyQt4.QtDeclarative.QDeclarativeView import rootObject [as 别名]
def __init__(self):
QWidget.__init__(self)
box = QVBoxLayout(self)
box.setContentsMargins(0, 0, 0, 0)
view = QDeclarativeView()
view.setMinimumSize(400, 400)
qml = os.path.join(paths.PATH, "ui", "StartPage.qml")
path = QDir.fromNativeSeparators(qml)
view.setSource(QUrl.fromLocalFile(path))
view.setResizeMode(QDeclarativeView.SizeRootObjectToView)
self._root = view.rootObject()
box.addWidget(view)
self._current_text = ""
# Timer
self.timer = QTimer(self)
self.timer.setInterval(3000)
self._show_welcome_text()
self.timer.timeout.connect(self._show_text)
self.timer.start()
示例12: __init__
# 需要导入模块: from PyQt4.QtDeclarative import QDeclarativeView [as 别名]
# 或者: from PyQt4.QtDeclarative.QDeclarativeView import rootObject [as 别名]
def __init__(self, parent=None):
super(Selector, self).__init__(parent,
Qt.Dialog | Qt.FramelessWindowHint)
# Configuración
self.setModal(True)
box = QVBoxLayout(self)
box.setContentsMargins(0, 0, 1, 1)
box.setSpacing(0)
# Interfáz QML
view = QDeclarativeView()
qml = os.path.join(paths.PATH, "ui", "selector", "selector.qml")
path = QDir.fromNativeSeparators(qml)
view.setSource(QUrl.fromLocalFile(path))
view.setResizeMode(QDeclarativeView.SizeRootObjectToView)
box.addWidget(view)
self.root = view.rootObject()
self.__cargar()
self.connect(self.root, SIGNAL("abrirArchivo(int)"),
self.__abrir_archivo)
示例13: PluginsStore
# 需要导入模块: from PyQt4.QtDeclarative import QDeclarativeView [as 别名]
# 或者: from PyQt4.QtDeclarative.QDeclarativeView import rootObject [as 别名]
class PluginsStore(QDialog):
def __init__(self, parent=None):
super(PluginsStore, self).__init__(parent, Qt.Dialog)
vbox = QVBoxLayout(self)
vbox.setContentsMargins(0, 0, 0, 0)
vbox.setSpacing(0)
self.view = QDeclarativeView()
self.view.setMinimumWidth(800)
self.view.setMinimumHeight(600)
self.view.setResizeMode(QDeclarativeView.SizeRootObjectToView)
self.view.setSource(ui_tools.get_qml_resource("PluginsStore.qml"))
self.root = self.view.rootObject()
vbox.addWidget(self.view)
self.nenv = nenvironment.NenvEggSearcher()
self.connect(self.nenv, SIGNAL("searchCompleted(PyQt_PyObject)"),
self.callback)
self.status = self.nenv.do_search()
def callback(self, values):
for each_val in values:
print each_val
示例14: main
# 需要导入模块: from PyQt4.QtDeclarative import QDeclarativeView [as 别名]
# 或者: from PyQt4.QtDeclarative.QDeclarativeView import rootObject [as 别名]
def main():
app = QApplication(sys.argv)
test = SignalTest()
# Create the QML user interface.
view = QDeclarativeView()
view.setSource(QUrl('Button.qml'))
view.setResizeMode(QDeclarativeView.SizeRootObjectToView)
view.setWindowTitle(u'栈')
rootObject = view.rootObject()
rootObject.updateTextRequired.connect(test.change_text)
# Update the user interface with the current date and time.
test.signal_test.connect(rootObject.updateText)
# Provide an initial message as a prompt.
rootObject.updateText(u"转眼间,你我已相遇...")
#stack.push(2)
# Display the user interface and allow the user to interact with it.
view.setGeometry(80, 80, 960, 580)
view.show()
app.exec_()
示例15: TabsHandler
# 需要导入模块: from PyQt4.QtDeclarative import QDeclarativeView [as 别名]
# 或者: from PyQt4.QtDeclarative.QDeclarativeView import rootObject [as 别名]
class TabsHandler(QFrame):
def __init__(self, parent=None):
super(TabsHandler, self).__init__(None, Qt.FramelessWindowHint | Qt.Popup)
self._main_container = parent
self.setAttribute(Qt.WA_TranslucentBackground)
self.setStyleSheet("background:transparent;")
# Create the QML user interface.
self.view = QDeclarativeView()
self.view.setResizeMode(QDeclarativeView.SizeRootObjectToView)
self.view.setSource(ui_tools.get_qml_resource("TabsHandler.qml"))
self._root = self.view.rootObject()
vbox = QVBoxLayout(self)
vbox.setContentsMargins(0, 0, 0, 0)
vbox.setSpacing(0)
vbox.addWidget(self.view)
self._model = {}
self._max_index = 0
self.connect(self._root, SIGNAL("open(QString)"), self._open)
self.connect(self._root, SIGNAL("close(QString)"), self._close)
self.connect(self._root, SIGNAL("hide()"), self.hide)
def _open(self, path):
self._main_container.open_file(path)
index = self._model[path]
self._max_index = max(self._max_index, index) + 1
self._model[path] = self._max_index
self.hide()
def _close(self, path):
ninjaide = IDE.get_service("ide")
nfile = ninjaide.get_or_create_nfile(path)
nfile.close()
def _add_model(self):
ninjaide = IDE.get_service("ide")
files = ninjaide.filesystem.get_files()
files_data = list(files.values())
# Update model
old = set(self._model.keys())
new = set([nfile.file_path for nfile in files_data])
result = old - new
for item in result:
del self._model[item]
current_editor = self._main_container.get_current_editor()
current_path = None
if current_editor:
current_path = current_editor.file_path
model = []
for nfile in files_data:
if nfile.file_path not in self._model:
self._model[nfile.file_path] = 0
neditable = ninjaide.get_or_create_editable(nfile.file_path)
checkers = neditable.sorted_checkers
checks = []
for items in checkers:
checker, color, _ = items
if checker.dirty:
checks.append({"checker_text": checker.dirty_text, "checker_color": color})
modified = neditable.document.isModified()
model.append([nfile.file_name, nfile.file_path, checks, modified])
if current_path:
index = self._model[current_path]
self._max_index = max(self._max_index, index) + 1
self._model[current_path] = self._max_index
model = sorted(model, key=lambda x: self._model[x[1]], reverse=True)
self._root.set_model(model)
def showEvent(self, event):
self._add_model()
width = max(self._main_container.width() / 3, 300)
logger.debug("This is the width")
logger.debug(width)
height = max(self._main_container.height() / 2, 400)
logger.debug("This is the height")
logger.debug(height)
self.view.setFixedWidth(width)
self.view.setFixedHeight(height)
super(TabsHandler, self).showEvent(event)
self._root.show_animation()
point = self._main_container.mapToGlobal(self.view.pos())
y_diff = self._main_container.combo_header_size
self.move(point.x(), point.y() + y_diff)
self.view.setFocus()
def hideEvent(self, event):
super(TabsHandler, self).hideEvent(event)
self._root.clear_model()
def next_item(self):
if not self.isVisible():
self.show()
self._root.next_item()
def previous_item(self):
if not self.isVisible():
self.show()
self._root.previous_item()
#.........这里部分代码省略.........