E5Gui/E5SideBar.py

branch
5_1_x
changeset 1452
c45568ff630d
parent 1448
b9c04bc0a692
child 1510
e75ecf2bd9dd
equal deleted inserted replaced
1448:b9c04bc0a692 1452:c45568ff630d
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
194 def addTab(self, widget, iconOrLabel, label = None): 195 def addTab(self, widget, iconOrLabel, label = None):
195 """ 196 """
196 Public method to add a tab to the sidebar. 197 Public method to add a tab to the sidebar.
197 198
198 @param widget reference to the widget to add (QWidget) 199 @param widget reference to the widget to add (QWidget)
199 @param iconOrLabel reference to the icon or the labeltext of the tab 200 @param iconOrLabel reference to the icon or the label text of the tab
200 (QIcon, string) 201 (QIcon, string)
201 @param label the labeltext of the tab (string) (only to be 202 @param label the labeltext of the tab (string) (only to be
202 used, if the second parameter is a QIcon) 203 used, if the second parameter is a QIcon)
203 """ 204 """
204 if label: 205 if label:
205 self.__tabBar.addTab(iconOrLabel, label) 206 index = self.__tabBar.addTab(iconOrLabel, label)
206 else: 207 self.__tabBar.setTabToolTip(index, label)
207 self.__tabBar.addTab(iconOrLabel) 208 else:
209 index = self.__tabBar.addTab(iconOrLabel)
210 self.__tabBar.setTabToolTip(index, iconOrLabel)
208 self.__stackedWidget.addWidget(widget) 211 self.__stackedWidget.addWidget(widget)
209 if self.__orientation in [E5SideBar.North, E5SideBar.South]: 212 if self.__orientation in [E5SideBar.North, E5SideBar.South]:
210 self.__minSize = self.minimumSizeHint().height() 213 self.__minSize = self.minimumSizeHint().height()
211 else: 214 else:
212 self.__minSize = self.minimumSizeHint().width() 215 self.__minSize = self.minimumSizeHint().width()
221 (QIcon, string) 224 (QIcon, string)
222 @param label the labeltext of the tab (string) (only to be 225 @param label the labeltext of the tab (string) (only to be
223 used, if the second parameter is a QIcon) 226 used, if the second parameter is a QIcon)
224 """ 227 """
225 if label: 228 if label:
226 self.__tabBar.insertTab(index, iconOrLabel, label) 229 index = self.__tabBar.insertTab(index, iconOrLabel, label)
227 else: 230 self.__tabBar.setTabToolTip(index, label)
228 self.__tabBar.insertTab(index, iconOrLabel) 231 else:
232 index = self.__tabBar.insertTab(index, iconOrLabel)
233 self.__tabBar.setTabToolTip(index, iconOrLabel)
229 self.__stackedWidget.insertWidget(index, widget) 234 self.__stackedWidget.insertWidget(index, widget)
230 if self.__orientation in [E5SideBar.North, E5SideBar.South]: 235 if self.__orientation in [E5SideBar.North, E5SideBar.South]:
231 self.__minSize = self.minimumSizeHint().height() 236 self.__minSize = self.minimumSizeHint().height()
232 else: 237 else:
233 self.__minSize = self.minimumSizeHint().width() 238 self.__minSize = self.minimumSizeHint().width()

eric ide

mercurial