def WpyPhysHandleConfigure(tkname, x, y, w, h, send): # Handle Configure events. These happen on resize or window move. # Only used for toplevel windows since the user can not resize child windows. # Only the size is used, so we can generate a size event on a resize by the user. # NOTE: Window location is invalid (unless "send" is "1" ???). self = wpyphysNamesToPhys[tkname] self.wpyLocX = string.atoi(x) self.wpyLocY = string.atoi(y) if self.wpyphysTopSizeX < 0: return w = string.atoi(w) h = string.atoi(h) if not self.wpyHasResize: self.wpyphysTopSizeX = w self.wpyphysTopSizeY = h wpyphysTk.call("wm", "geometry", self.wpyphysTopName, "") elif (self.wpyphysTopSizeX != w) or (self.wpyphysTopSizeY != h): event = wpy.WpyEvent() event.wpyNewSizeX = w event.wpyNewSizeY = h event.wpyOldSizeX = self.wpyphysTopSizeX event.wpyOldSizeY = self.wpyphysTopSizeY event.wpyChangeSizeX = w - event.wpyOldSizeX event.wpyChangeSizeY = h - event.wpyOldSizeY print "New resize", self, w, h self.wpyphysTopSizeX = w self.wpyphysTopSizeY = h self.WpySendSizeEvent(event)
def WpyPhysHandleMouse(tkname, eventtype, button, locx, locy, state): # Handle mouse events. These can only be sent to a toplevel or # child window, not to a dialog. try: self = wpyphysNamesToPhys[tkname] except KeyError: return x = string.atoi(locx) y = string.atoi(locy) while not self.wpyFlags & wpy.wpyFlagsWindow: # Find the window if self.wpyParent == None: # We are up to "App". return x = x + self.wpyLocX # Convert to parent coordinates. y = y + self.wpyLocY self = self.wpyParent if self.wpyFlags & wpy.wpyFlagsDialog: # No mouse for dialog. return event = wpy.WpyEvent() event.wpyType = eventtype state = string.atoi(state) event.wpyPressed = state >> 8 event.wpyButton = string.atoi(button) event.wpyLocX = x event.wpyLocY = y event.wpyShift = state & _wpyphysStateShift event.wpyControl = state & _wpyphysStateControl # Generate appropriate call for function or method. if type(self.WpyOnMouse) == wpyphysTypeMeth: self.WpyOnMouse(event) else: self.WpyOnMouse(self, event)
def WpyPhysHandleClose(tkname): try: self = wpyphysNamesToPhys[tkname] except KeyError: return event = wpy.WpyEvent() # Generate appropriate call for function or method. if type(self.WpyOnClose) == wpyphysTypeMeth: self.WpyOnClose(event) else: self.WpyOnClose(self, event)
def WpyPhysHandleFocus(tkname, focusin, detail): try: self = wpyphysNamesToPhys[tkname] except KeyError: return if detail == "NotifyVirtual": event = wpy.WpyEvent() event.wpyFocusIn = string.atoi(focusin) # Generate appropriate call for function or method. if type(self.WpyOnFocus) == wpyphysTypeMeth: self.WpyOnFocus(event) else: self.WpyOnFocus(self, event)
def WpyPhysHandleHScroll(tkname, pos): self = wpyphysNamesToPhys[tkname] pos = string.atoi(pos) t = self.wpyHScrollSize - self.wpyHScrollWinSize if pos > t: pos = t if pos < 0: pos = 0 event = wpy.WpyEvent() event.wpyScrollPos = pos # Generate appropriate call for function or method. if type(self.WpyOnHScroll) == wpyphysTypeMeth: self.WpyOnHScroll(event) else: self.WpyOnHScroll(self, event)
def WpyPhysHandleButton(tkname): # Handle button press events. try: self = wpyphysNamesToPhys[tkname] except KeyError: return event = wpy.WpyEvent() if self.__dict__.has_key("wpyPhysIvar"): self.wpyButtonValue = string.atoi( wpyphysTk.globalgetvar(self.wpyPhysIvar)) elif self.__dict__.has_key("wpyPhysVarName"): self.wpyGroup.wpyButtonValue = wpyphysNamesToPhys[ wpyphysTk.globalgetvar(self.wpyPhysVarName)] # Generate appropriate call for function or method. if type(self.WpyOnButton) == wpyphysTypeMeth: self.WpyOnButton(event) else: self.WpyOnButton(self, event)
def WpyPhysHandleChar(tkname, keyname, keynum, keyascii, state): try: self = wpyphysNamesToPhys[tkname] except KeyError: return keynum = string.atoi(keynum) if keynum >= 32 and keynum <= 127: pass elif keyname == "Return": if self.wpyDefaultButton != None: WpyPhysHandleButton(self.wpyDefaultButton.wpyphysTkName) return keynum = 13 keyascii = "\r" else: return event = wpy.WpyEvent() event.wpyKeyNum = keynum event.wpyKeyASCII = keyascii # Generate appropriate call for function or method. if type(self.WpyOnChar) == wpyphysTypeMeth: self.WpyOnChar(event) else: self.WpyOnChar(self, event)