示例#1
0
    def __init__(self, parent, frame, palette):
        self.frame = frame
        self.palette = palette  # the ancestor window that handles events for us

        wx.Choicebook.__init__(self, parent, wx.ID_ANY, style=wx.CHB_TOP)
        self.last = (-1, None)
        self.lists = []  # child listboxs
        self.lookup = {}  # name->(tabno,index)
        self.bad = {}  # name is bad
        self.imgs = wx.ImageList(12, 12, True, 0)
        # must be in same order as KnownDefs
        self.imgs.Add(wx.Bitmap("Resources/obj.png", wx.BITMAP_TYPE_PNG))
        self.imgs.Add(wx.Bitmap("Resources/obj.png", wx.BITMAP_TYPE_PNG))
        self.imgs.Add(wx.Bitmap("Resources/fac.png", wx.BITMAP_TYPE_PNG))
        self.imgs.Add(wx.Bitmap("Resources/for.png", wx.BITMAP_TYPE_PNG))
        self.imgs.Add(wx.Bitmap("Resources/lin.png", wx.BITMAP_TYPE_PNG))
        self.imgs.Add(wx.Bitmap("Resources/str.png", wx.BITMAP_TYPE_PNG))
        self.imgno_pol = self.imgs.GetImageCount()
        self.imgs.Add(wx.Bitmap("Resources/pol.png", wx.BITMAP_TYPE_PNG))
        self.imgno_ortho = self.imgs.GetImageCount()
        self.imgs.Add(wx.Bitmap("Resources/ortho.png", wx.BITMAP_TYPE_PNG))
        self.imgno_unknown = self.imgs.GetImageCount()
        self.imgs.Add(wx.Bitmap("Resources/unknown.png", wx.BITMAP_TYPE_PNG))
        self.imgno_multiple = self.imgs.GetImageCount()
        self.imgs.Add(wx.Bitmap("Resources/objs.png", wx.BITMAP_TYPE_PNG))
        self.imgs.Add(wx.Bitmap("Resources/objs.png", wx.BITMAP_TYPE_PNG))
        self.imgs.Add(wx.Bitmap("Resources/facs.png", wx.BITMAP_TYPE_PNG))
        self.imgs.Add(wx.Bitmap("Resources/fors.png", wx.BITMAP_TYPE_PNG))
        self.imgs.Add(wx.Bitmap("Resources/lins.png", wx.BITMAP_TYPE_PNG))
        self.imgs.Add(wx.Bitmap("Resources/strs.png", wx.BITMAP_TYPE_PNG))
        self.imgs.Add(wx.Bitmap("Resources/pols.png", wx.BITMAP_TYPE_PNG))
        self.imgs.Add(wx.Bitmap("Resources/orthos.png", wx.BITMAP_TYPE_PNG))
        self.imgs.Add(wx.Bitmap("Resources/unknowns.png", wx.BITMAP_TYPE_PNG))
        self.imgno_net = self.imgs.GetImageCount()
        self.imgs.Add(wx.Bitmap("Resources/net.png", wx.BITMAP_TYPE_PNG))
        self.imgno_exc = self.imgs.GetImageCount()
        self.imgs.Add(wx.Bitmap("Resources/exc.png", wx.BITMAP_TYPE_PNG))
        self.imgno_bad = self.imgs.GetImageCount()
        self.imgs.Add(
            wx.Bitmap("Resources/bad.png",
                      wx.BITMAP_TYPE_PNG))  # bad assumed below to be last
        wx.EVT_KEY_DOWN(self,
                        self.palette.OnKeyDown)  # does nothing on Windows
        wx.EVT_SET_FOCUS(self, self.palette.OnSetFocus)
        if 'GetChoiceCtrl' in dir(self):  # not available on wxMac 2.5
            ctrl = self.GetChoiceCtrl()
            if platform == 'win32':
                pass
            elif platform == 'darwin':
                wx.EVT_SET_FOCUS(
                    ctrl, self.palette.OnSetFocus
                )  # can get focus under Carbon, which looks ugly
                ctrl.GetContainingSizer().InsertSpacer(
                    0, 3)  # needs extra space under Cocoa
                ctrl.GetContainingSizer().AddSpacer(3)
            else:
                wx.EVT_SET_FOCUS(
                    ctrl, self.palette.OnSetFocus
                )  # give focus away so cursor keys scroll the canvas
示例#2
0
 def __init__(self, parent, frame):
     self.frame = frame
     self.lastkey = None
     self.previewkey = self.previewbmp = self.previewimg = self.previewsize = None
     self.sashsize = 4
     wx.SplitterWindow.__init__(self,
                                parent,
                                wx.ID_ANY,
                                style=wx.SP_3DSASH | wx.SP_NOBORDER
                                | wx.SP_LIVE_UPDATE)
     panel = wx.Panel(self)
     sizer = wx.BoxSizer(wx.VERTICAL)
     self.sb = wx.SearchCtrl(panel)
     self.sb.ShowCancelButton(True)
     sizer.Add(self.sb,
               0,
               flag=wx.EXPAND |
               (platform == 'darwin' and wx.ALL or wx.BOTTOM),
               border=3)
     if platform == 'darwin' and wx.VERSION < (2, 9):
         sizer.AddSpacer(6)  # layout on OSX sucks
     self.cb = PaletteChoicebook(panel, frame, self)
     sizer.Add(self.cb, 1, wx.EXPAND)
     panel.SetSizerAndFit(sizer)
     self.preview = wx.Panel(self,
                             wx.ID_ANY,
                             style=wx.FULL_REPAINT_ON_RESIZE)
     if platform == 'darwin':
         self.preview.ClearBackground = self.ClearPreviewBackground
     self.SetMinimumPaneSize(1)
     self.SplitHorizontally(panel, self.preview, -ClutterDef.PREVIEWSIZE)
     self.lastheight = self.GetSize().y
     wx.EVT_SIZE(self, self.OnSize)
     wx.EVT_KEY_DOWN(self, self.OnKeyDown)
     wx.EVT_SET_FOCUS(self, self.OnSetFocus)
     wx.EVT_KEY_DOWN(self.preview, self.OnKeyDown)
     wx.EVT_SET_FOCUS(self.preview, self.OnSetFocus)
     wx.EVT_SPLITTER_SASH_POS_CHANGING(self, self.GetId(),
                                       self.OnSashPositionChanging)
     wx.EVT_PAINT(self.preview, self.OnPaint)
     wx.EVT_TEXT(self.sb, self.sb.GetId(), self.OnSearch)
     wx.EVT_MOUSEWHEEL(
         self, self.OnMouseWheel
     )  # stop these events propagating to main window under wx2.9
     if wx.version() < '2.9.4.1':
         # cancel button doesn't send EVT_SEARCHCTRL_CANCEL_BTN under 2.9.4.0 - http://trac.wxwidgets.org/ticket/14799
         # event not needed under 2.9.4.1
         wx.EVT_SEARCHCTRL_CANCEL_BTN(self.sb, self.sb.GetId(),
                                      self.OnCancelSearch)
示例#3
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)
示例#4
0
 def __init__(self, parent, id, style, tabname, tabno, objects, pkgdir):
     if platform == 'win32': style |= wx.ALWAYS_SHOW_SB  # fails on GTK
     wx.VListBox.__init__(self, parent, id, style=style)
     self.font = wx.SystemSettings_GetFont(wx.SYS_DEFAULT_GUI_FONT)
     if platform.startswith('linux'):
         self.font.SetPointSize(10)  # Default is too big on Linux
     self.SetFont(self.font)
     (x, self.height) = self.GetTextExtent("Mq")
     if platform.startswith('linux'):
         self.height -= 1
     self.imgs = parent.imgs
     self.actfg = platform == 'darwin' and wx.Colour(
         255, 255, 255) or wx.SystemSettings_GetColour(
             wx.SYS_COLOUR_HIGHLIGHTTEXT)
     self.inafg = wx.SystemSettings_GetColour(wx.SYS_COLOUR_WINDOWTEXT)
     self.indent = 4
     self.parent = parent
     self.tabname = tabname
     self.tabno = tabno
     self.pkgdir = pkgdir
     self.populate(objects)
     wx.EVT_LISTBOX(self, self.GetId(), self.parent.OnChoice)
     wx.EVT_KEY_DOWN(self, self.parent.palette.OnKeyDown)
     wx.EVT_SET_FOCUS(self, self.parent.palette.OnSetFocus)
     self.SetDropTarget(PaletteDropTarget(self.parent.palette))
示例#5
0
    def __init__(self, wxWidget):
        """Constructor.
        @param wxWidget The wxWidget this Widget manages.
        """
        self.wxWidget = wxWidget
        self.menuItems = None
        self.focusId = ''
        self.menuId = None

        # Callback functions for listening directly to changes.
        self.reactors = []

        self.setNormalStyle()

        # Listen for right mouse clicks in case a popup menu should be
        # displayed.
        wx.EVT_RIGHT_DOWN(wxWidget, self.onRightClick)
        wx.EVT_RIGHT_UP(wxWidget, self.onRightClick)

        # A notification is sent when the widget is entered.
        wx.EVT_ENTER_WINDOW(wxWidget, self.onEnterWidget)

        # Listen for focus changes.
        wx.EVT_SET_FOCUS(wxWidget, self.onFocus)

        # Register a notification listener. These notifications are expected
        # to be handled by all widgets.
        events.addNotifyListener(self.onNotify,
                                 ['language-changed', 'focus-request'])
示例#6
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()
示例#7
0
    def __init__(self, parent, label, text_obj):
        SettingBase.__init__(self, parent, label)
        text.AnimatedText.__init__(self, text_obj)
        self.text_obj = text_obj
        self.parent = parent
        self.mpl_figure = text_obj.get_figure()

        self.__bkgd_region = None

        self.tc = wx.TextCtrl(parent,
                              -1,
                              value=text_obj.get_text(),
                              style=wx.TE_PROCESS_ENTER)
        wx.EVT_TEXT(parent, self.tc.GetId(), self.on_text_change)
        self.Add(self.tc, 1, wx.ALIGN_CENTRE_VERTICAL)

        prop_bmp = wx.ArtProvider.GetBitmap("avoplot_text_prop", wx.ART_BUTTON)
        self.prop_button = wx.BitmapButton(parent, wx.ID_ANY, prop_bmp)
        self.prop_button.SetToolTip(wx.ToolTip("Edit font properties"))
        self.Add(self.prop_button, 0,
                 wx.ALIGN_CENTER_VERTICAL | wx.RESERVE_SPACE_EVEN_IF_HIDDEN)
        wx.EVT_BUTTON(parent, self.prop_button.GetId(),
                      self.on_text_prop_button)

        wx.EVT_SET_FOCUS(self.tc, self.on_focus)
        wx.EVT_KILL_FOCUS(self.tc, self.on_unfocus)

        #hide the button if it is an empty string
        if not self.text_obj.get_text():
            self.prop_button.Show(False)
示例#8
0
 def createWindow(self):
     """Creates the widget for displaying the code. Does nothing if it is
     already created"""
     if self.window is not None:
         return self.window
     #1. Create the window
     self.window = Shell(self, self.view, -1)
     wx.EVT_SET_FOCUS(self.window, self.__set_focus)
     #print "getting id" #dbg
     self.id = self.window.GetId()
     #print "id:", self.id #dbg
     #self.window.view = self
     #2. Add the window at the correct place in the notebook widget
     if self.doc.index == 0:  #put the window at the beginning of the document
         #print "inserting cell" #dbg
         self.view.InsertCell(self.window, 0, update=False)
     else:
         #print "adding cell" #dbg
         prevcell = self.sheet.GetCell(self.doc.index - 1)
         viewplugin = prevcell.view
         #print self.doc.index #dbg
         #print viewplugin #dbg
         lastid = viewplugin.GetLastId()
         #print lastid #dbg
         index = self.view.GetIndex(lastid) + 1
         self.view.InsertCell(self.window, index, update=False)
     #3. Create line2log
     self.line2log = list()
     return self.window
    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)
示例#10
0
 def __bind_events(self):
     self.Bind(events.EVT_CHANGING, self.__on_changing_slider, self.slider)
     self.Bind(events.EVT_CHANGED, self.__on_changed_slider, self.slider)
     self.Bind(events.EVT_CHANGING, self.__on_changing_text, self.text_ctrl)
     self.Bind(events.EVT_CHANGED, self.__on_changed_text, self.text_ctrl)
     wx.EVT_SET_FOCUS(self, self.__on_set_focus)
     wx.EVT_SIZE(self, self.__on_size)
示例#11
0
    def __init__(self,
                 parent,
                 title,
                 size=wx.DefaultSize,
                 pos=wx.DefaultPosition,
                 style=wx.DEFAULT_DIALOG_STYLE,
                 resources=None,
                 host=None,
                 path=None):

        wx.Dialog.__init__(self, parent, -1, title, pos, size, style)

        self.host = host
        self.path = path
        self.resources = resources

        self.mySizer = wx.BoxSizer(wx.VERTICAL)
        self.accountPanel = self.resources.LoadPanel(self, "NewAccountPanel")
        self.mySizer.Add(self.accountPanel, 0, wx.ALIGN_CENTER | wx.ALL, 5)

        self.SetSizer(self.mySizer)
        self.mySizer.SetSizeHints(self)
        self.mySizer.Fit(self)

        self.textServer = wx.xrc.XRCCTRL(self, "TEXT_SERVERNAME")
        self.textServer.Disable()
        self.textServer.SetValue(host)

        self.textPath = wx.xrc.XRCCTRL(self, "TEXT_SERVERPATH")
        self.textPath.Disable()
        self.textPath.SetValue(path)

        self.textDesc = wx.xrc.XRCCTRL(self, "TEXT_DESCRIPTION")
        wx.EVT_SET_FOCUS(self.textDesc, self.OnFocusGained)
        self.textDesc.SetValue("WebDAV account on %s" % host)

        self.textUsername = wx.xrc.XRCCTRL(self, "TEXT_USERNAME")
        wx.EVT_SET_FOCUS(self.textUsername, self.OnFocusGained)

        self.textPassword = wx.xrc.XRCCTRL(self, "TEXT_PASSWORD")
        wx.EVT_SET_FOCUS(self.textPassword, self.OnFocusGained)

        self.Bind(wx.EVT_BUTTON, self.OnOk, id=wx.ID_OK)
        self.Bind(wx.EVT_BUTTON, self.OnCancel, id=wx.ID_CANCEL)

        self.SetDefaultItem(wx.xrc.XRCCTRL(self, "wxID_OK"))
        self.textDesc.SetFocus()
    def _CreateControl(self, parent, id):
        treeCtrl = OutlineTreeCtrl(parent, id)
        wx.EVT_TREE_SEL_CHANGED(treeCtrl, treeCtrl.GetId(), self.DoSelection)
        wx.EVT_SET_FOCUS(treeCtrl, self.DoSelection)
        wx.EVT_ENTER_WINDOW(treeCtrl, treeCtrl.CallDoLoadOutlineCallback)
        wx.EVT_RIGHT_DOWN(treeCtrl, self.OnRightClick)

        return treeCtrl
示例#13
0
文件: stc.py 项目: italomaia/spe
    def SetupScrollBars(self):
        # hook the scrollbars provided by the wxDynamicSashWindow
        # to this view
        v_bar = self.dyn_sash.GetVScrollBar(self)
        h_bar = self.dyn_sash.GetHScrollBar(self)
        wx.EVT_SCROLL(v_bar,self.OnSBScroll)
        wx.EVT_SCROLL(h_bar,self.OnSBScroll)
        wx.EVT_SET_FOCUS(v_bar, self.OnSBFocus)
        wx.EVT_SET_FOCUS(h_bar, self.OnSBFocus)
##        eventManager.Register(self.OnSBScroll, wx.EVT_SCROLL, v_bar)
##        eventManager.Register(self.OnSBScroll, wx.EVT_SCROLL, h_bar)
##        eventManager.Register(self.OnSBFocus,  wx.EVT_SET_FOCUS, v_bar)
##        eventManager.Register(self.OnSBFocus,  wx.EVT_SET_FOCUS, h_bar)

        # And set the wxStyledText to use these scrollbars instead
        # of its built-in ones.
        self.SetVScrollBar(v_bar)
        self.SetHScrollBar(h_bar)
示例#14
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))
示例#15
0
    def _bindWidgetEvents(self):
        self.Bind(wx.EVT_LIST_ITEM_SELECTED, self.onSelected,
                  self.linkListView)
        self.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.onActivated,
                  self.linkListView)
        self.Bind(wx.EVT_LIST_ITEM_RIGHT_CLICK, self.onRightClick,
                  self.linkListView)

        wx.EVT_SET_FOCUS(self.linkListView, self.onFocus)
        wx.EVT_KILL_FOCUS(self.linkListView, self.onUnFocus)
示例#16
0
 def _create_control(self, window, wxpos, wxthumbsize, wxrange):
     if self.orientation == 'horizontal':
         wxstyle = wx.HORIZONTAL
     else:
         wxstyle = wx.VERTICAL
     self._control = wx.ScrollBar(window.control, style=wxstyle)
     self._control.SetScrollbar(wxpos, wxthumbsize, wxrange, wxthumbsize, True)
     wx.EVT_SCROLL(self._control, self._wx_scroll_handler)
     wx.EVT_SET_FOCUS(self._control, self._yield_focus)
     wx.EVT_SCROLL_THUMBTRACK(self._control, self._thumbtrack)
     wx.EVT_SCROLL_THUMBRELEASE(self._control, self._thumbreleased)
     wx.EVT_SIZE(self._control, self._control_resized)
示例#17
0
    def __init__(self, mainControl, parent, id):
        wx.Notebook.__init__(self, parent, id)

        #         nb = wx.PreNotebook()
        #         self.PostCreate(nb)
        MiscEventSourceMixin.__init__(self)

        self.mainControl = mainControl
        self.mainControl.getMiscEvent().addListener(self)

        self.currentPresenter = None
        self.presenters = []
        self.mruTabIndex = []
        self.tabSwitchByKey = 0  # 2: Key hit, notebook change not processed;
        # 1: Key hit, nb. change processed
        # 0: Processing done
        self.currentPresenterProxyEvent = ProxyMiscEvent(self)

        # Last presenter for which a context menu was shown
        self.lastContextMenuPresenter = None

        self.runningPageChangedEvent = False

        #         res = xrc.XmlResource.Get()
        #         self.docPagePresContextMenu = res.LoadMenu("MenuDocPagePresenterTabPopup")

        self.tabDragCursor = wx.StockCursor(wx.CURSOR_HAND)
        self.tabDragging = wx.NOT_FOUND

        #         wx.EVT_NOTEBOOK_PAGE_CHANGED(self, self.GetId(),
        #                 self.OnNotebookPageChanged)
        self.Bind(wx.EVT_NOTEBOOK_PAGE_CHANGED, self.OnNotebookPageChanged)
        wx.EVT_KEY_UP(self, self.OnKeyUp)

        wx.EVT_LEFT_DOWN(self, self.OnLeftDown)
        wx.EVT_LEFT_UP(self, self.OnLeftUp)
        wx.EVT_MIDDLE_DOWN(self, self.OnMiddleDown)

        wx.EVT_MOTION(self, self.OnMotion)

        wx.EVT_CONTEXT_MENU(self, self.OnContextMenu)
        wx.EVT_SET_FOCUS(self, self.OnFocused)
        wx.EVT_KILL_FOCUS(self, self.OnKillFocus)
        #         EVT_AFTER_FOCUS(self, self.OnAfterFocus)

        wx.EVT_MENU(self, GUI_ID.CMD_CLOSE_THIS_TAB, self.OnCloseThisTab)
        wx.EVT_MENU(self, GUI_ID.CMD_CLOSE_CURRENT_TAB, self.OnCloseCurrentTab)
        wx.EVT_MENU(self, GUI_ID.CMD_THIS_TAB_SHOW_SWITCH_EDITOR_PREVIEW,
                    self.OnCmdSwitchThisEditorPreview)
        wx.EVT_MENU(self, GUI_ID.CMD_GO_NEXT_TAB, self.OnGoTab)
        wx.EVT_MENU(self, GUI_ID.CMD_GO_PREVIOUS_TAB, self.OnGoTab)
        wx.EVT_MENU(self, GUI_ID.CMD_CLIPBOARD_COPY_URL_TO_THIS_WIKIWORD,
                    self.OnCmdClipboardCopyUrlToThisWikiWord)
示例#18
0
文件: stc.py 项目: italomaia/spe
 def __init__(self,parent, child = None, *args,**kwds):
     PythonBaseSTC.__init__(self,parent,*args,**kwds)
     self.dyn_sash = parent
     self.child    = child
     self._args = args
     self._kwds = kwds
     self.SetupScrollBars()
     wx_gizmos.EVT_DYNAMIC_SASH_SPLIT(self,-1,self.OnSplit)
     wx_gizmos.EVT_DYNAMIC_SASH_UNIFY(self,-1,self.OnUnify)
     wx.EVT_SET_FOCUS(self,self.OnSetFocus)
     wx.EVT_KILL_FOCUS(self,self.OnKillFocus)
     self.SetScrollbar(wx.HORIZONTAL, 0, 0, 0)
     self.SetScrollbar(wx.VERTICAL, 0, 0, 0)
示例#19
0
    def _bindWidgetEvents(self):
        ZBoxedView._bindWidgetEvents(self)

        self.Bind(wx.EVT_TREE_SEL_CHANGED, self.onSelectionChanged,
                  self.treeView)
        self.Bind(wx.EVT_TREE_ITEM_RIGHT_CLICK, self.onItemRightClick,
                  self.treeView)
        self.Bind(wx.EVT_BUTTON, self.onDashboardButton, self.dashboardButton)
        self.Bind(wx.EVT_BUTTON, self.onCollapseAllButton,
                  self.collapseAllButton)
        self.Bind(ZEVT_REFRESH, self.onZoundryRefresh, self)

        wx.EVT_SET_FOCUS(self.treeView, self.onFocus)
        wx.EVT_KILL_FOCUS(self.treeView, self.onUnFocus)
示例#20
0
    def _bindWidgetEvents(self):
        ZBoxedView._bindWidgetEvents(self)

        self.Bind(ZEVT_REFRESH, self.onZoundryRefresh, self)
        self.Bind(wx.EVT_TREE_ITEM_ACTIVATED, self.onLinkActivated,
                  self.linksTreeView)
        self.Bind(wx.EVT_TREE_ITEM_RIGHT_CLICK, self.onLinkRightClick,
                  self.linksTreeView)
        self.Bind(wx.EVT_TREE_SEL_CHANGED, self.onLinkSelected,
                  self.linksTreeView)
        #        self.Bind(wx.EVT_LIST_BEGIN_DRAG, self.onEntryBeginDrag, self.linksTreeView)
        self.Bind(wx.EVT_TEXT_ENTER, self.onSearchText, self.searchTextBox)
        self.Bind(ZEVT_VIEW_SELECTION_CHANGED, self.onViewSelectionChanged)
        wx.EVT_SET_FOCUS(self.linksTreeView, self.onFocus)
        wx.EVT_KILL_FOCUS(self.linksTreeView, self.onUnFocus)
示例#21
0
    def __init__(self, parent):
        w, h = self.CalcSize(parent)
        wx.Window.__init__(self,
                           id=-1,
                           parent=parent,
                           pos=wxPoint(0, 0),
                           size=wx.Size(w, h),
                           style=wx.CLIP_CHILDREN | wx.SUNKEN_BORDER)
        self.child = cEmptyChild(self)
        self.child.Move(2, 2)
        self.__normal_colour = self.GetBackgroundColour()
        self.selected = False

        wx.EVT_SET_FOCUS(self, self._on_set_focus)
        wx.EVT_CHILD_FOCUS(self, self._on_child_focus)
示例#22
0
    def _CreateControl(self, parent, id):
        txtCtrl = STCTextEditor.TextCtrl(parent, id)
        txtCtrl.SetMarginWidth(1, 0)  # hide line numbers
        txtCtrl.SetReadOnly(True)

        if wx.Platform == '__WXMSW__':
            font = "Courier New"
        else:
            font = "Courier"
        txtCtrl.SetFont(wx.Font(10, wx.DEFAULT, wx.NORMAL, wx.NORMAL, faceName = font))
        txtCtrl.SetFontColor(wx.BLACK)
        txtCtrl.StyleClearAll()
        txtCtrl.UpdateStyles()
        wx.EVT_SET_FOCUS(txtCtrl, self.OnFocus)

        return txtCtrl
示例#23
0
    def _CreateControl(self, parent, id):
        txtCtrl = STCTextEditor.TextCtrl(parent, id, bind_left_up_event = False)
        txtCtrl.SetMarginWidth(1, 0)  # hide line numbers
        txtCtrl.SetReadOnly(True)
        txtCtrl.SetEdgeMode(wx.stc.STC_EDGE_NONE)

        if wx.Platform == '__WXMSW__':
            font = "Courier New"
        else:
            font = "Courier"
        txtCtrl.SetFont(wx.Font(10, wx.DEFAULT, wx.NORMAL, wx.NORMAL, faceName = font))
        txtCtrl.SetFontColor(wx.BLACK)
        txtCtrl.StyleClearAll()
        txtCtrl.UpdateStyles()
        wx.EVT_SET_FOCUS(txtCtrl, self.OnFocus)
        #fix the bug when double click the file line and show messagebox which cause wxEVT_MOUSE_CAPTURE_LOST problem
        wx.EVT_MOUSE_CAPTURE_LOST(txtCtrl,self.OnMouseCaptureLost)
        return txtCtrl
示例#24
0
    def _bindWidgetEvents(self):
        ZBoxedView._bindWidgetEvents(self)

        self.postsAccelTable.bindTo(self.entriesListView)

        self.Bind(ZEVT_REFRESH, self.onZoundryRefresh, self)
        self.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.onEntryActivated,
                  self.entriesListView)
        self.Bind(wx.EVT_LIST_ITEM_SELECTED, self.onEntrySelected,
                  self.entriesListView)
        self.Bind(wx.EVT_LIST_BEGIN_DRAG, self.onEntryBeginDrag,
                  self.entriesListView)
        self.Bind(wx.EVT_LIST_ITEM_RIGHT_CLICK, self.onEntryRightClick,
                  self.entriesListView)
        self.Bind(wx.EVT_COMBOBOX, self.onViewCombo, self.viewCombo)
        self.Bind(wx.EVT_TEXT_ENTER, self.onSearchText, self.searchTextBox)
        self.Bind(ZEVT_VIEW_SELECTION_CHANGED, self.onViewSelectionChanged)
        wx.EVT_SET_FOCUS(self.entriesListView, self.onFocus)
        wx.EVT_KILL_FOCUS(self.entriesListView, self.onUnFocus)
示例#25
0
    def __init__(self):

        wx.Frame.__init__(self,
                          None,
                          -1,
                          "FicheFrameWithFocus",
                          size=(275, 500))

        self.scroll = wx.ScrolledWindow(self, -1)

        self.frmPanel = wx.Panel(self.scroll, -1)

        # A sizer allows the horizontal scrollbar to appear when needed.
        flGrSzr = wx.FlexGridSizer(50, 2, 2, 2)  # rows, cols, hgap, vgap

        for i in range(50):
            textStr = " Champ (txt) %2d  : " % (i + 1)
            flGrSzr.Add(wx.StaticText(self.frmPanel, -1, textStr))

            txtCtrl = wx.TextCtrl(self.frmPanel, -1, size=(100, -1), style=0)
            wx.EVT_SET_FOCUS(txtCtrl, self.OnFocus)
            flGrSzr.Add(txtCtrl)

        # end for

        # Create a border around frmPnlSizer to the edges of the frame.
        frmPnlSizer = wx.BoxSizer(wx.VERTICAL)
        frmPnlSizer.Add(flGrSzr, proportion=1, flag=wx.ALL, border=20)

        self.frmPanel.SetSizer(frmPnlSizer)
        self.frmPanel.SetAutoLayout(True)
        self.frmPanel.Layout()
        self.frmPanel.Fit()  # frmPnlSizer borders will be respected

        self.Center()
        # self.MakeModal(True)

        # Scrolling parameters must be set AFTER all controls have been laid out.
        self.frmPanelWid, self.frmPanelHgt = self.frmPanel.GetSize()
        self.unit = 1
        self.scroll.SetScrollbars(self.unit, self.unit,
                                  self.frmPanelWid / self.unit,
                                  self.frmPanelHgt / self.unit)
示例#26
0
    def __init__(self, parent, ID, fixed_focus = 1, **args):
        """initialize: same arguments as wxAutoSplitterWindow

        **INPUTS**

        *wx.Window* parent -- parent window

        *wx.WindowID* ID

        *INT* fixed_focus -- which window (1 or 2) should accept the focus
        on an wx.EVT_SET_FOCUS event
        """

# initialize base class
        args["parent"] = parent
        args["ID"] = ID
        self.deep_construct( wxFixedFocusSplitter, 
            {"fixed_focus": fixed_focus}, args)
        wx.EVT_SET_FOCUS(self, self.on_focus)
示例#27
0
    def _wx_add_focus_listeners(self, control, on_set_focus, on_kill_focus):
        """ Recursively adds focus listeners to a control. """

        # NOTE: If we are passed a wx control that isn't correctly initialized
        # (like when the TraitsUIView isn't properly creating it) but it is
        # actually a wx control, then we get weird exceptions from trying to
        # register event handlers.  The exception messages complain that
        # the passed control is a str object instead of a wx object.
        if on_set_focus is not None:
            #control.Bind(wx.EVT_SET_FOCUS, on_set_focus)
            wx.EVT_SET_FOCUS(control, on_set_focus)

        if on_kill_focus is not None:
            #control.Bind(wx.EVT_KILL_FOCUS, on_kill_focus)
            wx.EVT_KILL_FOCUS(control, on_kill_focus)

        for child in control.GetChildren():
            self._wx_add_focus_listeners(child, on_set_focus, on_kill_focus)

        return
示例#28
0
    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, caption, title, filename):
        style = wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER
        super(RenameFileDialog, self).__init__(parent, -1, title, style=style)

        self.selectionSet = False

        text = wx.StaticText(self, -1, caption)

        text_ctrl = wx.TextCtrl(self, -1)
        text_ctrl.ChangeValue(filename)

        buttons = self.CreateButtonSizer(wx.OK | wx.CANCEL)
        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(text, 0, wx.ALL, 5)
        sizer.Add(text_ctrl, 1, wx.EXPAND | wx.ALL, 5)
        sizer.Add(buttons, 0, wx.EXPAND | wx.ALL, 5)
        self.SetSizerAndFit(sizer)
        self.text_ctrl = text_ctrl

        wx.EVT_SET_FOCUS(self.text_ctrl, self.OnFocus)
        self.text_ctrl.SetFocus()
示例#30
0
 def createWindow(self):
     """Creates the window. If it is already created returns it"""
     if self.window is None:  #create the window
         #1. Create the window and set the document plugin
         self.window = TextCtrl(self.view, -1)
         wx.EVT_SET_FOCUS(self.window, self.__set_focus)
         self.id = self.window.GetId()
         #print "id:", self.id #dbg
         self.window.view = self
         #2. Add the window at the correct place in the notebook widget
         if self.doc.index == 0:  #put the window at the beginning of the document
             self.view.InsertCell(self.window, 0, update=False)
         else:
             prevcell = self.sheet.GetCell(self.doc.index - 1)
             viewplugin = prevcell.view
             #print self.doc.index #dbg
             #print viewplugin #dbg
             lastid = viewplugin.GetLastId()
             #print lastid #dbg
             index = self.view.GetIndex(lastid) + 1
             self.view.InsertCell(self.window, index, update=False)
     return self.window