Skip to content

Commit

Permalink
Image support for tabs #380
Browse files Browse the repository at this point in the history
Also removed logging for icons
Updated testing
  • Loading branch information
jarvisteach committed May 28, 2019
1 parent 031503b commit 3f71c8a
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 7 deletions.
10 changes: 7 additions & 3 deletions appJar/appjar.py
Expand Up @@ -4911,7 +4911,10 @@ def setTabBg(self, title, tab, colour):
def tab(self, title, tabTitle=None, **kwargs):
beforeTab = kwargs.pop("beforeTab", None)
afterTab = kwargs.pop("afterTab", None)

icon = kwargs.pop("icon", None)
image = kwargs.pop("image", None)

if tabTitle is None:
tabTitle = title
title = None
Expand All @@ -4927,8 +4930,8 @@ def tab(self, title, tabTitle=None, **kwargs):
else:
tab = self.openTab(title, tabTitle)

if icon is not None:
self.setTabIcon(title, tabTitle, icon)
if icon is not None: self.setTabIcon(title, tabTitle, icon)
if image is not None: self.setTabImage(title, tabTitle, image)

self.configure(**kwargs)
try: yield tab
Expand All @@ -4937,7 +4940,8 @@ def tab(self, title, tabTitle=None, **kwargs):
def setTabIcon(self, title, tab, iconName):
nb = self.widgetManager.get(WIDGET_NAMES.TabbedFrame, title)
iconPath = self.getIconPath(iconName)
self.setTabImage(title, tab, iconPath)
with PauseLogger():
self.setTabImage(title, tab, iconPath)

def setTabImage(self, title, tab, imagePath):
nb = self.widgetManager.get(WIDGET_NAMES.TabbedFrame, title)
Expand Down
2 changes: 1 addition & 1 deletion examples/issues/issue380.py
Expand Up @@ -27,7 +27,7 @@ def press():
with app.tab(tabs[t], icon=icons[t]):
for i in range(5):
app.label(tabs[t]+str(i))
with app.tab('c', icon='wizard'):
with app.tab('c', image='lb3.gif'):
pass

with app.tab('tf', 'b', icon='wizard'):
Expand Down
2 changes: 1 addition & 1 deletion setup.py
@@ -1,7 +1,7 @@
from setuptools import setup, find_packages

__name__ = "appJar"
__version__ = "0.94.0"
__version__ = "0.95.0"
__author__ = "Richard Jarvis"
__desc__ = "An easy-to-use, feature-rich GUI wrapper for tKinter. Designed specifically for use in the classroom, but powerful enough to be used anywhere."
__author_email__ = "info@appjar.info"
Expand Down
7 changes: 5 additions & 2 deletions tests/widget_test.py
Expand Up @@ -2429,6 +2429,9 @@ def test_containers():
app.stopTab()
app.stopTabbedFrame()

app.setTabImage('tbf1', 'tab1', "1_entries.gif")
app.setTabIcon('tbf1', 'tab2', "save")

with pytest.raises(Exception) :
app.startTab()

Expand Down Expand Up @@ -3519,12 +3522,12 @@ def test_gui(btn=None):
app3.toolbar(["a", "b", "file", "open"], tester_function, icons=['a', 'b', 'file', 'open'], status=[1, 0, False, True], bg='pink')
app3.addStatusbar(TEXT_ONE, 1, "LEFT")
with app3.tabbedFrame("tf"):
with app3.tab("t1"):
with app3.tab("t1", icon='save'):
with app3.labelFrame("lf1"):
app3.addLabel("l1", "label")
with app3.toggleFrame("tf1"):
app3.addCheckBox("cb1")
with app3.tab("t2", afterTab='t1'):
with app3.tab("t2", afterTab='t1', image="1_entries.gif"):
with app3.panedFrame("pf1", sash=50):
with app3.panedFrame("vpf1", vertical=True):
app3.addLabel("l2", "label")
Expand Down

0 comments on commit 3f71c8a

Please sign in to comment.