Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
# sbhelper widget
sbhelper = ScrollbarHelper(self.widgetlist, scrolltype='both')
# widgetlisttv widget
widgetlisttv = ttk.Treeview(sbhelper)
widgetlisttv.configure(selectmode='browse', show='tree')
widgetlisttv.grid(column='0', row='0', sticky='nsew')
sbhelper.add_child(widgetlisttv)
sbhelper.configure(usemousewheel='true')
sbhelper.grid(column='0', row='0', sticky='nsew')
#Default widget image:
default_image = ''
try:
default_image = StockImage.get('22x22-tk.default')
except StockImageException as e:
pass
#Start building widget tree selector
roots = {}
sections = {}
for key, wc in treelist:
root, section = key.split('>')
#insert root
if root not in roots:
roots[root] = widgetlisttv.insert('', 'end', text=root)
#insert section
if key not in sections:
sections[key] = widgetlisttv.insert(roots[root], 'end', text=section)
#insert widget
w_image = default_image
#fix row position when using copy and paste
#If collision, increase by 1
row_count = self.get_max_row(root)
if row_count > int(row) and int(col) == 0:
row = str(row_count + 1)
data.set_layout_property('row', row)
image = ''
try:
image = StockImage.get('16x16-tk.default')
except StockImageException as e:
pass
try:
image = StockImage.get('16x16-{0}'.format(data.get_class()))
except StockImageException as e:
pass
values = (data.get_class(), row, col)
item = tree.insert(root, 'end', text=treelabel, values=values,
image=image)
data.attach(self)
self.app.set_changed()
return item
treelabel = data.get_id()
row = col = ''
if root != '' and 'layout' in data:
row = data.get_layout_property('row')
col = data.get_layout_property('column')
# fix row position when using copy and paste
# If collision, increase by 1
row_count = self.get_max_row(root)
if not from_file and (row_count > int(row) and int(col) == 0):
row = str(row_count + 1)
data.set_layout_property('row', row)
image = ''
try:
image = StockImage.get('16x16-tk.default')
except StockImageException:
# TODO: notify something here
pass
try:
image = StockImage.get('16x16-{0}'.format(data.get_class()))
except StockImageException:
# TODO: notify something here
pass
values = (data.get_class(), row, col)
item = tree.insert(root, 'end', text=treelabel, values=values,
image=image)
data.attach(self)
self.treedata[item] = data
def _create_indicators(self):
# selected indicators
self.indicators = []
anchors = {'nw': tk.SE, 'ne': tk.SW, 'sw': tk.NE, 'se': tk.NW}
for sufix in self.indicators_tag:
label = tk.Label(self.canvas,
image=StockImage.get('indicator_' + sufix))
self.indicators.append(label)
self.canvas.create_window(-10, -10, anchor=anchors[sufix],
window=label, tags=sufix)
self._bold = w = CheckbuttonPropertyEditor(container1)
img = StockImage.get('format-text-bold')
w.parameters(style='Toolbutton', text='B', image=img,
onvalue='bold', offvalue='')
w.grid(row=0, column=3, sticky='we')
w.bind('<>', self._on_variable_changed)
self._italic = w = CheckbuttonPropertyEditor(container1)
img = StockImage.get('format-text-italic')
w.parameters(style='Toolbutton', text='I', image=img,
onvalue='italic', offvalue='')
w.grid(row=0, column=4, sticky='we')
w.bind('<>', self._on_variable_changed)
self._underline = w = CheckbuttonPropertyEditor(container1)
img = StockImage.get('format-text-underline')
w.parameters(style='Toolbutton', text='U', image=img,
onvalue='underline', offvalue='')
w.grid(row=0, column=5, sticky='we')
w.bind('<>', self._on_variable_changed)
self._overstrike = w = CheckbuttonPropertyEditor(container1)
img = StockImage.get('format-text-strikethrough')
w.parameters(style='Toolbutton', text='S', image=img,
onvalue='overstrike', offvalue='')
w.grid(row=0, column=6, sticky='we')
w.bind('<>', self._on_variable_changed)
self.columnconfigure(0, weight=1)
self._populate_options()
treelabel = data.get_id()
row = col = ''
if root != '' and 'layout' in data:
row = data.get_layout_property('row')
col = data.get_layout_property('column')
#fix row position when using copy and paste
#If collision, increase by 1
row_count = self.get_max_row(root)
if row_count > int(row) and int(col) == 0:
row = str(row_count + 1)
data.set_layout_property('row', row)
image = ''
try:
image = StockImage.get('16x16-tk.default')
except StockImageException as e:
pass
try:
image = StockImage.get('16x16-{0}'.format(data.get_class()))
except StockImageException as e:
pass
values = (data.get_class(), row, col)
item = tree.insert(root, 'end', text=treelabel, values=values,
image=image)
data.attach(self)
self.app.set_changed()
return item
# fix row position when using copy and paste
# If collision, increase by 1
row_count = self.get_max_row(root)
if not from_file and (row_count > int(row) and int(col) == 0):
row = str(row_count + 1)
data.set_layout_property('row', row)
image = ''
try:
image = StockImage.get('16x16-tk.default')
except StockImageException:
# TODO: notify something here
pass
try:
image = StockImage.get('16x16-{0}'.format(data.get_class()))
except StockImageException:
# TODO: notify something here
pass
values = (data.get_class(), row, col)
item = tree.insert(root, 'end', text=treelabel, values=values,
image=image)
data.attach(self)
self.treedata[item] = data
# Update grid r/c data
self._update_max_grid_rc(root, from_file=True)
self.app.set_changed()
return item
def _setup_styles(self):
s = ttk.Style()
s.configure('ColorSelectorButton.Toolbutton',
image=StockImage.get('mglass'))
s.configure('ImageSelectorButton.Toolbutton',
image=StockImage.get('mglass'))
if sys.platform == 'linux':
#change background of comboboxes
color = s.lookup('TEntry', 'fieldbackground')
s.map('TCombobox', fieldbackground=[('readonly', color)])
s.map('TSpinbox', fieldbackground=[('readonly', color)])
def show_invalid(self, value=True):
img = ''
if value:
img = StockImage.get('property_invalid')
self._error_label.configure(image=img)