コード例 #1
0
ファイル: wxplt.py プロジェクト: mueller-physics/Chromagnon
    def __init__(self,
                 parent,
                 id=-1,
                 pos=wx.DefaultPosition,
                 size=wx.DefaultSize,
                 **attr):
        wx.Window.__init__(self, parent, id, pos, size)
        wx.EVT_PAINT(self, self.on_paint)

        property_object.__init__(self, attr)
        background = wx.NamedColour(self.background_color)
        self.backgroundBrush = wx.Brush(background)

        self.SetBackgroundColour(background)
        self.SetBackgroundStyle(wx.BG_STYLE_CUSTOM)  # seb added: no flickering
        ##self.title = text_object('')
        ##self.x_title = text_object('')
        ##self.y_title = text_object('')
        self.title = text_window(self, '')
        self.x_title = text_window(self, '')
        self.y_title = text_window(self, '')
        self.all_titles = [self.title, self.x_title,
                           self.y_title]  #handy to have
        ##self.x_axis = axis_object(graph_location='above',rotate=0)
        ##self.y_axis = axis_object(graph_location='right',rotate=90)
        self.x_axis = axis_window(self, graph_location='above', rotate=0)
        self.y_axis = axis_window(self, graph_location='right', rotate=90)

        self.image_list = graphic_list()
        self.line_list = auto_line_list()  # make this the data object.
        self.legend = legend_object()
        self.text_list = None  # list of text objects to place on screen
        self.overlays = None  # list of objects to draw on top of graph
        # (boxes, circles, etc.)
        ##self.y2_axis = axis_object(graph_location='left',rotate=90)
        self.client_size = (0, 0)
        # zoom selection helpers
        self._mouse_selection = 0
        self._mouse_selection_start = wx.Point(0, 0)
        self._mouse_selection_stop = wx.Point(0, 0)

        #20090603: zoom history
        self.zoom_hist = []
        self.zoom_hist_i = 0
        self.on_zoom_forget()

        # mouse events
        wx.EVT_RIGHT_DOWN(self, self.on_right_down)
        wx.EVT_LEFT_DOWN(self, self.on_mouse_event)
        wx.EVT_LEFT_UP(self, self.on_mouse_event)
        wx.EVT_MOTION(self, self.on_mouse_event)
        wx.EVT_MOTION(self, self.on_mouse_event)
        wx.EVT_SIZE(self, self.update)
コード例 #2
0
    def updateSolverGrid(self):
        """Update solver configuration grid"""
        if not self.engine.getSolver():
            return
        solverProps = self.engine.getSolver().propertyList
        self.configGrid.ClearGrid()
        solverConfig = self.engine.getSolver().configuration
        cfgSize = len(solverConfig)
        gridSize = self.configGrid.GetNumberRows()
        if gridSize > cfgSize:
            self.configGrid.DeleteRows(0, gridSize - cfgSize)
        elif gridSize < cfgSize:
            self.configGrid.AppendRows(cfgSize - gridSize)
        self.configGrid.SetRowLabelSize(0)
        self.configGrid.DisableDragGridSize()
        self.configGrid.SetColSize(1, 200)

        i = 0
        keyList = solverConfig.keys()
        keyList.sort()
        for key in keyList:
            self.configGrid.SetCellValue(i, 0, solverProps[key][0])
            self.configGrid.SetReadOnly(i, 0, True)
            self.configGrid.SetCellValue(i, 1, str(solverConfig[key]))
            self.configGrid.SetRowLabelValue(i, key)
            i += 1
        wx.EVT_MOTION(self.configGrid.GetGridWindow(), self.OnConfigGridMotion)
        self.configGrid.SetColMinimalAcceptableWidth(80)
        self.configGrid.AutoSize()
        self.configGrid.ForceRefresh()
        self.configGrid.Show()
コード例 #3
0
    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)
        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._glRobotTexture = None
        self._buttonSize = 64

        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._OnGuiMouseLeftDown)
        wx.EVT_LEFT_UP(self, self._OnGuiMouseLeftUp)
        wx.EVT_MOTION(self, self._OnGuiMouseMotion)
        wx.EVT_CHAR(self, self._OnGuiKeyChar)
        wx.EVT_KILL_FOCUS(self, self.OnFocusLost)
コード例 #4
0
ファイル: TestUpdate.py プロジェクト: foloumi/wxPythonDemos
    def __init__(self):
        wx.Frame.__init__(self, None, -1, "DrawLines Test",
                         wx.DefaultPosition,
                         size=(500,500),
                         style=wx.DEFAULT_FRAME_STYLE | wx.NO_FULL_REPAINT_ON_RESIZE)

        ## Set up the MenuBar
        MenuBar = wx.MenuBar()
        
        file_menu = wx.Menu()

        ID_CLEAR_MENU = wx.NewId()
        file_menu.Append(ID_CLEAR_MENU, "&Clear","Clear the Screen")
        wx.EVT_MENU(self, ID_CLEAR_MENU, self.Clear)

        ID_ANIMATE_MENU = wx.NewId()
        file_menu.Append(ID_ANIMATE_MENU, "&Animate","Animate the Screen")
        wx.EVT_MENU(self, ID_ANIMATE_MENU, self.Animate)

        ID_EXIT_MENU = wx.NewId()
        file_menu.Append(ID_EXIT_MENU, "E&xit","Terminate the program")
        wx.EVT_MENU(self, ID_EXIT_MENU, self.OnQuit)

        MenuBar.Append(file_menu, "&File")
        self.SetMenuBar(MenuBar)

        wx.EVT_PAINT(self, self.OnPaint)
        wx.EVT_MOTION(self, self.OnMouseMove )
        wx.EVT_LEFT_DOWN(self, self.OnLeftDown )

        self.LineData = []
コード例 #5
0
    def __init__(self, parent, ID):
        wx.Window.__init__(self, parent, ID, style=wx.NO_FULL_REPAINT_ON_RESIZE)
        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)
コード例 #6
0
 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)
     glcanvas.GLCanvas.__init__(self, parent, attribList=attribList)
     self.parent = parent
     self.context = glcanvas.GLContext(self)
     wx.EVT_PAINT(self, self.OnPaint)
     wx.EVT_SIZE(self, self.OnSize)
     wx.EVT_ERASE_BACKGROUND(self, self.OnEraseBackground)
     wx.EVT_MOTION(self, self.OnMouseMotion)
     wx.EVT_MOUSEWHEEL(self, self.OnMouseWheel)
     self.yaw = 30
     self.pitch = 60
     self.zoom = 300
     self.offsetX = 0
     self.offsetY = 0
     self.view3D = True
     self.gcodeDisplayList = None
     self.gcodeDisplayListMade = None
     self.gcodeDisplayListCount = 0
     self.objColor = [[1.0, 0.8, 0.6, 1.0], [0.2, 1.0, 0.1, 1.0],
                      [1.0, 0.2, 0.1, 1.0], [0.1, 0.2, 1.0, 1.0]]
     self.oldX = 0
     self.oldY = 0
     self.dragType = ''
     self.tempRotate = 0
コード例 #7
0
    def __init__(self, parent, editor, type):
        grid.Grid.__init__(self, parent, -1)
        self.Parent = parent
        self.Editor = editor
        self.Type = type

        if self.Type == 'fuel':
            self.NumRows = len(config.grid_fuel_rows)
            self.NumCols = len(config.grid_fuel_cols)
        elif self.Type == 'timing':
            self.NumRows = len(config.grid_timing_rows)
            self.NumCols = len(config.grid_timing_cols)

        self.SetDefaultRowSize(20)
        self.SetDefaultColSize(35)
        self.SetMargins(0, 0)
        self.EnableDragColSize(False)
        self.EnableDragRowSize(False)
        self.EnableDragGridSize(False)

        self.color_max = 0
        self.color_min = 0
        self.color_adder = 0

        #        self.Bind(wx.EVT_MOTION, self.ShowTooltip, self.GetGridWindow())
        wx.EVT_MOTION(self.GetGridWindow(), self.ShowTooltip)
コード例 #8
0
ファイル: imageView.py プロジェクト: FA1984/python-microscopy
    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_MIDDLE_DOWN(self, self.OnMiddleDown)
        wx.EVT_MIDDLE_UP(self, self.OnMiddleUp)
        wx.EVT_MOTION(self, self.OnMotion)

        self.selecting = False
        self.panning = False

        self.do.WantChangeNotification.append(self.Refresh)
コード例 #9
0
 def __init__(self,parent,id=-1,ctrlStyle=(wx.LC_REPORT|wx.LC_SINGLE_SEL)):
     """Init."""
     wx.Panel.__init__(self,parent,id, style=wx.WANTS_CHARS)
     sizer = wx.BoxSizer(wx.VERTICAL)
     self.SetSizer(sizer)
     self.SetSizeHints(-1,50)
     #--ListCtrl
     listId = self.listId = wx.NewId()
     self.list = ListCtrl(self, listId, style=ctrlStyle)
     self.checkboxes = singletons.images['mash.checkboxes']
     #--Columns
     self.PopulateColumns()
     #--Items
     self.sortDirty = 0
     self.PopulateItems()
     self.hitIcon = 0
     self.mouseItem = None
     #--Events
     wx.EVT_SIZE(self, self.OnSize)
     wx.EVT_LEFT_DOWN(self.list,self.OnLeftDown)
     wx.EVT_COMMAND_RIGHT_CLICK(self.list, listId, self.DoItemMenu)
     wx.EVT_LIST_COL_CLICK(self, listId, self.DoItemSort)
     wx.EVT_LIST_COL_RIGHT_CLICK(self, listId, self.DoColumnMenu)
     wx.EVT_LIST_COL_END_DRAG(self, listId, self.OnColumnResize)
     wx.EVT_MOTION(self.list, self.OnMouse)
     wx.EVT_LEAVE_WINDOW(self.list, self.OnMouse)
     # Theming
     if interface.style['lists.font.color'] is not None:
         [self.list.SetItemTextColour(x, interface.style['lists.font.color']) for x in xrange(self.list.GetItemCount())]
         self.fontDefaultColor = interface.style['lists.font.color']
     else: self.fontDefaultColor = wx.SystemSettings.GetColour(wx.SYS_COLOUR_LISTBOXTEXT)
     self.list.Bind(wx.EVT_ENTER_WINDOW, self.hoverInCtrl)
コード例 #10
0
ファイル: diana.py プロジェクト: yanweiLiang/diana
    def __init__(self, parent):
        self.win = parent
        #self.image = wx.Image(os.path.join(HOME,'target.png'), wx.BITMAP_TYPE_PNG)
        self.image = images.gettargetImage()
        #self.mask = wx.Image(os.path.join(HOME,'mask.png'), wx.BITMAP_TYPE_PNG)
        self.mask = images.getmaskImage()
        self.aspect = self.image.GetWidth() / float(self.image.GetHeight())
        self.color = "RED"
        self.click = 0
        self.score = 0
        self.time = 0
        self.lastPos = None
        self.shoots = []

        wx.Window.__init__(self,
                           parent,
                           -1,
                           size=(200, 200),
                           style=wx.SIMPLE_BORDER)
        wx.EVT_SIZE(self, self.OnSize)
        wx.EVT_PAINT(self, self.OnPaint)
        wx.EVT_LEFT_DOWN(self, self.OnLeftClick)
        wx.EVT_LEFT_UP(self, self.OnLeftClickEnd)
        wx.EVT_MOTION(self, self.OnMotion)
        try:
            self.shoot = wx.Sound(os.path.join(HOME, "shoot.wav"))
        except:
            self.shoot = None
コード例 #11
0
ファイル: playfield.py プロジェクト: P4thos/eggofpanku
    def __init__(self, parent, id=wx.ID_ANY, eventTarget=None):
        canvas.L5RCanvas.__init__(self, parent, id)
        self.eventTarget = eventTarget or self

        self.gameState = None
        self.player = None
        self.isLocal = False

        self.markerPos = None
        self.markerOffset = (0, 0)
        self.attachMarker = None

        self.texBorderFrame = self.LoadTexture(
            os.path.join(locationsettings.data_dir, "images/border2.png"))
        self.texAttach = self.LoadTexture(
            os.path.join(locationsettings.data_dir, "images/border3.png"))

        wx.EVT_LEFT_DOWN(self, self.OnLeftMouseDown)
        wx.EVT_LEFT_DCLICK(self, self.OnDoubleClick)
        wx.EVT_RIGHT_DOWN(self, self.OnRightMouseDown)
        wx.EVT_MOTION(self, self.OnMotion)
        wx.EVT_MOUSEWHEEL(self, self.OnMouseWheel)
        wx.EVT_MIDDLE_DOWN(self, self.OnMouseWheelDown)

        self.SetDropTarget(
            dragdrop.CardDropTarget(self.OnDragData, self.OnDragOver,
                                    self.OnDragLeave))

        self.texToken = {}
        self.texMarker = {}
        self.contextCard = None
        self.hoverCard = None
        self.pfHeight = DEFAULT_PLAYFIELD_HEIGHT
        self.background = PlayfieldCanvasBackground()
コード例 #12
0
 def _on_close(self, event):
     # Might be scrollbars or other native components under
     # us that are generating this event
     if event.GetWindow() == self.control:
         self._gc = None
         wx.EVT_ERASE_BACKGROUND(self.control, None)
         wx.EVT_PAINT(self.control, None)
         wx.EVT_SIZE(self.control, None)
         wx.EVT_LEFT_DOWN(self.control, None)
         wx.EVT_LEFT_UP(self.control, None)
         wx.EVT_LEFT_DCLICK(self.control, None)
         wx.EVT_MIDDLE_DOWN(self.control, None)
         wx.EVT_MIDDLE_UP(self.control, None)
         wx.EVT_MIDDLE_DCLICK(self.control, None)
         wx.EVT_RIGHT_DOWN(self.control, None)
         wx.EVT_RIGHT_UP(self.control, None)
         wx.EVT_RIGHT_DCLICK(self.control, None)
         wx.EVT_MOTION(self.control, None)
         wx.EVT_ENTER_WINDOW(self.control, None)
         wx.EVT_LEAVE_WINDOW(self.control, None)
         wx.EVT_MOUSEWHEEL(self.control, None)
         wx.EVT_KEY_DOWN(self.control, None)
         wx.EVT_KEY_UP(self.control, None)
         wx.EVT_CHAR(self.control, None)
         wx.EVT_WINDOW_DESTROY(self.control, None)
         self.control.SetDropTarget(None)
         self.control = None
         self.component.cleanup(self)
         self.component.parent = None
         self.component.window = None
         self.component = None
     return
コード例 #13
0
 def _bindMouseEvents(self):
     """Binds wx mouse events and custom mouse events"""
     wx.EVT_MOUSE_EVENTS(self, self._mouseActions)
     wx.EVT_MOTION(self, self._mouseMotion)
     self.Bind(EVT_MOTION, self.OnMotion)
     self.Bind(EVT_MOUSE_EVENTS, self.MouseActions)
     self.Bind(wx.EVT_CONTEXT_MENU, self.OnContextMenu)
コード例 #14
0
ファイル: openglGui.py プロジェクト: lssang/testRepo
	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._glRobotTexture = 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_CHAR(self, self._OnGuiKeyChar)
		wx.EVT_KILL_FOCUS(self, self.OnFocusLost)
		wx.EVT_IDLE(self, self._OnIdle)
コード例 #15
0
ファイル: listviews.py プロジェクト: DevangThakkar/Snatch
 def CreateControls(self):
     """Create our sub-controls"""
     wx.EVT_LIST_COL_CLICK(self, self.GetId(), self.OnReorder)
     wx.EVT_LIST_ITEM_SELECTED(self, self.GetId(), self.OnNodeSelected)
     wx.EVT_MOTION(self, self.OnMouseMove)
     wx.EVT_LIST_ITEM_ACTIVATED(self, self.GetId(), self.OnNodeActivated)
     self.CreateColumns()
コード例 #16
0
    def __init__(self, parent):
        wx.Panel.__init__(self, parent)

        wx.EVT_SIZE(self, self.OnSize)
        wx.EVT_IDLE(self, self.OnIdle)
        wx.EVT_MOVE(self, self.OnMove)
        wx.EVT_SET_FOCUS(self, self.OnFocus)
        wx.EVT_KILL_FOCUS(self, self.OnLostFocus)
        wx.EVT_MAXIMIZE(self, self.OnMaximize)

        wx.EVT_LEFT_DOWN(self, self.OnLeftDown)
        #~ wx.EVT_LEFT_UP(self, self.OnLeftUp)
        wx.EVT_RIGHT_DOWN(self, self.OnRightDown)
        wx.EVT_MIDDLE_DOWN(self, self.OnMiddleDown)
        wx.EVT_RIGHT_UP(self, self.OnRightUp)
        wx.EVT_MIDDLE_UP(self, self.OnMiddleUp)
        wx.EVT_MOTION(self, self.OnMotion)
        wx.EVT_KEY_DOWN(self, self.OnKeyDown)

        self._3dDisplay = None
        self._inited = False
        self.DynaZoom = False
        self.DynaRotate = False
        self.DynaPan = False
        self.dragStartPos = None
        self._drawbox = None
        self._selection = None

        if sys.platform == 'win32':
            self.Init3dViewer()
コード例 #17
0
    def _CreateCanvas(self, parent):
        self._canvas = ogl.ShapeCanvas(parent)
        wx.EVT_LEFT_DOWN(self._canvas, self.OnLeftClick)
        wx.EVT_LEFT_UP(self._canvas, self.OnLeftUp)
        wx.EVT_MOTION(self._canvas, self.OnLeftDrag)
        wx.EVT_LEFT_DCLICK(self._canvas, self.OnLeftDoubleClick)
        wx.EVT_KEY_DOWN(self._canvas, self.OnKeyPressed)

        # need this otherwise mouse clicks don't set focus to this view
        wx.EVT_LEFT_DOWN(self._canvas, self.FocusOnClick)
        wx.EVT_LEFT_DCLICK(self._canvas, self.FocusOnClick)
        wx.EVT_RIGHT_DOWN(self._canvas, self.FocusOnClick)
        wx.EVT_RIGHT_DCLICK(self._canvas, self.FocusOnClick)
        wx.EVT_MIDDLE_DOWN(self._canvas, self.FocusOnClick)
        wx.EVT_MIDDLE_DCLICK(self._canvas, self.FocusOnClick)

        wx.EVT_KILL_FOCUS(self._canvas, self.OnKillFocus)
        wx.EVT_SET_FOCUS(self._canvas, self.OnFocus)

        self._canvas.SetScrollbars(20, 20, self._maxWidth / 20,
                                   self._maxHeight / 20)

        self._canvas.SetBackgroundColour(self._backgroundColor)
        self._diagram = ogl.Diagram()
        self._canvas.SetDiagram(self._diagram)
        self._diagram.SetCanvas(self._canvas)
        self._canvas.SetFont(NORMALFONT)
コード例 #18
0
    def setupCallbacks(self):
        """Setup various callbacks for this context

        Binds most of the wxPython event types to callbacks on this
        object, which allows interactive sub-classes to easily
        manage the bindings without needing any wxPython-specific
        logic.
        """
        if not self.init:
            self.init = 1
            # Bind the wxPython background erase event
            # Without this binding, the canvas will tend to flicker
            wx.EVT_ERASE_BACKGROUND(self, self.wxOnEraseBackground)
            # Handle resizing of the window
            wx.EVT_SIZE(self, self.wxOnSize)
            # Handle requests to display this canvas
            wx.EVT_PAINT(self, self.wxOnPaint)
            # Handle keyboard events...
            wx.EVT_KEY_DOWN(self, self.wxOnKeyDown)
            wx.EVT_KEY_UP(self, self.wxOnKeyUp)
            wx.EVT_CHAR(self, self.wxOnCharacter)
            # Handle mouse events...
            wx.EVT_LEFT_DOWN(self, self.wxOnMouseButton)
            wx.EVT_RIGHT_DOWN(self, self.wxOnMouseButton)
            wx.EVT_MIDDLE_DOWN(self, self.wxOnMouseButton)
            wx.EVT_LEFT_UP(self, self.wxOnMouseButton)
            wx.EVT_RIGHT_UP(self, self.wxOnMouseButton)
            wx.EVT_MIDDLE_UP(self, self.wxOnMouseButton)
            wx.EVT_MOTION(self, self.wxOnMouseMove)
            if hasattr(self, 'OnIdle'):
                wx.EVT_IDLE(self, self.wxOnIdle)
コード例 #19
0
    def __init__(self, parent, id, shapes=None, **kwds):
        wx.glcanvas.GLCanvas.__init__(self, parent, id, **kwds)
        self.parent = parent
        self.camera = Camera()
        self.init = False
        self.lastx = self.x = 30
        self.lasty = self.y = 30

        self.create_menu()

        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_MIDDLE_DOWN(self, self.OnMouseDown)
        wx.EVT_RIGHT_DOWN(self, self.OnMouseDown)
        wx.EVT_LEFT_UP(self, self.OnMouseUp)
        wx.EVT_MIDDLE_UP(self, self.OnMouseUp)
        wx.EVT_RIGHT_UP(self, self.OnMouseUp)
        wx.EVT_MOTION(self, self.OnMouseMotion)

        self.popup_menu = 0
        self.color = (0., 0., 0.)  #black
        #self.color = (1.,1.,1.) #white
        self.dlist = None
        self.measure = False
        self.sketching = False
        self.shapes = shapes

        self.left_button_click = True
        self.middle_button_click = True
        self.right_button_click = True

        self.beginx, self.beginy = 0, 0
        return
コード例 #20
0
    def __init__(self, parent, winid, value=0.0, title='', **kwds):
        """Layout similar to a bar, but provides a slider for user setting of the value.
        Fires off events when the user changes the value, see add_listener."""
        self._state = "IDLE"  # The state of the control for responding to mouse events
        self._processed = False
        wxBar.__init__(self, parent, winid, value=value, title=title, **kwds)

        self._listeners = []
        self._bar_rect = None  # The rectangle for the bar.  Also see comments in __move_mouse
        self._ptr_rect = None  # The rectangle where the pointer is drawn
        self._rbutton = None  # Rectangle for right button
        self._lbutton = None  # Rectangle for left button
        self._counter = None  # Number of timer ticks since mouse down
        self._value_point = None  # Last x position of the pointer's mark
        self._original_value_point = None  # The pointer mark x position at the moment when mouse down occurred
        self._original_value = None  # The value shown by the slider when mouse went down
        self._last_rect = None  # The last value for the full rectangle (used in scaling)
        self._jump_value = None  # X position of the mouse for a jump operation
        self._offset = None  # Difference between the mouse pointer and the slider mark
        self._is_close = None  # True when the mouse was clicked close to one of the vernier buttons

        wx.EVT_LEFT_DOWN(self, self.__left_down)
        wx.EVT_LEFT_UP(self, self.__left_up)
        wx.EVT_MOTION(self, self.__move_mouse)
        wx.EVT_RIGHT_UP(self, self.__right_up)

        self._timer = wx.Timer(self, 100)
        wx.EVT_TIMER(self, 100, self.__tick)
        self._i_have_mouse = False
コード例 #21
0
    def __init__(self, parent):
        GLCanvas.__init__(self,
                          parent,
                          -1,
                          attribList=[wx.glcanvas.WX_GL_DOUBLEBUFFER])

        self.t_graph = TransferGraph(self)

        wx.EVT_PAINT(self, self.OnDraw)
        wx.EVT_SIZE(self, self.OnSize)
        wx.EVT_MOTION(self, self.OnMouseMotion)
        wx.EVT_LEFT_DOWN(self, self.OnMouseLeftDown)
        wx.EVT_LEFT_UP(self, self.OnMouseLeftUp)
        wx.EVT_ERASE_BACKGROUND(self, lambda e: None)
        wx.EVT_CLOSE(self, self.OnClose)
        wx.EVT_CHAR(self, self.OnKeyDown)

        self.SetFocus()

        # So we know when new values are added / changed on the tgraph
        self.t_graph.Connect(-1, -1, wx.wxEVT_COMMAND_SLIDER_UPDATED,
                             self.OnTGraphUpdate)

        self.init = False
        self.rotation_y = 0.0
        self.rotation_x = 0.0
        self.prev_y = 0
        self.prev_x = 0
        self.mouse_down = False

        self.width = 400
        self.height = 400

        self.fragment_shader_src = '''
        uniform sampler1D TransferFunction;
        uniform sampler3D VolumeData;       
        void main(void)
        {            
            gl_FragColor = vec4(1.0, 0.0, 0.0, 0.0);
        }
        '''

        self.vertex_shader_src = '''
        void main(void)
        {
            gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
        }
        '''
        self.fragment_src_file = 'earth.f.c'
        self.vertex_src_file = 'earth.v.c'
        self.lighting = False
        self.light_count = 1

        # List of textures that need to be freed
        self.texture_list = []
        # List of VBOs that need to be freed
        self.buffers_list = []
        # This is the transfer graph
        self.t_graph.Show()
コード例 #22
0
ファイル: glCanvasTest.py プロジェクト: cboirum/pyVideoWall
 def __init__(self, parent):
     GLCanvas.__init__(self, parent,-1, attribList=[wx.glcanvas.WX_GL_DOUBLEBUFFER])
     wx.EVT_PAINT(self, self.OnDraw)
     wx.EVT_SIZE(self, self.OnSize)
     wx.EVT_MOTION(self, self.OnMouseMotion)
     wx.EVT_WINDOW_DESTROY(self, self.OnDestroy)
     
     self.init = True
コード例 #23
0
ファイル: rangedslider.py プロジェクト: deosai/bitpim
    def __init__(self,
                 parent,
                 id=-1,
                 size=wx.DefaultSize,
                 pos=wx.DefaultPosition,
                 style=0):
        wx.PyWindow.__init__(self,
                             parent,
                             id=id,
                             size=size,
                             pos=pos,
                             style=style | wx.FULL_REPAINT_ON_RESIZE)

        self.bg = wx.Brush(parent.GetBackgroundColour())

        self.imgcurrent = guihelper.getimage("ranged-slider-current")
        self.bmpcurrent = self.imgcurrent.ConvertToBitmap()
        self.imgstart = guihelper.getimage("ranged-slider-start")
        self.bmpstart = self.imgstart.ConvertToBitmap()
        self.imgend = guihelper.getimage("ranged-slider-end")
        self.bmpend = self.imgend.ConvertToBitmap()

        # first coord is added to desired x to get where to draw x
        # second is added to centre of line to get where to draw y
        self.hotcurrent = -self.imgcurrent.GetWidth(
        ) / 2, -self.imgcurrent.GetHeight() + 2
        self.hotstart = -13, -20
        self.hotend = -7, -20

        self.pickers=(self.imgcurrent, self.bmpcurrent,self.hotcurrent), \
                      (self.imgstart, self.bmpstart, self.hotstart), \
                      (self.imgend, self.bmpend, self.hotend)

        self.padleft = 2 + max([0] + [-h[0] for _, _, h in self.pickers])
        self.padright = 2 + max(
            [0] + [i.GetWidth() + h[0] for i, _, h in self.pickers])

        assert self.padleft >= 2
        assert self.padright >= 2
        self.padleft = max(self.padleft, self.padright)
        self.padright = self.padleft

        self.poscurrent = 0.5
        self.posstart = 0.0
        self.posend = 1.0

        self._bufbmp = None

        self.pen = wx.Pen(wx.NamedColour("LIGHTSTEELBLUE3"), self.THICKNESS)
        self.pen.SetCap(wx.CAP_BUTT)

        self.clickinfo = None

        wx.EVT_ERASE_BACKGROUND(self, lambda evt: None)
        wx.EVT_PAINT(self, self.OnPaint)
        wx.EVT_LEFT_DOWN(self, self.OnLeftDown)
        wx.EVT_LEFT_UP(self, self.OnLeftUp)
        wx.EVT_MOTION(self, self.OnMotion)
コード例 #24
0
    def show(self):
        """ Shows the feature bar.
        """
        # Make sure all prerequisites are met:
        dock_control, parent = self.dock_control, self.parent
        if (dock_control is None) or (parent is None):
            return

        # Create the actual control (if needed):
        control = self.control
        if control is None:
            self.control = control = wx.Frame(None,
                                              -1,
                                              '',
                                              style=wx.BORDER_NONE)

            # Set up the 'erase background' event handler:
            wx.EVT_ERASE_BACKGROUND(control, self._erase_background)

            # Set up the 'paint' event handler:
            wx.EVT_PAINT(control, self._paint)

            # Set up mouse event handlers:
            wx.EVT_LEFT_DOWN(control, self._left_down)
            wx.EVT_LEFT_UP(control, self._left_up)
            wx.EVT_RIGHT_DOWN(control, self._right_down)
            wx.EVT_RIGHT_UP(control, self._right_up)
            wx.EVT_MOTION(control, self._mouse_move)
            wx.EVT_ENTER_WINDOW(control, self._mouse_enter)

            control.SetDropTarget(PythonDropTarget(self))

        # Calculate the best size and position for the feature bar:
        size = wx.Size(32, 32)
        width = height = 0
        horizontal = self.horizontal
        for feature in dock_control.active_features:
            bitmap = feature.bitmap
            if bitmap is not None:
                if horizontal:
                    width += (bitmap.GetWidth() + 3)
                    height = max(height, bitmap.GetHeight())
                else:
                    width = max(width, bitmap.GetWidth())
                    height += (bitmap.GetHeight() + 3)

        if width > 0:
            if horizontal:
                size = wx.Size(width + 5, height + 8)
            else:
                size = wx.Size(width + 8, height + 5)

        control.SetSize(size)
        px, py = parent.GetScreenPosition()
        fx, fy = dock_control.feature_popup_position
        control.SetPosition(wx.Point(px + fx, py + fy))
        control.Show()
コード例 #25
0
 def MapEvents(self):
     wx.EVT_SCROLLWIN(self, self.OnScroll)
     wx.EVT_PAINT(self, self.OnPaint)
     wx.EVT_SIZE(self, self.OnSize)
     wx.EVT_ERASE_BACKGROUND(self, self.OnEraseBackground)
     wx.EVT_LEFT_DOWN(self, self.OnMouseButtonEvent)
     wx.EVT_LEFT_UP(self, self.OnMouseButtonEvent)
     wx.EVT_MOTION(self, self.OnMouseButtonEvent)
     wx.EVT_CHAR(self, self.OnChar)
コード例 #26
0
          def __init__(self, parent, game):
              pypoujol.ClanlibCanvas.__init__(self, parent, game)

              wx.EVT_PAINT(self.canvas, self.OnPaint)
              wx.EVT_IDLE(self.canvas, self.OnIdle)
              wx.EVT_LEFT_DOWN(self.canvas, speculoos.on_left_button_down)
              wx.EVT_LEFT_UP(self.canvas, speculoos.on_left_button_up)
              wx.EVT_RIGHT_DOWN(self.canvas, speculoos.on_right_button_down)
              wx.EVT_MOTION(self.canvas, speculoos.on_mouse_motion)
コード例 #27
0
    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)
        #self.initGL()

        #Load in candide mesh information and store in an index buffer
        fin = open('candideFaces.txt', 'r')
        self.candideIndices = np.array([[int(a) for a in x.split()]
                                        for x in fin.readlines()],
                                       dtype=np.int32)
        self.candideFaces = vbo.VBO(candideIndices,
                                    target=GL_ELEMENT_ARRAY_BUFFER)
        fin.close()
        fin = open('candideTexCoords.txt', 'r')
        self.texCoords = vbo.VBO(
            np.array([[float(a) for a in x.split()] for x in fin.readlines()],
                     dtype=np.float32))
        fin.close()
        self.texID = -1
コード例 #28
0
ファイル: testGMDS.py プロジェクト: ctralie/G-RFLCT
    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.initiallyResized = False

        self.bbox = BBox3D()
        self.unionbbox = BBox3D()
        random.seed()

        #Face mesh variables and manipulation variables
        self.mesh1 = None
        self.mesh1Dist = None
        self.mesh1DistLoaded = False
        self.mesh2 = None
        self.mesh2DistLoaded = False
        self.mesh2Dist = None
        self.mesh3 = None
        #Holds the transformations of the best iteration in ICP
        self.transformations = []
        self.savingMovie = False
        self.movieIter = 0

        self.displayMeshFaces = True
        self.displayMeshEdges = False
        self.displayMeshVertices = False
        self.displayMeshNormals = False
        self.displayPrincipalAxes = False
        self.vertexColors = np.zeros(0)

        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)
コード例 #29
0
    def init(self, parent):
        """ Finishes initializing the editor by creating the underlying toolkit
            widget.
        """
        factory = self.factory
        # Establish the range of the slider:
        low, high = factory.low, factory.high
        if high <= low:
            low = high = None
            range = self.object.trait(self.name).handler
            if isinstance(range, Range):
                low, high = range._low, range._high
            if low is None:
                if high is None:
                    high = 1.0
                low = high - 1.0
            elif high is None:
                high = low + 1.0

        # Establish the slider increment:
        increment = factory.increment
        if increment <= 0.0:
            if isinstance(low, int):
                increment = 1.0
            else:
                increment = pow(10, int(log10((high - low) / 1000.0)))

        # Save the values we calculated:
        self.set(low=low, high=high, increment=increment)

        # Create the control:
        self.control = control = wx.Window(parent,
                                           -1,
                                           size=wx.Size(70, 20),
                                           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_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)
        wx.EVT_ENTER_WINDOW(control, self._enter_window)
        wx.EVT_LEAVE_WINDOW(control, self._leave_window)

        # Set up the control resize handler:
        wx.EVT_SIZE(control, self._resize)

        # Set the tooltip:
        if not self.set_tooltip():
            control.SetToolTipString('[%g..%g]' % (low, high))
コード例 #30
0
 def genericinit(self, iconfile):
     self.SetCursor(wx.StockCursor(wx.CURSOR_HAND))
     bitmap=wx.Bitmap(guihelper.getresourcefile(iconfile), wx.BITMAP_TYPE_PNG)
     bit=wx.StaticBitmap(self, -1, bitmap)
     self.Show(True)
     wx.EVT_RIGHT_UP(bit, self.OnRButtonUp)
     wx.EVT_LEFT_UP(bit, self.OnLButtonUp)
     wx.EVT_MOTION(bit, self.OnMouseMotion)
     wx.EVT_LEFT_DOWN(bit, self.OnLeftDown)
     self.bit=bit