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)
示例#2
0
    def create_widget(self):
        tb_style = wx.TB_HORIZONTAL | self.style
        if wx.Platform == '__WXGTK__':
            tb_style |= wx.TB_DOCKABLE | wx.TB_FLAT
        if self.parent:
            self.pwidget = self.widget = wx.ToolBar(
                self.parent.widget, -1, style=tb_style)
            self.parent.widget.SetToolBar(self.pwidget)
        else:
            # "top-level" toolbar
            self.pwidget = wx.Frame(None, -1, misc.design_title(self.name))
            self.pwidget.SetClientSize((400, 30))
            self.widget = wx.ToolBar(self.pwidget, -1, style=tb_style)
            self.pwidget.SetToolBar(self.widget)
            self.pwidget.SetBackgroundColour(self.widget.GetBackgroundColour())
            icon = wx.EmptyIcon()
            xpm = os.path.join(config.icons_path, 'toolbar.xpm')
            icon.CopyFromBitmap(misc.get_xpm_bitmap(xpm))
            self.pwidget.SetIcon(icon)
            wx.EVT_CLOSE(self.pwidget, lambda e: self.hide_widget())
            wx.EVT_LEFT_DOWN(self.widget, self.on_set_focus)
            if wx.Platform == '__WXMSW__':
                # MSW isn't smart enough to avoid overlapping windows, so
                # at least move it away from the 3 wxGlade frames
                self.pwidget.CenterOnScreen()
        wx.EVT_LEFT_DOWN(self.pwidget, self.on_set_focus)

        # set the various property values
        self._set_bitmapsize()
        self._set_margins()
        self._set_packing()
        self._set_separation()

        self._set_tools()  # show the menus
示例#3
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)
示例#4
0
    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()
示例#5
0
    def __init__(self, parent, **traits):
        """ Creates a new widget. """

        # Base class constructors.
        super(ImageWidget, self).__init__(**traits)

        # Add some padding around the image.
        size = (self.bitmap.GetWidth() + 10, self.bitmap.GetHeight() + 10)

        # Create the toolkit-specific control.
        self.control = wx.Window(parent, -1, size=size)
        self.control.__tag__ = 'hack'

        self._mouse_over = False
        self._button_down = False

        # Set up mouse event handlers:
        wx.EVT_ENTER_WINDOW(self.control, self._on_enter_window)
        wx.EVT_LEAVE_WINDOW(self.control, self._on_leave_window)
        wx.EVT_LEFT_DCLICK(self.control, self._on_left_dclick)
        wx.EVT_LEFT_DOWN(self.control, self._on_left_down)
        wx.EVT_LEFT_UP(self.control, self._on_left_up)
        wx.EVT_PAINT(self.control, self._on_paint)

        # Pens used to draw the 'selection' marker:
        # ZZZ: Make these class instances when moved to the wx toolkit code.
        self._selectedPenDark = wx.Pen(
            wx.SystemSettings_GetColour(wx.SYS_COLOUR_3DSHADOW), 1, wx.SOLID)

        self._selectedPenLight = wx.Pen(
            wx.SystemSettings_GetColour(wx.SYS_COLOUR_3DHIGHLIGHT), 1,
            wx.SOLID)

        return
示例#6
0
    def __init__(self,
                 parent,
                 bitmap,
                 selected=None,
                 handler=None,
                 padding=10):
        """ Initializes the object.
        """
        wx.Window.__init__(self,
                           parent,
                           -1,
                           size=wx.Size(bitmap.GetWidth() + padding,
                                        bitmap.GetHeight() + padding))
        self._bitmap = bitmap
        self._selected = selected
        self._handler = handler
        self._mouse_over = False
        self._button_down = False

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

        # Set up mouse event handlers:
        wx.EVT_LEFT_DOWN(self, self._on_left_down)
        wx.EVT_LEFT_UP(self, self._on_left_up)
        wx.EVT_ENTER_WINDOW(self, self._on_enter)
        wx.EVT_LEAVE_WINDOW(self, self._on_leave)
 def create_widget(self):
     choices = [c[0] for c in self.choices]
     self.widget = wx.CheckListBox(self.parent.widget,
                                   self.id,
                                   choices=choices)
     self.widget.SetSelection(self.selection)
     wx.EVT_LEFT_DOWN(self.widget, self.on_set_focus)
示例#8
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()
示例#9
0
    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)
示例#10
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)
示例#11
0
 def NextDialog2(self):
     self.Flag = 2
     self.question.SetLabel("Choose the Chapter:")
     self.butList[0].SetLabel("Addition")
     self.butList[1].SetLabel("Subtraction")
     self.butList[2].SetLabel("Multiplication")
     self.butList[3].SetLabel("Division")
     self.butList.append(wx.Button(self.MainPanel, 4, 'LCM'))
     self.butList[4].Bind(wx.EVT_BUTTON, self.OnButtonClick)
     self.butList.append(wx.Button(self.MainPanel, 5, 'Exit'))
     self.butList[5].Bind(wx.EVT_BUTTON, self.OnExitClick)
     x, y = self.butList[0].GetPosition()
     maxx, maxy = wx.GetDisplaySize()
     for i in range(6):
         sz = len(self.butList[i].GetLabel())
         wd = 30 * sz + 10
         self.butList[i].SetSize((wd, 60))
         self.butList[i].SetFont(self.font)
         if x + wd + 20 > maxx:
             y += 80
             x = 20
         self.butList[i].SetPosition((x, y))
         x += wd + 20
     self.menuRefresh()
     wx.EVT_LEFT_DOWN(self.MainPanel, self.OnLeftClick3)  #Mouse Event
示例#12
0
    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
示例#13
0
    def __init__(self, parent, wxId, id, style=0):
        self.style = style

        if style == List.STYLE_CHECKBOX:
            # Listbox with checkable items.
            base.Widget.__init__(self, wx.CheckListBox(parent, wxId))
        elif style == List.STYLE_COLUMNS:
            base.Widget.__init__(self,
                                 wx.ListCtrl(parent, wxId, style=wx.LC_REPORT))
            #wx.SIMPLE_BORDER)))
            wx.EVT_LEFT_DOWN(self.getWxWidget(), self.onLeftUp)
            wx.EVT_LIST_ITEM_SELECTED(parent, wxId, self.onItemSelected)
            wx.EVT_LIST_ITEM_DESELECTED(parent, wxId, self.onItemDeselected)
            wx.EVT_LIST_COL_CLICK(parent, wxId, self.onColumnClick)
        else:
            # Normal listbox.
            if style == List.STYLE_MULTIPLE:
                styleFlags = wx.LB_EXTENDED
            elif style == List.STYLE_SINGLE:
                styleFlags = wx.LB_SINGLE
            base.Widget.__init__(self,
                                 wx.ListBox(parent, wxId, style=styleFlags))

        # Will be used when sending notifications.
        self.widgetId = id

        self.expandingColumnIndex = -1

        self.items = []
        self.columns = []

        wx.EVT_SIZE(self.getWxWidget(), self.onSize)
示例#14
0
    def OnInit(self):

        rsrc = xrc.XmlResource(RSRC_FILE)
        self.frame = rsrc.LoadFrame(None, "FRAME")
        self.frame.Show()
        self.img_panel = xrc.XRCCTRL(self.frame, "PANEL")
        box = wx.BoxSizer(wx.VERTICAL)
        self.img_panel.SetSizer(box)
        self.img_wind = wxvideo.GLCanvas(self.img_panel, -1)
        box.Add(self.img_wind, 1, wx.EXPAND)
        self.img_panel.SetAutoLayout(True)
        self.img_panel.Layout()

        wx.EVT_LEFT_DOWN(self.img_wind, self.MouseClick)
        #self.img_wind.Bind(wx.EVT_LEFT_DOWN,self.MouseClick)

        #self.filename = '/home/kristin/FLIES/data/walking_arena/movie20071009_155327.sbfmf'
        #self.movie = movies.Movie(self.filename,True)
        #imd,stamp = self.movie.get_frame( 1 )
        #print 'imd = ' + str(imd)
        #print 'minv = ' + str(nx.min(imd))
        #im8 = imagesk.double2mono8(imd)
        #print 'im8 = ' + str(im8)
        #print 'minv = ' + str(nx.min(im8))
        #print 'im8.shape = ' + str(im8.shape)

        #im8 = nx.zeros((1024,1024),dtype=nx.uint8)

        #self.img_wind.update_image_and_drawings('camera',im8,format='MONO8')

        return True
示例#15
0
 def __init__(self,
              parent,
              id=-1,
              ctrlStyle=(wx.LC_REPORT | wx.LC_SINGLE_SEL)):
     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 = globals.images['mash.checkboxes']
     #--Columns
     self.PopulateColumns()
     #--Items
     self.sortDirty = 0
     self.PopulateItems()
     #--Events
     wx.EVT_SIZE(self, self.OnSize)
     #--Events: Items
     self.hitIcon = 0
     wx.EVT_LEFT_DOWN(self.list, self.OnLeftDown)
     wx.EVT_COMMAND_RIGHT_CLICK(self.list, listId, self.DoItemMenu)
     #--Events: Columns
     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)
示例#16
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)
示例#17
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
示例#18
0
文件: dhtgui.py 项目: zygzx/rtclite
    def __init__(self, parent=None, size=(500, 600), model=None, control=None):
        wx.Panel.__init__(self, parent, size=size)
        wx.EVT_PAINT(self, self.OnPaint)
        wx.EVT_LEFT_DOWN(self, self.OnMouseDown)
        wx.EVT_SIZE(self, self.OnSize)
        self.model = model
        self.control = control
        self.brush = dict(glass=wx.Brush('white', style=wx.TRANSPARENT), blue=wx.Brush('#d0d0ff', style=wx.SOLID), grey=wx.Brush('#d0d0d0', style=wx.SOLID), red=wx.Brush('#ff0000', style=wx.SOLID), green=wx.Brush('#008000', style=wx.SOLID))
        self.pen   = dict(glass=wx.Pen('white', width=0, style=wx.TRANSPARENT), black=wx.Pen('black', 1, style=wx.SOLID), grey=wx.Pen('#d0d0d0', width=1, style=wx.SOLID), blue=wx.Pen('#d0d0ff', width=1, style=wx.SOLID), red=wx.Pen('red', width=2, style=wx.DOT), green=wx.Pen('#008000', width=2, style=wx.SOLID))

        self.key = wx.TextCtrl(self, pos=wx.Point(20, size[1]-60), size=wx.Size(70, 20), value='Key')
        self.value = wx.TextCtrl(self, pos=wx.Point(100, size[1]-60), size=wx.Size(70, 20), value='Value')
        self.put = wx.Button(self, pos=wx.Point(180, size[1]-60), size=wx.Size(40, 20), label='put')
        self.get = wx.Button(self, pos=wx.Point(230, size[1]-60), size=wx.Size(40, 20), label='get')
        self.remove = wx.Button(self, pos=wx.Point(280, size[1]-60), size=wx.Size(40, 20), label='rm')
        self.user = wx.TextCtrl(self, pos=wx.Point(20, size[1]-30), size=wx.Size(130, 20), value='*****@*****.**')
        self.bind = wx.Button(self, pos=wx.Point(160, size[1]-30), size=wx.Size(80, 20), label='bind')
        self.conn = wx.Button(self, pos=wx.Point(250, size[1]-30), size=wx.Size(80, 20), label='connect')
        self.sendto = wx.Button(self, pos=wx.Point(340, size[1]-30), size=wx.Size(80, 20), label='sendto')
        self.put.Bind(wx.EVT_BUTTON, self.onUserButton)
        self.get.Bind(wx.EVT_BUTTON, self.onUserButton)
        self.remove.Bind(wx.EVT_BUTTON, self.onUserButton)
        self.bind.Bind(wx.EVT_BUTTON, self.onUserButton)
        self.conn.Bind(wx.EVT_BUTTON, self.onUserButton)
        self.sendto.Bind(wx.EVT_BUTTON, self.onUserButton)
示例#19
0
 def NextDialog1(self):
     self.Flag = 1
     self.question.SetLabel(
         "Choose the Speed of Cursor Movement \n(Present cursor movement is the slowest)"
     )
     self.butList[0].SetLabel("Fastest")
     self.butList[1].SetLabel("Fast")
     self.butList[2].SetLabel("Slow")
     self.butList.append(
         wx.Button(self.MainPanel, 3, 'Slower', size=(190, 60)))
     self.butList[3].Bind(wx.EVT_BUTTON, self.OnButtonClick)
     self.font.SetPointSize(30)
     x, y = self.butList[0].GetPosition()
     maxx, maxy = wx.GetDisplaySize()
     for i in range(4):
         sz = len(self.butList[i].GetLabel())
         wd = 30 * sz + 10
         self.butList[i].SetFont(self.font)
         self.butList[i].SetSize((wd, 60))
         if x + wd + 20 > maxx:
             y += 80
             x = 20
         self.butList[i].SetPosition((x, y))
         x += wd + 20
     self.menuRefresh()
     wx.EVT_LEFT_DOWN(self.MainPanel, self.OnLeftClick2)  #Mouse Event
示例#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,
                 editor,
                 parent,
                 wid=-1,
                 pos=wx.DefaultPosition,
                 size=wx.DefaultSize):

        super(KeyBindingCtrl,
              self).__init__(parent,
                             wid,
                             pos,
                             size,
                             style=wx.CLIP_CHILDREN | wx.WANTS_CHARS)
        # Save the reference to the controlling editor object:
        self.editor = editor

        # Indicate we don't have the focus right now:
        editor.has_focus = False

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

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

        # Set up the focus change handlers:
        wx.EVT_SET_FOCUS(self, self._get_focus)
        wx.EVT_KILL_FOCUS(self, self._lose_focus)

        # Set up mouse event handlers:
        wx.EVT_LEFT_DOWN(self, self._set_focus)
        wx.EVT_LEFT_DCLICK(self, self._clear_contents)

        # Handle key events:
        wx.EVT_CHAR(self, self._on_char)
示例#22
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)
示例#23
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, 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)
示例#24
0
    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 = []
示例#25
0
    def OnCreate(self, doc, flags):
        if len(doc.GetFilename()) == 0:
            wx.MessageBox(_("Cannot create a new image file.\n%s has no paint capability.") % wx.GetApp().GetAppName(),
                                _("New Image File"),
                                wx.OK | wx.ICON_EXCLAMATION)
            return False
            
        try:
            self._bitmap = wx.Image(doc.GetFilename()).ConvertToBitmap()
        except:
            wx.MessageBox(_("Error loading '%s'. %s") % (doc.GetPrintableName(), sys.exc_value),
                                _("Open Image File"),
                                wx.OK | wx.ICON_EXCLAMATION)
            return False

        frame = wx.GetApp().CreateDocumentFrame(self, doc, flags)
        panel = wx.Panel(frame, -1)            
        self._ctrl = wx.StaticBitmap(panel, -1, self._bitmap, (0,0), (self._bitmap.GetWidth(), self._bitmap.GetHeight()))
        wx.EVT_LEFT_DOWN(self._ctrl, self.OnFocus)
        wx.EVT_LEFT_DCLICK(self._ctrl, self.OnFocus)
        wx.EVT_RIGHT_DOWN(self._ctrl, self.OnFocus)
        wx.EVT_RIGHT_DCLICK(self._ctrl, self.OnFocus)
        wx.EVT_MIDDLE_DOWN(self._ctrl, self.OnFocus)
        wx.EVT_MIDDLE_DCLICK(self._ctrl, self.OnFocus)
        panel.SetClientSize(self._bitmap.GetSize())
        frame.SetClientSize(panel.GetSize())
        self.Activate()
        return True
示例#26
0
    def __init__(self, parent, ID, label, url):
        wx.Panel.__init__(self, parent, ID)

        self.url = url
        self.text_bg = wx.Panel(self)
        self.text = wx.StaticText(self.text_bg, label=label)

        self.clicked = False

        self.FONT_DEFAULT = self.text.GetFont()
        self.FONT_HIGHLIGHT = self.text.GetFont()
        self.FONT_HIGHLIGHT.SetUnderlined(True)

        wx.EVT_LEFT_DOWN(self.text, self.OnLeftClick)
        wx.EVT_ENTER_WINDOW(self.text_bg, self.OnMouseOver)
        wx.EVT_LEAVE_WINDOW(self.text_bg, self.OnMouseOut)

        self.text.SetForegroundColour(wx.Colour(0, 0, 255))

        layout_V1 = BoxSizer(wx.VERTICAL)
        layout_V1.AddSpacer(1, wx.EXPAND)
        layout_V1.Add(self.text_bg, 0, wx.ALIGN_CENTER)
        layout_V1.AddSpacer(1, wx.EXPAND)

        self.SetAutoLayout(True)
        self.SetSizer(layout_V1)
        self.Layout()
示例#27
0
    def __init__(self, parent, id, pt, sz, style):
        wx.ListCtrl.__init__(self, parent, id, pt, sz, style | wx.LC_REPORT)
        self.m_imageList = wx.ImageList(16, 16, True)

        self.InsertColumn(0, u"Value", wx.LIST_FORMAT_LEFT, 80)

        wx.EVT_LEFT_DOWN(self, self.OnMouseEvent)
示例#28
0
    def switchToGrid(self, evt=None, register=True):
        """Switch to the grid selector."""

        self.mode = 'grid'

        if not self.lockedMode:
            self.switchControl.SetBitmap(self.contractBitmap)
            wx.EVT_LEFT_DOWN(self.switchControl, self.switchToMini)

        # Show the grid selector
        self.gridSelectorControl.Show()

        if register:
            # Register the grid selector
            self.gridSelector.register()
            # Tell the mini selector to update the grid selector
            self.miniSelector.companion = self.gridSelector

        # Set the grid selector item and indices from the mini selector
        self.gridSelector.switchFromCompanion(
            item=self.miniSelector.item,
            indices=self.miniSelector.getIndices())

        # Set the sizer
        self.SetSizer(self.gridSizer, deleteOld=False)
        self.gridSizer.Layout()
        if not self.embed:
            self.GetParent().SetClientSize(self.GetBestSize())
示例#29
0
    def __init__(self,
                 parent=None,
                 id=-1,
                 title='Title',
                 pos=wx.DefaultPosition,
                 size=wx.DefaultSize,
                 style=wx.DEFAULT_FRAME_STYLE | wx.CLIP_CHILDREN):
        """Create a Frame instance.
        """

        # Create the actual window (a wx Frame)
        self._wx = wx.Frame(parent, id, title, pos, size, style)

        self._keys = keys.Keys()
        self._keys.attach(self)

        # Set up the wx main menu bar
        self._menu_id_manager = idmanager.IDManager(10)
        menubar = wx.MenuBar()
        self._wx.SetMenuBar(menubar)
        self._menu = None

        self.CreateStatusBar()

        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_RIGHT_DOWN(self, self.onRightDown)
        wx.EVT_RIGHT_UP(self, self.onRightUp)
示例#30
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