Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _create_callback(self, cpname, command):
callback = command
if cpname in ('validatecommand', 'invalidcommand'):
args = self.properties.get(cpname + '_args', '')
if args:
args = args.split(' ')
callback = (self.widget.register(command),) + tuple(args)
else:
callback = self.widget.register(command)
return callback
register_widget('ttk.Combobox', TTKCombobox, 'Combobox',
('Control & Display', 'ttk'))
class TTKScrollbar(TTKWidgetBO):
OPTIONS_SPECIFIC = ('command', 'orient')
class_ = ttk.Scrollbar
container = False
properties = TTKWidgetBO.OPTIONS_STANDARD + OPTIONS_SPECIFIC
command_properties = ('command',)
register_widget('ttk.Scrollbar', TTKScrollbar,
'Scrollbar', ('Control & Display', 'ttk'))
class TTKSizegrip(TTKWidgetBO):
class_ = ttk.Sizegrip
container = False
properties = (TTKWidgetBO.OPTIONS_STANDARD +
TTKWidgetBO.OPTIONS_SPECIFIC)
class TTKButton(TTKWidgetBO):
OPTIONS_STANDARD = (TTKWidgetBO.OPTIONS_STANDARD +
TTKWidgetBO.OPTIONS_LABEL +
TTKWidgetBO.OPTIONS_COMPATIBILITY)
OPTIONS_SPECIFIC = ('command', 'default')
class_ = ttk.Button
container = False
properties = OPTIONS_STANDARD + OPTIONS_SPECIFIC
command_properties = ('command',)
register_widget('ttk.Button', TTKButton,
'Button', ('Control & Display', 'ttk'))
class TTKCheckbutton(TTKWidgetBO):
OPTIONS_STANDARD = (TTKWidgetBO.OPTIONS_STANDARD +
TTKWidgetBO.OPTIONS_LABEL +
TTKWidgetBO.OPTIONS_COMPATIBILITY)
OPTIONS_SPECIFIC = ('command', 'offvalue', 'onvalue', 'variable')
class_ = ttk.Checkbutton
container = False
properties = OPTIONS_STANDARD + OPTIONS_SPECIFIC
command_properties = ('command',)
register_widget('ttk.Checkbutton', TTKCheckbutton,
'Checkbutton', ('Control & Display', 'ttk'))
class TTKRadiobutton(TTKWidgetBO):
OPTIONS_STANDARD = (TTKWidgetBO.OPTIONS_STANDARD +
TTKWidgetBO.OPTIONS_LABEL +
register_widget('ttk.Labelframe', TTKLabelframe,
'Labelframe', ('Containers', 'ttk'))
class TTKPanedwindow(TTKWidgetBO, PanedWindowBO):
OPTIONS_SPECIFIC = ('orient', 'height', 'width')
class_ = ttk.Panedwindow
allowed_children = ('ttk.Panedwindow.Pane',)
properties = TTKWidgetBO.OPTIONS_STANDARD + OPTIONS_SPECIFIC
ro_properties = ('class_', 'orient')
register_widget('ttk.Panedwindow', TTKPanedwindow,
'Panedwindow', ('Containers', 'ttk'))
class TTKNotebook(TTKWidgetBO):
OPTIONS_SPECIFIC = ('height', 'padding', 'width')
class_ = ttk.Notebook
container = True
allow_container_layout = False
allowed_children = ('ttk.Notebook.Tab',)
properties = TTKWidgetBO.OPTIONS_STANDARD + OPTIONS_SPECIFIC
register_widget('ttk.Notebook', TTKNotebook,
'Notebook', ('Containers', 'ttk'))
class TTKMenubuttonBO(TTKWidgetBO):
OPTIONS_STANDARD = (TTKWidgetBO.OPTIONS_STANDARD +
TTKWidgetBO.OPTIONS_LABEL +
TTKWidgetBO.OPTIONS_COMPATIBILITY)
OPTIONS_SPECIFIC = ('direction',) # 'menu'
register_widget('ttk.Progressbar', TTKProgressbar,
'Progressbar', ('Control & Display', 'ttk'))
class TTKScale(TTKWidgetBO):
OPTIONS_SPECIFIC = ('command', 'from_', 'length', 'orient',
'to', 'value', 'variable')
class_ = ttk.Scale
container = False
properties = TTKWidgetBO.OPTIONS_STANDARD + OPTIONS_SPECIFIC
command_properties = ('command',)
register_widget('ttk.Scale', TTKScale, 'Scale', ('Control & Display', 'ttk'))
class TTKSeparator(TTKWidgetBO):
OPTIONS_SPECIFIC = ('orient',)
class_ = ttk.Separator
container = False
properties = TTKWidgetBO.OPTIONS_STANDARD + OPTIONS_SPECIFIC
register_widget('ttk.Separator', TTKSeparator,
'Separator', ('Control & Display', 'ttk'))
class TTKLabelframe(TTKWidgetBO):
OPTIONS_STANDARD = TTKFrame.OPTIONS_STANDARD
OPTIONS_SPECIFIC = (TTKFrame.OPTIONS_SPECIFIC +
('labelanchor', 'text', 'underline'))
class_ = ttk.Labelframe
container = True
properties = OPTIONS_STANDARD + OPTIONS_SPECIFIC
def set_heading(self, col_id, attrs):
if self._headings is None:
self._headings = OrderedDict()
self._headings[col_id] = attrs
register_widget('ttk.Treeview', TTKTreeviewBO,
'Treeview', ('Control & Display', 'ttk'))
#
# Helpers for Standard ttk widgets
#
class TTKPanedwindowPane(TTKWidgetBO, PanedWindowPaneBO):
OPTIONS_STANDARD = tuple()
OPTIONS_SPECIFIC = ('weight',)
class_ = None
container = True
allowed_parents = ('ttk.Panedwindow',)
maxchildren = 1
properties = OPTIONS_STANDARD + OPTIONS_SPECIFIC
register_widget('ttk.Panedwindow.Pane', TTKPanedwindowPane,
'Panedwindow.Pane', ('Pygubu Helpers', 'ttk'))
class TTKNotebookTab(TTKWidgetBO):
OPTIONS_STANDARD = tuple()
OPTIONS_SPECIFIC = ('state', 'sticky', 'padding', 'text',
'image', 'compound', 'underline')
'Separator', ('Control & Display', 'ttk'))
class TTKLabelframe(TTKWidgetBO):
OPTIONS_STANDARD = TTKFrame.OPTIONS_STANDARD
OPTIONS_SPECIFIC = (TTKFrame.OPTIONS_SPECIFIC +
('labelanchor', 'text', 'underline'))
class_ = ttk.Labelframe
container = True
properties = OPTIONS_STANDARD + OPTIONS_SPECIFIC
register_widget('ttk.Labelframe', TTKLabelframe,
'Labelframe', ('Containers', 'ttk'))
class TTKPanedwindow(TTKWidgetBO, PanedWindowBO):
OPTIONS_SPECIFIC = ('orient', 'height', 'width')
class_ = ttk.Panedwindow
allowed_children = ('ttk.Panedwindow.Pane',)
properties = TTKWidgetBO.OPTIONS_STANDARD + OPTIONS_SPECIFIC
ro_properties = ('class_', 'orient')
register_widget('ttk.Panedwindow', TTKPanedwindow,
'Panedwindow', ('Containers', 'ttk'))
class TTKNotebook(TTKWidgetBO):
OPTIONS_SPECIFIC = ('height', 'padding', 'width')
class_ = ttk.Notebook
container = True
allow_container_layout = False
allowed_children = ('ttk.Notebook.Tab',)
class TTKRadiobutton(TTKWidgetBO):
OPTIONS_STANDARD = (TTKWidgetBO.OPTIONS_STANDARD +
TTKWidgetBO.OPTIONS_LABEL +
TTKWidgetBO.OPTIONS_COMPATIBILITY)
OPTIONS_SPECIFIC = ('command', 'value', 'variable')
class_ = ttk.Radiobutton
container = False
properties = OPTIONS_STANDARD + OPTIONS_SPECIFIC
ro_properties = ('class_',)
command_properties = ('command',)
register_widget('ttk.Radiobutton', TTKRadiobutton,
'Radiobutton', ('Control & Display', 'ttk'))
class TTKCombobox(TTKWidgetBO):
OPTIONS_SPECIFIC = ('exportselection', 'justify', 'height',
'postcommand', 'state', 'textvariable', 'values',
'width', 'validate', 'validatecommand',
'invalidcommand', 'xscrollcommand')
OPTIONS_CUSTOM = ('validatecommand_args', 'invalidcommand_args')
class_ = ttk.Combobox
container = False
properties = (TTKWidgetBO.OPTIONS_STANDARD + OPTIONS_SPECIFIC +
OPTIONS_CUSTOM)
command_properties = ('postcommand', 'validatecommand',
'invalidcommand', 'xscrollcommand')
def _set_property(self, target_widget, pname, value):
if pname in ('validatecommand_args', 'invalidcommand_args'):
pass
else:
'Panedwindow', ('Containers', 'ttk'))
class TTKNotebook(TTKWidgetBO):
OPTIONS_SPECIFIC = ('height', 'padding', 'width')
class_ = ttk.Notebook
container = True
allow_container_layout = False
allowed_children = ('ttk.Notebook.Tab',)
properties = TTKWidgetBO.OPTIONS_STANDARD + OPTIONS_SPECIFIC
register_widget('ttk.Notebook', TTKNotebook,
'Notebook', ('Containers', 'ttk'))
class TTKMenubuttonBO(TTKWidgetBO):
OPTIONS_STANDARD = (TTKWidgetBO.OPTIONS_STANDARD +
TTKWidgetBO.OPTIONS_LABEL +
TTKWidgetBO.OPTIONS_COMPATIBILITY)
OPTIONS_SPECIFIC = ('direction',) # 'menu'
class_ = ttk.Menubutton
container = False
properties = OPTIONS_STANDARD + OPTIONS_SPECIFIC
allowed_children = ('tk.Menu',)
maxchildren = 1
def add_child(self, bobject):
self.widget.configure(menu=bobject.widget)
register_widget('ttk.Menubutton', TTKMenubuttonBO,
'Menubutton', ('Menu', 'Control & Display', 'ttk',))
OPTIONS_STANDARD = TTKWidgetBO.OPTIONS_STANDARD + ('xscrollcommand',)
OPTIONS_SPECIFIC = ('exportselection', 'font', 'invalidcommand',
'justify', 'show', 'state', 'textvariable',
'validate', 'validatecommand', 'width')
OPTIONS_CUSTOM = ('text', 'validatecommand_args', 'invalidcommand_args')
class_ = ttk.Entry
container = False
properties = OPTIONS_STANDARD + OPTIONS_SPECIFIC + OPTIONS_CUSTOM
command_properties = ('validatecommand', 'invalidcommand',
'xscrollcommand')
register_widget('ttk.Entry', TTKEntry, 'Entry', ('Control & Display', 'ttk'))
class TTKProgressbar(TTKWidgetBO):
OPTIONS_SPECIFIC = ('orient', 'length', 'mode', 'maximum',
'value', 'variable') # 'phase' is read-only
class_ = ttk.Progressbar
container = False
properties = TTKWidgetBO.OPTIONS_STANDARD + OPTIONS_SPECIFIC
register_widget('ttk.Progressbar', TTKProgressbar,
'Progressbar', ('Control & Display', 'ttk'))
class TTKScale(TTKWidgetBO):
OPTIONS_SPECIFIC = ('command', 'from_', 'length', 'orient',
'to', 'value', 'variable')
class_ = ttk.Scale
container = False
properties = TTKWidgetBO.OPTIONS_STANDARD + OPTIONS_SPECIFIC
class TTKScrollbar(TTKWidgetBO):
OPTIONS_SPECIFIC = ('command', 'orient')
class_ = ttk.Scrollbar
container = False
properties = TTKWidgetBO.OPTIONS_STANDARD + OPTIONS_SPECIFIC
command_properties = ('command',)
register_widget('ttk.Scrollbar', TTKScrollbar,
'Scrollbar', ('Control & Display', 'ttk'))
class TTKSizegrip(TTKWidgetBO):
class_ = ttk.Sizegrip
container = False
properties = (TTKWidgetBO.OPTIONS_STANDARD +
TTKWidgetBO.OPTIONS_SPECIFIC)
register_widget('ttk.Sizegrip', TTKSizegrip,
'Sizegrip', ('Control & Display', 'ttk'))
class TTKEntry(TTKWidgetBO, EntryBaseBO):
OPTIONS_STANDARD = TTKWidgetBO.OPTIONS_STANDARD + ('xscrollcommand',)
OPTIONS_SPECIFIC = ('exportselection', 'font', 'invalidcommand',
'justify', 'show', 'state', 'textvariable',
'validate', 'validatecommand', 'width')
OPTIONS_CUSTOM = ('text', 'validatecommand_args', 'invalidcommand_args')
class_ = ttk.Entry
container = False
properties = OPTIONS_STANDARD + OPTIONS_SPECIFIC + OPTIONS_CUSTOM
command_properties = ('validatecommand', 'invalidcommand',
'xscrollcommand')