def main(): import sys app = QtWidgets.QApplication(sys.argv) panel = Project_name_get() panel.show() sys.exit(app.exec_())
def main(launch_args): # Be sure server won't crash at any moment but just print traceback sys.excepthook = safe_excepthook # Create QtApplication for tools # - QApplicaiton is also main thread/event loop of the server qt_app = QtWidgets.QApplication([]) # Execute pipeline installation api.install(tvpaint) # Create Communicator object and trigger launch # - this must be done before anything is processed communicator = CommunicationWrapper.create_communicator(qt_app) communicator.launch(launch_args) def process_in_main_thread(): """Execution of `MainThreadItem`.""" item = communicator.main_thread_listen() if item: item.execute() timer = QtCore.QTimer() timer.setInterval(100) timer.timeout.connect(process_in_main_thread) timer.start() # Register terminal signal handler def signal_handler(*_args): print("You pressed Ctrl+C. Process ended.") communicator.stop() signal.signal(signal.SIGINT, signal_handler) signal.signal(signal.SIGTERM, signal_handler) qt_app.setQuitOnLastWindowClosed(False) qt_app.setStyleSheet(style.load_stylesheet()) # Load avalon icon icon_path = get_icon_path() if icon_path: icon = QtGui.QIcon(icon_path) qt_app.setWindowIcon(icon) # Set application name to be able show application icon in task bar if platform.system().lower() == "windows": ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID( u"WebsocketServer") # Run Qt application event processing sys.exit(qt_app.exec_())
return "Blacklist" def _get_listed_machines(self): items = [ self.listed_machines.item(r) for r in range(self.listed_machines.count()) ] listed_machines = [i.text() for i in items] return listed_machines def launch(): global application toplevel_widgets = QtWidgets.QApplication.topLevelWidgets() mainwindow = next(widget for widget in toplevel_widgets if widget.objectName() == "MayaWindow") application = App(parent=mainwindow) application.show() if __name__ == '__main__': import sys app = QtWidgets.QApplication(sys.argv) test = App() test.show() app.exec_()
def application(): app = QtWidgets.QApplication(sys.argv) yield app.exec_()
import psutil from avalon.tools import loader from avalon.tools import workfiles from avalon.tools import publish from avalon.tools import creator import pyblish.api from avalon.vendor.Qt import QtWidgets from avalon import api import avalon.tvpaint #from avalon.vendor.Qt.QtNetwork import * import pytvpaint_avalon.functions as tvp import socketserver QT_APP = QtWidgets.QApplication.instance() or QtWidgets.QApplication([]) class MyRequestHandler(socketserver.BaseRequestHandler): """ The request handler class for our server. It is instantiated once per connection to the server, and must override the handle() method to implement communication to the client. """ def handle(self): # self.request is the TCP socket connected to the client self.data = self.request.recv(1024).strip() print(f"{self.client_address[0]} wrote: {self.data}") global QT_APP if self.data == b"START":