SF.net SVN: fclient: [605] trunk/fclient/src/fclient/Ui_ViewBrowser.py
Status: Pre-Alpha
Brought to you by:
jurner
From: <jU...@us...> - 2008-07-13 14:07:15
|
Revision: 605 http://fclient.svn.sourceforge.net/fclient/?rev=605&view=rev Author: jUrner Date: 2008-07-13 07:07:23 -0700 (Sun, 13 Jul 2008) Log Message: ----------- add basic browser view impl Added Paths: ----------- trunk/fclient/src/fclient/Ui_ViewBrowser.py Added: trunk/fclient/src/fclient/Ui_ViewBrowser.py =================================================================== --- trunk/fclient/src/fclient/Ui_ViewBrowser.py (rev 0) +++ trunk/fclient/src/fclient/Ui_ViewBrowser.py 2008-07-13 14:07:23 UTC (rev 605) @@ -0,0 +1,109 @@ + + +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__)] + +import logging +import sys +logging.basicConfig(stream=sys.stdout, level=logging.DEBUG) + +from PyQt4 import QtCore, QtGui + + +from . import config +from . import Ui_View + +from .tpls.Ui_ViewBrowserWidgetTpl import Ui_ViewBrowserWidget +#********************************************************************************** +# +#********************************************************************************** +class Settings(config.SettingsBase): + _key_ = config.IdViewBrowserWidget + _settings_ = ( + ) + +#*********************************************************************** +# +#*********************************************************************** +class ViewBrowserWidget(QtGui.QWidget, Ui_ViewBrowserWidget): + + + def __init__(self, parent): + QtGui.QWidget.__init__(self, parent) + self._acts = [] + self._isCreated = False + self._mainWindowMenus = [] + + self.settings = Settings() + + self.setupUi(self) + config.ObjectRegistry.register(self) + + # atatch menus to main window if present. have to do it in __init__ to reserve order + menuBarWrap = config.ObjectRegistry.get(config.IdMainWindowMenuBarWrap, None) + if menuBarWrap is not None: + menu = QtGui.QMenu(self.viewDisplayName(), menuBarWrap.menuBar()) + for act in self.acts(): + print act + menu.addAction(act) + self._mainWindowMenus = ( + menuBarWrap.addViewMenu(menu), + ) + + ######################################### + ## methods + ######################################### + def acts(self): + if not self._acts: + self._acts = ( + ) + return self._acts + + + def controlById(self, idControl): + return getattr(self, idControl) + + ######################################### + ##view methods + ######################################### + def viewClose(self): + pass + + def viewDisplayName(self): + return self.trUtf8('Browser') + + def viewHandleCurrentChanged(self, isCurrent): + for menu in self._mainWindowMenus: + menu.children()[0].setVisible(isCurrent) + + def viewIcon(self): + return QtGui.QIcon() + + def viewName(self): + return self.objectName() + + ######################################### + ## overwritten events + ######################################### + def showEvent(self, event): + if self._isCreated: + return + self._isCreated = True + +#********************************************************************************** +# +#********************************************************************************** +if __name__ == '__main__': + import sys + from . import Ui_ViewLogger + + app = QtGui.QApplication(sys.argv) + w = ViewBrowserWidget(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. |