def forceFocus(self, cursorToo=True): # only force focus if window is viewable if not wutil.isViewable(self.top.winfo_id()): return # warp cursor # if no previous position, move to center gw = self.gwidget if gw: if gw.lastX is None or \ (gw.lastX == 0 and gw.lastY == 0): swCurObj = gw.getSWCursor() if swCurObj: gw.lastX = int(swCurObj.lastx*gw.winfo_width()) gw.lastY = int((1.-swCurObj.lasty)*gw.winfo_height()) else: gw.lastX = int(gw.winfo_width()/2.) gw.lastY = int(gw.winfo_height()/2.) if cursorToo: wutil.moveCursorTo(gw.winfo_id(), gw.winfo_rootx(), gw.winfo_rooty(), gw.lastX, gw.lastY) # On non-X, "focus_force()" places focus on the gwidget canvas, but # this may not have the global focus; it may only be the widget seen # when the application itself has focus. We may need to force the # app itself to have focus first, so we do that here too. wutil.forceFocusToNewWindow() gw.focus_force()
def __init__(self, filename=logo, text=None, textcolor="blue", **kw): # look for file in both local directory and this script's directory if not os.path.exists(filename): tfilename = os.path.join(os.path.dirname(__file__),filename) if not os.path.exists(tfilename): raise ValueError("Splash image `%s' not found" % filename) filename = tfilename self.filename = filename self.nlines = 1 self.textcolor = textcolor if text: if isinstance(text, type("")): text = text.split("\n") self.nlines = len(text) self.initialText = text else: self.initialText = [None] # put focus on this app (Mac only) self.__termWin = None if wutil.hasGraphics and wutil.WUTIL_ON_MAC: self.__termWin = wutil.getFocalWindowID() # the terminal window wutil.forceFocusToNewWindow() # create it SplashScreen.__init__(self, **kw) self.defaultCursor = self['cursor'] self.bind("<Button>", self.killCursor) self.bind("<ButtonRelease>", self.Destroy)
def __init__(self, filename=logo, text=None, textcolor="blue", **kw): # look for file in both local directory and this script's directory if not os.path.exists(filename): tfilename = os.path.join(os.path.dirname(__file__), filename) if not os.path.exists(tfilename): raise ValueError("Splash image `%s' not found" % filename) filename = tfilename self.filename = filename self.nlines = 1 self.textcolor = textcolor if text: if isinstance(text, type("")): text = text.split("\n") self.nlines = len(text) self.initialText = text else: self.initialText = [None] # put focus on this app (Mac only) self.__termWin = None if wutil.hasGraphics and wutil.WUTIL_ON_MAC: self.__termWin = wutil.getFocalWindowID() # the terminal window wutil.forceFocusToNewWindow() # create it SplashScreen.__init__(self, **kw) self.defaultCursor = self['cursor'] self.bind("<Button>", self.killCursor) self.bind("<ButtonRelease>", self.Destroy)
def epar(theTask, parent=None, isChild=0): if wutil is None or not wutil.hasGraphics: raise IrafError("Cannot run epar without graphics windows") if not isChild: oldFoc = wutil.getFocalWindowID() wutil.forceFocusToNewWindow() PyrafEparDialog(theTask, parent, isChild) if not isChild: wutil.setFocusTo(oldFoc)