def __init__(self,parent): x,y,w,h = self.CalcSizePos(parent) wx.Window.__init__(self,id = -1,parent = parent, pos = wxPoint(x,y), size = wx.Size(w,h), style = wx.CLIP_CHILDREN) self.down = False self.entered = False wx.EVT_LEFT_DOWN(self,self.OnPress) wx.EVT_LEFT_UP(self,self.OnRelease) wx.EVT_PAINT(self,self.OnPaint) wx.EVT_LEAVE_WINDOW(self,self.OnLeave) wx.EVT_ENTER_WINDOW(self,self.OnEnter)
def __init__(self, parent, id=-1, image=None, tailleCadre=(384, 384)): wx.Window.__init__(self, parent, -1, wx.DefaultPosition, wx.DefaultSize, wx.NO_FULL_REPAINT_ON_RESIZE |wx.SUNKEN_BORDER) self.tailleCadre = tailleCadre self.fichierImageSource = image self.InitImage() # Binds wx.EVT_PAINT(self, self.evt_paint) wx.EVT_SIZE(self, self.evt_size) wx.EVT_KEY_DOWN(self, self.evt_key) wx.EVT_LEFT_DOWN(self, self.evt_mouse) wx.EVT_LEFT_UP(self, self.evt_mouse) wx.EVT_MOTION(self, self.evt_mouse) wx.EVT_LEAVE_WINDOW(self, self.OnLeaveWindow)
def OnInit(self): wx.InitAllImageHandlers() self.frame = TopFrame(None, -1, "", bitmapFile=self.bitmapFile) self.SetTopWindow(self.frame) self.frame.Show() self.frame.Center() self.SetTopWindow(self.frame) self.ID_Timer = wx.NewId() self.timer = wx.Timer(self, self.ID_Timer) wx.EVT_TIMER(self, self.ID_Timer, self.end) wx.EVT_LEFT_UP(self, self.mouse_action) wx.EVT_RIGHT_UP(self, self.mouse_action) wx.EVT_MIDDLE_UP(self, self.mouse_action) self.timer.Start(self.delay) return True
def __init__(self, *args, **kwds): # begin wxGlade: WaveformView.__init__ kwds["style"] = wx.BORDER_SUNKEN | wx.TAB_TRAVERSAL wx.ScrolledWindow.__init__(self, *args, **kwds) self.__set_properties() self.__do_layout() # end wxGlade # test for wxPython type cdc = wx.ClientDC(self) self.isWxPhoenix = False if not "SetClippingRect" in dir(cdc): self.isWxPhoenix = True # Other initialization self.doc = None self.maxWidth = 1 self.maxHeight = 1 self.isDragging = False self.basicScrubbing = False self.curFrame = 0 self.oldFrame = 0 self.buffer = None self.clipRect = None self.sampleWidth = defaultSampleWidth self.samplesPerFrame = defaultSamplesPerFrame self.samplesPerSec = 24 * self.samplesPerFrame self.frameWidth = self.sampleWidth * self.samplesPerFrame self.phraseBottom = 16 self.wordBottom = 32 self.phonemeTop = 128 # Connect event handlers # window events wx.EVT_PAINT(self, self.OnPaint) wx.EVT_SIZE(self, self.OnSize) # mouse events wx.EVT_LEFT_DOWN(self, self.OnMouseDown) wx.EVT_RIGHT_DOWN(self, self.OnMouseDown) wx.EVT_LEFT_DCLICK(self, self.OnMouseDown) wx.EVT_LEFT_UP(self, self.OnMouseUp) wx.EVT_RIGHT_UP(self, self.OnMouseUp) wx.EVT_MOTION(self, self.OnMouseMove) wx.EVT_MOUSEWHEEL(self, self.OnMouseWheel) # Force an update self.OnSize()
def __init__(self, parent, id, pos, rDevice): wx.Window.__init__(self,parent,id,pos,size=(1024,600)) #self.SetBackgroundColour() self.PngFile = "screenshot.png" self.remoteDevice=rDevice #Update Timer self.timerUpdate = wx.Timer(self) self.timerUpdate.Start(5000, False) #install event handler wx.EVT_PAINT(self, self.OnPaint) wx.EVT_LEFT_DOWN(self, self.OnMouse) wx.EVT_LEFT_UP(self, self.OnMouse) #wx.EVT_MOTION(self, self.OnMouse) self.Bind(wx.EVT_TIMER, self.OnTimeOut, self.timerUpdate)
def __init__(self, parent, start=None, end=None): self._start = start or datetime.datetime.combine( datetime.datetime.now().date(), datetime.time(0, 0, 0)) self._end = end or self._start + datetime.timedelta(days=7) super(CalendarCanvas, self).__init__(parent, wx.ID_ANY, style=wx.FULL_REPAINT_ON_RESIZE) self._coords = dict( ) # Event => (startIdx, endIdx, startIdxRecursive, endIdxRecursive, yMin, yMax) self._maxIndex = 0 self._minSize = (0, 0) # Drawing attributes self._precision = 1 # Minutes self._gridSize = 15 # Minutes self._eventHeight = 32.0 self._eventWidthMin = 0.1 self._eventWidth = 0.1 self._margin = 5.0 self._marginTop = 22.0 self._outlineColorDark = wx.Colour(180, 180, 180) self._outlineColorLight = wx.Colour(210, 210, 210) self._headerSpans = [] self._daySpans = [] self._selection = set() self._mouseState = self.MS_IDLE self._mouseOrigin = None self._mouseDragPos = None self._todayColor = wx.Colour(0, 0, 128) self._hScroll = wx.ScrollBar(self, wx.ID_ANY, style=wx.SB_HORIZONTAL) self._vScroll = wx.ScrollBar(self, wx.ID_ANY, style=wx.SB_VERTICAL) self._hScroll.Hide() self._vScroll.Hide() wx.EVT_SCROLL(self._hScroll, self._OnScroll) wx.EVT_SCROLL(self._vScroll, self._OnScroll) wx.EVT_PAINT(self, self._OnPaint) wx.EVT_SIZE(self, self._OnResize) wx.EVT_LEFT_DOWN(self, self._OnLeftDown) wx.EVT_LEFT_UP(self, self._OnLeftUp) wx.EVT_RIGHT_DOWN(self, self._OnRightDown) wx.EVT_MOTION(self, self._OnMotion) self._Invalidate()
def __init__(self, parent, ID, clientProfile, sharedAppClient): wx.Window.__init__(self, parent, ID, style=wx.NO_FULL_REPAINT_ON_RESIZE) ## Attributes self.clientProfile = clientProfile self.user = self.clientProfile.GetName() self.sharedAppClient = sharedAppClient self.id = self.sharedAppClient.GetPublicId() # <AGtk code> # Register event callback self.sharedAppClient.RegisterEventCallback(events.DRAWING_EVENT, self.GetDrawingEvent) # <AGtk code> """ Background image & Cursor icon """ self.backImage = None self.SetCursor(wx.StockCursor(wx.CURSOR_CROSS)) self.SetBackgroundColour("WHITE") self.listeners = [] self.thickness = 1 self.SetColour("Black") self.lines = [] self.x = self.y = 0 self.MakeMenu() self.InitBuffer() # hook some mouse events wx.EVT_LEFT_DOWN(self, self.OnLeftDown) wx.EVT_LEFT_UP(self, self.OnLeftUp) wx.EVT_RIGHT_UP(self, self.OnRightUp) wx.EVT_MOTION(self, self.OnMotion) # the window resize event and idle events for managing the buffer wx.EVT_SIZE(self, self.OnSize) wx.EVT_IDLE(self, self.OnIdle) # and the refresh event wx.EVT_PAINT(self, self.OnPaint) # When the window is destroyed, clean up resources. wx.EVT_WINDOW_DESTROY(self, self.Cleanup)
def __init__(self,parent,side): self.side = side x,y,w,h = self.CalcSizePos(parent) wx.Window.__init__(self,id = -1,parent = parent, pos = wxPoint(x,y), size = wx.Size(w,h), style = wx.CLIP_CHILDREN) self.px = None # Previous X self.py = None # Previous Y self.isDrag = False # In Dragging wx.EVT_LEAVE_WINDOW(self,self.OnLeave) wx.EVT_ENTER_WINDOW(self,self.OnEnter) wx.EVT_MOTION(self,self.OnMouseMove) wx.EVT_LEFT_DOWN(self,self.OnPress) wx.EVT_LEFT_UP(self,self.OnRelease) wx.EVT_PAINT(self,self.OnPaint)
def __init__(self, *args, **kwds): # begin wxGlade: WaveformView.__init__ kwds["style"] = wx.SUNKEN_BORDER | wx.TAB_TRAVERSAL wx.ScrolledWindow.__init__(self, *args, **kwds) self.__set_properties() self.__do_layout() # end wxGlade # Other initialization self.doc = None self.currentVoice = None self.maxWidth = 1 self.maxHeight = 1 self.isDragging = False self.basicScrubbing = False self.curFrame = 0 self.oldFrame = 0 self.buffer = None self.clipRect = None self.sampleWidth = defaultSampleWidth self.samplesPerFrame = defaultSamplesPerFrame self.samplesPerSec = 24 * self.samplesPerFrame self.frameWidth = self.sampleWidth * self.samplesPerFrame self.phraseBottom = 16 self.wordBottom = 32 self.phonemeTop = 128 self.voice = None # Connect event handlers # window events wx.EVT_PAINT(self, self.OnPaint) wx.EVT_SIZE(self, self.OnSize) # mouse events wx.EVT_LEFT_DOWN(self, self.OnMouseDown) wx.EVT_RIGHT_DOWN(self, self.OnMouseDown) wx.EVT_LEFT_DCLICK(self, self.OnMouseDown) wx.EVT_LEFT_UP(self, self.OnMouseUp) wx.EVT_RIGHT_UP(self, self.OnMouseUp) wx.EVT_MOTION(self, self.OnMouseMove) # Force an update self.OnSize()
def _init_ctrls(self, prnt): # generated method, don't edit wx.Panel.__init__(self, id=wxID_CONSOLECLASS, name='', parent=prnt, # pos=wx.Point(355, 226), size=wx.Size(604, 339), pos=wx.Point(0, 350), size=wx.Size(604, 339), style=wx.MAXIMIZE_BOX | wx.TAB_TRAVERSAL) self._init_utils() self.SetClientSize(wx.Size(596, 315)) self.SetAutoLayout(True) self.Console = wx.TextCtrl(id=wxID_CONSOLECLASSCONSOLE, name='Console', parent=self, pos=wx.Point(0, 0), size=wx.Size(596, 315), style=wx.TE_MULTILINE, value='') self.Console.SetFont(wx.Font(12, wx.MODERN, wx.NORMAL, wx.NORMAL, false,'')) self.Console.SetConstraints(LayoutAnchors(self.Console, True, True, True, True)) wx.EVT_CHAR(self.Console, self.OnconsoleChar) wx.EVT_RIGHT_DOWN(self.Console, self.OnConsoleRightDown) wx.EVT_LEFT_UP(self.Console, self.OnConsoleLeftUp)
def __init__(self,parent): glcanvas.GLCanvas.__init__(self, parent, -1) self.init = False self.width = 0 self.height = 0 self.zoom = 50.0 self.minZoom = 5.0 self.maxZoom = 400.0 self.lookingAtX = 0 self.lookingAtY = 0 self.lookingAtZ = 0 self.viewAngleSky = 50.0 self.viewAngleFloor = 90.0 self.angleSpeed = 3.0 self.viewX = 0 self.viewY = 0 self.viewZ = 0 self.point = Numeric.zeros((1,4),typecode=Numeric.Float) self.clearCache() self.frustum = [] self.viewMatrixInv = Numeric.identity(4,Numeric.Float) self.modelMatrix = None self.currentModelView = None self.redrawRequested = False self.preprocessed = False self.preprocessing = False wx.EVT_ERASE_BACKGROUND(self, self.OnEraseBackground) wx.EVT_SIZE(self, self.OnSize) wx.EVT_PAINT(self, self.OnPaint) wx.EVT_LEFT_DOWN(self, self.OnMouseDown) wx.EVT_LEFT_UP(self, self.OnMouseUp) wx.EVT_MOTION(self, self.OnMouseMotion) wx.EVT_MOUSEWHEEL(self, self.OnMouseWheel) wx.EVT_KEY_DOWN(self, self.OnKeyDown) wx.EVT_KEY_UP(self,self.OnKeyUp)
def init(self, parent): """ Finishes initializing the editor by creating the underlying toolkit widget. """ factory = self.factory evaluate = factory.evaluate if evaluate is None: handler = self.object.trait(self.name).handler evaluate = getattr(handler, 'evaluate', None) if evaluate is None: evaluate = _Identity() self.evaluate = evaluate self.sync_value(factory.evaluate_name, 'evaluate', 'from') padding_x = padding_y = 0 if factory.theme is not None: slice = self.image_slice padding_x = slice.xleft + slice.xright padding_y = slice.xtop + slice.xbottom self.control = control = wx.Window( parent, -1, size=wx.Size(padding_x + 70, padding_y + 20), style=wx.FULL_REPAINT_ON_RESIZE | wx.WANTS_CHARS) self._text_size = None # Set up the painting event handlers: wx.EVT_ERASE_BACKGROUND(control, self._erase_background) wx.EVT_PAINT(control, self._on_paint) wx.EVT_CHAR(control, self._inactive_key_entered) # Handle 'focus' events: wx.EVT_SET_FOCUS(control, self._set_focus) wx.EVT_LEFT_UP(control, self._set_focus) # Handle 'resize' events: wx.EVT_SIZE(control, self._resize) self.set_tooltip()
def __init__(self, parent): attribs = (glcanvas.WX_GL_RGBA, glcanvas.WX_GL_DOUBLEBUFFER, glcanvas.WX_GL_DEPTH_SIZE, 24) glcanvas.GLCanvas.__init__(self, parent, -1, attribList=attribs) self.context = glcanvas.GLContext(self) self.parent = parent #Camera state variables self.size = self.GetClientSize() #self.camera = MouseSphericalCamera(self.size.x, self.size.y) self.camera = MousePolarCamera(self.size.width, self.size.height) #Main state variables self.MousePos = [0, 0] self.bbox = BBox3D() #Face mesh variables and manipulation variables self.mesh = None self.meshCentroid = None self.displayMeshFaces = True self.displayMeshEdges = False self.displayBoundary = False self.displayMeshVertices = True self.displayVertexNormals = False self.displayFaceNormals = False self.useLighting = True self.useTexture = False self.GLinitialized = False #GL-related events wx.EVT_ERASE_BACKGROUND(self, self.processEraseBackgroundEvent) wx.EVT_SIZE(self, self.processSizeEvent) wx.EVT_PAINT(self, self.processPaintEvent) #Mouse Events wx.EVT_LEFT_DOWN(self, self.MouseDown) wx.EVT_LEFT_UP(self, self.MouseUp) wx.EVT_RIGHT_DOWN(self, self.MouseDown) wx.EVT_RIGHT_UP(self, self.MouseUp) wx.EVT_MIDDLE_DOWN(self, self.MouseDown) wx.EVT_MIDDLE_UP(self, self.MouseUp) wx.EVT_MOTION(self, self.MouseMotion)
def __init__(self, parent): attribs = (glcanvas.WX_GL_RGBA, glcanvas.WX_GL_DOUBLEBUFFER, glcanvas.WX_GL_DEPTH_SIZE, 24) glcanvas.GLCanvas.__init__(self, parent, -1, attribList=attribs) self.context = glcanvas.GLContext(self) self.parent = parent #Camera state variables self.size = self.GetClientSize() self.camera = MousePolarCamera(self.size.width, self.size.height) #Main state variables self.MousePos = [0, 0] self.initiallyResized = False self.bbox = np.array([[1, 1, 1], [-1, -1, -1]]) random.seed() #Point cloud and playing information self.displayCount = 0 self.SampleDelays = np.array([]) self.NFrames = 0 self.currFrame = 0 self.PointClouds = [] self.Playing = False self.PlayIDX = 0 self.GLinitialized = False #GL-related events wx.EVT_ERASE_BACKGROUND(self, self.processEraseBackgroundEvent) wx.EVT_SIZE(self, self.processSizeEvent) wx.EVT_PAINT(self, self.processPaintEvent) #Mouse Events wx.EVT_LEFT_DOWN(self, self.MouseDown) wx.EVT_LEFT_UP(self, self.MouseUp) wx.EVT_RIGHT_DOWN(self, self.MouseDown) wx.EVT_RIGHT_UP(self, self.MouseUp) wx.EVT_MIDDLE_DOWN(self, self.MouseDown) wx.EVT_MIDDLE_UP(self, self.MouseUp) wx.EVT_MOTION(self, self.MouseMotion)
def __init__(self, parent): attribList = (glcanvas.WX_GL_RGBA, glcanvas.WX_GL_DOUBLEBUFFER, glcanvas.WX_GL_DEPTH_SIZE, 24, glcanvas.WX_GL_STENCIL_SIZE, 8, 0) glcanvas.GLCanvas.__init__(self, parent, style=wx.WANTS_CHARS, attribList=attribList) self._base = self self._focus = None self._container = None self._container = glGuiContainer(self, (0, 0)) self._shownError = False self._context = glcanvas.GLContext(self) #self._glButtonsTexture = None self._buttonSize = 64 self._animationList = [] self.glReleaseList = [] self._refreshQueued = False self._idleCalled = False wx.EVT_PAINT(self, self._OnGuiPaint) wx.EVT_SIZE(self, self._OnSize) wx.EVT_ERASE_BACKGROUND(self, self._OnEraseBackground) wx.EVT_LEFT_DOWN(self, self._OnGuiMouseDown) wx.EVT_LEFT_DCLICK(self, self._OnGuiMouseDown) wx.EVT_LEFT_UP(self, self._OnGuiMouseUp) wx.EVT_RIGHT_DOWN(self, self._OnGuiMouseDown) wx.EVT_RIGHT_DCLICK(self, self._OnGuiMouseDown) wx.EVT_RIGHT_UP(self, self._OnGuiMouseUp) wx.EVT_MIDDLE_DOWN(self, self._OnGuiMouseDown) wx.EVT_MIDDLE_DCLICK(self, self._OnGuiMouseDown) wx.EVT_MIDDLE_UP(self, self._OnGuiMouseUp) wx.EVT_MOTION(self, self._OnGuiMouseMotion) wx.EVT_KEY_DOWN(self, self._OnGuiKeyDown) wx.EVT_KEY_UP(self, self._OnGuiKeyUp) wx.EVT_KILL_FOCUS(self, self.OnFocusLost) wx.EVT_IDLE(self, self._OnIdle)
def _make_calendar_widget(self, month_offset): """ Add a calendar widget to the screen and hook up callbacks. Parameters ---------- month_offset : int The number of months from today, that the calendar should start at. """ date = self.shift_datetime(self.date, month_offset) panel = wx.Panel(self, -1) cal = wxMouseBoxCalendarCtrl( panel, -1, date, style=wx.calendar.CAL_SUNDAY_FIRST | wx.calendar.CAL_SEQUENTIAL_MONTH_SELECTION # | wx.calendar.CAL_SHOW_HOLIDAYS ) self.sizer.Add(panel) cal.highlight_changed() # Set up control to sync the other calendar widgets and coloring: self.Bind(wx.calendar.EVT_CALENDAR_MONTH, self.month_changed, cal) self.Bind(wx.calendar.EVT_CALENDAR_YEAR, self.month_changed, cal) wx.EVT_LEFT_DOWN(cal, self._left_down) if self.multi_select: wx.EVT_LEFT_UP(cal, self._left_up) wx.EVT_RIGHT_UP(cal, self._process_box_select) wx.EVT_LEAVE_WINDOW(cal, self._process_box_select) wx.EVT_MOTION(cal, self._mouse_drag) self.Bind( wx.calendar.EVT_CALENDAR_WEEKDAY_CLICKED, self._weekday_clicked, cal, ) return cal
def __init__(self, parent, coverSong, SSMPlot): attribs = (glcanvas.WX_GL_RGBA, glcanvas.WX_GL_DOUBLEBUFFER, glcanvas.WX_GL_DEPTH_SIZE, 24) glcanvas.GLCanvas.__init__(self, parent, -1, attribList=attribs) self.context = glcanvas.GLContext(self) self.coverSong = coverSong self.SSMPlot = SSMPlot #Camera state variables self.size = self.GetClientSize() self.camera = MousePolarCamera(self.size.width, self.size.height) #Main state variables self.MousePos = [0, 0] self.initiallyResized = False self.bbox = np.array([[1, 1, 1], [-1, -1, -1]]) #Set up OpenGL vertex buffer for points and colors self.YVBO = vbo.VBO(np.array(self.coverSong.Y, dtype='float32')) self.YColorsVBO = vbo.VBO( np.array(self.coverSong.YColors, dtype='float32')) #Point cloud and playing information self.DrawEdges = False self.Playing = False self.GLinitialized = False #GL-related events wx.EVT_ERASE_BACKGROUND(self, self.processEraseBackgroundEvent) wx.EVT_SIZE(self, self.processSizeEvent) wx.EVT_PAINT(self, self.processPaintEvent) #Mouse Events wx.EVT_LEFT_DOWN(self, self.MouseDown) wx.EVT_LEFT_UP(self, self.MouseUp) wx.EVT_RIGHT_DOWN(self, self.MouseDown) wx.EVT_RIGHT_UP(self, self.MouseUp) wx.EVT_MIDDLE_DOWN(self, self.MouseDown) wx.EVT_MIDDLE_UP(self, self.MouseUp) wx.EVT_MOTION(self, self.MouseMotion)
def __init__(self, parent, image, previewwindow=None, id=1, resultsize=(100,100), size=wx.DefaultSize, pos=wx.DefaultPosition, style=0): wx.ScrolledWindow.__init__(self, parent, id=id, size=size, pos=pos, style=style|wx.FULL_REPAINT_ON_RESIZE) self.previewwindow=previewwindow self.bg=wx.Brush(wx.WHITE) self.parentbg=wx.Brush(parent.GetBackgroundColour()) self._bufbmp=None self.anchors=None wx.EVT_ERASE_BACKGROUND(self, lambda evt: None) wx.EVT_PAINT(self, self.OnPaint) self.image=image self.origimage=image self.setresultsize(resultsize) # cursors for outside, inside, on selection, pressing bad mouse button self.cursors=[wx.StockCursor(c) for c in (wx.CURSOR_ARROW, wx.CURSOR_HAND, wx.CURSOR_SIZING, wx.CURSOR_NO_ENTRY)] self.clickpoint=None wx.EVT_MOTION(self, self.OnMotion) wx.EVT_LEFT_DOWN(self, self.OnLeftDown) wx.EVT_LEFT_UP(self, self.OnLeftUp)
def __init__(self, parent, image, glCanvas, do, chan=0, zdim=2): wx.Panel.__init__(self, parent, -1, size=parent.Size) self.image = image self.glCanvas = glCanvas self.do = do self.chan = chan self.zdim = zdim wx.EVT_PAINT(self, self.OnPaint) wx.EVT_SIZE(self, self.OnSize) wx.EVT_MOUSEWHEEL(self, self.OnWheel) wx.EVT_KEY_DOWN(self, self.OnKeyPress) wx.EVT_LEFT_DOWN(self, self.OnLeftDown) wx.EVT_LEFT_UP(self, self.OnLeftUp) wx.EVT_MOTION(self, self.OnMotion) self.selecting = False self.do.WantChangeNotification.append(self.Refresh)
def __init__(self, parent): attrib_list = (glcanvas.WX_GL_RGBA, glcanvas.WX_GL_DOUBLEBUFFER, glcanvas.WX_GL_DEPTH_SIZE, 24, glcanvas.WX_GL_STENCIL_SIZE, 8, 0) glcanvas.GLCanvas.__init__(self, parent, style=wx.WANTS_CHARS, attribList=attrib_list) self._base = self self._focus = None self._container = None self._container = glGuiContainer(self, (0, 0)) self._shown_error = False self._context = glcanvas.GLContext(self) self._button_size = 64 self._animation_list = [] self.gl_release_list = [] self._refresh_queued = False self._idle_called = False wx.EVT_PAINT(self, self._on_gui_paint) wx.EVT_SIZE(self, self._on_size) wx.EVT_ERASE_BACKGROUND(self, self._on_erase_background) wx.EVT_LEFT_DOWN(self, self._on_gui_mouse_down) wx.EVT_LEFT_DCLICK(self, self._on_gui_mouse_down) wx.EVT_LEFT_UP(self, self._on_gui_mouse_up) wx.EVT_RIGHT_DOWN(self, self._on_gui_mouse_down) wx.EVT_RIGHT_DCLICK(self, self._on_gui_mouse_down) wx.EVT_RIGHT_UP(self, self._on_gui_mouse_up) wx.EVT_MIDDLE_DOWN(self, self._on_gui_mouse_down) wx.EVT_MIDDLE_DCLICK(self, self._on_gui_mouse_down) wx.EVT_MIDDLE_UP(self, self._on_gui_mouse_up) wx.EVT_MOTION(self, self._on_gui_mouse_motion) wx.EVT_KEY_DOWN(self, self._on_gui_key_down) wx.EVT_KEY_UP(self, self._on_gui_key_up) wx.EVT_KILL_FOCUS(self, self._on_focus_lost) wx.EVT_IDLE(self, self._on_idle)
def plotMouseEventHandlerSet(handler=None, figureNo=None): """ if handler is None: reset to default mouse handler (zooming) exampler `handler`: def h(evt): p = evt.GetPosition() if evt.LeftDown(): print plotMouse__window2graph(p) """ fig = _getFig(figureNo) import wx pc = fig.client # canvas if handler is None: handler = pc.on_mouse_event wx.EVT_LEFT_DOWN(pc, handler) wx.EVT_LEFT_UP(pc, handler) wx.EVT_MOTION(pc, handler) wx.EVT_MOTION(pc, handler)
def __init__(self, master, gradient_table, color_space, width, height): """Initialize a function control widget on tkframe master. Parameters: ----------- master: The master widget. Note that this widget *must* have the methods specified in the `AbstractGradientEditorWidget` interface. on_table_changed: Callback function taking a bool argument of meaning 'FinalUpdate'. FinalUpdate is true if a control point is dropped, created or removed and false if the update is due to a control point currently beeing dragged (but not yet dropped) color_space: String which specifies the channels painted on this control. May be any combination of h,s,v,r,g,b,a in which each channel occurs only once. set_status_text: a callback used to set the status text when using the editor. """ FunctionControl.__init__(self, master, gradient_table, color_space, width, height) wx.Panel.__init__(self, master, size=wx.Size(width, height), name="RGBHSVA Editor") self.update() wx.EVT_LEFT_DOWN(self, self.on_left_button_down) wx.EVT_LEFT_UP(self, self.on_left_button_up) wx.EVT_RIGHT_DOWN(self, self.on_right_button_down) wx.EVT_RIGHT_UP(self, self.on_right_button_up) wx.EVT_MOTION(self, self.on_mouse_move) wx.EVT_PAINT(self, self.on_paint) wx.EVT_LEAVE_WINDOW(self, self.on_leave_window)
def __init__(self, parent): attribs = (glcanvas.WX_GL_RGBA, glcanvas.WX_GL_DOUBLEBUFFER, glcanvas.WX_GL_DEPTH_SIZE, 24) glcanvas.GLCanvas.__init__(self, parent, -1, attribList = attribs) self.context = glcanvas.GLContext(self) self.parent = parent #Camera state variables self.size = self.GetClientSize() #self.camera = MouseSphericalCamera(self.size.x, self.size.y) self.camera = MousePolarCamera(self.size.width, self.size.height) #Skeleton animation variables self.skeleton = Skeleton() self.animator = SkeletonAnimator(self.skeleton) self.animationState = 0 self.animating = False #Main state variables self.MousePos = [0, 0] self.initiallyResized = False self.bbox = np.array([[-1, -1, -1], [1, 1, 1]]) random.seed() self.GLinitialized = False #GL-related events wx.EVT_ERASE_BACKGROUND(self, self.processEraseBackgroundEvent) wx.EVT_SIZE(self, self.processSizeEvent) wx.EVT_PAINT(self, self.processPaintEvent) #Mouse Events wx.EVT_LEFT_DOWN(self, self.MouseDown) wx.EVT_LEFT_UP(self, self.MouseUp) wx.EVT_RIGHT_DOWN(self, self.MouseDown) wx.EVT_RIGHT_UP(self, self.MouseUp) wx.EVT_MIDDLE_DOWN(self, self.MouseDown) wx.EVT_MIDDLE_UP(self, self.MouseUp) wx.EVT_MOTION(self, self.MouseMotion)
def __init__(self, parent, id, model): wx.ScrolledWindow.__init__(self, parent, id, style=wx.NO_FULL_REPAINT_ON_RESIZE) self.model = model self.node_dict = {} self.link_dict = {} self.node_size = 25 self.dragNode = None self.dragImage = None self.queue = event_queue() self.SetBackgroundColour("WHITE") self.SetCursor(wx.StockCursor(wx.CURSOR_ARROW)) # Mouse buttons and motion wx.EVT_LEFT_DOWN(self, self.OnLeftDown) wx.EVT_LEFT_UP(self, self.OnLeftUp) wx.EVT_MOTION(self, self.OnMotion) wx.EVT_PAINT(self, self.OnPaint) wx.EVT_IDLE(self, self.OnIdle) self.SetMode("Select") # Register network events callback DispatchEvent. # See net_view.DispatchEvent() for details. model.Bind(net_model.ADD_NODE, self.DispatchEvent, self.add_node) model.Bind(net_model.REMOVE_NODE, self.DispatchEvent, self.del_node) model.Bind(net_model.ADD_LINK, self.DispatchEvent, self.add_radio_link) model.Bind(net_model.REMOVE_LINK, self.DispatchEvent, self.del_radio_link) model.Bind(net_model.NET_CHANGED, self.DispatchEvent, self.new_network) model.Bind(net_model.FORWARD_PACKET, self.DispatchEvent, self.forward_radio_packet)
def __init__(self, parent): attribs = (glcanvas.WX_GL_RGBA, glcanvas.WX_GL_DOUBLEBUFFER, glcanvas.WX_GL_DEPTH_SIZE, 24) glcanvas.GLCanvas.__init__(self, parent, -1, attribList=attribs) self.context = glcanvas.GLContext(self) self.GUIState = STATE_NORMAL self.GUISubstate = SUBSTATE_NONE self.parent = parent #Camera state variables self.size = self.GetClientSize() self.camera = MouseSphericalCamera(self.size.x, self.size.y) #self.camera = MousePolarCamera(self.size.width, self.size.height) #Main state variables self.MousePos = [0, 0] self.initiallyResized = False self.bbox = BBox3D() self.unionbbox = BBox3D() random.seed() #State variables for saving screenshots self.rotfilePrefix = "Rotation" self.rotstartAngle = -50 self.rotendAngle = 50 self.rotangleInc = 5 self.rotAngle = 0 self.lightPhi = 0 self.lightTheta = 0 self.lightIter = 0 #State variables for laplacian mesh operations self.laplacianConstraints = { } #Elements will be key-value pairs (idx, Point3D(new position)) self.laplaceCurrentIdx = -1 self.eigvalues = np.zeros(0) self.eigvectors = np.zeros(0) #Face mesh variables and manipulation variables self.mesh = None self.meshCentroid = None self.meshPrincipalAxes = None self.displayMeshFaces = True self.displayMeshEdges = False self.displayMeshVertices = False self.displayMeshNormals = False self.displayPrincipalAxes = False self.useLighting = True self.useTexture = True self.vertexColors = np.zeros(0) self.PRSTPlaneMesh = None self.PRSTPointPairs = [] self.cutPlane = None self.displayCutPlane = False self.GLinitialized = False #GL-related events wx.EVT_ERASE_BACKGROUND(self, self.processEraseBackgroundEvent) wx.EVT_SIZE(self, self.processSizeEvent) wx.EVT_PAINT(self, self.processPaintEvent) #Mouse Events wx.EVT_LEFT_DOWN(self, self.MouseDown) wx.EVT_LEFT_UP(self, self.MouseUp) wx.EVT_RIGHT_DOWN(self, self.MouseDown) wx.EVT_RIGHT_UP(self, self.MouseUp) wx.EVT_MIDDLE_DOWN(self, self.MouseDown) wx.EVT_MIDDLE_UP(self, self.MouseUp) wx.EVT_MOTION(self, self.MouseMotion)
def updateComponent(self, which): wName, wClass = self.components.wComponentList.stringSelection.split(" : ") propName = which if propName in self.checkItems: value = self.components["chk"+propName].checked elif propName in self.popItems: value = self.components["pop"+propName].stringSelection elif propName in ('items', 'userdata') or (wClass == 'TextArea' and propName == 'text'): value = self.components["fld"+propName].text else: value = self.components["fld"+propName].text if propName == "textArea": propName = 'text' if propName not in ['name', 'label', 'stringSelection', 'text', 'toolTip', 'userdata']: try: value = eval(value) except: pass # KEA 2004-05-10 # need to figure out where to stick validation code # but for now just need to make sure that if we're changing the name # attribute that it is valid, but similar checks will be necessary for # integer fields, a list of items, etc. # also maybe each attribute should have a doc or help string displayed # saying what the attribute does, example values, etc. if propName == 'name': badValue = False # if it isn't valid then display an alert and exit # must start with a letter and only contain alphanumeric characters if value == "" or value[0] not in string.ascii_letters: badValue = True else: alphanumeric = string.ascii_letters + string.digits for c in value: if c not in alphanumeric: badValue = True break if badValue: dialog.alertDialog(None, "Name must start with a letter and only contain letters and numbers.", 'Error: Name is invalid') self.components["fld"+which].text = wName self.components["fld"+which].setFocus() self.components["fld"+which].setSelection(-1, -1) return # check for duplicate names is done below ##widget = self.components[wName] widget = self._comp[wName] # KEA 2002-02-23 # I can't remember why this is actually necessary if propName == 'size': width, height = value if wClass not in ['BitmapCanvas', 'HtmlWindow']: bestWidth, bestHeight = widget.GetBestSize() if width == -1: width = bestWidth if height == -1: height = bestHeight widget.size = (width, height) else: if (propName in self.cantModify) or \ (propName == 'items' and wClass == 'RadioGroup') or \ (propName in ['label', 'text']): if (propName == 'layout'): xx,yy = widget.size widget.size = yy, xx order = self._comp.order.index(wName) desc = multiresourceOutput.widgetAttributes(self._parent, widget) if desc.endswith(',\n'): desc = eval(desc[:-2]) else: desc = eval(desc) if propName == 'name': if value == wName: # user didn't actually change the name return elif value in self._comp: # we already have a component with that name dialog.alertDialog(self, 'Another component already exists with the name ' + value, 'Error: unable to rename component') self.components["fldname"].text = wName self.components["fldname"].setFocus() self.components["fldname"].setSelection(-1, -1) return if propName in ['label', 'text']: if not self.components.chkallowNameLabelVariation.checked: if value == "": result = dialog.messageDialog(self, 'To set '+propName+' to be empty, you must allow Name and '+propName+' to differ.\n'+ 'Do you want to allow that ?', 'Empty '+propName, wx.ICON_QUESTION | wx.YES_NO | wx.NO_DEFAULT) if result.accepted: self.components.chkallowNameLabelVariation.checked = True desc[propName] = value else: # don't allow this change #self.components["fldname"].text = wName self.components["fld"+propName].text = desc[propName] self.components["fld"+propName].setFocus() self.components["fld"+propName].setSelection(-1, -1) return else: oldval = desc[propName] desc[propName] = value self._parent.deriveNameFromLabel(desc) if desc['name'] in self._comp: # we already have a component with that name dialog.alertDialog(self, 'Another component already exists with the name ' + value, 'Error: unable to rename component') desc['name'] = wName desc[propName] = oldval self.components["fldname"].text = wName self.components["fld"+propName].text = desc[propName] self.components["fld"+propName].setFocus() self.components["fld"+propName].setSelection(-1, -1) return if value is None: desc[propName] = 'none' elif propName in ['min', 'max']: desc[propName] = int(value) else: desc[propName] = value # need to experiment with freeze and thaw to avoid # a lot of update events startTime = time.time() # this is going to trigger a changed event # as we delete the old component self._updatingComponent = True del self._comp[wName] if propName in ['name']: if not self.components.chkallowNameLabelVariation.checked: self._parent.deriveLabelFromName(desc) wName = desc['name'] elif propName in ['label', 'text']: if not self.components.chkallowNameLabelVariation: self._parent.deriveNameFromLabel(desc) wName = desc['name'] # this is going to trigger another changed event # as we create a new component with the changed attribute self._comp[wName] = desc c = self._comp[wName] wx.EVT_LEFT_DOWN(c, self._parent.on_mouseDown) wx.EVT_LEFT_UP(c, self._parent.on_mouseUp) wx.EVT_MOTION(c, self._parent.on_mouseDrag) # now restore the order of the component # have to update the startName in case the name was updated if propName == 'name': self._parent.startName = wName self._comp.order.remove(wName) self._comp.order.insert(order, wName) self._parent.fixComponentOrder(wName) self._updatingComponent = False endTime = time.time() #print "attribute change took:", endTime - startTime else: if wClass in ['Image', 'ImageButton'] and propName == 'file': cwd = os.getcwd() try: os.chdir(self._parent.filename) except: pass setattr(widget, propName, value) os.chdir(cwd) else: setattr(widget, propName, value) #print propName, value # KEA 2002-02-23 self._parent.showSizingHandles(wName) # and check if we now have matching name/label, and if so, assume they now maintain derivation self.determineNameLabelState(wName)
def __init__(self, parent): attribs = (glcanvas.WX_GL_RGBA, glcanvas.WX_GL_DOUBLEBUFFER, glcanvas.WX_GL_DEPTH_SIZE, 24) glcanvas.GLCanvas.__init__(self, parent, -1, attribList=attribs) self.context = glcanvas.GLContext(self) self.setText = False self.parent = parent #Camera state variables self.size = self.GetClientSize() #self.camera = MouseSphericalCamera(self.size.x, self.size.y) self.camera = MousePolarCamera(self.size.width, self.size.height) #Main state variables self.MousePos = [0, 0] self.initiallyResized = False random.seed() #GUI State Variables self.GUIState = STATE_INTRO self.GUISubstate = -1 #Head Mesh self.headMesh = PolyMesh() self.headMesh.loadFile('NotreDameMedium.off') self.headMeshLowres = PolyMesh() self.headMeshLowres.loadFile('NotreDameLowres.off') self.styrofoamHead = PolyMesh() self.styrofoamHead.loadFile('StyrofoamHead.off') self.rotAngle = 0 self.zoom = 0 self.rotCount = 0 self.timelineCount = 0 #User's face self.userMesh = None self.colorUserMesh = None #ICP state variables self.ICPTransformation = np.zeros(0) self.ICPMutex = Lock() self.ICPThread = None self.bbox = self.headMesh.getBBox() self.camera.centerOnBBox(self.bbox, theta=-math.pi / 2, phi=math.pi / 2) self.zCenter = (self.bbox.zmax + self.bbox.zmin) / 2.0 self.GLinitialized = False #GL-related events wx.EVT_ERASE_BACKGROUND(self, self.processEraseBackgroundEvent) wx.EVT_SIZE(self, self.processSizeEvent) wx.EVT_PAINT(self, self.processPaintEvent) #Mouse Events wx.EVT_LEFT_DOWN(self, self.MouseDown) wx.EVT_LEFT_UP(self, self.MouseUp) wx.EVT_RIGHT_DOWN(self, self.MouseDown) wx.EVT_RIGHT_UP(self, self.MouseUp) wx.EVT_MIDDLE_DOWN(self, self.MouseDown) wx.EVT_MIDDLE_UP(self, self.MouseUp) wx.EVT_MOTION(self, self.MouseMotion) self.initGL()
def updateComponent(self): wName, wClass = self.components.wComponentList.stringSelection.split( " : ") propName = self.components.wPropertyList.stringSelection if propName in self.checkItems: value = self.components.wChecked.checked elif propName in self.popItems: value = self.components.wPop.stringSelection elif propName in ('items', 'userdata') or (wClass == 'TextArea' and propName == 'text'): value = self.components.wTextArea.text else: #value = self.components.wField.GetValue() value = self.components.wField.text if propName not in [ 'label', 'stringSelection', 'text', 'toolTip', 'userdata' ]: try: value = eval(value) except: pass # KEA 2004-05-10 # need to figure out where to stick validation code # but for now just need to make sure that if we're changing the name # attribute that it is valid, but similar checks will be necessary for # integer fields, a list of items, etc. # also maybe each attribute should have a doc or help string displayed # saying what the attribute does, example values, etc. if propName == 'name': badValue = False # if it isn't valid then display an alert and exit # must start with a letter and only contain alphanumeric characters if value == "" or value[0] not in string.ascii_letters: badValue = True else: alphanumeric = string.ascii_letters + string.digits for c in value: if c not in alphanumeric: badValue = True break if badValue: dialog.alertDialog( None, "Name must start with a letter and only contain letters and numbers.", 'Error: Name is invalid') self.components.wField.setFocus() self.components.wField.setSelection(-1, -1) return # check for duplicate names is done below ##widget = self.components[wName] widget = self._comp[wName] # KEA 2002-02-23 # I can't remember why this is actually necessary if propName == 'size': width, height = value if wClass not in ['BitmapCanvas', 'HtmlWindow']: bestWidth, bestHeight = widget.GetBestSize() if width == -1: width = bestWidth if height == -1: height = bestHeight widget.size = (width, height) #setattr(widget, propName, (width, height)) #print widget.size, propName, width, height else: if (propName in self.cantModify) or \ (propName == 'items' and wClass == 'RadioGroup'): order = self._comp.order.index(wName) desc = resourceOutput.widgetAttributes(self._parent, widget) if desc.endswith(',\n'): desc = eval(desc[:-2]) else: desc = eval(desc) if propName == 'name': if value == wName: # user didn't actually change the name return elif value in self._comp: # we already have a component with that name dialog.alertDialog( self, 'Another component already exists with the name ' + value, 'Error: unable to rename component') return if value is None: desc[propName] = 'none' elif propName in ['min', 'max']: desc[propName] = int(value) else: desc[propName] = value # need to experiment with freeze and thaw to avoid # a lot of update events startTime = time.time() # this is going to trigger a changed event # as we delete the old component self._updatingComponent = True del self._comp[wName] if propName == 'name': wName = value # this is going to trigger another changed event # as we create a new component with the changed attribute self._comp[wName] = desc c = self._comp[wName] wx.EVT_LEFT_DOWN(c, self._parent.on_mouseDown) wx.EVT_LEFT_UP(c, self._parent.on_mouseUp) wx.EVT_MOTION(c, self._parent.on_mouseDrag) # now restore the order of the component # have to update the startName in case the name was updated if propName == 'name': self._parent.startName = wName self._comp.order.remove(wName) self._comp.order.insert(order, wName) self._parent.fixComponentOrder(wName) self._updatingComponent = False endTime = time.time() #print "attribute change took:", endTime - startTime else: if wClass in ['Image', 'ImageButton'] and propName == 'file': cwd = os.getcwd() try: os.chdir(self._parent.filename) except: pass setattr(widget, propName, value) os.chdir(cwd) else: setattr(widget, propName, value) #print propName, value # KEA 2002-02-23 self._parent.showSizingHandles(wName)
def handle_interaction(self, pixel_data): '''Run a UI that gets an angle from the user''' import wx if pixel_data.ndim == 2: # make a color matrix for consistency pixel_data = np.dstack((pixel_data, pixel_data, pixel_data)) pd_min = np.min(pixel_data) pd_max = np.max(pixel_data) if pd_min == pd_max: pixel_data[:, :, :] = 0 else: pixel_data = ((pixel_data - pd_min) * 255.0 / (pd_max - pd_min)) # # Make a 100 x 100 image so it's manageable # isize = 200 i, j, k = np.mgrid[0:isize, 0:int(isize * pixel_data.shape[1] / pixel_data.shape[0]), 0:3].astype(float) i *= float(pixel_data.shape[0]) / float(isize) j *= float(pixel_data.shape[0]) / float(isize) pixel_data = scind.map_coordinates(pixel_data, (i, j, k)) # # Make a dialog box that contains the image # dialog = wx.Dialog(None, title="Rotate image") sizer = wx.BoxSizer(wx.VERTICAL) dialog.SetSizer(sizer) sizer.Add( wx.StaticText(dialog, label="Drag image to rotate, hit OK to continue"), 0, wx.ALIGN_CENTER_HORIZONTAL) canvas = wx.StaticBitmap(dialog) canvas.SetDoubleBuffered(True) canvas.BackgroundColour = wx.Colour(0, 0, 0, wx.ALPHA_TRANSPARENT) sizer.Add( canvas, 0, wx.ALIGN_CENTER_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5) angle = [0] angle_text = wx.StaticText(dialog, label="Angle: %d" % angle[0]) sizer.Add(angle_text, 0, wx.ALIGN_CENTER_HORIZONTAL) def imshow(): angle_text.Label = "Angle: %d" % int(angle[0]) angle_text.Refresh() my_angle = -angle[0] * np.pi / 180.0 transform = np.array([[np.cos(my_angle), -np.sin(my_angle)], [np.sin(my_angle), np.cos(my_angle)]]) # Make it rotate about the center offset = affine_offset(pixel_data.shape, transform) x = np.dstack((scind.affine_transform(pixel_data[:, :, 0], transform, offset, order=0), scind.affine_transform(pixel_data[:, :, 1], transform, offset, order=0), scind.affine_transform(pixel_data[:, :, 2], transform, offset, order=0))) buff = x.astype(np.uint8).tostring() bitmap = wx.BitmapFromBuffer(x.shape[1], x.shape[0], buff) canvas.SetBitmap(bitmap) imshow() # # Install handlers for mouse down, mouse move and mouse up # dragging = [False] initial_angle = [0] hand_cursor = wx.StockCursor(wx.CURSOR_HAND) arrow_cursor = wx.StockCursor(wx.CURSOR_ARROW) def get_angle(event): center = np.array(canvas.Size) / 2 point = np.array(event.GetPositionTuple()) offset = point - center return -np.arctan2(offset[1], offset[0]) * 180.0 / np.pi def on_mouse_down(event): canvas.Cursor = hand_cursor dragging[0] = True initial_angle[0] = get_angle(event) - angle[0] canvas.CaptureMouse() wx.EVT_LEFT_DOWN(canvas, on_mouse_down) def on_mouse_up(event): if dragging[0]: canvas.ReleaseMouse() dragging[0] = False canvas.Cursor = arrow_cursor wx.EVT_LEFT_UP(canvas, on_mouse_up) def on_mouse_lost(event): dragging[0] = False canvas.Cursor = arrow_cursor wx.EVT_MOUSE_CAPTURE_LOST(canvas, on_mouse_lost) def on_mouse_move(event): if dragging[0]: angle[0] = get_angle(event) - initial_angle[0] imshow() canvas.Refresh(eraseBackground=False) wx.EVT_MOTION(canvas, on_mouse_move) # # Put the OK and Cancel buttons on the bottom # btnsizer = wx.StdDialogButtonSizer() btn = wx.Button(dialog, wx.ID_OK) btn.SetDefault() btnsizer.AddButton(btn) btn = wx.Button(dialog, wx.ID_CANCEL) btnsizer.AddButton(btn) btnsizer.Realize() sizer.Add(btnsizer, 0, wx.ALIGN_CENTER_HORIZONTAL | wx.ALL, 5) dialog.Fit() result = dialog.ShowModal() dialog.Destroy() if result == wx.ID_OK: return angle[0] raise ValueError("Canceled by user in FlipAndRotate")
def init(self, parent): """ Finishes initializing the editor by creating the underlying toolkit widget. """ factory = self.factory # Establish the range of the slider: low_name = high_name = '' low, high = factory.low, factory.high if high <= low: low = high = None handler = self.object.trait(self.name).handler if isinstance(handler, BaseRange): low_name, high_name = handler._low_name, handler._high_name if low_name == '': low = handler._low if high_name == '': high = handler._high elif isinstance(handler, BaseEnum): if handler.name == '': self.mapping = handler.values else: self.sync_value(handler.name, 'mapping', 'from') low, high = 0, self.high # Create the control: self.control = control = wx.Window(parent, -1, size=wx.Size(50, 18), style=wx.FULL_REPAINT_ON_RESIZE | wx.TAB_TRAVERSAL) # Set up the painting event handlers: wx.EVT_ERASE_BACKGROUND(control, self._erase_background) wx.EVT_PAINT(control, self._on_paint) wx.EVT_SET_FOCUS(control, self._set_focus) # Set up mouse event handlers: wx.EVT_LEAVE_WINDOW(control, self._leave_window) wx.EVT_ENTER_WINDOW(control, self._enter_window) wx.EVT_LEFT_DOWN(control, self._left_down) wx.EVT_LEFT_UP(control, self._left_up) wx.EVT_MOTION(control, self._motion) wx.EVT_MOUSEWHEEL(control, self._mouse_wheel) # Set up the control resize handler: wx.EVT_SIZE(control, self._resize) # Set the tooltip: self._can_set_tooltip = (not self.set_tooltip()) # Save the values we calculated: self.set(low=low, high=high) self.sync_value(low_name, 'low', 'from') self.sync_value(high_name, 'high', 'from') # Force a reset (in case low = high = None, which won't cause a # notification to fire): self._reset_scrubber()