Skip to content

Commit

Permalink
winIcon now property of each window #462
Browse files Browse the repository at this point in the history
  • Loading branch information
jarvisteach committed Aug 21, 2018
1 parent 8d9b842 commit 3a8ef51
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions appJar/appjar.py
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,6 @@ def _logToRoot(message, *args, **kwargs):
self.dnd = None # the dnd manager
self.doFlash = False # set up flash variable
self.hasTitleBar = True # used to hide/show title bar
self.winIcon = None # store the path to any icon

# validate function callbacks - used by numeric texts
# created first time a widget is used
Expand Down Expand Up @@ -623,6 +622,7 @@ def _setFocus(e):
title = "appJar" if gui.exe_file is None else gui.exe_file

self.setTitle(title)
self.topLevel.winIcon = None # will store the path to any icon

# configure the geometry of the window
self.topLevel.escapeBindId = None # used to exit fullscreen
Expand Down Expand Up @@ -2841,16 +2841,17 @@ def getTitle(self):

# set an icon
def setIcon(self, image):
self.winIcon = image
container = self._getTopLevel()
container.winIcon = image
if image.endswith('.ico'):
container.wm_iconbitmap(image)
else:
icon = self._getImage(image)
container.iconphoto(True, icon)

def getIcon(self):
return self.winIcon
container = self._getTopLevel()
return container.winIcon

# property for setTitle
icon = property(getIcon, setIcon)
Expand Down Expand Up @@ -5615,14 +5616,18 @@ def startSubWindow(self, name, title=None, modal=False, blocking=False, transien
top = SubWindow(self, self.topLevel, name, title=title, stopFunc = self.confirmHideSubWindow,
modal=modal, blocking=blocking, transient=transient, grouped=grouped)

ico = self._getTopLevel().winIcon

self.widgetManager.add(WIDGET_NAMES.SubWindow, name, top)

# now, add to top of stack
self._addContainer(name, WIDGET_NAMES.SubWindow, top, 0, 1, "")

# add an icon if required
if self.winIcon is not None:
self.setIcon(self.winIcon)
if ico is not None:
self.setIcon(ico)
else:
top.winIcon = None

return top

Expand Down Expand Up @@ -5819,6 +5824,9 @@ def _packLabelBox(self, frame, widget):
# not using this for two reasons:
# - doesn't really work when font size changes
# - breaks when things in containers

# this can be made into a container property

# def _updateLabelBoxes(self, title, column):
# if len(title) >= self.labWidth.get(column, -1):
# self.labWidth[column] = len(title)
Expand Down

0 comments on commit 3a8ef51

Please sign in to comment.