def __init__(self, master, list_of_items=None, autocomplete_function=None, listbox_width=None, listbox_height=7, ignorecase_match=False, startswith_match=True, vscrollbar=True, hscrollbar=True, **kwargs): if hasattr(self, "autocomplete_function"): if autocomplete_function is not None: raise ValueError( "Combobox_Autocomplete subclass has 'autocomplete_function' implemented") else: if autocomplete_function is not None: self.autocomplete_function = autocomplete_function else: if list_of_items is None: raise ValueError( "If not given complete function, list_of_items can't be 'None'") elif ignorecase_match: if startswith_match: def matches_function(entry_data, item): return item.startswith(entry_data) else: def matches_function(entry_data, item): return item in entry_data self.autocomplete_function = lambda entry_data: [ item for item in self.list_of_items if matches_function(entry_data, item)] else: if startswith_match: def matches_function(escaped_entry_data, item): if re.match(escaped_entry_data, item, re.IGNORECASE): return True else: return False else: def matches_function(escaped_entry_data, item): if re.search(escaped_entry_data, item, re.IGNORECASE): return True else: return False def autocomplete_function2(entry_data): escaped_entry_data = re.escape(entry_data) return [item for item in self.list_of_items if matches_function(escaped_entry_data, item)] self.autocomplete_function = autocomplete_function2 self._listbox_height = int(listbox_height) self._listbox_width = listbox_width self.list_of_items = list_of_items self._use_vscrollbar = vscrollbar self._use_hscrollbar = hscrollbar kwargs.setdefault("background", "white") if "textvariable" in kwargs: self._entry_var = kwargs["textvariable"] else: self._entry_var = kwargs["textvariable"] = StringVar() Entry.__init__(self, master, **kwargs) self._trace_id = self._entry_var.trace('w', self._on_change_entry_var) self._listbox = None self.bind("<Tab>", self._on_tab) self.bind("<Up>", self._previous) self.bind("<Down>", self._next) self.bind('<Control-n>', self._next) self.bind('<Control-p>', self._previous) self.bind("<Return>", self._update_entry_from_listbox) self.bind("<Escape>", lambda event: self.unpost_listbox())
def __init__(self, *args, **kwargs): Entry.__init__(self, *args, **kwargs) self.var = self["textvariable"] if self.var == '': self.var = self["textvariable"] = tk.StringVar() self.lb_up = False self.bind("<space>", self.changed)
def __init__(self, parent, validate_fun, **kwargs): """ Initialise input field. - validate_fun: A function used to validate the field's input value. """ # Variable for entered value if 'name' in kwargs: self.name = kwargs.get('name') self.value = StringVar(parent, name=self.name) else: self.value = StringVar(parent) self.value.set('') self.value.trace('w', self._follow_changes) self.validator = validate_fun if 'to_trace' in kwargs: self.reference = kwargs.get('to_trace') self.reference.trace('w', self._follow_ref_val) # Entry field Entry.__init__(self, parent, textvariable=self.value, width=kwargs.get('width', FIELD_WIDTH))
def __init__(self, master, width=4, bg=globals.BOARD_COLOR.get(), fg=globals.UI_OUTLINE.get(), insertbackground=globals.UI_OUTLINE.get(), highlightbackground=globals.UI_OUTLINE.get(), highlightcolor=globals.UI_OUTLINE.get(), *args, **kwargs): Entry.__init__(self, master, width=width, bg=bg, fg=fg, insertbackground=insertbackground, highlightbackground=highlightbackground, highlightcolor=highlightcolor, *args, *kwargs) globals.events.setting_change += lambda: self.config(width=4, bg=globals.BOARD_COLOR.get(), fg=globals.UI_OUTLINE.get(), insertbackground=globals.UI_OUTLINE.get(), highlightbackground=globals.UI_OUTLINE.get(), highlightcolor=globals.UI_OUTLINE.get())
def __init__(self, *args, **kwargs): Entry.__init__(self, *args, **kwargs) self['bd'] = 0 self['highlightthickness'] = 0 self['relief'] = 'flat' self['selectbackground'] = 'gray30' self['disabledbackground'] = 'gray10' if kwargs.get('bg', '') == '': self['bg'] = 'gray20' else: self['bg'] = kwargs.get('bg', '') if kwargs.get('fg', '') == '': self['fg'] = 'gray40' else: self['fg'] = kwargs.get('fg', '') if kwargs.get('font', '') == '': self['font'] = ('Helvetica', 11, "normal") else: self['font'] = kwargs.get('font', '') if kwargs.get('width', 0) == 0: self['width'] = 10 else: self['width'] = kwargs.get('width', 0)
def iniciar(self, master: object) -> None: Entry.__init__(self, master=master, cnf=self.defs.cnf) self.insert(0, self.defs.mcnf['placeholder']) if self.defs.mcnf['focus']: self.focus() self.mostrar()
def __init__(self, frame, font = mediumtext, foreground = secondary_text_color, background = secondary_color, anchor = "w"): Entry.__init__(self, frame, font = font, foreground = foreground, background = background, borderwidth = 0, highlightthickness = 0, exportselection = False ) self.text_var = StringVar() self.configure(textvariable = self.text_var)
def __init__(self, parent, placeholder, **kw): if parent is not None: Entry.__init__(self, parent, **kw) self.var = self["textvariable"] = StringVar() self.placeholder = placeholder self.placeholder_color = "grey" self.bind("<FocusIn>", self.foc_in) self.bind("<FocusOut>", self.foc_out) self.put_placeholder()
def __init__(self, parent): Entry.__init__(self, parent, borderwidth=2, font=("Calibri", 12), width=28) self.pack_configure(side="left", padx=15) self.barcode = StringVar(value="") self["textvariable"] = self.barcode def on_focusout(event): if (self.get() == ""): self.delete(0, "end") self.insert(0, 'Scanner le code à barre') self.config(fg='grey') def on_entry_click(event): if (self.get() == "Scanner le code à barre"): self.delete(0, "end") self.insert(0, '') self.config(fg='black') self.insert(0, 'Scanner le code à barre') self.config(fg='grey') self.bind('<FocusIn>', on_entry_click) self.bind('<FocusOut>', on_focusout) self.barcode.trace("w", lambda *args: limitSize(self.barcode, 28)) # # Two buttons to validate choice and delete the string in the entry self.vCode = Button(parent, borderwidth=1, font=("Calibri", 11), height=2, width=8, text="valider", background="white", foreground="green") self.vCode.pack(side="left", padx=15) dCode = Button(parent, borderwidth=1, font=("Calibri", 11), height=2, width=8, text="supprimer", background="white", foreground="red") dCode.pack(side="left", padx=15) # deleting the data input in the entry fpr barcode dCode["command"] = lambda: self.delete(0, "end")
def __init__(self, parent, variavel, *arg, **kwarg): """ parent -> Widget de origem variavel -> StringVar para para obter o text da Entry """ Entry.__init__(self, parent, *arg, **kwarg) self.focus() self.textvariable = variavel self['textvariable'] = self.textvariable self.textvariable.set(" / / ") self.textvariable.trace('w', self.__validaData)
def __init__(self, lista, *args, **kwargs): Entry.__init__(self, *args, **kwargs) self.lista = lista self.var = self["textvariable"] if self.var == '': self.var = self["textvariable"] = StringVar() self.var.trace('w', self.changed) self.bind("<Right>", self.selection) self.bind("<Up>", self.up) self.bind("<Down>", self.down) self.lb_up = False
def __init__(self, parent, text_variable=None, allow_expression=False, constraints=None, **kw): self._var = text_variable or StringVar() self._allow_expression = allow_expression self._constraints = constraints or Constraints() self._var.set(1) self._number = 1 self.refresh_input() Entry.__init__(self, parent, textvariable=self._var, width=10, **kw) self.bind("<FocusOut>", lambda event: self.refresh_input())
def __init__(self, parent, row, col, borderwidth=0, relief="flat", **kwargs): Entry.__init__(self, parent, relief=relief, borderwidth=borderwidth, **kwargs) self._parent = parent self._row = row self._col = col self._init_on_click()
def __init__(self, *args, **kwargs): Entry.__init__(self, width=100, *args, **kwargs) self.focus_set() self.pack() self.var = self["textvariable"] if self.var == '': self.var = self["textvariable"] = StringVar() self.var.trace('w', self.changed) self.bind("<Right>", self.selection) self.bind("<Up>", self.up) self.bind("<Down>", self.down) self.bind("<Return>", self.enter) self.lb_up = False self.lb = None
def __init__(self, parent, autocompleteList, *args, **kwargs): self.parent = parent # Listbox length if 'listboxLength' in kwargs: self.listboxLength = kwargs['listboxLength'] del kwargs['listboxLength'] else: self.listboxLength = 8 if 'window_frame' in kwargs: self.window_frame = kwargs['window_frame'] del kwargs['window_frame'] else: self.window_frame = tk.Tk() # Custom matches function if 'matchesFunction' in kwargs: self.matchesFunction = kwargs['matchesFunction'] del kwargs['matchesFunction'] else: def matches(fieldValue, acListEntry): pattern = re.compile('.*' + re.escape(fieldValue) + '.*', re.IGNORECASE) return re.match(pattern, acListEntry) self.matchesFunction = matches Entry.__init__(self, master=parent, *args, **kwargs) self.focus() self.autocompleteList = autocompleteList self.var = self["textvariable"] if self.var == '': self.var = self["textvariable"] = StringVar() self.var.trace('w', self.changed) self.bind("<Right>", self.selection) self.bind("<Up>", self.moveUp) self.bind("<Down>", self.moveDown) self.listboxUp = False
def __init__(self, *args, **kwargs): Entry.__init__(self, *args, **kwargs) self.config(highlightthickness=1, relief='flat') self.config(highlightbackground="#AAA", highlightcolor="#AAA") self.changes = [""] self.steps = int() self.context_menu = Menu(self, tearoff=0) self.context_menu.add_command(label="Cut") self.context_menu.add_command(label="Copy") self.context_menu.add_command(label="Paste") self.bind("<KeyRelease>", self.on_change) self.bind("<Control-z>", self.undo) self.bind("<Control-Shift-Z>", self.redo) self.bind("<Button-3>", self.popup)
def __init__(self, master=None, row=None, column=None, *args, **kwargs): Entry.__init__(self, master, *args, **kwargs) self.__row = row self.__column = column self.__origin_value = None self.__origin_color = None
def __init__(self, master, **kw): self.strVar = StringVar() vcmd = (master.register(self.isValid), '%d', '%i', '%P', '%s', '%S', '%v', '%V', '%W') Entry.__init__(self, master, textvariable=self.strVar, validate='key', validatecommand=vcmd, **kw)
def __init__( self, parent, type, type_class, **kw): Entry.__init__( self, parent, kw) self.arrow = None self.type_class = type_class # is one of ("internal", "reference") self.type = type
def __init__(self, master=None): Entry.__init__(self, master) self._value = StringVar() self['textvariable'] = self._value self._value.trace('w', self._valuechanged) self.model = TextHolderModel(view=self)
def __init__(self, parent, value='', **kwargs): Entry.__init__(self, parent, **kwargs) vcmd = (self.register(self._validate), '%S') self.config(validate='key', vcmd=vcmd) self.insert(0, value)
def __init__(self, parent=None, **config): Entry.__init__(self, parent, **config) self.var = StringVar() self.config(textvariable=self.var)
def __init__(self, parent, text, relx, rely): self.parent, self.text, self.relx, self.rely = parent, text, relx, rely Entry.__init__(self, self.parent) self.defaults()
def __init__(self, parent, **config): Entry.__init__(self, parent, **config) self.parent = parent self.displayed_picture = False self.bind("<Button-3>", lambda event: self.ask_name()) self.bind("<KeyRelease>", lambda event: self.config(bg="white"))
def __init__(self,parent,**config): Entry.__init__(self,parent,**config) self.parent = parent self.displayed_picture = False self.bind("<Button-3>", lambda event : self.ask_name()) self.bind("<KeyRelease>", lambda event : self.config(bg="white"))
def __init__(self, master=None, cnf={}, **kw): Entry.__init__(self, master, cnf, **kw) self.config(bd=bd, insertbackground=sand_color, bg=main_color, fg=sand_color)
def __init__(self, master=None, fontsize=8, cnf={}, **kw): Entry.__init__(self, master=master, cnf=cnf, **kw) self.configure(bg='black', fg='teal', font=('verdana', fontsize))
def __init__(self, master, value=0.0, **kwargs): Entry.__init__(self, master, **kwargs) self.insert(0, str(value)) vcmd = (self.register(self._is_valid), '%s', '%P') self.configure(vcmd=vcmd, validate='all') self._value = float(value)