def __init__(self, parent, vsProc): wx.Panel.__init__(self, parent, -1, style=wx.WANTS_CHARS) self.parent = parent self.vsProc = vsProc # the grid gbs = wx.GridBagSizer(3, 4) # source chooser # static text label = wx.StaticText(self, -1, _("Source file:")) gbs.Add(label, (0,0)) # text entry id = wx.NewId() self.teSource = wx.TextCtrl(self, id, "", size=(200,-1), style=wx.TE_PROCESS_ENTER) wx.EVT_TEXT_ENTER(self.teSource, id, self.enteredSourceText) gbs.Add(self.teSource, (0,1), flag=wx.EXPAND) self.vsProc.registerEditor(self.teSource, "") # button sBtn = wx.Button(self, wx.ID_OPEN) wx.EVT_BUTTON(sBtn, wx.ID_OPEN, parent.onFileOpen) gbs.Add(sBtn, (0,2)) # destination chooser # static text label = wx.StaticText(self, -1, _("Destination file:")) gbs.Add(label, (1,0)) # text entry id = wx.NewId() self.teDestin = wx.TextCtrl(self, id, "", size=(200,-1), style=wx.TE_PROCESS_ENTER) wx.EVT_TEXT_ENTER(self.teDestin, id, self.enteredDestinText) gbs.Add(self.teDestin, (1,1), flag=wx.EXPAND) self.vsProc.registerEditor(self.teDestin, "") # button dBtn = wx.Button(self, wx.ID_SAVE) wx.EVT_BUTTON(dBtn, wx.ID_SAVE, parent.onDestChooser) gbs.Add(dBtn, (1,2)) # format chooser id = wx.NewId() self.options = ["HTML", "LaTeX", "XML"] self.rbFormat = wx.RadioBox(self, id, _("Destination format"), wx.DefaultPosition, wx.DefaultSize, self.options, 1, style=wx.RA_SPECIFY_COLS) wx.EVT_RADIOBOX(self.rbFormat, id, self.rbSelection) gbs.Add(self.rbFormat, (0,3), (3,1)) # process button id = wx.NewId() procBtn = wx.Button(self, id, _("Process")) wx.EVT_BUTTON(procBtn, id, parent.goProcess) vsProc.registerAction(procBtn) gbs.Add(procBtn, (2,4)) self.SetSizer(gbs) return
def init(self, parent): """ Finishes initializing the editor by creating the underlying toolkit widget. """ style = 0 if self.factory.enter_set: style = wx.TE_PROCESS_ENTER self.control = wx.SearchCtrl(parent, -1, value=self.value, style=style) self.control.SetDescriptiveText(self.factory.text) self.control.ShowSearchButton(self.factory.search_button) self.control.ShowCancelButton(self.factory.cancel_button) if self.factory.auto_set: wx.EVT_TEXT(parent, self.control.GetId(), self.update_object) if self.factory.enter_set: wx.EVT_TEXT_ENTER(parent, self.control.GetId(), self.update_object) wx.EVT_SEARCHCTRL_SEARCH_BTN( parent, self.control.GetId(), self.update_object ) wx.EVT_SEARCHCTRL_CANCEL_BTN( parent, self.control.GetId(), self.clear_text )
def createControl(self, parent, value, idx, sizeX, style=wx.TE_PROCESS_ENTER): value = self.propEditor.valueToIECValue() self.editorCtrl = wx.TextCtrl(parent, self.wID, value, (-2, idx * oiLineHeight - 2), (sizeX, oiLineHeight + 3), style=style) wx.EVT_TEXT_ENTER(parent, self.wID, self.OnSelect) InspectorEditorControl.createControl(self) if value: self.editorCtrl.SetSelection(0, len(value)) # Ugly hack. It doesn't get focus the very first time if TextCtrlIEC.ugly_hack: if wx.Platform != "__WXMSW__": wx.GetApp().frame.pb.Freeze() wx.GetApp().frame.pb.nb.SetSelection(1) wx.GetApp().frame.pb.nb.SetSelection(0) if wx.Platform != "__WXMSW__": wx.GetApp().frame.pb.Thaw() TextCtrlIEC.ugly_hack = False
def wx_editor_factory(parent, editor, use_dir=False, *args): import wx from traitsui.wx.helper import TraitsUIPanel editor.control = panel = TraitsUIPanel(parent, -1) sizer = wx.BoxSizer(wx.HORIZONTAL) editor.use_dir = use_dir pad = 8 bmp = wx.ArtProvider.GetBitmap(wx.ART_FOLDER_OPEN, size=(15, 15)) button = wx.BitmapButton(panel, -1, bitmap=bmp) editor.text_control = text_control = wx.TextCtrl(panel, -1, '', style=wx.TE_PROCESS_ENTER) _do_update_obj = lambda ev: update_file_obj(editor) wx.EVT_TEXT_ENTER(panel, text_control.GetId(), _do_update_obj) wx.EVT_KILL_FOCUS(text_control, _do_update_obj) sizer.Add(text_control, 1, wx.EXPAND | wx.ALIGN_CENTER) sizer.Add(button, 0, wx.RIGHT | wx.ALIGN_CENTER, pad) wx.EVT_BUTTON(panel, button.GetId(), lambda ev: button_click(editor)) panel.SetSizerAndFit(sizer) return panel
def __init__(self, parent, title, label, wildcardDesc, fileSelectCB): wx.Panel.__init__(self, parent, -1, style=0) self.title = title self.fileSelectCB = fileSelectCB self.wildcardDesc = wildcardDesc self.path = "" self.lastFilterIndex = 0 sizer = self.sizer = wx.BoxSizer(wx.HORIZONTAL) t = wx.StaticText(self, -1, label) sizer.Add(t, 0, wx.ALIGN_CENTER_VERTICAL) self.text = wx.TextCtrl(self, -1, style=wx.TE_PROCESS_ENTER) sizer.Add(self.text, 1, wx.ALIGN_CENTER_VERTICAL) wx.EVT_TEXT_ENTER(self, self.text.GetId(), self.OnTextEnter) if not (IsOSX() and wx.VERSION >= (2, 5, 3, 0)): wx.EVT_KILL_FOCUS(self.text, self.OnTextLoseFocus) b = wx.Button(self, -1, "Browse") sizer.Add(b, 0) wx.EVT_BUTTON(self, b.GetId(), self.OnBrowse) self.SetSizer(sizer) self.SetAutoLayout(1) self.Fit()
def __do_events(self): wx.EVT_BUTTON(self.parent_window, self.tab_send.GetId(), self.OnSendMessage) wx.EVT_BUTTON(self.parent_window, self.tab_clear.GetId(), self.OnClearMessage) wx.EVT_TEXT_ENTER(self.tab_panel, self.tab_chatBox.GetId(), self.OnSendMessage) wx.EVT_KEY_DOWN(self.parent_window, self.OnKeyDown) wx.EVT_LIST_ITEM_RIGHT_CLICK(self.tab_panel, self.tab_listPeople.GetId(), self.OnRightClick_People) wx.EVT_RIGHT_DOWN(self.tab_chatArea, self.OnRightClick_ChatArea) #wx.EVT_RIGHT_DOWN(self.tab_panel, self.tab_chatArea.GetId(), self.OnRightClick_ChatArea) wx.EVT_MENU(self.tab_panel, ID_POPUP_USERS_PRIVATEMSG, self.OnPrivateMessage) wx.EVT_MENU(self.tab_panel, ID_POPUP_USERS_SETAWAY, self.OnSetAway) wx.EVT_MENU(self.tab_panel, ID_POPUP_USERS_GETINFO, self.OnGetUserInfo) wx.EVT_MENU(self.tab_panel, ID_POPUP_CHANNEL_LOGGING, self.OnLogging) wx.EVT_MENU(self.tab_panel, ID_POPUP_CHANNEL_TIMESTAMP, self.OnTimeStamps) wx.EVT_MENU(self.tab_panel, ID_POPUP_CHANNEL_CLOSE, self.OnCloseTab)
def __init__(self, lev_init): wx.Dialog.__init__(self, None, -1, "Build a local octree source", size=(400, 150)) pan = wx.Panel(self, -1) pan.Bind(wx.EVT_KEY_DOWN, self.OnKeyDown) pan.SetFocus() wx.StaticText(pan, 0, "Fields to read : ", pos=(10, 10)) self.rhoCheckBox = wx.CheckBox(pan, -1, 'rho', (20, 30)) self.rhoCheckBox.SetValue(True) self.PCheckBox = wx.CheckBox(pan, -1, 'P', (20, 60)) self.PCheckBox.SetValue(True) self.velCheckBox = wx.CheckBox(pan, -1, 'vel', (20, 90)) self.velCheckBox.SetValue(True) wx.StaticText(pan, 0, "ngrid_max :", pos=(170, 30)) self.ngrid_maxTextCtrl = wx.TextCtrl(pan, -1, size=(100,30), pos=(250,20),\ style=wx.TE_PROCESS_ENTER) self.ngrid_maxTextCtrl.SetValue("2e6") wx.StaticText(pan, 0, "levelmax :", pos=(170, 70)) self.levTextCtrl = wx.TextCtrl(pan, -1, size=(100,30), pos=(250,60),\ style=wx.TE_PROCESS_ENTER) self.levTextCtrl.SetValue(str(lev_init)) wx.EVT_TEXT_ENTER(pan, -1, self.On_load_btn) self.load = False load_btn = wx.Button(pan, -1, "Load", pos=(200, 100)) load_btn.Bind(wx.EVT_BUTTON, self.On_load_btn) self.CentreOnParent(wx.BOTH)
def init(self, parent): """ Finishes initializing the editor by creating the underlying toolkit widget. """ if not self.factory.low_name: self.low = self.factory.low if not self.factory.high_name: self.high = self.factory.high self.sync_value(self.factory.low_name, 'low', 'from') self.sync_value(self.factory.high_name, 'high', 'from') if self.factory.enter_set: control = wx.TextCtrl(parent, -1, self.str_value, style=wx.TE_PROCESS_ENTER) wx.EVT_TEXT_ENTER(parent, control.GetId(), self.update_object) else: control = wx.TextCtrl(parent, -1, self.str_value) wx.EVT_KILL_FOCUS(control, self.update_object) if self.factory.auto_set: wx.EVT_TEXT(parent, control.GetId(), self.update_object) self.evaluate = self.factory.evaluate self.sync_value(self.factory.evaluate_name, 'evaluate', 'from') self.control = control self.set_tooltip()
def init(self, parent): """ Finishes initializing the editor by creating the underlying widget. """ self.control = self._panel = parent = TraitsUIPanel(parent, -1) sizer = wx.BoxSizer(wx.HORIZONTAL) # 'text_control' is the text display of the color. text_control = wx.TextCtrl(parent, -1, self.str_value, style=wx.TE_PROCESS_ENTER) wx.EVT_KILL_FOCUS(text_control, self.update_object) wx.EVT_TEXT_ENTER(parent, text_control.GetId(), self.update_object) # 'button_control' shows the 'Edit' button. button_control = wx.Button(parent, label='Edit', style=wx.BU_EXACTFIT) wx.EVT_BUTTON(button_control, button_control.GetId(), self.open_color_dialog) sizer.Add(text_control, wx.ALIGN_LEFT) sizer.AddSpacer(8) sizer.Add(button_control, wx.ALIGN_RIGHT) self.control.SetSizer(sizer) self._text_control = text_control self._button_control = button_control self.set_tooltip() return
def init ( self, parent ): """ Finishes initializing the editor by creating the underlying toolkit widget. """ factory = self.factory style = self.base_style self.evaluate = factory.evaluate self.sync_value( factory.evaluate_name, 'evaluate', 'from' ) if (not factory.multi_line) or factory.password: style &= ~wx.TE_MULTILINE if factory.password: style |= wx.TE_PASSWORD multi_line = ((style & wx.TE_MULTILINE) != 0) if multi_line: self.scrollable = True if factory.enter_set and (not multi_line): control = wx.TextCtrl( parent, -1, self.str_value, style = style | wx.TE_PROCESS_ENTER ) wx.EVT_TEXT_ENTER( parent, control.GetId(), self.update_object ) else: control = wx.TextCtrl( parent, -1, self.str_value, style = style ) wx.EVT_KILL_FOCUS( control, self.update_object ) if factory.auto_set: wx.EVT_TEXT( parent, control.GetId(), self.update_object ) self.control = control self.set_error_state( False ) self.set_tooltip()
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 _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 init(self, parent): """ Finishes initializing the editor by creating the underlying toolkit widget. """ super(SimpleEditor, self).init(parent) factory = self.factory if factory.evaluate is None: self.control = control = wx.Choice(parent, -1, wx.Point(0, 0), wx.Size(-1, -1), self.names) wx.EVT_CHOICE(parent, self.control.GetId(), self.update_object) else: self.control = control = wx.ComboBox(parent, -1, '', wx.Point(0, 0), wx.Size(-1, -1), self.names, style=wx.CB_DROPDOWN) wx.EVT_COMBOBOX(parent, control.GetId(), self.update_object) wx.EVT_TEXT_ENTER(parent, control.GetId(), self.update_text_object) wx.EVT_KILL_FOCUS(control, self.on_kill_focus) if (not factory.is_grid_cell) and factory.auto_set: wx.EVT_TEXT(parent, control.GetId(), self.update_text_object) self._no_enum_update = 0 self.set_tooltip()
def dispose(self): """ Disposes of the control at the end of its life cycle. """ control, self.control = self.control, None parent = control.GetParent() wx.EVT_COMBOBOX(parent, control.GetId(), None) wx.EVT_TEXT_ENTER(parent, control.GetId(), None) wx.EVT_KILL_FOCUS(control, None)
def __init__(self, parent): wx.Dialog.__init__(self, parent, wx.ID_ANY, title = "Scan Processor", \ pos = (300, 300), style = wx.CAPTION | wx.STAY_ON_TOP) self.sizer = wx.BoxSizer(wx.VERTICAL) self.text2 = wx.StaticText(self, wx.ID_ANY, "Please enter number of sides to scan:") self.control2 = wx.TextCtrl(self, wx.ID_ANY, size=(200, -1)) self.text4 = wx.StaticText(self, wx.ID_ANY, "Please select page size:") self.radio1 = wx.RadioBox(self, wx.ID_ANY, choices=['A3', 'A4']) self.radio1.SetSelection(0) self.text5 = wx.StaticText(self, wx.ID_ANY, "Please select duplex or single sided:") self.radio2 = wx.RadioBox(self, wx.ID_ANY, choices=['Duplex', 'Single Sided']) self.radio2.SetSelection(0) self.text6 = wx.StaticText(self, wx.ID_ANY, "Upload to queXF?") self.radio3 = wx.RadioBox(self, wx.ID_ANY, choices=['No', 'Yes upload']) self.radio3.SetSelection(0) self.text3 = wx.StaticText(self, wx.ID_ANY, "Please enter project prefix:") self.control3 = wx.TextCtrl(self, wx.ID_ANY, size=(200, -1)) self.text = wx.StaticText(self, wx.ID_ANY, "Please scan barcode:") self.control = wx.TextCtrl(self, wx.ID_ANY, size = (200, -1), \ style = wx.TE_PROCESS_ENTER) self.button = wx.Button(self, wx.ID_CANCEL, label="Cancel") self.sizer.Add(self.text2, 0, wx.ALL, 10) self.sizer.Add(self.control2, 1, wx.ALL, 10) self.sizer.Add(self.text4, 0, wx.ALL, 10) self.sizer.Add(self.radio1, 0, wx.ALL, 10) self.sizer.Add(self.text5, 0, wx.ALL, 10) self.sizer.Add(self.radio2, 0, wx.ALL, 10) self.sizer.Add(self.text6, 0, wx.ALL, 10) self.sizer.Add(self.radio3, 0, wx.ALL, 10) self.sizer.Add(self.text3, 0, wx.ALL, 10) self.sizer.Add(self.control3, 1, wx.ALL, 10) self.sizer.Add(self.text, 0, wx.ALL, 10) self.sizer.Add(self.control, 1, wx.ALL, 10) self.sizer.Add(self.button, 0, wx.ALL, 10) self.SetSizer(self.sizer) self.SetAutoLayout(1) self.sizer.Fit(self) self.manager = None self.scanner = None self.id = None self.numPages = None wx.EVT_TEXT_ENTER(self, wx.ID_ANY, self.scan) wx.EVT_CLOSE(self, self.onClose) self.threads = []
def init ( self, parent ): """ Finishes initializing the editor by creating the underlying toolkit widget. """ self.control = wx.TextCtrl( parent, -1, self.str_value, style = wx.TE_PROCESS_ENTER ) wx.EVT_KILL_FOCUS( self.control, self.update_object ) wx.EVT_TEXT_ENTER( parent, self.control.GetId(), self.update_object ) self.set_tooltip()
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, parent, name, number, minnamelen, maxnamelen): wxskinDialog.__init__(self, parent, -1, "Phonebook edit entry") self.SetAutoLayout(True) self.name = None self.number = None nameTextId = wx.NewId() # Main window resizer object border = wx.BoxSizer(wx.VERTICAL) label = wx.StaticText( self, -1, "Enter the phonebook entry name, number and press OK.") border.Add(label, 1, wx.ALL, 10) #fgs = wx.FlexGridSizer(2,3,5,20) fgs = wx.BoxSizer(wx.HORIZONTAL) label = wx.StaticText(self, -1, "Name (max %d): " % maxnamelen) fgs.Add(label, 1, wx.ALIGN_LEFT | wx.LEFT, 10) self.nameCtrl = wx.TextCtrl(self, nameTextId, name, validator=pySIMvalidator( None, minnamelen, maxnamelen)) fgs.Add(self.nameCtrl, 1, wx.ALIGN_RIGHT | wx.RIGHT, 10) border.Add(fgs, 1, wx.ALL) fgs = wx.BoxSizer(wx.HORIZONTAL) label = wx.StaticText(self, -1, "Number (max 20): ") fgs.Add(label, 1, wx.ALIGN_LEFT | wx.LEFT, 10) self.numberCtrl = wx.TextCtrl(self, -1, number, validator=pySIMvalidator( "+*#pw0123456789", None, 20)) fgs.Add(self.numberCtrl, 1, wx.ALIGN_RIGHT | wx.RIGHT, 10) border.Add(fgs, 1, wx.ALL) buttons = wx.BoxSizer(wx.HORIZONTAL) buttons.Add(wx.Button(self, ID_BUTTON_OK, "Okay"), 1, wx.ALIGN_LEFT | wx.ALL, 20) buttons.Add(wx.Button(self, wx.ID_CANCEL, "Cancel"), 1, wx.ALIGN_RIGHT | wx.ALL, 20) border.Add(buttons, 1, wx.ALL) wx.EVT_BUTTON(self, ID_BUTTON_OK, self.onOK) wx.EVT_TEXT_ENTER(self, nameTextId, self.onOK) self.SetAutoLayout(1) self.SetSizer(border) border.Fit(self) self.Layout()
def POL_SetupWindow_textbox(self, message, title, value): self.Destroy_all() self.DrawDefault(message, title) self.space = message.count("\\n")+1 self.champ.SetPosition((20,85+self.space*16)) self.champ.SetValue(value) self.champ.Show() self.DrawCancel() self.DrawNext() wx.EVT_BUTTON(self, wx.ID_FORWARD, self.release_champ) wx.EVT_TEXT_ENTER(self, 400, self.release_champ)
def _init_ctrls(self, prnt): wx.MiniFrame.__init__(self, id=wxID_DOCGUI, name='DocGUI', parent=prnt, pos=wx.Point(395, 276), size=wx.Size(625, 338), style=wx.DEFAULT_FRAME_STYLE, title='Doc') self._init_utils() self.SetClientSize(wx.Size(625, 338)) self.SetToolTipString('Doc') self.GetName = wx.TextCtrl(id=wxID_DOCGUIGETNAME, name='GetName', parent=self, pos=wx.Point(8, 8), size=wx.Size(184, 22), style=wx.TE_PROCESS_ENTER | wx.TE_PROCESS_TAB, value='') self.GetName.SetToolTipString('Enter name') wx.EVT_TEXT_ENTER(self.GetName, wxID_DOCGUIGETNAME, self.OnGetnameTextEnter) self.DocText = wx.TextCtrl(id=wxID_DOCGUIDOCTEXT, name='DocText', parent=self, pos=wx.Point(8, 64), size=wx.Size(608, 264), style=wx.TE_READONLY | wx.TE_MULTILINE, value='') self.DocText.SetToolTipString('') self.DocLabel = wx.StaticText(id=wxID_DOCGUIDOCLABEL, label='Enter name to get documentation', name='DocLabel', parent=self, pos=wx.Point(200, 10), size=wx.Size(183, 16), style=0) self.DocName = wx.StaticText(id=wxID_DOCGUIDOCNAME, label='doc name', name='DocName', parent=self, pos=wx.Point(8, 38), size=wx.Size(184, 16), style=0)
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 _show_numctrl(self, ctrl, enable=True): """ Show/Hide on Win Enable/Disable on MAC """ if ON_MAC: ctrl.Enable(enable) children = ctrl.GetChildren() if len(children) > 0: ctrl.GetChildren()[0].SetBackGroundColour(self.color) if enable: wx.EVT_TEXT_ENTER(self.numberctr, -1, self.on_number) else: if not ctrl.IsEnabled(): ctrl.Enable(True) ctrl.Show(enable)
def __init__(self, ctrl, id, callback_func, validator_func, ignore_initial_value=False, pending_color='#FF7F7F', valid_color=None, text_color=None): self.ctrl = ctrl self.id = id self.callback_func = callback_func self.validator_func = validator_func self.pending_color = pending_color if valid_color is None: self.valid_color = self.ctrl.GetBackgroundColour() else: self.valid_color = valid_color if text_color is None: self.text_color = self.ctrl.GetForegroundColour() else: self.text_color = text_color self.ctrl.SetForegroundColour(self.text_color) if ignore_initial_value: #print 'ignoring' self.set_state('pending') self.last_valid_value = None else: if self.validator_func(self.ctrl.GetValue()): self.set_state('valid') self.last_valid_value = self.ctrl.GetValue() else: raise ValueError('initial value for ctrl is invald!') style = self.ctrl.GetWindowStyleFlag() # oh, yeah, baby! if not (style & wx.TE_PROCESS_ENTER): self.ctrl.SetWindowStyle(style | wx.TE_PROCESS_ENTER) wx.EVT_TEXT(self.ctrl, self.id, self._OnText) wx.EVT_TEXT_ENTER(self.ctrl, self.id, self._OnTextEnter) wx.EVT_KILL_FOCUS(self.ctrl, self._OnKillFocus)
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 __init__(self, *args, **kwds): wx.ComboBox.__init__(self, *args, **kwds) #wx.EVT_CHAR(self, self.on_char) #wx.EVT_TEXT(self, -1, self.on_text) #wx.EVT_COMBOBOX(self, -1, self.on_combo) wx.EvtHandler.Bind(self, wx.EVT_CHAR, self.on_char) wx.EvtHandler.Bind(self, wx.EVT_TEXT, self.on_text, id=-1) wx.EvtHandler.Bind(self, wx.EVT_COMBOBOX, self.on_combo, id=-1) if wx.Platform == '__WXMAC__': wx.EVT_TEXT_ENTER(self, -1, self.on_text_enter) self.want_completion = False self.olddir = None self.completions = None self._skip_on_combo = False self._dont_reset_insertion_point = False self._history = {}
def create_control(self, parent): """ Creates the control. """ self.control = control = wx.ComboBox(parent, -1, self.value, wx.Point(0, 0), wx.Size(-1, -1), self.history, style=wx.CB_DROPDOWN) wx.EVT_COMBOBOX(parent, control.GetId(), self._update_value) wx.EVT_KILL_FOCUS(control, self._kill_focus) wx.EVT_TEXT_ENTER(parent, control.GetId(), self._update_text_value) if self.auto_set: wx.EVT_TEXT(parent, control.GetId(), self._update_value_only) return control
def init(self, parent): """ Finishes initializing the editor by creating the underlying toolkit widget. """ self.control = panel = TraitsUIPanel(parent, -1) sizer = wx.BoxSizer(wx.HORIZONTAL) factory = self.factory if factory.entries > 0: from history_control import HistoryControl self.history = HistoryControl(entries=factory.entries, auto_set=factory.auto_set) control = self.history.create_control(panel) pad = 3 button = wx.Button(panel, -1, '...', size=wx.Size(28, -1)) else: if factory.enter_set: control = wx.TextCtrl(panel, -1, '', style=wx.TE_PROCESS_ENTER) wx.EVT_TEXT_ENTER(panel, control.GetId(), self.update_object) else: control = wx.TextCtrl(panel, -1, '') wx.EVT_KILL_FOCUS(control, self.update_object) if factory.auto_set: wx.EVT_TEXT(panel, control.GetId(), self.update_object) bmp = wx.ArtProvider.GetBitmap(wx.ART_FOLDER_OPEN, size=(15, 15)) button = wx.BitmapButton(panel, -1, bitmap=bmp) pad = 8 self._file_name = control sizer.Add(control, 1, wx.EXPAND | wx.ALIGN_CENTER) sizer.Add(button, 0, wx.LEFT | wx.ALIGN_CENTER, pad) wx.EVT_BUTTON(panel, button.GetId(), self.show_file_dialog) panel.SetDropTarget(FileDropTarget(self)) panel.SetSizerAndFit(sizer) self._button = button self.set_tooltip(control)
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 dispose(self): """ Disposes of the contents of an editor. """ panel = self.control wx.EVT_BUTTON(panel, self._button.GetId(), None) self._button = None if self.history is not None: self.history.dispose() self.history = None else: factory = self.factory control, self._file_name = self._file_name, None wx.EVT_KILL_FOCUS(control, None) wx.EVT_TEXT_ENTER(panel, control.GetId(), None) wx.EVT_TEXT(panel, control.GetId(), None) super(SimpleEditor, self).dispose()