E5Gui/E5SideBar.py

changeset 1451
65bdd7da65f7
parent 1447
715bfc0c02db
child 1509
c0b5e693b0eb
equal deleted inserted replaced
1450:14c47fd776f6 1451:65bdd7da65f7
6 """ 6 """
7 Module implementing a sidebar class. 7 Module implementing a sidebar class.
8 """ 8 """
9 9
10 from PyQt4.QtCore import QEvent, QSize, Qt, QByteArray, QDataStream, QIODevice 10 from PyQt4.QtCore import QEvent, QSize, Qt, QByteArray, QDataStream, QIODevice
11 from PyQt4.QtGui import QTabBar, QWidget, QStackedWidget, QBoxLayout, QToolButton, QSizePolicy 11 from PyQt4.QtGui import QTabBar, QWidget, QStackedWidget, QBoxLayout, QToolButton, \
12 QSizePolicy
12 13
13 from E5Gui.E5Application import e5App 14 from E5Gui.E5Application import e5App
14 15
15 import UI.PixmapCache 16 import UI.PixmapCache
16 17
195 def addTab(self, widget, iconOrLabel, label=None): 196 def addTab(self, widget, iconOrLabel, label=None):
196 """ 197 """
197 Public method to add a tab to the sidebar. 198 Public method to add a tab to the sidebar.
198 199
199 @param widget reference to the widget to add (QWidget) 200 @param widget reference to the widget to add (QWidget)
200 @param iconOrLabel reference to the icon or the labeltext of the tab 201 @param iconOrLabel reference to the icon or the label text of the tab
201 (QIcon, string) 202 (QIcon, string)
202 @param label the labeltext of the tab (string) (only to be 203 @param label the labeltext of the tab (string) (only to be
203 used, if the second parameter is a QIcon) 204 used, if the second parameter is a QIcon)
204 """ 205 """
205 if label: 206 if label:
206 self.__tabBar.addTab(iconOrLabel, label) 207 index = self.__tabBar.addTab(iconOrLabel, label)
207 else: 208 self.__tabBar.setTabToolTip(index, label)
208 self.__tabBar.addTab(iconOrLabel) 209 else:
210 index = self.__tabBar.addTab(iconOrLabel)
211 self.__tabBar.setTabToolTip(index, iconOrLabel)
209 self.__stackedWidget.addWidget(widget) 212 self.__stackedWidget.addWidget(widget)
210 if self.__orientation in [E5SideBar.North, E5SideBar.South]: 213 if self.__orientation in [E5SideBar.North, E5SideBar.South]:
211 self.__minSize = self.minimumSizeHint().height() 214 self.__minSize = self.minimumSizeHint().height()
212 else: 215 else:
213 self.__minSize = self.minimumSizeHint().width() 216 self.__minSize = self.minimumSizeHint().width()
222 (QIcon, string) 225 (QIcon, string)
223 @param label the labeltext of the tab (string) (only to be 226 @param label the labeltext of the tab (string) (only to be
224 used, if the second parameter is a QIcon) 227 used, if the second parameter is a QIcon)
225 """ 228 """
226 if label: 229 if label:
227 self.__tabBar.insertTab(index, iconOrLabel, label) 230 index = self.__tabBar.insertTab(index, iconOrLabel, label)
228 else: 231 self.__tabBar.setTabToolTip(index, label)
229 self.__tabBar.insertTab(index, iconOrLabel) 232 else:
233 index = self.__tabBar.insertTab(index, iconOrLabel)
234 self.__tabBar.setTabToolTip(index, iconOrLabel)
230 self.__stackedWidget.insertWidget(index, widget) 235 self.__stackedWidget.insertWidget(index, widget)
231 if self.__orientation in [E5SideBar.North, E5SideBar.South]: 236 if self.__orientation in [E5SideBar.North, E5SideBar.South]:
232 self.__minSize = self.minimumSizeHint().height() 237 self.__minSize = self.minimumSizeHint().height()
233 else: 238 else:
234 self.__minSize = self.minimumSizeHint().width() 239 self.__minSize = self.minimumSizeHint().width()

eric ide

mercurial