def __init__(self, master=None, cnf={}, **kw): kw = _cnfmerge((kw, cnf)) self._trace_fix(kw) tkinter.Radiobutton.__init__(self, master, kw) self._radiobuttons.append(self) self._cnf = dict( variable=kw.get('variable'), selectcolor=self['selectcolor'], foreground=self['foreground'], background=self['background'], ) # Set the patch if indicatoron is set to 0. if self._check_setit(): self._setit() self._bind_handler( { 'className': "on_press", "sequence": "<Button-1>", "func": self._on_press }, { 'className': "on_release", "sequence": "<ButtonRelease-1>", "func": self._on_release }, )
def __init__(self, master=None, cnf={}, **kw): kw = _cnfmerge((cnf, kw)) self._stop_state = False self.after_id = ' ' cnf = dict( text=kw.pop('text', ''), font=kw.pop('font', 'TkDefaultFont'), fg=kw.pop('fg', 'black') if kw.get('fg') else kw.pop( 'foreground', 'black'), fps=kw.pop('fps', 30), justify=kw.pop('justify', 'left'), left_margin=kw.pop('left_margin', 10), initial_delay=kw.pop('initial_delay', 1000), end_delay=kw.pop('end_delay', 1000), smoothness=kw.pop('smoothness', 1), # 1 <= smooth < 1 disabledforeground=kw.pop('disabledforeground', 'grey')) cnf['foreground'] = cnf['fg'] cnf = {k: v for k, v in cnf.items() if v is not None} kw['height'] = kw.get('height', 24) kw['highlightthickness'] = kw.get('highlightthickness', 0) tkinter.Canvas.__init__(self, master=master, **kw) self.cnf = check_param(self, 'marquee', **cnf) self._set_text() _bind(self, className='configure', sequence='<Configure>', func=self._check)
def _configure(self, cmd, cnf=None, kw=None): cnf = self._set_configure(_cnfmerge((cnf, kw))) _return = tkinter.Frame._configure(self, cmd, None, cnf) if kw.get('bg', kw.get('background')): self.cnf['canvas']['bg'] = self['bg'] if isinstance(_return, dict): _return.update(self.cnf) for k in list(_return): if k not in SFRAME_PROPERTIES: _return.pop(k) return _return
def _configure(self, cmd, cnf=None, kw=None): """Internal function.""" kw1 = _cnfmerge((cnf, kw)) for i in list(kw1): if i in COLORSCALE_FEATURES: self.cnf.update(self._check_param({i: kw1.pop(i)})) values = _Canvas._configure(self, cmd, None, kw1) if _cnfmerge((cnf, kw)).get('gradient'): self._create_items('create', safe_create=True, avoid=('borderline', 'marker', 'markerbg', 'info')) self._set_mousewheel() if values and isinstance(values, dict): values.update(self.cnf) for k in list(values): if k not in COLORSCALE_PROPERTIES: values.pop(k) return values
def _check_param(self, cnf={}, **kw): kw = _cnfmerge((cnf, kw)) if 'gradient' in kw: if kw['gradient'] != 'default': cond = isinstance(kw['gradient'], (list, tuple)) if not cond or (cond and len(kw['gradient']) <= 1): raise tkinter.TclError( 'expected sequence of two color values but got "%s"' % kw['gradient']) for c in kw['gradient']: self.winfo_rgb(c) kw = check_param(self, 'colorscale', kw) return kw
def __init__(self, master=None, cnf={}, **kw): kw = _cnfmerge((cnf, kw)) kw['class_'] = kw.get('class_', 'Sframe') self._after_ids = {} self._over_scrollbar = False cnf = {} cnf['scrollbarwidth'] = kw.pop('scrollbarwidth', 10) cnf['mousewheel'] = kw.pop('mousewheel', True) cnf['avoidmousewheel'] = kw.pop('avoidmousewheel', ()) cnf['autohidescrollbar'] = kw.pop('autohidescrollbar', False) cnf['autohidescrollbardelay'] = kw.pop('autohidescrollbardelay', 1000) cnf['canvas'] = kw.pop( 'canvas', tkinter.Canvas(master=master, highlightthickness=0, width=kw.pop('width', 250), height=kw.pop('height', 250))) cnf['scrollbar'] = kw.pop( 'scrollbar', tkinter.Scrollbar(cnf['canvas'], orient='vertical', width=cnf.get('scrollbarwidth'))) tkinter.Frame.__init__(self, cnf['canvas'], **kw) self.cnf = check_param(self, 'sframe', **cnf) self.cnf['canvas']['bg'] = self['bg'] if not self.cnf['autohidescrollbar']: self.cnf['scrollbar'].place( relx=1, rely=0, anchor='ne', relheight=1) self.cnf['scrollbar'].configure(command=self.cnf['canvas'].yview) self.cnf['canvas'].configure(yscrollcommand=self.cnf['scrollbar'].set) self.cnf['canvas'].create_window( 0, 0, anchor='nw', tags="window", window=self, width=self.cnf['canvas'].winfo_reqwidth()-self.cnf['scrollbar'].winfo_reqwidth()) self.cnf['canvas'].bind("<Configure>", self._configure_height, add="+") _bind(self, className='configure', sequence='<Configure>', func=self._configure_window) _bind(self, className='auto_hide_motion', sequence='<Motion>', func=self._auto_hide_scrollbar) _bind( self['scrollbar'], className='auto_hide_motion', sequence='<Enter>', func=lambda _: self._auto_hide_scrollbar('show')) _bind( self['scrollbar'], className='auto_hide_motion', sequence='<Leave>', func=self._auto_hide_scrollbar) self._mouse_scrolling(self.cnf['mousewheel']) self._avoid_mousewheel(self.cnf.get('avoidmousewheel')) self._geometryManager()
def _configure(self, cmd, cnf, kw): """Internal function.""" kw = _cnfmerge((cnf, kw)) diff = set(self.keys()).difference( list(tkinter.Canvas._configure(self, cmd, None, None))) for i in diff: if i in kw: self.cnf.update(check_param(self, 'marquee', {i: kw.pop(i)})) self._set_text() self._set_height() values = tkinter.Canvas._configure(self, cmd, None, kw) if values is not None and isinstance(values, dict): values.update(self.cnf.copy()) for i in list(values.copy()): if i not in MARQUEE_PROPERTIES: values.pop(i) return values
def __init__(self, master=None, cnf={}, **kw): kw = {k: v for k, v in _cnfmerge((cnf, kw)).items() if v is not None} cnf = { k: kw.pop(k, None) for k in kw.copy() if k in COLORSCALE_FEATURES } cnf['command'] = cnf.get('command', '') cnf['gradient'] = cnf.get('gradient', 'default') cnf['mousewheel'] = cnf.get('mousewheel', False) cnf['orient'] = cnf.get('orient', 'vertical') cnf['showinfo'] = cnf.get('showinfo', True) cnf['showinfodelay'] = cnf.get('showinfodelay', 1500) cnf['value'] = cnf.get('value', 'hex') cnf['variable'] = cnf.get('variable', '') kw['width'] = kw.get("width", 250 if 'ver' in cnf['orient'] else 30) kw['height'] = kw.get("height", 30 if 'ver' in cnf['orient'] else 250) kw['highlightthickness'] = kw.get('highlightthickness', 0) _Canvas.__init__(self, master=master, cnf={}, **kw) self.cnf = self._check_param(**cnf) self._size = (0, 0) self._marker_color = 'black' self._xy = int((self.winfo_reqwidth() if 'ver' in self.cnf['orient'] else self.winfo_reqheight()) / 3) binds = [{ 'className': 'set_size', 'sequence': '<Configure>', 'func': self._set_size }, { 'className': 'b1_on_motion', 'sequence': '<B1-Motion>', 'func': self._check_marker }, { 'className': 'b1_press', 'sequence': '<Button-1>', 'func': self._check_marker }] _bind(self, *binds) self._set_mousewheel()
def _configure(self, cmd, cnf, kw): """Internal function.""" self._set_configure(_cnfmerge((cnf, kw))) return super()._configure(cmd, cnf, kw)