Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
command_properties = ('xscrollcommand', 'yscrollcommand')
def _set_property(self, target_widget, pname, value):
if pname == 'text':
state = target_widget.cget('state')
if state == tk.DISABLED:
target_widget.configure(state=tk.NORMAL)
target_widget.insert('0.0', value)
target_widget.configure(state=tk.DISABLED)
else:
target_widget.insert('0.0', value)
else:
super(TKText, self)._set_property(target_widget, pname, value)
register_widget('tk.Text', TKText, 'Text', ('Control & Display', 'tk', 'ttk'))
class TKPanedWindow(PanedWindowBO):
class_ = tk.PanedWindow
allowed_children = ('tk.PanedWindow.Pane',)
OPTIONS_STANDARD = (
'background', 'borderwidth', 'cursor', 'orient', 'relief',)
OPTIONS_SPECIFIC = (
'handlepad', 'handlesize', 'height', 'opaqueresize',
'sashcursor', 'sashpad', 'sashrelief', 'sashwidth', 'showhandle',
'width')
properties = OPTIONS_STANDARD + OPTIONS_SPECIFIC
register_widget('tk.PanedWindow', TKPanedWindow,
'PanedWindow', ('Containers', 'tk'))
class_ = tk.Scale
container = False
OPTIONS_STANDARD = (
'activebackground', 'background', 'borderwidth',
'cursor', 'font', 'foreground',
'highlightbackground', 'highlightcolor', 'highlightthickness',
'orient', 'relief', 'repeatdelay', 'repeatinterval',
'takefocus', 'troughcolor')
OPTIONS_SPECIFIC = (
'bigincrement', 'command', 'digits', 'from_', 'label', 'length',
'resolution', 'showvalue', 'sliderlength', 'sliderrelief',
'state', 'tickinterval', 'to', 'variable', 'width')
properties = OPTIONS_STANDARD + OPTIONS_SPECIFIC
command_properties = ('command',)
register_widget('tk.Scale', TKScale, 'Scale', ('Control & Display', 'tk'))
class TKScrollbar(BuilderObject):
class_ = tk.Scrollbar
container = False
OPTIONS_STANDARD = (
'activebackground', 'background', 'borderwidth', 'cursor',
'highlightbackground', 'highlightcolor', 'highlightthickness',
'jump', 'orient', 'relief', 'repeatdelay', 'repeatinterval',
'takefocus', 'troughcolor')
OPTIONS_SPECIFIC = (
'activerelief', 'command', 'elementborderwidth', 'width')
properties = OPTIONS_STANDARD + OPTIONS_SPECIFIC
command_properties = ('command',)
register_widget('tk.Scrollbar', TKScrollbar,
def configure(self):
pass
def layout(self):
pass
register_widget('tk.Menuitem.Submenu', TKMenuitemSubmenu,
'Menuitem.Submenu', ('Menu', 'Pygubu Helpers', 'tk', 'ttk'))
class TKMenuitemCommand(TKMenuitem):
allowed_parents = ('tk.Menu', 'tk.Menuitem.Submenu')
itemtype = tk.COMMAND
register_widget('tk.Menuitem.Command', TKMenuitemCommand,
'Menuitem.Command', ('Menu', 'Pygubu Helpers', 'tk', 'ttk'))
class TKMenuitemCheckbutton(TKMenuitem):
allowed_parents = ('tk.Menu', 'tk.Menuitem.Submenu')
itemtype = tk.CHECKBUTTON
OPTIONS_STANDARD = TKMenuitem.OPTIONS_STANDARD
OPTIONS_SPECIFIC = \
TKMenuitem.OPTIONS_SPECIFIC + \
('indicatoron', 'selectcolor', 'selectimage', 'variable')
OPTIONS_CUSTOM = TKMenuitem.OPTIONS_CUSTOM
properties = OPTIONS_STANDARD + OPTIONS_SPECIFIC + OPTIONS_CUSTOM
register_widget('tk.Menuitem.Checkbutton', TKMenuitemCheckbutton,
'Menuitem.Checkbutton', ('Menu', 'Pygubu Helpers', 'tk', 'ttk'))
container = False
OPTIONS_STANDARD = (
'activebackground', 'activeforeground', 'anchor',
'background', 'bitmap', 'borderwidth', 'compound', 'cursor',
'disabledforeground', 'font', 'foreground',
'highlightbackground', 'highlightcolor', 'highlightthickness',
'image', 'justify', 'padx', 'pady', 'relief',
'takefocus', 'text', 'textvariable', 'underline', 'wraplength')
OPTIONS_SPECIFIC = (
'command', 'height', 'indicatoron', 'overrelief', 'offrelief',
'offvalue', 'onvalue', 'overrelief', 'selectcolor', 'selectimage',
'state', 'tristateimage', 'tristatevalue', 'variable', 'width')
properties = OPTIONS_STANDARD + OPTIONS_SPECIFIC
command_properties = ('command',)
register_widget('tk.Checkbutton', TKCheckbutton,
'Checkbutton', ('Control & Display', 'tk'))
class TKListbox(BuilderObject):
class_ = tk.Listbox
container = False
OPTIONS_STANDARD = (
'background', 'borderwidth', 'cursor',
'disabledforeground', 'exportselection', 'font',
'foreground', 'highlightbackground', 'highlightcolor',
'highlightthickness', 'relief',
'selectbackground', 'selectborderwidth', 'selectforeground',
'setgrid', 'takefocus', 'xscrollcommand', 'yscrollcommand')
OPTIONS_SPECIFIC = ('activestyle', 'height', 'listvariable',
'selectmode', 'state', 'width')
properties = OPTIONS_STANDARD + OPTIONS_SPECIFIC
class_ = tk.Menu
container = True
allow_container_layout = False
OPTIONS_STANDARD = ('activebackground', 'activeborderwidth',
'activeforeground', 'background', 'borderwidth',
'cursor', 'disabledforeground', 'font', 'foreground',
'relief', 'takefocus')
OPTIONS_SPECIFIC = ('postcommand', 'tearoff', 'tearoffcommand', 'title')
properties = OPTIONS_STANDARD + OPTIONS_SPECIFIC
command_properties = ('postcommand', 'tearoffcommand')
allow_bindings = False
def layout(self):
pass
register_widget('tk.Menu', TKMenu, 'Menu', ('Menu', 'Containers', 'tk', 'ttk'))
#
# Helpers for Standard tk widgets
#
class TKMenuitem(BuilderObject):
class_ = None
container = False
itemtype = None
layout_required = False
OPTIONS_STANDARD = ('activebackground', 'activeforeground', 'background',
'bitmap', 'compound', 'foreground', 'state')
OPTIONS_SPECIFIC = ('accelerator', 'columnbreak', 'command',
'font', 'hidemargin', 'image', 'label', 'underline')
OPTIONS_CUSTOM = ('command_id_arg',)
class TKLabel(BuilderObject):
OPTIONS_STANDARD = (
'activebackground', 'activeforeground', 'anchor',
'background', 'bitmap', 'borderwidth', 'compound',
'cursor', 'disabledforeground', 'font', 'foreground', 'height',
'highlightbackground', 'highlightcolor', 'highlightthickness',
'image', 'justify', 'padx', 'pady', 'relief',
'takefocus', 'text', 'textvariable', 'underline',
'wraplength')
OPTIONS_SPECIFIC = ('height', 'state', 'width')
class_ = tk.Label
container = False
properties = OPTIONS_STANDARD + OPTIONS_SPECIFIC
register_widget('tk.Label', TKLabel, 'Label', ('Control & Display', 'tk'))
class TKLabelFrame(BuilderObject):
class_ = tk.LabelFrame
container = True
OPTIONS_STANDARD = (
'borderwidth', 'cursor', 'font', 'foreground',
'highlightbackground', 'highlightcolor', 'highlightthickness',
'padx', 'pady', 'relief', 'takefocus', 'text')
OPTIONS_SPECIFIC = ('background', 'class_', 'height',
'labelanchor', 'width')
properties = OPTIONS_STANDARD + OPTIONS_SPECIFIC
register_widget('tk.LabelFrame', TKLabelFrame,
'LabelFrame', ('Containers', 'tk'))
class_ = tk.Canvas
container = False
OPTIONS_STANDARD = (
'background', 'borderwidth', 'cursor', 'highlightbackground',
'highlightcolor', 'highlightthickness',
'insertbackground', 'insertborderwidth', 'insertofftime',
'insertontime', 'insertwidth', 'relief', 'selectbackground',
'selectborderwidth', 'selectforeground', 'takefocus',
'xscrollcommand', 'yscrollcommand')
OPTIONS_SPECIFIC = (
'closeenough', 'confine', 'height', 'scrollregion', 'state',
'width', 'xscrollincrement', 'yscrollincrement')
properties = OPTIONS_STANDARD + OPTIONS_SPECIFIC
command_properties = ('xscrollcommand', 'yscrollcommand')
register_widget('tk.Canvas', TKCanvas,
'Canvas', ('Control & Display', 'tk', 'ttk'))
class TKMenu(BuilderObject):
layout_required = False
allowed_parents = ('root', 'tk.Menubutton', 'ttk.Menubutton')
allowed_children = (
'tk.Menuitem.Submenu', 'tk.Menuitem.Checkbutton',
'tk.Menuitem.Command', 'tk.Menuitem.Radiobutton',
'tk.Menuitem.Separator')
class_ = tk.Menu
container = True
allow_container_layout = False
OPTIONS_STANDARD = ('activebackground', 'activeborderwidth',
'activeforeground', 'background', 'borderwidth',
'cursor', 'disabledforeground', 'font', 'foreground',
class TKLabelwidgetBO(BuilderObject):
class_ = None
container = True
allowed_parents = ('tk.LabelFrame', 'ttk.Labelframe')
maxchildren = 1
layout_required = False
allow_bindings = False
def realize(self, parent):
self.widget = parent.widget
return self.widget
def add_child(self, bobject):
self.widget.configure(labelwidget=bobject.widget)
register_widget('pygubu.builder.widgets.Labelwidget', TKLabelwidgetBO,
'Labelwidget', ('Pygubu Helpers', 'tk', 'ttk'))
properties = OPTIONS_STANDARD + OPTIONS_SPECIFIC + OPTIONS_CUSTOM
register_widget('tk.Menuitem.Radiobutton', TKMenuitemRadiobutton,
'Menuitem.Radiobutton', ('Menu', 'Pygubu Helpers', 'tk', 'ttk'))
class TKMenuitemSeparator(TKMenuitem):
allowed_parents = ('tk.Menu', 'tk.Menuitem.Submenu')
itemtype = tk.SEPARATOR
OPTIONS_STANDARD = tuple()
OPTIONS_SPECIFIC = tuple()
OPTIONS_CUSTOM = tuple()
properties = tuple()
command_properties = tuple()
register_widget('tk.Menuitem.Separator', TKMenuitemSeparator,
'Menuitem.Separator', ('Menu', 'Pygubu Helpers', 'tk', 'ttk'))
class TKPanedWindowPane(PanedWindowPaneBO):
class_ = None
container = True
allowed_parents = ('tk.PanedWindow',)
maxchildren = 1
OPTIONS_SPECIFIC = ('height', 'hide', 'minsize',
'padx', 'pady', 'sticky', 'stretch', 'width')
properties = OPTIONS_SPECIFIC
register_widget('tk.PanedWindow.Pane', TKPanedWindowPane,
'PanedWindow.Pane', ('Pygubu Helpers', 'tk'))