from PyQt5.QtCore import QUrl, QThread, pyqtSignal, QObject, pyqtSlot, Qt from PyQt5.QtWidgets import QApplication, QTabBar from PyQt5.QtQuick import QQuickView, QQuickItem, QQuickWindow from PyQt5.QtQml import QQmlApplicationEngine from PyQt5.QtGui import QGuiApplication, QKeyEvent import IrcHandler class IrcWindow(QQuickWindow): def __init__(self, view): super(self.__class__, self).__init__() self.view = view self.handler = IrcHandler.IrcHandler(self) self.dumpQMLComponents(self.view) self.connect_button = self.view.findChild(QQuickItem, "connect_button") self.send_button = self.view.findChild(QQuickItem, "send_button") self.input_field = self.view.findChild(QQuickItem, "input") self.chat_area = self.view.findChild(QQuickItem, "chat_area") self.nick_list = self.view.findChild(QQuickItem, "nick_list") self.channel_tabs = self.view.findChild(QQuickItem, "channel_tabs") self.send_button.clicked.connect(self.handle_input) self.connect_button.clicked.connect(self.connect_to_irc) self.input_field.send_to_irc.connect(self.handle_input) def connect_to_irc(self): self.handler.connect_to_irc(self) def handle_input(self): self.handler.handle_input() def get_input(self, channel): print(channel) channel_tab = self.view.findChild(QQuickItem, "channel-" + channel) channel_input = channel_tab.findChild(QQuickItem, "input") return channel_input.property("text") def reset_input(self, channel): channel_tab = self.view.findChild(QQuickItem, "channel-" + channel) channel_input = channel_tab.findChild(QQuickItem, "input") channel_input.setProperty("text", "") @pyqtSlot(str) def update_chat(self, channel, text): channel_tab = self.view.findChild(QQuickItem, "channel-" + channel) channel_chat_area = channel_tab.findChild(QQuickItem, "chat_area") channel_chat_area.append(text) def update_topic(self, channel, topic): print(channel.get_view()) topic_field = channel.get_view().findChild(QQuickItem, "topic") topic_field.setProperty("text", topic) def dumpQMLComponents(self, root): children = root.findChildren(QObject) for item in children: print(item, item.objectName())