Skip to content

Commit

Permalink
Clicking on SpinControl does not need to trigger an action.
Browse files Browse the repository at this point in the history
Allow tabs in a notebook to be selected programmatically.
  • Loading branch information
Andy Lewis committed Jan 24, 2021
1 parent aeeda87 commit 76e6045
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions brywidgets/widgetset.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,10 @@ def __init__(self, pagelist=[], tabheight="2em", className=None, id=None):

def addpage(self, page):
self <= page
tab = NotebookTab(self, len(self.pagelist), page.title, self.tabheight, page.tabwidth)
tab.style.backgroundColor = page.style.backgroundColor
if page.id: tab.id = page.id+"_tab"
self.tabrow.insertBefore(tab, self.clearfloat)
page.tab = NotebookTab(self, len(self.pagelist), page.title, self.tabheight, page.tabwidth)
page.tab.style.backgroundColor = page.style.backgroundColor
if page.id: page.tab.id = page.id+"_tab"
self.tabrow.insertBefore(page.tab, self.clearfloat)
page.style.display="block" if len(self.pagelist)==0 else "none"
self.pagelist.append(page)

Expand Down Expand Up @@ -132,7 +132,7 @@ def __init__(self, notebook, index, title, height, width):
self.index = index
self.bind("click", self.select)

def select(self, event):
def select(self, event=None):
for p in self.notebook.pagelist:
p.style.display="none"
self.notebook.pagelist[self.index].style.display="block"
Expand Down Expand Up @@ -193,7 +193,7 @@ class SpinControl(html.DIV):
action: function to be called when the value is changed. Takes one parameter, the current value of the control.
Optional parameter:
stepvalue: the amount by which the value is increased or decreased (default is 1)'''
def __init__(self, initialvalue, minvalue, maxvalue, action, stepvalue=1, className=None, id=None):
def __init__(self, initialvalue, minvalue, maxvalue, action=None, stepvalue=1, className=None, id=None):
decrease = html.IMG(src=minus_b64, id="minus", style={"height":"100%", "float":"left"})
decrease.bind("click", self.ondecrease)
increase = html.IMG(src=plus_b64, id="plus", style={"height":"100%", "float":"right"})
Expand All @@ -217,12 +217,12 @@ def setValue(self, n):
def ondecrease(self, event):
if self.currentvalue-self.stepvalue >= self.minvalue: self.currentvalue -= self.stepvalue
self.valuespan.text = str(self.currentvalue)
self.action(self.currentvalue)
if self.action: self.action(self.currentvalue)

def onincrease(self, event):
if self.currentvalue+self.stepvalue <= self.maxvalue: self.currentvalue += self.stepvalue
self.valuespan.text = str(self.currentvalue)
self.action(self.currentvalue)
if self.action: self.action(self.currentvalue)

class Panel(html.DIV):
'''Just a container with a default border. Optional parameters:
Expand Down

0 comments on commit 76e6045

Please sign in to comment.