diff --git a/appJar/appjar.py b/appJar/appjar.py index 9c90658..d3f9b54 100755 --- a/appJar/appjar.py +++ b/appJar/appjar.py @@ -942,6 +942,12 @@ def __dimensionWindow(self): # on MAC & LINUX, w_width/w_height always 1 # on WIN, w_height is bigger then r_height - leaving empty space + # show the tb if needed + toggleTb = False + if self.hasTb and not self.tbPinned: + self.__toggletb() + toggleTb = True + # get the apps requested width & height r_width = self.__getTopLevel().winfo_reqwidth() r_height = self.__getTopLevel().winfo_reqheight() @@ -988,6 +994,10 @@ def __dimensionWindow(self): # and set it as the minimum size self.__getTopLevel().minsize(width, height) + # remove the tb again if needed + if toggleTb: + self.__toggletb() + # if the window hasn't been positioned by the user, put it in the # middle if not self.locationSet: @@ -5477,7 +5487,7 @@ def setPieChart(self, title, name, value): # FUNCTIONS for tool bar ##################################### # adds a list of buttons along the top - like a tool bar... - def addToolbar(self, names, funcs, findIcon=False, pinned=True): + def addToolbar(self, names, funcs, findIcon=False): if not self.hasTb: self.hasTb = True @@ -5522,15 +5532,23 @@ def addToolbar(self, names, funcs, findIcon=False, pinned=True): # add the pinned image - self.pinBut = Label(self.tb) + self.pinBut = None + + def __setPinBut(self): + + # only call this once + if self.pinBut is not None: + return + # try to get the icon, if none - then set but to None, and ignore from now on imgFile = os.path.join(self.icon_path, "pin.gif") try: imgObj = self.__getImage(imgFile) + self.pinBut = Label(self.tb) except: - self.pinBut = None + return - # if image found, then et up the label + # if image found, then set up the label if self.pinBut is not None: if gui.GET_PLATFORM() == gui.MAC: self.pinBut.config(cursor="pointinghand") @@ -5540,16 +5558,16 @@ def addToolbar(self, names, funcs, findIcon=False, pinned=True): self.pinBut.bind("", self.__toggletb) self.pinBut.config(image=imgObj)#, compound=TOP, text="", justify=LEFT) self.pinBut.image = imgObj # keep a reference! + self.__addTooltip(self.pinBut, "Click here to pin/unpin the toolbar.", True) self.pinBut.pack(side=RIGHT, anchor=NE, padx=0, pady=0) - self.setToolbarPinned(pinned) - # called by pinBut, to toggle the pin status of the toolbar def __toggletb(self, event=None): self.setToolbarPinned(not self.tbPinned) def setToolbarPinned(self, pinned=True): self.tbPinned = pinned + self.__setPinBut() if not self.tbPinned: if self.pinBut is not None: try: diff --git a/examples/toolbar2.py b/examples/toolbar2.py index dc99913..25067cd 100644 --- a/examples/toolbar2.py +++ b/examples/toolbar2.py @@ -18,8 +18,6 @@ def tbIn(btn): app.showToolbar() app.addToolbar(["Save", "Open", "Close", "a", "b", "c", "d", "e", "f", "g"], tbFunc, True) app.addButtons(["Pin", "Unpin", "Hide", "Show"], [pin, unpin, tbOut, tbIn]) -app.addLabel("l1", "", colspan=2) -#app.setLabelOverFunction("l1", [tbIn, tbOut]) #app.setToolbarPinned(False) app.go()