def can_submit(self): """ Checks if it's possible to submit versions given the current context/environment. :returns: Flag telling if the hook can submit a version. :rtype: bool """ if not self.__create_client_module.is_create_installed(): QtGui.QMessageBox( QtGui.QMessageBox.Warning, "Cannot submit to Shotgun", "Shotgun Create is not installed!", flags=QtCore.Qt.Dialog | QtCore.Qt.MSWindowsFixedSizeDialogHint | QtCore.Qt.WindowStaysOnTopHint | QtCore.Qt.X11BypassWindowManagerHint, ).exec_() self.__create_client_module.open_shotgun_create_download_page( self.__app.sgtk.shotgun ) return False return True
def show_user_mismatch_popup(bundle, user_id): """ Display modal popup to inform user about user website/shotgun Create mismatch :param bundle: Bundle object :param user_id: Id of user requesting a connection """ # get current user details current_user = sgtk.util.get_current_user(bundle.sgtk) # get other user details user_details = bundle.shotgun.find_one("HumanUser", [["id", "is", user_id]], ["name"]) warning_msg = ( "A request was received from ShotGrid from user %s. ShotGrid " "Create is currently authenticated with user %s, so the " "request was rejected. You will need to log into ShotGrid " "Create as user %s in order to receive Toolkit menu actions " "or use local file linking for that user in ShotGrid." % (user_details["name"], current_user["name"], user_details["name"])) logger.warning(warning_msg) from sgtk.platform.qt import QtGui, QtCore msg_box = QtGui.QMessageBox(QtGui.QMessageBox.Warning, "Requesting User Not Authenticated", warning_msg) msg_box.setWindowFlags(msg_box.windowFlags() | QtCore.Qt.WindowStaysOnTopHint) msg_box.exec_()
def on_import_clicked(self): # Validate state if not self.state['project']: msg = QtGui.QMessageBox() msg.setText('You must select a project to import from.') msg.exec_() return if not self.state['environments']: msg = QtGui.QMessageBox() msg.setText('The project you have chosen has no Environments.') msg.exec_() return # Confirm import project = app.context.project['name'] response = QtGui.QMessageBox.question( self, 'Import Environments', ('Importing will replace all Environments in %s.\n' 'Are you sure you want to continue?') % project, QtGui.QMessageBox.Yes | QtGui.QMessageBox.No, ) if response == QtGui.QMessageBox.No: return app.info('Importing environments to %s...' % project) for env in app.io.get_environments(): app.info('Deleting %s - %s' % (env['id'], env['code'])) app.io.delete_environment(env['id']) for env in self.state['environments']: app.info('Importing %s' % env['code']) app.io.update_environment( code=env['code'], engine=env['sg_engine'], requires=env['sg_requires'], project=app.context.project, ) self.accept()
def _after_submit(self, ticket): msg = QtGui.QMessageBox() msg.setWindowIcon(QtGui.QIcon(res.get_path('icon_256.png'))) msg.setWindowTitle('Ticket Submitted') msg.setText('Your Ticket is #%s.' % ticket['id']) view_ticket = msg.addButton('View Ticket', msg.AcceptRole) msg.addButton('Okay', msg.AcceptRole) msg.exec_() if msg.clickedButton() == view_ticket: webbrowser.open(app.get_ticket_url(ticket['id']), new=2)
def messagebox_alert(self, mb_title, mb_message): """Pop up a message box alert when needed. Args: mb_title (str): A title for the message box. mb_message (str): The message for the message box. """ QtGui.QMessageBox( QtGui.QMessageBox.Warning, mb_title, mb_message, flags=QtCore.Qt.Dialog | QtCore.Qt.MSWindowsFixedSizeDialogHint | QtCore.Qt.WindowStaysOnTopHint | QtCore.Qt.X11BypassWindowManagerHint, ).exec_()
def pre_render( self, input_path, output_path, width, height, first_frame, last_frame, version, name, color_space, ): """ Callback executed before the media rendering :param str path: Path to the input frames for the movie :param str output_path: Path to the output movie that will be rendered :param int width: Width of the output movie :param int height: Height of the output movie :param int first_frame: The first frame of the sequence of frames. :param int last_frame: The last frame of the sequence of frames. :param int version: Version number to use for the output movie slate and burn-in :param str name: Name to use in the slate for the output movie :param str color_space: Colorspace of the input frames :returns: Location of the rendered media :rtype: str """ engine = sgtk.platform.current_engine() if not engine.adobe.get_active_document(): QtGui.QMessageBox( QtGui.QMessageBox.Warning, "Unable to render", "No active document found.", flags=QtCore.Qt.Dialog | QtCore.Qt.MSWindowsFixedSizeDialogHint | QtCore.Qt.WindowStaysOnTopHint | QtCore.Qt.X11BypassWindowManagerHint, ).exec_() raise RuntimeError("No active document found.")
def show_message(self, msg, level="info"): """ Displays a dialog with the message according to the severity level specified. """ from sgtk.platform.qt import QtGui, QtCore level_icon = { "info": QtGui.QMessageBox.Information, "error": QtGui.QMessageBox.Critical, "warning": QtGui.QMessageBox.Warning, } dlg = QtGui.QMessageBox() dlg.setIcon(level_icon[level]) dlg.setText(msg) dlg.setWindowTitle(ENGINE_NICE_NAME) dlg.setWindowFlags(dlg.windowFlags() | QtCore.Qt.WindowStaysOnTopHint) dlg.show() dlg.exec_()
def show_site_mismatch_popup(bundle, site_url): """ Display modal popup to inform user about site website/shotgun Create mismatch :param bundle: Bundle object :param site_url: Url of site requesting a connection """ warning_msg = ( "A request was received from %s. ShotGrid Create is currently not logged into " "that site, so the request has been rejected. You will need to log into %s from " "ShotGrid Create in order to see Toolkit menu actions or make use of local file " "linking on that ShotGrid site." % (site_url, site_url)) logger.warning(warning_msg) from sgtk.platform.qt import QtGui, QtCore msg_box = QtGui.QMessageBox(QtGui.QMessageBox.Warning, "Not Authenticated", warning_msg) msg_box.setWindowFlags(msg_box.windowFlags() | QtCore.Qt.WindowStaysOnTopHint) msg_box.exec_()
def can_submit(self): """ Checks if it's possible to submit versions given the current context/environment. :returns: Flag telling if the hook can submit a version. :rtype: bool """ if not self._upload_to_shotgun and not self._store_on_disk: QtGui.QMessageBox( QtGui.QMessageBox.Warning, "Cannot submit to Shotgun", "Application is not configured to store images on disk or upload to shotgun!", flags=QtCore.Qt.Dialog | QtCore.Qt.MSWindowsFixedSizeDialogHint | QtCore.Qt.WindowStaysOnTopHint | QtCore.Qt.X11BypassWindowManagerHint, ).exec_() return False return True
def show_message(self, msg, level="info"): """ Displays a dialog with the message according to the severity level specified. """ if self._qt_app_central_widget: from sgtk.platform.qt import QtGui, QtCore level_icon = { "info": QtGui.QMessageBox.Information, "error": QtGui.QMessageBox.Critical, "warning": QtGui.QMessageBox.Warning, } dlg = QtGui.QMessageBox(self._qt_app_central_widget) dlg.setIcon(level_icon[level]) dlg.setText(msg) dlg.setWindowTitle("Shotgun Harmony Engine") dlg.setWindowFlags(dlg.windowFlags() | QtCore.Qt.WindowStaysOnTopHint) dlg.show() dlg.exec_()
def _confirm_action_on_deprecated(self, action_name): """ Confirms that the user really wants to do an action on a deprecated file. :param action_name: The name of the action requested. :returns: If the action should be done or not """ box = QtGui.QMessageBox() box.setText("Loading a Deprecated File") box.setInformativeText( "You are about to %s a deprecated file. Do you really want to %s it?" % (action_name, action_name)) box.setIcon(QtGui.QMessageBox.Warning) accept = box.addButton(action_name.capitalize(), QtGui.QMessageBox.YesRole) cancel = box.addButton(QtGui.QMessageBox.Cancel) box.setDefaultButton(cancel) box.exec_() return box.clickedButton() == accept
def execute(self, parent_ui): """ Perform a new-scene operation initialized with the current context. :param parent_ui: Parent dialog executing this action. """ if not NewFileAction.can_do_new_file(self._environment): # should never get here as the new button in the UI should # be disabled! return False try: # create folders and validate that we can save using the work template: try: # create folders if needed: FileAction.create_folders_if_needed( self._environment.context, self._environment.work_template) # and double check that we can get all context fields for the work template: self._environment.context.as_template_fields( self._environment.work_template, validate=True) except TankError as tank_error: self._app.log_exception( "Unable to resolve template fields after folder creation!") error_title = "Failed to complete '{}' action".format( self.label) error_text = "{title}:\n\n{body}".format( title=error_title, body= ("Unable to resolve template fields after folder creation! This could mean " "there is a mismatch between your folder schema and templates. Please " "contact us via {} if you need help fixing this.".format( support_url)), ) error_details = str(tank_error) msg_box = QtGui.QMessageBox( QtGui.QMessageBox.Information, error_title, error_text, QtGui.QMessageBox.Ok, parent_ui, ) msg_box.setDefaultButton(QtGui.QMessageBox.Ok) if error_details: msg_box.setDetailedText(error_details) msg_box.exec_() return False else: # reset the current scene: if not reset_current_scene(self._app, NEW_FILE_ACTION, self._environment.context): self._app.log_debug( "Unable to perform New Scene operation after failing to reset scene!" ) return False # prepare the new scene: prepare_new_scene(self._app, NEW_FILE_ACTION, self._environment.context) if not self._environment.context == self._app.context: # Change context FileAction.change_context(self._environment.context) except Exception as e: error_title = "Failed to complete '%s' action" % self.label QtGui.QMessageBox.information(parent_ui, error_title, "%s:\n\n%s" % (error_title, e)) self._app.log_exception(error_title) return False else: try: self._app.log_metric("New Workfile") except: # ignore all errors. ex: using a core that doesn't support metrics pass return True
def __init__(self): self.name = os.path.splitext(os.path.basename(__file__))[0] self.mbox = QtGui.QMessageBox()
from sgtk.platform.qt import QtGui mbox = QtGui.QMessageBox() def get_media_panel_custom_ui_actions(): menu = { 'name': 'Test:', 'actions': [ { 'name': 'test1', 'execute': test1 }, { 'name': 'test2', 'execute': test2 }, { 'name': 'test3', 'execute': test3 }, { 'name': 'test4', 'execute': test4 }, { 'name': 'test5', 'execute': test5 }, {