def __init__(self, parent, ID, mainControl, title=None, pos=wx.DefaultPosition, size=wx.DefaultSize, style=wx.NO_3D): d = wx.PreDialog() self.PostCreate(d) self.mainControl = mainControl res = wx.xrc.XmlResource.Get() res.LoadOnDialog(self, parent, "SpellCheckDialog") if title is not None: self.SetTitle(title) # Create styled explanation tfToCheck = wx.TextCtrl(self, GUI_ID.tfToCheck, style=wx.TE_MULTILINE|wx.TE_RICH) res.AttachUnknownControl("tfToCheck", tfToCheck, self) tfReplaceWith = wx.TextCtrl(self, GUI_ID.tfReplaceWith, style=wx.TE_RICH) res.AttachUnknownControl("tfReplaceWith", tfReplaceWith, self) self.ctrls = XrcControls(self) self.ctrls.btnCancel.SetId(wx.ID_CANCEL) self.ctrls.lbReplaceSuggestions.InsertColumn(0, "Suggestion") self.session = SpellCheckerSession(self.mainControl.getWikiDocument()) self.currentCheckedWord = None self.currentStart = -1 self.currentEnd = -1 self.session.setCurrentDocPage( self.mainControl.getActiveEditor().getLoadedDocPage()) # Fixes focus bug under Linux self.SetFocus() wx.EVT_BUTTON(self, GUI_ID.btnIgnore, self.OnIgnore) wx.EVT_BUTTON(self, GUI_ID.btnIgnoreAll, self.OnIgnoreAll) wx.EVT_BUTTON(self, GUI_ID.btnReplace, self.OnReplace) wx.EVT_BUTTON(self, GUI_ID.btnReplaceAll, self.OnReplaceAll) wx.EVT_BUTTON(self, GUI_ID.btnAddWordGlobal, self.OnAddWordGlobal) wx.EVT_BUTTON(self, GUI_ID.btnAddWordLocal, self.OnAddWordLocal) wx.EVT_BUTTON(self, wx.ID_CANCEL, self.OnClose) wx.EVT_CLOSE(self, self.OnClose) # EVT_LISTBOX(self, GUI_ID.lbReplaceSuggestions, # self.OnLbReplaceSuggestions) wx.EVT_LIST_ITEM_SELECTED(self, GUI_ID.lbReplaceSuggestions, self.OnLbReplaceSuggestions) wx.EVT_CHAR(self.ctrls.tfReplaceWith, self.OnCharReplaceWith) wx.EVT_CHAR(self.ctrls.lbReplaceSuggestions, self.OnCharReplaceSuggestions)
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)
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)
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)
def __init__(self, title="wxRUR - Application", world=None): self.frame = RURFrame(self, title, world) self.onExit = False self.KeyDelay = 0.01 self.TimerPeriod = 0.5 self.onTimerEvent = HandlerNone wx.EVT_CHAR(self.frame.WorldDisplay, HandlerNone)
def _pop_up_text(self): """ Pop-up a text control to allow the user to enter a value using the keyboard. """ control = self.control factory = self.factory style = (self.text_styles[self.alignment] | wx.TE_PROCESS_ENTER) if factory.password: style |= wx.TE_PASSWORD self._text = text = wx.TextCtrl(control, -1, self.str_value, style=style) slice = self.image_slice wdx, wdy = control.GetClientSize() tdx, tdy = text.GetSize() text.SetPosition( wx.Point(slice.xleft, ((wdy + slice.xtop - slice.xbottom - tdy) / 2) + 1)) text.SetSize(wx.Size(wdx - slice.xleft - slice.xright, tdy)) text.SetSelection(-1, -1) text.SetFocus() wx.EVT_KILL_FOCUS(text, self._text_completed) wx.EVT_CHAR(text, self._key_entered) wx.EVT_TEXT_ENTER(control, text.GetId(), self.update_object) if factory.auto_set and (not factory.is_grid_cell): wx.EVT_TEXT(control, text.GetId(), self.update_object)
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)
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
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()
def init_events(self): tID = self.GetId() wx.EVT_LIST_BEGIN_DRAG(self, tID, self.OnMouseDown) wx.EVT_LEFT_DCLICK(self, self.OnDoubleClick) wx.EVT_LIST_ITEM_SELECTED(self, tID, self.OnItemSelected) wx.EVT_LIST_ITEM_ACTIVATED(self, tID, self.OnItemSelected) wx.EVT_LIST_ITEM_RIGHT_CLICK(self, tID, self.OnRightClick) wx.EVT_CHAR(self, self.OnKeyPress)
def __register_interests(self): self.SetModEventMask (wx.stc.STC_MOD_INSERTTEXT | wx.stc.STC_MOD_DELETETEXT | wx.stc.STC_PERFORMED_USER) wx.stc.EVT_STC_MODIFIED (self, self.GetId(), self.__on_STC_modified) wx.EVT_KEY_DOWN (self, self.__on_key_down) wx.EVT_KEY_UP (self, self.__OnKeyUp) wx.EVT_CHAR(self, self.__on_char)
def __init__(self, parent, text, title, validateFunc=None): wx.Dialog.__init__(self, parent, -1, title, style=wx.DEFAULT_DIALOG_STYLE | wx.WANTS_CHARS) # function to call to validate the input string on OK. can be # None, in which case it is not called. if it returns "", the # input is valid, otherwise the string it returns is displayed in # a message box and the dialog is not closed. self.validateFunc = validateFunc vsizer = wx.BoxSizer(wx.VERTICAL) vsizer.Add(wx.StaticText(self, -1, text), 1, wx.EXPAND | wx.BOTTOM, 5) self.tc = wx.TextCtrl(self, -1, style=wx.TE_PROCESS_ENTER) vsizer.Add(self.tc, 1, wx.EXPAND) vsizer.Add(wx.StaticLine(self, -1), 0, wx.EXPAND | wx.TOP | wx.BOTTOM, 5) hsizer = wx.BoxSizer(wx.HORIZONTAL) cancelBtn = gutil.createStockButton(self, "Cancel") hsizer.Add(cancelBtn) okBtn = gutil.createStockButton(self, "OK") hsizer.Add(okBtn, 0, wx.LEFT, 10) vsizer.Add(hsizer, 0, wx.EXPAND | wx.TOP, 5) util.finishWindow(self, vsizer) wx.EVT_BUTTON(self, cancelBtn.GetId(), self.OnCancel) wx.EVT_BUTTON(self, okBtn.GetId(), self.OnOK) wx.EVT_TEXT_ENTER(self, self.tc.GetId(), self.OnOK) wx.EVT_CHAR(self.tc, self.OnCharEntry) wx.EVT_CHAR(cancelBtn, self.OnCharButton) wx.EVT_CHAR(okBtn, self.OnCharButton) self.tc.SetFocus()
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)
def __init__(self, parent, id, size=wx.DefaultSize): wx.TextCtrl.__init__(self, parent, id, style=wx.TE_RICH2, size=size) wx.EVT_TEXT_ENTER(self, self.GetId(), self.OnEnter) wx.EVT_CHAR(self, self.OnChar) wx.EVT_KEY_DOWN(self, self.OnKeyDown) self.chars = []
def __init__(self, speculoos, parent, id, title): EditableListBox.__init__(self, parent, id, title, style=wxEL_ALLOW_EDIT | wxEL_ALLOW_NEW | wxEL_ALLOW_NEW | wxEL_ALLOW_DELETE | wxEL_ALLOW_UPDOWN) self.speculoos = speculoos self.creating = False self.bxmanager = BoxSystemManager() button_parent = self.GetNewButton().GetParent() self.newbox = wx.BitmapButton( button_parent, -1, wx.Bitmap(get_image_path('newbox.xpm'), wx.BITMAP_TYPE_XPM)) self.subsizer.Insert(0, self.newbox, 0, wx.ALIGN_CENTRE_VERTICAL | wx.TOP | wx.BOTTOM, BTN_BORDER) self.newbox.SetToolTipString(_("Create a new box")) self.newbox.Disable() self.newpoint = wx.BitmapButton( button_parent, -1, wx.Bitmap(get_image_path('split_li.xpm'), wx.BITMAP_TYPE_XPM)) self.subsizer.Insert(1, self.newpoint, 0, wx.ALIGN_CENTRE_VERTICAL | wx.TOP | wx.BOTTOM, BTN_BORDER) self.newpoint.SetToolTipString(_("Create a new point")) self.newpoint.Disable() self.delpoint = wx.BitmapButton( button_parent, -1, wx.Bitmap(get_image_path('gomme.xpm'), wx.BITMAP_TYPE_XPM)) self.subsizer.Insert(2, self.delpoint, 0, wx.ALIGN_CENTRE_VERTICAL | wx.TOP | wx.BOTTOM, BTN_BORDER) self.delpoint.SetToolTipString(_("Delete a point")) self.delpoint.Disable() self.subsizer.Fit(self.subp) wx.EVT_BUTTON(self.newbox, -1, self.on_new_box) wx.EVT_BUTTON(self.newpoint, -1, self.on_new_point) wx.EVT_BUTTON(self.delpoint, -1, self.on_delete_point) wx.EVT_SIZE(self, self.on_size) listctrl = self.GetListCtrl() wx.EVT_LIST_ITEM_SELECTED(listctrl, listctrl.GetId(), self.on_change_selection) wx.EVT_LIST_END_LABEL_EDIT(listctrl, listctrl.GetId(), self.on_end_edit) button = self.GetDelButton() wx.EVT_BUTTON(button, -1, self.on_delete_boxsystem) wx.EVT_CHAR(listctrl, self.OnChar)
def _create_control(self, parent): shell = PyShell(parent, -1) # Listen for key press events. wx.EVT_CHAR(shell, self._wx_on_char) # Enable the shell as a drag and drop target. shell.SetDropTarget(PythonDropTarget(self)) return shell
def __init__(self, parent, id=-1, pos=wx.DefaultPosition, size=wx.DefaultSize, style=wx.CLIP_CHILDREN | wx.SUNKEN_BORDER): """Create Editor instance.""" self.window = EditWindow(self, parent, id, pos, size, style) self.id = self.window.GetId() self.buffer = None # Assign handlers for keyboard events. wx.EVT_CHAR(self.window, self.OnChar) wx.EVT_KEY_DOWN(self.window, self.OnKeyDown)
def __init__(self, parent, title): TitledPage.__init__(self, parent, title) self.text = wx.StaticText( self, -1, """The name fields should contain your first and last name; requests with incomplete names may be rejected. The e-mail address will be used for verification; please make sure it is valid. The domain represents the institution you belong to; it will default to the hostname part of your email address. The domain will be used for verification; please make sure it is valid. The passphrase will be used to access your generated certificate after it is created. You will need to remember it: it is not possible to determine the passphrase from the certificate, and it cannot be reset.""") self.firstNameId = wx.NewId() self.lastNameId = wx.NewId() self.emailId = wx.NewId() self.domainId = wx.NewId() self.passwrdId = wx.NewId() self.passwrd2Id = wx.NewId() self.firstNameText = wx.StaticText(self, -1, "First name:") self.lastNameText = wx.StaticText(self, -1, "Last name:") self.emailText = wx.StaticText(self, -1, "E-mail:") self.domainText = wx.StaticText(self, -1, "Domain:") self.passwordText = wx.StaticText(self, -1, "Passphrase:") self.passwordVerText = wx.StaticText(self, -1, "Retype passphrase:") self.firstNameCtrl = wx.TextCtrl(self, self.firstNameId) self.lastNameCtrl = wx.TextCtrl(self, self.lastNameId) self.emailCtrl = wx.TextCtrl(self, self.emailId) self.domainCtrl = wx.TextCtrl(self, self.domainId) self.passwordCtrl = wx.TextCtrl(self, self.passwrdId, style=wx.TE_PASSWORD) self.passwordVerCtrl = wx.TextCtrl(self, self.passwrd2Id, style=wx.TE_PASSWORD) self.SetValidator(IdentityCertValidator()) wx.EVT_TEXT(self, self.firstNameId, self.EnterText) wx.EVT_TEXT(self, self.lastNameId, self.EnterText) wx.EVT_TEXT(self.emailCtrl, self.emailId, self.EnterEmailText) wx.EVT_TEXT(self.domainCtrl, self.domainId, self.EnterDomainText) wx.EVT_TEXT(self.passwordCtrl, self.passwrdId, self.EnterText) wx.EVT_TEXT(self.passwordVerCtrl, self.passwrd2Id, self.EnterText) wx.EVT_CHAR(self.domainCtrl, self.EnterDomainChar) self.__Layout() # # State to set if the user entered anything in the domain # textbox. If so, don't change it on them. # self.userEnteredDomain = 0
def __init__(self, parent, size=None, defaultsize=(420, 380), name="", caption=None, **kwargs): # be sure to have a caption if caption is None: caption = name kwargs['name'] = name # use defaultsize if no size if size is None: size = defaultsize else: kwargs['size'] = size kwargs['defaultsize'] = defaultsize # init wx.Dialog.__init__(self, parent, -1, caption, style = wx.TAB_TRAVERSAL | wx.DEFAULT_DIALOG_STYLE, size = size) # container self.m_html = wxUrlClickHtmlWindow(self, -1, style = wx.CLIP_CHILDREN | wx.html.HW_SCROLLBAR_NEVER | wx.TAB_TRAVERSAL) EVT_HTML_URL_CLICK(self.m_html, self.OnLinkClick) # set the content apply(self.SetContents,(),kwargs) # layout the content self.SetAutoLayout(True) lc = wx.LayoutConstraints() lc.top.SameAs(self, wx.Top, 5) lc.left.SameAs(self, wx.Left, 5) lc.bottom.SameAs(self, wx.Bottom, 5) lc.right.SameAs(self, wx.Right, 5) self.m_html.SetConstraints(lc) self.Layout() self.GetDefaultItem().SetFocus() # from wxWindows docs: This function (wxWindow::OnCharHook) is # only relevant to top-level windows (frames and dialogs), and # under Windows only. Under GTK the normal EVT_CHAR_ event has # the functionality, i.e. you can intercepts it and if you # don't call wxEvent::Skip the window won't get the event. if sys.platform not in ["windows","nt"]: wx.EVT_CHAR_HOOK(self,self.OnCharHook) else: wx.EVT_CHAR(self,self.OnCharHook)
def make_object_button(widget, icon_path, toplevel=False, tip=None): """\ creates a button for the widgets toolbar. Params: - widget: (name of) the widget the button will add to the app - icon_path: path to the icon used for the button - toplevel: true if the widget is a toplevel object (frame, dialog) - tip: tool tip to display Returns: the newly created wxBitmapButton """ #from wxPython import wx import wx from tree import WidgetTree id = wx.NewId() if not os.path.isabs(icon_path): icon_path = os.path.join(wxglade_path, icon_path) if wx.Platform == '__WXGTK__': style = wx.NO_BORDER else: style = wx.BU_AUTODRAW import misc bmp = misc.get_xpm_bitmap(icon_path) tmp = wx.BitmapButton(palette, id, bmp, size=(31, 31), style=style) if not toplevel: wx.EVT_BUTTON(tmp, id, add_object) else: wx.EVT_BUTTON(tmp, id, add_toplevel_object) refs[id] = widget if not tip: tip = _('Add a %s') % widget.replace(_('Edit'), '') tmp.SetToolTip(wx.ToolTip(tip)) WidgetTree.images[widget] = icon_path # add support for ESC key. We bind the handler to the button, because # (at least on GTK) EVT_CHAR are not generated for wxFrame objects... def on_char(event): #print 'on_char' if event.HasModifiers() or event.GetKeyCode() != wx.WXK_ESCAPE: event.Skip() return global adding_widget, adding_sizer, widget_to_add adding_widget = False adding_sizer = False widget_to_add = None import misc if misc._currently_under_mouse is not None: misc._currently_under_mouse.SetCursor(wx.STANDARD_CURSOR) event.Skip() wx.EVT_CHAR(tmp, on_char) return tmp
def __init__(self, parent, ID): stc.StyledTextCtrl.__init__(self, parent, ID) self.lineNumsVisible = False self.ToggleLineNumbers() # following shd prob. have settable fontsize per screen like TCs above self.StyleSetSpec(stc.STC_STYLE_DEFAULT, "size:14,face:Courier") self.Bind(stc.EVT_STC_DOUBLECLICK, self.OnDoubleClick) self.Bind(stc.EVT_STC_CHANGE, self.OnChange) ##bug: after line is double-clicked up to scansion work area, it ##becomes impossible to type in the main window ##first experiment in fixing this: bind an on-click event, and have ##its method simply reassert focus #self.Bind(wx.EVT_LEFT_DOWN, self.OnMouseClickInTextWindow) ##well, that didn't work wx.EVT_CHAR(self, self.OnKeyDown)
def __init__(self, view, parent, id=-1, pos=wx.DefaultPosition, size=wx.DefaultSize, style=wx.CLIP_CHILDREN): """Create Shell instance.""" editwindow.EditWindow.__init__(self, parent, id, pos, size, style) CellCtrlBase.__init__(self, parent, id, pos, size, style) self.view = view #self.document = view.doc #self.log = self.document.log self.oldlineno = 1 # used by OnModified. Is there a way to # declare this inside the method? Like a # C++ static variable self.oldpos = (0, 0) self.wrap() # Find out for which keycodes the interpreter will autocomplete. #self.autoCompleteKeys = self.document.log.interp.getAutoCompleteKeys() #TODO: fix this. IPython must tell us which keys go here self.autoCompleteKeys = [] # Keep track of the last non-continuation prompt positions. #self.promptPosStart = 0 self.promptPosEnd = 0 # Keep track of multi-line commands. self.more = False # Create the command history. Commands are added into the # front of the list (ie. at index 0) as they are entered. # self.historyIndex is the current position in the history; it # gets incremented as you retrieve the previous command, # decremented as you retrieve the next, and reset when you hit # Enter. self.historyIndex == -1 means you're on the current # command, not in the history. #self.history = [] #self.historyIndex = -1 # Assign handlers for keyboard events. wx.EVT_CHAR(self, self.OnChar) #This is unnecessary. The method is called by CellCtrlBase.KeyDown #wx.EVT_KEY_DOWN(self, self.OnKeyDown) # Assign handler for idle time. self.waiting = False wx.EVT_IDLE(self, self.OnIdle) stc.EVT_STC_MODIFIED(self, id, self.OnModified) stc.EVT_STC_UPDATEUI(self, id, self.OnUpdateUI)
def __init__(self, parent, image_size=(16, 16), **traits): """ Creates a new tree viewer. 'parent' is the toolkit-specific control that is the tree's parent. 'image_size' is a tuple in the form (int width, int height) that specifies the size of the label images (if any) displayed in the tree. """ # Base class constructor. super(TreeViewer, self).__init__(**traits) # Create the toolkit-specific control. self.control = tree = wx.TreeCtrl(parent, -1, style=self._get_style()) # Get our actual Id. wxid = tree.GetId() # Wire up the wx tree events. wx.EVT_CHAR(tree, self._on_char) wx.EVT_LEFT_DOWN(tree, self._on_left_down) wx.EVT_RIGHT_DOWN(tree, self._on_right_down) wx.EVT_TREE_ITEM_ACTIVATED(tree, wxid, self._on_tree_item_activated) wx.EVT_TREE_ITEM_COLLAPSED(tree, wxid, self._on_tree_item_collapsed) wx.EVT_TREE_ITEM_COLLAPSING(tree, wxid, self._on_tree_item_collapsing) wx.EVT_TREE_ITEM_EXPANDED(tree, wxid, self._on_tree_item_expanded) wx.EVT_TREE_ITEM_EXPANDING(tree, wxid, self._on_tree_item_expanding) wx.EVT_TREE_BEGIN_LABEL_EDIT(tree, wxid, self._on_tree_begin_label_edit) wx.EVT_TREE_END_LABEL_EDIT(tree, wxid, self._on_tree_end_label_edit) wx.EVT_TREE_BEGIN_DRAG(tree, wxid, self._on_tree_begin_drag) wx.EVT_TREE_SEL_CHANGED(tree, wxid, self._on_tree_sel_changed) # The image list is a wxPython-ism that caches all images used in the # control. self._image_list = ImageList(image_size[0], image_size[1]) if self.show_images: tree.AssignImageList(self._image_list) # Mapping from element to wx tree item Ids. self._element_to_id_map = {} # Add the root item. if self.input is not None: self._add_element(None, self.input) return
def _bindEvents(self): """ Binding events to the gui widgets. """ wx.EVT_BUTTON(self, self.buttonPing.GetId(), self.OnPing) wx.EVT_BUTTON(self, self.buttonUpdate.GetId(), self.OnUpdate) wx.EVT_BUTTON(self, self.buttonClose.GetId(), self.OnClose) wx.EVT_BUTTON(self, self.buttonDeleteGroup.GetId(), self.OnDeleteGroup) wx.EVT_BUTTON(self, self.buttonCreateGroup.GetId(), self.OnCreateGroup) wx.EVT_BUTTON(self, self.buttonDeleteSelected.GetId(), self.OnDelete) wx.EVT_BUTTON(self, self.buttonRegisterItem.GetId(), self.OnRegisterItem) wx.EVT_BUTTON(self, self.buttonShowMeta.GetId(), self.OnShowMeta) wx.EVT_BUTTON(self, self.buttonSetMeta.GetId(), self.OnSetMeta) wx.EVT_TEXT_ENTER(self, self.txtCtrlNSHost.GetId(), self.OnCheckNS) wx.EVT_TEXT_ENTER(self, self.txtCtrlNSPort.GetId(), self.OnCheckNS) wx.EVT_CHAR(self.treeCtrlItems, self.OnKeyPressed)
def _pop_up_text(self): """ Pop-up a text control to allow the user to enter a value using the keyboard. """ control = self.control self._text = text = wx.TextCtrl(control, -1, self.text, size=control.GetSize(), style=self.text_styles[self.factory.alignment] | wx.TE_PROCESS_ENTER) text.SetSelection(-1, -1) text.SetFocus() wx.EVT_TEXT_ENTER(control, text.GetId(), self._text_completed) wx.EVT_KILL_FOCUS(text, self._text_completed) wx.EVT_ENTER_WINDOW(text, self._enter_text) wx.EVT_LEAVE_WINDOW(text, self._leave_text) wx.EVT_CHAR(text, self._key_entered)
def _pop_up_text(self): control = self.control self._text = text = wx.TextCtrl( control, -1, str(self.value), size=control.GetSize(), style=self.text_styles[self.factory.alignment] | wx.TE_PROCESS_ENTER) text.SetSelection(-1, -1) text.SetFocus() wx.EVT_TEXT_ENTER(control, text.GetId(), self._text_completed) wx.EVT_KILL_FOCUS(text, self._text_completed) wx.EVT_ENTER_WINDOW(text, self._enter_text) wx.EVT_LEAVE_WINDOW(text, self._leave_text) wx.EVT_CHAR(text, self._key_entered)
def display(self, parent): self.id = wx.NewId() val = self.get_value() val = val.replace('\\n', '\n') sb = wx.StaticBox(parent, -1, "") label = widget_properties.wxGenStaticText( parent, -1, _('Extra code for this widget')) self._enabler = wx.CheckBox(parent, self.id + 1, '') tooltip = """\ You can use this property to add some extra code to that generated by wxGlade. Please note that you should use this ability only if you have the \ "Overwrite existing sources" option set. NOTE: at the moment, this property is supported only by the following code \ generators: Python C++ XRC""" style = wx.TE_MULTILINE | wx.HSCROLL self.text = wx.TextCtrl(parent, self.id, val, style=style, size=(1, -1)) font = wx.Font(12, wx.FONTFAMILY_MODERN, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL) self.text.SetFont(font) label.SetToolTip(wx.ToolTip(tooltip)) wx.EVT_CHECKBOX(self._enabler, self.id + 1, lambda event: self.toggle_active(event.IsChecked())) self.text.Enable(self.is_active()) self._enabler.SetValue(self.is_active()) self._target = self.text szr = wx.BoxSizer(wx.HORIZONTAL) szr.Add(label, 1, wx.ALL | wx.EXPAND, 3) szr.Add(self._enabler, 0, wx.ALL | wx.EXPAND, 3) sizer = wx.StaticBoxSizer(sb, wx.VERTICAL) sizer.Add(szr, 0, wx.EXPAND) sizer.Add(self.text, 1, wx.ALL | wx.EXPAND, 3) h = self.text.GetCharHeight() sizer.SetItemMinSize(self.text, -1, h * 3) self.panel = sizer self.bind_event(self.on_change_val) wx.EVT_CHAR(self.text, self.on_char)
def __init__(self, underlying, **args): """ **INPUTS** *wx.TextCtrl* underlying -- existing wx.TextCtrl. Must have wx.TE_PROCESS_ENTER style, and be a single line control (not wx.TE_MULTILINE) """ self.deep_construct(wxCmdPromptWithHistory, {"stored": "", "stored_selection": (0, 0), "text": underlying}, args) wx.EVT_TEXT_ENTER(self.text, self.text.GetId(), self._on_command_enter) wx.EVT_CHAR(self.text, self._on_command_char)
def _create_control(self, parent): # Create the controller based on the version of the installed IPython klass = IPythonController if IPYTHON_VERSION[0] == 0: if IPYTHON_VERSION[1] == 9: klass = IPython09Controller elif IPYTHON_VERSION[1] == 10: klass = IPython010Controller shell = klass(parent, -1, shell=self.interp) # Listen for key press events. wx.EVT_CHAR(shell, self._wx_on_char) # Enable the shell as a drag and drop target. shell.SetDropTarget(PythonDropTarget(self)) return shell
def _create_control ( self, parent ): """ Creates the toolkit-specific control for the widget. """ # changed the way this method was created. # fixme: We probably should refactor this in the pyface class so that # we don't have to overload this entire method for this change. shell = PyShell( parent, -1, locals = self.context, InterpClass = GlobalAndLocalInterpreter ) # Listen for key press events. wx.EVT_CHAR( shell, self._wx_on_char ) # Enable the shell as a drag and drop target. shell.SetDropTarget( PythonDropTarget( self ) ) return shell