Skip to content

Commit

Permalink
merge differences between */toolbar.py.
Browse files Browse the repository at this point in the history
Refactoring.
  • Loading branch information
shlomif committed Apr 8, 2019
1 parent a452aba commit d3561e0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 20 deletions.
10 changes: 4 additions & 6 deletions pysollib/tile/toolbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,16 +73,16 @@ class ToolbarCheckbutton(AbstractToolbarButton, ttk.Checkbutton):
def __init__(self, parent, toolbar, toolbar_name, position, **kwargs):
kwargs['style'] = 'Toolbutton'
ttk.Checkbutton.__init__(self, parent, **kwargs)
AbstractToolbarButton.__init__(self, parent, toolbar,
toolbar_name, position)
AbstractToolbarButton.__init__(
self, parent, toolbar, toolbar_name, position)


class ToolbarButton(AbstractToolbarButton, ttk.Button):
def __init__(self, parent, toolbar, toolbar_name, position, **kwargs):
kwargs['style'] = 'Toolbutton'
ttk.Button.__init__(self, parent, **kwargs)
AbstractToolbarButton.__init__(self, parent, toolbar,
toolbar_name, position)
AbstractToolbarButton.__init__(
self, parent, toolbar, toolbar_name, position)


class ToolbarSeparator(ttk.Separator):
Expand Down Expand Up @@ -453,8 +453,6 @@ def rightclickHandler(self, event):
if self._busy():
return EVENT_HANDLED
if self.popup:
# print event.x, event.y, \
# event.x_root, event.y_root, event.__dict__
self.popup.tk_popup(event.x_root, event.y_root)
return EVENT_HANDLED

Expand Down
21 changes: 7 additions & 14 deletions pysollib/tk/toolbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,6 @@
from .tkwidget import MfxTooltip


# ************************************************************************
# *
# ************************************************************************

class AbstractToolbarButton:
def __init__(self, parent, toolbar, toolbar_name, position):
self.toolbar = toolbar
Expand Down Expand Up @@ -125,7 +121,7 @@ class ToolbarFlatSeparator(ToolbarSeparator):

class ToolbarLabel(tkinter.Message):
def __init__(self, parent, toolbar, toolbar_name, position, **kwargs):
tkinter.Message.__init__(self, parent, kwargs)
tkinter.Message.__init__(self, parent, **kwargs)
self.toolbar = toolbar
self.toolbar_name = toolbar_name
self.position = position
Expand Down Expand Up @@ -164,7 +160,6 @@ def __init__(self, top, menubar, dir,
size=0, relief='flat', compound='none'):
self.top = top
self.menubar = menubar
# self._setRelief(relief)
self.side = -1
self._tooltips = []
self._widgets = []
Expand Down Expand Up @@ -238,14 +233,14 @@ def config(self, w, v):
prev_visible = None
last_visible = None
for w in self._widgets:
if w.__class__ is ToolbarSeparator:
if prev_visible is None or \
prev_visible.__class__ is ToolbarSeparator:
if isinstance(w, ToolbarSeparator):
if prev_visible is None or isinstance(prev_visible,
ToolbarSeparator):
w.hide()
else:
w.show(orient=self.orient)
elif w.__class__ is ToolbarFlatSeparator:
if prev_visible.__class__ is ToolbarSeparator:
elif isinstance(w, ToolbarFlatSeparator):
if isinstance(prev_visible, ToolbarSeparator):
prev_visible.hide()
if w.visible:
prev_visible = w
Expand Down Expand Up @@ -416,7 +411,7 @@ def setCursor(self, cursor):
self.frame.update_idletasks()

def updateText(self, **kw):
for name in list(kw.keys()):
for name in kw.keys():
label = getattr(self, name + "_label")
label["text"] = kw[name]

Expand Down Expand Up @@ -483,8 +478,6 @@ def rightclickHandler(self, event):
if self._busy():
return EVENT_HANDLED
if self.popup:
# print event.x, event.y, event.x_root, \
# event.y_root, event.__dict__
self.popup.tk_popup(event.x_root, event.y_root)
return EVENT_HANDLED

Expand Down

0 comments on commit d3561e0

Please sign in to comment.