SF.net SVN: fclient: [550] trunk/fclient/src/fclient/Ui_View.py
Status: Pre-Alpha
Brought to you by:
jurner
From: <jU...@us...> - 2008-07-08 10:54:06
|
Revision: 550 http://fclient.svn.sourceforge.net/fclient/?rev=550&view=rev Author: jUrner Date: 2008-07-08 03:53:00 -0700 (Tue, 08 Jul 2008) Log Message: ----------- started implementing view interface Added Paths: ----------- trunk/fclient/src/fclient/Ui_View.py Added: trunk/fclient/src/fclient/Ui_View.py =================================================================== --- trunk/fclient/src/fclient/Ui_View.py (rev 0) +++ trunk/fclient/src/fclient/Ui_View.py 2008-07-08 10:53:00 UTC (rev 550) @@ -0,0 +1,110 @@ + +from __future__ import absolute_import +if __name__ == '__main__': # see --> http://bugs.python.org/issue1510172 . works only current dir and below + import os; __path__ = [os.path.dirname(__file__)] + + +from PyQt4 import QtCore, QtGui + + +from . import config +from .lib import fcp2 +from .lib.qt4ex import settingsbase +from .tpls.Ui_ViewTpl import Ui_ViewTpl + +#********************************************************************************** +# +#********************************************************************************** +class UserSettings(settingsbase.SettingsBase): + + KEY_SETTINGS = 'UserSettingsView' + SETTINGS = [ + ] + +#*********************************************************************** +# +#*********************************************************************** +class ViewWidget(QtGui.QWidget, Ui_ViewTpl): + + IdTabTop = 'tabTop' + IdTabBottom = 'tabBottom' + + + + def __init__(self, parent, cfg=None): + QtGui.QWidget.__init__(self, parent) + + self.cfg = config.Config(self) if cfg is None else cfg + self.userSettings = UserSettings() + self.views = {} + + self.setupUi(self) + + tabTop = self.controlById(self.IdTabTop) + tabTop.removeTab(0) + tabBottom = self.controlById(self.IdTabBottom) + tabBottom.removeTab(0) + + + + def controlById(self, idControl): + return getattr(self, idControl) + + + def addViews(top=True, *views): + tab = self.controlById(self.IdTabTop) if top else self.controlById(self.IdTabBottom) + for view in views: + uuid = view.uuid() + if uuid in self.views: + raise ValueError('view is already present: %s' % uuid) + i = tab.addTab(view.widget(tab), view.displayName(), view.icon()) + self.views[uuid] = (i, tab, view) + + + def viewFromUuid(self, uuid): + return self.views[uuid] + + def setCurrentView(self, view): + index, tab, view = view + + +#********************************************************************************** +# +#********************************************************************************** +class View(object): + """base class for views""" + + UUID = '' + + def __init__(self): + pass + + + def displayName(self): + return 'tab' + + def icon(self): + pass + + def uuid(self): + return self.UUID + + def widget(self, parent): + pass + + +#********************************************************************************** +# +#********************************************************************************** +if __name__ == '__main__': + import sys + + app = QtGui.QApplication(sys.argv) + w = ViewWidget(None) + w.show() + res = app.exec_() + sys.exit(res) + + + + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |