本文整理汇总了Python中PyQt5.QtGui.QGuiApplication类的典型用法代码示例。如果您正苦于以下问题:Python QGuiApplication类的具体用法?Python QGuiApplication怎么用?Python QGuiApplication使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QGuiApplication类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, qml):
app = QGuiApplication(sys.argv)
model = QmlModel()
model.register()
qmlUrl = QUrl(qml)
assert qmlUrl.isValid()
print(qmlUrl.path())
# assert qmlUrl.isLocalFile()
"""
Create an engine a reference to the window?
window = QuickWindowFactory().create(qmlUrl=qmlUrl)
window.show() # visible
"""
engine = QQmlApplicationEngine()
"""
Need this if no stdio, i.e. Android, OSX, iOS.
OW, qWarnings to stdio.
engine.warnings.connect(self.errors)
"""
engine.load(qmlUrl)
engine.quit.connect(app.quit)
app.exec_() # !!! C exec => Python exec_
print("Application returned")
示例2: start
def start():
app = QGuiApplication(sys.argv)
ui = DefaultUI()
ui.gamesList.gameChanged.connect(test2)
ui.platformSelector.platformChanged.connect(test)
ui.show()
sys.exit(app.exec_())
示例3: main
def main():
print("start")
app = QGuiApplication(sys.argv)
engine = QQmlApplicationEngine()
engine.load(QUrl("main.qml"))
engine.rootObjects()[0].show()
sys.exit(app.exec_())
示例4: main
def main():
app = QGuiApplication(sys.argv)
qmlRegisterType(MainController, 'MainController', 1, 0, 'MainController')
qmlRegisterType(ProfileViewModel, 'ProfileViewModel', 1, 0, 'ProfileViewModel')
engine = QQmlApplicationEngine()
main_controller = MainController()
main_controller.profile_selection_changed(0)
engine.rootContext().setContextProperty('mainController', main_controller)
engine.load(QUrl.fromLocalFile(pkg_resources.resource_filename('yarg.resource', 'main.qml')))
sys.exit(app.exec_())
示例5: onClipboardChanged
def onClipboardChanged(self, mode):
if mode == QClipboard.Clipboard:
if not QGuiApplication.clipboard().ownsClipboard():
self.clipboardTimer.start()
else:
self.clipboardTimer.stop()
elif mode == QClipboard.Selection:
if not QGuiApplication.clipboard().ownsSelection():
self.selectionTimer.start()
else:
self.selectionTimer.stop()
示例6: handle_click
def handle_click(self, reason):
if reason != QSystemTrayIcon.Trigger:
return
QGuiApplication.primaryScreen().grabWindow(0).save('scr.jpg', 'jpg')
ssh = SSHClient()
ssh.load_system_host_keys()
ssh.connect(hostname=self.ssh_hostname, port=self.ssh_port, username=self.ssh_username)
scp = SCPClient(ssh.get_transport())
dest_name = time.strftime("screenshot_%Y%m%d_%H%M%S.jpg", time.localtime())
scp.put('scr.jpg', self.ssh_remote_path + '/' + dest_name)
示例7: setGrabbing
def setGrabbing(self, grabbing):
if(self._grabbing != grabbing):
self._grabbing = grabbing
if(self._grabbing):
self.installEventFilter(self._colorPickingEventFilter)
QGuiApplication.setOverrideCursor(QCursor(QtCore.Qt.CrossCursor))
self.grabMouse()
else:
self.ungrabMouse()
self.removeEventFilter(self._colorPickingEventFilter)
QGuiApplication.restoreOverrideCursor()
self.grabbingChanged.emit()
示例8: updateCurrentColor
def updateCurrentColor(self):
cursorPos = QCursor.pos()
# Catch the pixel pointed by the mouse on a pixmap
pixmap = QGuiApplication.screens()[self._desktop.screenNumber()].grabWindow(self._desktop.winId(), cursorPos.x(), cursorPos.y(), 1, 1)
qImage = pixmap.toImage()
qColor = QColor(qImage.pixel(0, 0))
self.setCurrentColor(qColor)
示例9: handleCursorPositionChanged
def handleCursorPositionChanged(self):
cursor = self.textCursor()
# update block format toolbar
blockFmt = cursor.blockFormat()
blockStyle = blockFmt.property(QTextFormat.UserProperty)
self.updateBlockFormat.emit(blockStyle)
# update text format toolbar
charFmt = cursor.charFormat() # get the QTextCharFormat at the current cursor position
charStyle = charFmt.property(QTextFormat.UserProperty)
self.updateCharFormat.emit(charStyle)
# open/close URL editor for external links
if charStyle and charStyle[0] == 'link':
if not (QGuiApplication.keyboardModifiers() & Qt.ControlModifier):
url = charFmt.anchorHref()
# get global cursor position
pos = self.cursorRect()
pos = pos.bottomLeft()
pos = self.viewport().mapToGlobal(pos)
self.l.move(pos)
self.l.setUrl(url)
self.l.show()
else:
self.l.hide()
示例10: __init__
def __init__(self):
self._controller = Controller(self)
self._gui = QGuiApplication(sys.argv)
self._qml_dir = os.path.dirname(os.path.realpath(__file__))
self._main = QQuickView()
self._main.setResizeMode(QQuickView.SizeRootObjectToView)
self._main.setSource(QUrl(self._qml_dir + "/main.qml"))
self._main.rootObject().create_node.connect(self._controller.create_node)
self._main.rootObject().mouse_position.connect(self._controller.mouse_position)
self._main.rootObject().save.connect(self._controller.save)
self._main.rootObject().load.connect(self._controller.load)
self._main.rootObject().lose_focus.connect(self._controller.lose_focus)
self._main.rootObject().node_color_sel.connect(self._controller.node_color_sel)
self._main.rootObject().edge_color_sel.connect(self._controller.edge_color_sel)
self._main.rootObject().workspace_size_changed.connect(self._controller.window_resize)
self._main.rootObject().edge_type_sel.connect(self._controller.edge_type_sel)
self._main.rootObject().node_shape_sel.connect(self._controller.node_shape_sel)
self._main.rootObject().clear_workspace.connect(self._controller.clear_workspace)
self._main.rootObject().node_width_changed.connect(self._controller.node_width_changed)
self._main.rootObject().node_height_changed.connect(self._controller.node_height_changed)
self._main.rootObject().node_text_color_sel.connect(self._controller.node_text_color_sel)
self._main.rootObject().node_text_size_changed.connect(self._controller.node_text_size_changed)
self._main.rootObject().edge_thickness_changed.connect(self._controller.edge_thickness_changed)
self._main.rootObject().show_edge_controls.connect(self._controller.show_edge_controls)
self._main.rootObject().hide_edge_controls.connect(self._controller.hide_edge_controls)
self._main.rootObject().exporting.connect(self._controller.exporting)
self._main.setProperty("width", self._controller.project.workspace_width)
self._main.setProperty("height", self._controller.project.workspace_height)
self._main.show()
示例11: __init__
def __init__(self, config_dict):
super().__init__()
self.config_dict = config_dict
self.clipboard = QGuiApplication.clipboard()
self.reconstruct = enable_rhc(config_dict["random_hit_chance"])(
self.reconstruct
)
self.clipboard.dataChanged.connect(self.reconstruct)
示例12: emitChanged
def emitChanged(self, mode):
clipboard = QGuiApplication.clipboard()
mimeData = clipboard.mimeData()
data = {}
for format in self.formats:
if mimeData.hasFormat(format):
data[format] = mimeData.data(format)
self.changed.emit(data)
示例13: main
def main(argv):
a = QGuiApplication(argv)
a.setOrganizationDomain("mapeditor.org")
a.setApplicationName("TmxRasterizer")
a.setApplicationVersion("1.0")
options = CommandLineOptions()
parseCommandLineArguments(options)
if (options.showVersion):
showVersion()
return 0
if (options.showHelp or options.fileToOpen=='' or options.fileToSave==''):
showHelp()
return 0
if (options.scale <= 0.0 and options.tileSize <= 0):
showHelp()
return 0
w = TmxRasterizer()
w.setAntiAliasing(options.useAntiAliasing)
w.setIgnoreVisibility(options.ignoreVisibility)
w.setLayersToHide(options.layersToHide)
if (options.tileSize > 0):
w.setTileSize(options.tileSize)
elif (options.scale > 0.0):
w.setScale(options.scale)
return w.render(options.fileToOpen, options.fileToSave)
示例14: __init__
def __init__(self, parent = None):
super().__init__(parent)
self.app = QGuiApplication.instance()
self._queue = deque()
self.frontendpy = parent
self._listener = threading.Thread(target = self.listenerThread, daemon = True,
name = "frontend communication listener")
self._listener.start()
tasks = sys.argv[1:]
if tasks:
self.createTasksAction(tasks)
self.urlExtractor = UrlExtractor(self)
self._clipboard = QGuiApplication.clipboard()
self.app.settings.applySettings.connect(self.slotWatchClipboardToggled)
示例15: __init__
def __init__(self, parent = None):
super().__init__(parent)
# set cache
self._cachePath = QNetworkDiskCache(self)
cacheLocation = QGuiApplication.instance().settings.get("frontend", "cachelocation")
self._cachePath.setCacheDirectory(cacheLocation)
self._cachePath.setMaximumCacheSize(20 * 1024 * 1024) # 20M
self.setCache(self._cachePath)