fclient-commit Mailing List for fclient (Page 16)
Status: Pre-Alpha
Brought to you by:
jurner
You can subscribe to this list here.
2007 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(23) |
Nov
(54) |
Dec
|
---|---|---|---|---|---|---|---|---|---|---|---|---|
2008 |
Jan
(17) |
Feb
(209) |
Mar
(63) |
Apr
(31) |
May
(7) |
Jun
(39) |
Jul
(390) |
Aug
(122) |
Sep
(6) |
Oct
|
Nov
|
Dec
|
From: <jU...@us...> - 2008-07-12 11:09:29
|
Revision: 587 http://fclient.svn.sourceforge.net/fclient/?rev=587&view=rev Author: jUrner Date: 2008-07-12 04:09:38 -0700 (Sat, 12 Jul 2008) Log Message: ----------- comb over logging Modified Paths: -------------- trunk/fclient/src/fclient/lib/fcp2/iohandler.py Modified: trunk/fclient/src/fclient/lib/fcp2/iohandler.py =================================================================== --- trunk/fclient/src/fclient/lib/fcp2/iohandler.py 2008-07-12 11:08:48 UTC (rev 586) +++ trunk/fclient/src/fclient/lib/fcp2/iohandler.py 2008-07-12 11:09:38 UTC (rev 587) @@ -99,6 +99,7 @@ @param host: (str) host to connect to @param port: (int) port to use """ + consts.ConstLogger.IO.debug(consts.ConstLogMessages.Connecting + ' {%r' % {'host': host, 'port': port}) if self.isOpen(): self.close() self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) @@ -132,6 +133,7 @@ raise consts.ErrorIOBroken(details, consts.ConstLogger.IO.error) def close(self): + consts.ConstLogger.IO.debug(consts.ConstLogMessages.Closing) if self.socket is None: raise consts.ErrorIOClosed('Closed', consts.ConstLogger.IO.error) self.socket.close() @@ -199,7 +201,6 @@ try: self.io.connect(**kwargs) except consts.ErrorIOConnectFailed, details: - consts.ConstLogger.IOHandler.info(consts.ConstLogMessages.ConnectingFailed + ' (%s)' % details) yield False else: consts.ConstLogger.IOHandler.info(consts.ConstLogMessages.Connected) @@ -207,7 +208,7 @@ break # continue polling - consts.ConstLogger.IOHandler.info(consts.ConstLogMessages.Retry) + consts.ConstLogger.IOHandler.info(consts.ConstLogMessages.RetryingConnect) timeElapsed += timeout time.sleep(timeout) @@ -322,7 +323,7 @@ self._receiveBuffer = chunk + self._receiveBuffer raise ErrorIOTimeout(details) - consts.ConstLogger.IOHandler.debug(consts.ConstLogMessages.Received + msg.pprint()) + consts.ConstLogger.IOHandler.log(consts.ConstDebugVerbosity.Message, consts.ConstLogMessages.Received + msg.pprint()) return msg @@ -332,7 +333,7 @@ @return: Message @raise L{consts.ErrorIOBroken}: if the connection to the io dies unexpectedly """ - consts.ConstLogger.IOHandler.debug(consts.ConstLogMessages.Sending + msg.pprint()) + consts.ConstLogger.IOHandler.log(consts.ConstDebugVerbosity.Message, consts.ConstLogMessages.Sending + msg.pprint()) self.io.write(msg.toString()) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jU...@us...> - 2008-07-12 11:08:48
|
Revision: 586 http://fclient.svn.sourceforge.net/fclient/?rev=586&view=rev Author: jUrner Date: 2008-07-12 04:08:48 -0700 (Sat, 12 Jul 2008) Log Message: ----------- added extra debug level for messages Modified Paths: -------------- trunk/fclient/src/fclient/lib/fcp2/consts.py Modified: trunk/fclient/src/fclient/lib/fcp2/consts.py =================================================================== --- trunk/fclient/src/fclient/lib/fcp2/consts.py 2008-07-12 11:08:08 UTC (rev 585) +++ trunk/fclient/src/fclient/lib/fcp2/consts.py 2008-07-12 11:08:48 UTC (rev 586) @@ -102,6 +102,7 @@ """Consts indicating the verbosity level for debugging""" Chatty = logging.DEBUG - 1 Debug = logging.DEBUG + Message = logging.INFO -1 Info = logging.INFO Warning = logging.WARNING Error = logging.ERROR @@ -231,8 +232,9 @@ IOHandler =logging.getLogger('Fcp.Client.IOHandler') IO =logging.getLogger('Fcp.Client.IOHandler.IO') Message = logging.getLogger('Fcp.Client.Message') -logging.addLevelName(ConstDebugVerbosity.Chatty, 'chatty') -logging.addLevelName(ConstDebugVerbosity.Quiet, 'quiet') +logging.addLevelName(ConstDebugVerbosity.Chatty, 'CHATTY') +logging.addLevelName(ConstDebugVerbosity.Quiet, 'QUIET') +logging.addLevelName(ConstDebugVerbosity.Message, 'MESSAGE') logging.basicConfig(stream=sys.stdout, level=logging.DEBUG) class ConstLogMessages: @@ -241,7 +243,7 @@ Connecting = 'connecting' Connected = 'connected to node' ConnectingFailed = 'connecting to node failed' - Retry = 'Retrying' + RetryingConnect = 'Retrying to connect' Closing = 'Closing' Sending = 'Sending' This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jU...@us...> - 2008-07-12 11:08:10
|
Revision: 585 http://fclient.svn.sourceforge.net/fclient/?rev=585&view=rev Author: jUrner Date: 2008-07-12 04:08:08 -0700 (Sat, 12 Jul 2008) Log Message: ----------- left over print statement Modified Paths: -------------- trunk/fclient/src/fclient/Ui_ViewLogger.py Modified: trunk/fclient/src/fclient/Ui_ViewLogger.py =================================================================== --- trunk/fclient/src/fclient/Ui_ViewLogger.py 2008-07-12 11:07:35 UTC (rev 584) +++ trunk/fclient/src/fclient/Ui_ViewLogger.py 2008-07-12 11:08:08 UTC (rev 585) @@ -62,8 +62,6 @@ return getattr(self, idControl) def addMessage(self, text): - print text, type(text) - ed = self.controlById(self.IdEddLogger) ed.append(text) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jU...@us...> - 2008-07-12 11:07:25
|
Revision: 584 http://fclient.svn.sourceforge.net/fclient/?rev=584&view=rev Author: jUrner Date: 2008-07-12 04:07:35 -0700 (Sat, 12 Jul 2008) Log Message: ----------- continued working on widget Modified Paths: -------------- trunk/fclient/src/fclient/Ui_ViewConnection.py Modified: trunk/fclient/src/fclient/Ui_ViewConnection.py =================================================================== --- trunk/fclient/src/fclient/Ui_ViewConnection.py 2008-07-12 11:06:56 UTC (rev 583) +++ trunk/fclient/src/fclient/Ui_ViewConnection.py 2008-07-12 11:07:35 UTC (rev 584) @@ -5,11 +5,9 @@ from PyQt4 import QtCore, QtGui - from . import config -from . import Ui_View - from .lib import fcp2 +from . import Ui_View from .tpls.Ui_ViewConnectionWidgetTpl import Ui_ViewConnectionWidget #********************************************************************************** # @@ -17,126 +15,126 @@ class Settings(config.SettingsBase): _key_ = config.IdViewConnectionWidget _settings_ = ( - ('AutoConnect', 'Bool', False), - ('ConnectionHost', 'String', fcp2.Client.DefaultFcpHost), - ('ConnectionName', 'String', ''), #TODO: we need a python ansi string - ('ConnectionPort', 'UInt', fcp2.Client.DefaultFcpPort), + ('ConnectionTimerTimeout', 'UInt', 100, config.SettingScopeExpert), + + ('AutoConnect', 'Bool', False, config.SettingScopeUser), + ('ConnectionName', 'String', '', config.SettingScopeUser), #TODO: we need a python ansi string + ('ConnectionHost', 'String', fcp2.Client.DefaultFcpHost, config.SettingScopeUser), + ('ConnectionPort', 'UInt', fcp2.Client.DefaultFcpPort, config.SettingScopeUser), ) +#********************************************************************************** +# +#********************************************************************************** +class ConnectionTimer(QtCore.QTimer): + + def __init__(self,parent): + QtCore.QTimer.__init__(self, parent) + self.iterConnect = None + self.nodeHello = None + self.connect(self, QtCore.SIGNAL('timeout()'), self.handleNext) + + def start(self, settings): + self.iterConnect = config.fcpClient.iterConnect() #TODO: ...more args + QtCore.QTimer.start(self, settings.value('ConnectionTimerTimeout')) + + def handleNext(self): + try: + result = self.iterConnect.next() + except StopIteration: + self.stop() + else: + if result is not None: + self.stop() + self.nodeHello = result + #*********************************************************************** # #*********************************************************************** class ViewConnectionWidget(QtGui.QWidget, Ui_ViewConnectionWidget): IdBtConnect = 'btConnect' - IdEdConnectionHost = 'edConnectionHost' + IdEdConnectionHost = 'edConnectionHost' #TODO: combobox? validate input. IdSpinConnectionPort = 'spinConnectionPort' - def __init__(self, parent, cfg=None): QtGui.QWidget.__init__(self, parent) self._isCreated = False - self.settings = Settings() + self._connectionTimer = ConnectionTimer(self) + self.settings = Settings() self.setupUi(self) - - self.settings.restore() config.ObjectRegistry.register(self) - + ######################################### + ## + ######################################### def controlById(self, idControl): return getattr(self, idControl) - - def retranslateUi(self, w): - Ui_ViewConnectionWidget.retranslateUi(self, w) - bt = self.controlById(self.IdBtConnect) - if bt.isChecked(): - bt.setText() - ######################################### - ## events + ## overwritten events ######################################### def showEvent(self, event): QtGui.QWidget.showEvent(self, event) - if self._isCreated: + if self._isCreated: return - self._isCreated = True + self.connect( self.controlById(self.IdBtConnect), QtCore.SIGNAL('clicked(bool)'), - self.onBtConnectClicked + self.handleBtConnectClicked ) + self.settings.restore() + # setup host / port boxes edHost = self.controlById(self.IdEdConnectionHost) edHost.setText(self.settings.value('ConnectionHost')) spinPort = self.controlById(self.IdSpinConnectionPort) - #TODO: no idea if port range (0, 0xFFFF) this is reasonable - spinPort.setRange(0, 0xFFFF) + spinPort.setRange(0, 0xFFFF) #TODO: no idea if port range (0, 0xFFFF) this is reasonable spinPort.setValue(self.settings.value('ConnectionPort')) - # autoconnect if desired - self.settings.restore() if self.settings.value('AutoConnect'): self.controlById(self.IdBtConnect).setChecked(True) self.onBtConnectClicked(True) - #XXX - self.settings.setValues(ConnectionName='abc') - - + ######################################### - ## + ## overwritten methods ######################################### - def onBtConnectClicked(self, checked): + def retranslateUi(self, w): + Ui_ViewConnectionWidget.retranslateUi(self, w) bt = self.controlById(self.IdBtConnect) + if bt.isChecked(): + bt.setText() + + ######################################### + ## event handlers + ######################################### + def handleBtConnectClicked(self, checked): + bt = self.controlById(self.IdBtConnect) if checked: - bt.setText(QtGui.QApplication.translate("ViewConnectionWidget", "Disconnect", None, QtGui.QApplication.UnicodeUTF8)) + bt.setText(QtGui.QApplication.translate(config.IdViewConnectionWidget, "Disconnect", None, QtGui.QApplication.UnicodeUTF8)) if config.fcpClient.isConnected(): config.fcpClient.close() - t = self.ConnectTimer(self) + self._connectionTimer.start(self.settings) else: - bt.setText(QtGui.QApplication.translate("ViewConnectionWidget", "Connect", None, QtGui.QApplication.UnicodeUTF8)) + bt.setText(QtGui.QApplication.translate(config.IdViewConnectionWidget, "Connect", None, QtGui.QApplication.UnicodeUTF8)) config.fcpClient.close() - - #TODO: under construction! - class ConnectTimer(QtCore.QTimer): - - def __init__(self,parent): - QtCore.QTimer.__init__(self, parent) - #self.setInterval(10) - self.connect(self, QtCore.SIGNAL('timeout()'), self.handleNext) + self._connectionTimer.stop() - self.iterConnect = config.fcpClient.iterConnect() # ...more args - self.start(10) - - def handleNext(self): - try: - result = self.iterConnect.next() - except StopIteration: - self.stop() - else: - if result is not None: - self.stop() - - - - - - - - - def handleFoo(self): + ######################################### + ## fcp event handlers + ######################################### + def handleFcpClientDisconected(self, event): pass - - - + #********************************************************************************** # #********************************************************************************** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jU...@us...> - 2008-07-12 11:06:48
|
Revision: 583 http://fclient.svn.sourceforge.net/fclient/?rev=583&view=rev Author: jUrner Date: 2008-07-12 04:06:56 -0700 (Sat, 12 Jul 2008) Log Message: ----------- added scope consts for settings Modified Paths: -------------- trunk/fclient/src/fclient/config.py Modified: trunk/fclient/src/fclient/config.py =================================================================== --- trunk/fclient/src/fclient/config.py 2008-07-11 19:42:24 UTC (rev 582) +++ trunk/fclient/src/fclient/config.py 2008-07-12 11:06:56 UTC (rev 583) @@ -50,11 +50,17 @@ #********************************************************************************** # #********************************************************************************** +SettingScopeExpert = 0x1 +SettingScopePrivate = 0x2 +SettingScopeUser = 0x4 +SettingSkopeMask = SettingScopeExpert | SettingScopePrivate | SettingScopeUser + class SettingsBase(settings.SettingsBase): """application wide base class for settings""" _config_settings_ = None + #TODO: we have to notify all instances on changes. yuk def settingsObject(self): settingsDir = self._config_settings_.value('SettingsDir') @@ -75,8 +81,8 @@ class Settings(SettingsBase): _key_ = 'ConfigSettings' _settings_ = ( - ('SettingsDir', 'String', QtCore.QString(SettingsDir)), # if not None, settings are stored locally in the app folder - ('SettingsAllUsers', 'Bool', False), # store settings for all users? + ('SettingsDir', 'String', QtCore.QString(SettingsDir), SettingScopeUser), # if not None, settings are stored locally in the app folder + ('SettingsAllUsers', 'Bool', False, SettingScopeUser), # store settings for all users? ) SettingsBase._config_settings_ = Settings() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jU...@us...> - 2008-07-11 19:42:16
|
Revision: 582 http://fclient.svn.sourceforge.net/fclient/?rev=582&view=rev Author: jUrner Date: 2008-07-11 12:42:24 -0700 (Fri, 11 Jul 2008) Log Message: ----------- after 4 months of work. celebrate. the node is alive /houston Modified Paths: -------------- trunk/fclient/src/fclient/Ui_ViewConnection.py Modified: trunk/fclient/src/fclient/Ui_ViewConnection.py =================================================================== --- trunk/fclient/src/fclient/Ui_ViewConnection.py 2008-07-11 19:37:10 UTC (rev 581) +++ trunk/fclient/src/fclient/Ui_ViewConnection.py 2008-07-11 19:42:24 UTC (rev 582) @@ -96,10 +96,47 @@ bt = self.controlById(self.IdBtConnect) if checked: bt.setText(QtGui.QApplication.translate("ViewConnectionWidget", "Disconnect", None, QtGui.QApplication.UnicodeUTF8)) + + if config.fcpClient.isConnected(): + config.fcpClient.close() + t = self.ConnectTimer(self) + else: bt.setText(QtGui.QApplication.translate("ViewConnectionWidget", "Connect", None, QtGui.QApplication.UnicodeUTF8)) - - + config.fcpClient.close() + + #TODO: under construction! + class ConnectTimer(QtCore.QTimer): + + def __init__(self,parent): + QtCore.QTimer.__init__(self, parent) + #self.setInterval(10) + self.connect(self, QtCore.SIGNAL('timeout()'), self.handleNext) + + self.iterConnect = config.fcpClient.iterConnect() # ...more args + self.start(10) + + def handleNext(self): + try: + result = self.iterConnect.next() + except StopIteration: + self.stop() + else: + if result is not None: + self.stop() + + + + + + + + + def handleFoo(self): + pass + + + #********************************************************************************** # #********************************************************************************** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jU...@us...> - 2008-07-11 19:37:03
|
Revision: 581 http://fclient.svn.sourceforge.net/fclient/?rev=581&view=rev Author: jUrner Date: 2008-07-11 12:37:10 -0700 (Fri, 11 Jul 2008) Log Message: ----------- pretend we can be certain.. Modified Paths: -------------- trunk/fclient/src/fclient/lib/fcp2/client.py Modified: trunk/fclient/src/fclient/lib/fcp2/client.py =================================================================== --- trunk/fclient/src/fclient/lib/fcp2/client.py 2008-07-11 19:36:40 UTC (rev 580) +++ trunk/fclient/src/fclient/lib/fcp2/client.py 2008-07-11 19:37:10 UTC (rev 581) @@ -440,7 +440,7 @@ return nodeHello - def isOpen(self): + def isConnected(self): """Checks if the clients connection is open @return: (bool) True if so, False otherwise """ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jU...@us...> - 2008-07-11 19:36:30
|
Revision: 580 http://fclient.svn.sourceforge.net/fclient/?rev=580&view=rev Author: jUrner Date: 2008-07-11 12:36:40 -0700 (Fri, 11 Jul 2008) Log Message: ----------- hello node. can't hear you Modified Paths: -------------- trunk/fclient/src/fclient/config.py Modified: trunk/fclient/src/fclient/config.py =================================================================== --- trunk/fclient/src/fclient/config.py 2008-07-11 16:37:09 UTC (rev 579) +++ trunk/fclient/src/fclient/config.py 2008-07-11 19:36:40 UTC (rev 580) @@ -83,7 +83,7 @@ #********************************************************************************** # #********************************************************************************** -fcpClient = fcp2.Client() # global fcp client +fcpClient = fcp2.Client(debugVerbosity=fcp2.ConstDebugVerbosity.Debug) # global fcp client settings = Settings(None) # global settings class #********************************************************************************** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jU...@us...> - 2008-07-11 16:37:12
|
Revision: 579 http://fclient.svn.sourceforge.net/fclient/?rev=579&view=rev Author: jUrner Date: 2008-07-11 09:37:09 -0700 (Fri, 11 Jul 2008) Log Message: ----------- adapt to recent Modified Paths: -------------- trunk/fclient/src/fclient/lib/qt4ex/README Modified: trunk/fclient/src/fclient/lib/qt4ex/README =================================================================== --- trunk/fclient/src/fclient/lib/qt4ex/README 2008-07-11 16:35:17 UTC (rev 578) +++ trunk/fclient/src/fclient/lib/qt4ex/README 2008-07-11 16:37:09 UTC (rev 579) @@ -9,12 +9,17 @@ 0.1.0 ******************************************************************* news: - x. + x. qt4ex.qtools has a new function castVariant() bugfixes: x. settingsbase/SettingsBase 'toUInt' did not work as expected. instead of an UInt a tuple(UInt, bool) was returned. fixed +deprecated: + + x. qt4ex.settingsbase. use qt4ex.settings istead + + ******************************************************************* 0.1.0 ******************************************************************* This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jU...@us...> - 2008-07-11 16:35:08
|
Revision: 578 http://fclient.svn.sourceforge.net/fclient/?rev=578&view=rev Author: jUrner Date: 2008-07-11 09:35:17 -0700 (Fri, 11 Jul 2008) Log Message: ----------- new fuction castVariant() to tame QVariant a bit Modified Paths: -------------- trunk/fclient/src/fclient/lib/qt4ex/qtools.py Modified: trunk/fclient/src/fclient/lib/qt4ex/qtools.py =================================================================== --- trunk/fclient/src/fclient/lib/qt4ex/qtools.py 2008-07-11 16:34:31 UTC (rev 577) +++ trunk/fclient/src/fclient/lib/qt4ex/qtools.py 2008-07-11 16:35:17 UTC (rev 578) @@ -56,10 +56,51 @@ #********************************************************************** # #********************************************************************** +class _castVariant(object): + """for some reason PyQt does the right thing for int, long (...) variant type conversions returning (value, ok) + emulating it here for all other types as well""" + _pyqt_does_the_right_thing_ = ( + QtCore.QVariant.Double, + QtCore.QVariant.Int, + QtCore.QVariant.LongLong, + QtCore.QVariant.UInt, + QtCore.QVariant.ULongLong, + ) + #NOTE: if QVariant gets equipped with another enum we are f***d + _variant_type_mapping = {} + _reversed_variant_type_mapping = {} + for name in dir(QtCore.QVariant): + if name[0].isupper(): + value = getattr(QtCore.QVariant, name) + if isinstance(value, int): + _variant_type_mapping[value] = name + _reversed_variant_type_mapping[name] = value + del name, value + @classmethod + def castVariant(clss, v, variantType): + """casts a variant to an object of the desired type + @param v: (QVariant) to convert + @param variantType: (QVariant.Type*) to convert to. alternatively the variantType can be a specified + as string corrosponding to QVariant.to* methods e.g. 'Bool', 'UInt' + @return: (tuple) object, ok + """ + if isinstance(variantType, int): + szVariantType = clss._variant_type_mapping[variantType] + else: + szVariantType = variantType + variantType = clss._reversed_variant_type_mapping[variantType] + mthd = getattr(v, 'to' + szVariantType) + if variantType in clss._pyqt_does_the_right_thing_: + obj, ok = mthd() + else: + ok = v.convert(variantType) + obj = mthd() + return obj, ok +castVariant =_castVariant.castVariant + - This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jU...@us...> - 2008-07-11 16:34:21
|
Revision: 577 http://fclient.svn.sourceforge.net/fclient/?rev=577&view=rev Author: jUrner Date: 2008-07-11 09:34:31 -0700 (Fri, 11 Jul 2008) Log Message: ----------- deprecate settingsbase use qt4ex.settings instead Added Paths: ----------- trunk/fclient/src/fclient/lib/qt4ex/settings.py Added: trunk/fclient/src/fclient/lib/qt4ex/settings.py =================================================================== --- trunk/fclient/src/fclient/lib/qt4ex/settings.py (rev 0) +++ trunk/fclient/src/fclient/lib/qt4ex/settings.py 2008-07-11 16:34:31 UTC (rev 577) @@ -0,0 +1,368 @@ +"""helpers to work with QSettings +""" +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 operator +from PyQt4 import QtCore, QtGui + +from . import qtools +#******************************************************************************** +# +#******************************************************************************** +class Setting(object): + __slots__ = ('default', 'type', 'userData', 'value') + def __init__(self, type, value, default, userData=None): + self.default = default + self.type = type + self.userData = userData + self.value = value + +#******************************************************************************** +# +#******************************************************************************** +class SettingsBase(object): + """Base class to deal with reading and writing of settings + + this class tries to take away most of the pain when dealing with QSettings. + + * settings are automatically dumped to disk when they are set + * if a setting can not be read from disk or its type is not ok its default value is taken instead + * settings are always saved and restored in the specified settings order + * any user defined data may be associated to a setting at runtime + + blah more here + + + you should derrive a class from SettingsBase and implement its L{settingsObject} method. + this method is called whenever a settings object is required to read or write a setting. + the subclass must define a '_key_' attribute (key to store the settings to) and a tuple + _settings_. + + blah more here + + + sample usage:: + + class MySettings(settings.SettingsBase): + _key_ = 'MyKey' + _settings_ = ( + ('MySetting-1', 'Bool', True), # name, type, default + ('MySetting-1', 'Bool', True, 0), # or.. name, type, default, userData + ) + + def settingsObject(self): + return QtCore.QSettings() + + s = MySettings() + s.restore() + s.value('MySetting-1') + >> True + + + you may define handlers for custom types as well:: + + class MySettings(settings.SettingsBase): + _key_ = 'MyKey' + _settings_ = ( + ('MySetting-1', 'MyType', True), + ) + + def settingsObject(self): + return QtCore.QSettings() + + def fromMyType(self, settings, name, value): + return QTCore.QVariant(value), True + + def toMyType(self, settings, name, v): + return v.toBool(), True + + + finalisation of the settings object can be handled as well:: + + class MySettings(settings.SettingsBase): + _key_ = 'MyKey' + _settings_ = ( + ('MySetting-1', 'MyType', True), + ) + + def settingsObject(self): + s = QtCore.QSettings() + s.beginGroup('whatever') + return s + + def finalizeSettingsObject(self, settingsObject): + settingsObject.endGroup() + + """ + _settings_ = () # (ValueName, type, DefaultValue, (optional)UserData) + _key_ = '' # + + + def __init__(self, parent=None): + """ + @param parent: (QObject) or None + """ + + self._parent = parent + self._settingsDict = None + self._settingsOrder = None + + self.updateSettingsDict() + + + def finalizeSettingsObject(self, settingsObject): + """called when done with a settings object as returned from L{settingsObject} + @param settingsObject: (QSettings) + @note: default implementation does nothing. overwrite to handle + """ + + + def settingsObject(self): + """should return the QSettings object to store settings to + @return: (QSettings) + @raise NotImplementedError: overrite to handle + """ + raise NotImplementedError() + + ############################################# + ## + ############################################# + def default(self, name): + """returns the default value of a setting + @param name: (str) name of the setting + """ + return self._settingsDict[name].default + + + def parent(self): + """returns the parent of the settings instance""" + return self._parent + + def restore(self): + """restores settings from disk + + @note: values are restored in settings order + @note: the method tries first to find a method to<DesiredType> . if present the method + will be called with three arguments (QSettings,settingName, variant). the method should + convert the variant to the deired value type and return it along with a boolean flag indicating + if the value is ok or not. if it is not ok the settings default value is picked up:: + dumped to disk or not:: + + def toMyType(settings, name, v): + if v.isValid(): + s = v.toString() + if not s.isEmpty(): + return s, True + return None, False + + if no such handler is found it is assumed that the value can be converted directly from the QVariant + by calling QVariant.to<DesiredType>() + + @note: L{finalizeSettingsObject} is called emidiately after the call to allow for clean ups of the settings object + """ + settings = self.settingsObject() + settings.beginGroup(self._key_) + try: + for name in self._settingsOrder: + typeSetting = self.type(name) + if typeSetting is not None: + v = settings.value(name) + # check if we have a conversion method at hand.. + mthd = getattr(self, 'to' + typeSetting, None) + # ..if not definded assert it is a QVariant method + if mthd is None: + mthd = getattr(v, 'to' + typeSetting, None) + if mthd is None: + raise ValueError('%s: no conversion method found for type: %r' % (name, typeSetting)) + obj, ok = qtools.castVariant(v, typeSetting) + else: + obj, ok = getattr(self, 'to' + typeSetting)(settings, name, v) + self._settingsDict[name].value = obj if ok else self.default(name) + finally: + settings.endGroup() + self.finalizeSettingsObject(settings) + + + def restoreDefaults(self, *names): + """restores default values for settings + @param names: names to restore defaults for or no name to restore defaults of all settings + """ + names = names if names else self._settingsOrder + return self.setValues(**dict([(name, self.default(name)) for name in names])) + + + def setDefault(self, name, value): + """sets the default value of a setting + @param name: (str) name of the setting + @param value: default value + """ + self._settingsDict[name].default = value + + + def setType(self, name, value): + """sets the type of a setting + @param name: (str) name of the setting + @param value: desired type + @note: the settings value is not adjusted in the call and it is not dumped to disk. + use L{updateSettingsDict} followed by L{setValues} to do so + """ + self._settingsDict[name].type = value + + + def setUserData(self, name, value): + """associates (any) user defined data to a setting + @param name: (str) name of the setting + """ + self._settingsDict[name].userData = value + + + def setValues(self, **kws): + """sets the value of one or more setting and dumps it to disk + @param kws: name --> value to set + @note: if no kws are specified all settings are dumped to disk + + @note: values are set in settings order + @note: the method tries first to find a method from<DesiredType> . if present the method + will be called with three arguments (QSettings,settingName, settingValue). the method should + convert the value to a QVariant and return it along with a boolean flag indicating if the value should be + dumped to disk or not:: + + def fromMyType(settings, name, value): + v = QtCore.QVariant(value) + if v.isValid(): + return v, True + return None, False + + if no such handler is found it is assumed that the value can be converted directly to a QVariant + + @note: L{finalizeSettingsObject} is called emidiately after the call to allow for clean ups of the settings object + """ + kws = kws if kws else self._settingsDict + + # sort kws by settings order + try: + L = [(self._settingsOrder.index(i[0]), i[0], i[1]) for i in kws.items()] + except ValueError: + raise ValueError('No such setting: %s' % [i for i in kws if i not in self._settingsOrder][0]) + L.sort(key=operator.itemgetter(0)) + + settings = self.settingsObject() + settings.beginGroup(self._key_) + try: + for _, name, value in L: + typeSetting = self.type(name) + self._settingsDict[name].value = value + if typeSetting is not None: + mthd = getattr(self, 'from' + typeSetting, None) + if mthd is None: + v = QtCore.QVariant(value) + ok = True + else: + v, ok = mthd(settings, name, value) + settings.setValue(name, v) if ok else settings.setValue(name, QtCore.QVariant(self.default(name))) + finally: + settings.endGroup() + self.finalizeSettingsObject(settings) + + + def toDict(self): + """Returns a dict containing the current state of the settings object + @return: dict{SettingsName: value} + """ + return dict([(name, setting.value) for (name, setting) in self._settingsDict.items()]) + + + def type(self, name): + """returns the type of a setting + @param name: (str) name of the setting + """ + return self._settingsDict[name].type + + + def updateSettingsDict(self): + """Updates the internal state of the settings object + @note: use this for example if you dynamically add or remove settings + """ + self._settingsDict = {} + self._settingsOrder = [] + for i in self._settings_: + if len(i) == 3: + setting = Setting(i[1], i[2], i[2]) + elif len(i) == 4: + setting = Setting(i[1], i[2], i[2], userData=i[3]) + else: + raise ValueError('setting data should be 2 or three tuple: %r' % name) + name = i[0] + if name in self._settingsOrder: + raise valueError('setting already exists: %r' % name) + self._settingsDict[name] = setting + self._settingsOrder.append(name) + + + def userData(self, name): + """returns the user data associated to a setting + @param name: (str) name of the setting + """ + return self._settingsDict[name].userData + + + def value(self, name): + """returns the value of a setting + @param name: (str) name of the setting + """ + return self._settingsDict[name].value + + ############################################# + ## + ############################################# + def fromQColor(self, settings, name, value): + """default handler to convert a QColor to a QVariant""" + if value is not None: + return QtCore.QVariant(value.name()), True + return QtCore.QVariant(), False + + def toQColor(self, settings, name, v): + """default handler to convert a QVariant to a QColor""" + if v.isValid(): + color = QtGui.QColor(v.toString()) + if color.isValid(): + return color, True + return None, False + + def _fromQPixmap(self, settings, name, value, pixmapFormat): + """helper to convert a QPixmap to a QVariant""" + if value is not None: + arr = QtCore.QByteArray() + p = QtCore.QBuffer(arr) + p.open(QtCore.QIODevice.WriteOnly) + value.save(p, pixmapFormat) + return QtCore.QVariant(arr), True + return None, False + + def _toPixmap(self, settings, name, v): + """helper to convert a QVariant to a QPixmap""" + if v.isValid(): + px = QtGui.QPixmap() + if px.loadFromData(v.toByteArray()): + return px, True + return None, False + + def toQPixmapBmp(self, settings, name, v): return self._toPixmap(settings, name, v) + def fromQPixmapBmp(self, settings, name, value): return self._fromPixmap(settings, name, value, 'BMP') + + def toQPixmapJpg(self, settings, name, v): return self._toPixmap(settings, name, v) + def fromQPixmapJpg(self, settings, name, value): return self._fromPixmap(settings, name, value, 'JPG') + + def toQPixmapPng(self, settings, name, v): return self._toPixmap(settings, name, v) + def fromQPixmapPng(self, settings, name, value): return self._fromPixmap(settings, name, value, 'PNG') + + def toQPixmapXbm(self, settings, name, v): return self._toPixmap(settings, name, v) + def fromQPixmapXbm(self, settings, name, value): return self._fromPixmap(settings, name, value, 'XBM') + + def toQPixmapXpm(self, settings, name, v): return self._toPixmap(settings, name, v) + def fromQPixmapXpm(self, settings, name, value): return self._fromPixmap(settings, name, value, 'XPM') + + \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jU...@us...> - 2008-07-11 16:33:46
|
Revision: 576 http://fclient.svn.sourceforge.net/fclient/?rev=576&view=rev Author: jUrner Date: 2008-07-11 09:33:56 -0700 (Fri, 11 Jul 2008) Log Message: ----------- deprecate settingsbase Modified Paths: -------------- trunk/fclient/src/fclient/lib/qt4ex/settingsbase.py Modified: trunk/fclient/src/fclient/lib/qt4ex/settingsbase.py =================================================================== --- trunk/fclient/src/fclient/lib/qt4ex/settingsbase.py 2008-07-11 16:33:36 UTC (rev 575) +++ trunk/fclient/src/fclient/lib/qt4ex/settingsbase.py 2008-07-11 16:33:56 UTC (rev 576) @@ -1,7 +1,10 @@ """Base class for settings to take awasy a bit of the hassle of working with QSettings """ - +import warnings +warnings.warn('deprecated module. use <settings> instead', DeprecationWarning) + + from PyQt4 import QtCore, QtGui __version__ = '0.0.2' @@ -22,25 +25,24 @@ ('MySettingsName2', ['ConvertValue', None]) ) - with the first member being the name of the setting, and the secon member + with the first member being the name of the setting, and the second member being a list[type, default-value]. The type is used to convert the settings value - to a desired type. It can be either a QVariant method (in wich case the type - conversion is handled automatically) or a user supplied method name to - call to do the type conversion. + to a desired type. It can be either a QVariant method (the type conversion is handled + automatically) or a user supplied method name to call to do the type conversion. If it is a user supplied method name, a method "toMethodName" will be called upon reading settings to convert a QVariant into the desired type and return its value, - and a method "fromMethodName" will be called to convert the value of the setting into + and a method "fromMethodName" will be called to convert the value of the setting into something that can be fed to a QVariant to store as setting while dumping settings. - Note that the "from" method may return None. In this case the return value is ignored, - else the return value will be stored in the instances settings. + Note that the "from" method may return None. In this case the return value is ignored. + any other return value will be stored in the instances settings. - Also note that the variant passed to the "to" method be None, so ckeck for it. + Also note that the variant passed to the "to" method may be None, so ckeck for it. The order in wich settings appear is always preserved. - Type can be None aswell, in wich case the setting will never get read or dumped to disk + Type can be None aswell. if so, the setting will never get read or dumped to or read from disk Sample: @@ -105,7 +107,7 @@ def __setitem__(self, settingsName, value): - """Sets the value of a setting""" + """Sets the value of a setting and marks it as dirty if the value has changed""" if value != self.settingsDict[settingsName][1]: self.setDirty(settingsName, True) self.settingsDict[settingsName][1] = value @@ -132,6 +134,34 @@ settings.endGroup() + def dumpNow(self, parent, settings, **values): + """Sets and emidiately dumps settings to the specified settings object + @arg parent: parent window + @arg settings: QSettings + @arg values: settingsName --> value pairs to dump + """ + settings.beginGroup(self.KEY_SETTINGS) + + for name, value in values.items(): + settingsType, value, isDirty = self.settingsDict[name] + if settingsType is None: + continue + + if not hasattr(QtCore.QVariant, settingsType): + value = getattr(self, 'from' + settingsType)(parent, settings, name, value) + if value == None: + continue + + + + settings.setValue(name, QtCore.QVariant(value) ) + + settings.endGroup() + + + + + def isDirty(self, settingsName): """Checks if a setting is dirty""" return self.settingsDict[settingsName][2] @@ -189,7 +219,12 @@ def setDirty(self, settingsName, flag): - """Marks a setting as dirty""" + """Marks a setting as dirty + @param settingsName: name of the setting to mark + @flag: (bool) + + @note: use this flag for whatever purpose you want + """ self.settingsDict[settingsName][2] = flag This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jU...@us...> - 2008-07-11 16:33:31
|
Revision: 575 http://fclient.svn.sourceforge.net/fclient/?rev=575&view=rev Author: jUrner Date: 2008-07-11 09:33:36 -0700 (Fri, 11 Jul 2008) Log Message: ----------- too many changes to list Modified Paths: -------------- trunk/fclient/src/fclient/Ui_ViewLogger.py Modified: trunk/fclient/src/fclient/Ui_ViewLogger.py =================================================================== --- trunk/fclient/src/fclient/Ui_ViewLogger.py 2008-07-11 16:33:29 UTC (rev 574) +++ trunk/fclient/src/fclient/Ui_ViewLogger.py 2008-07-11 16:33:36 UTC (rev 575) @@ -3,6 +3,9 @@ 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 QtGui @@ -14,21 +17,56 @@ #********************************************************************************** # #********************************************************************************** +class Settings(config.SettingsBase): + + _key_ = config.IdViewLoggerWidget + _settings_ = ( + ('MaxLines', 'UInt', 1000), + ) + #*********************************************************************** # #*********************************************************************** class ViewLoggerWidget(QtGui.QWidget, Ui_ViewLoggerWidget): - def __init__(self, parent, cfg=None): - QtGui.QWidget.__init__(self, parent) + IdEddLogger = 'edLogger' + + class MyLoggingHandler(logging.Handler): + def __init__(self, myLogf, *args, **kwargs): + logging.Handler.__init__(self, *args, **kwargs) + self.myLogf = myLogf - self.cfg = config.Config(self) if cfg is None else cfg + def emit(self, record): + self.myLogf( + '%s:%s:%s' % (record.levelname, record.name, record.getMessage()) + ) + + + def __init__(self, parent, cfg=None, level=logging.NOTSET): + QtGui.QWidget.__init__(self, parent) + self.settings = Settings() - self.setupUi(self) config.ObjectRegistry.register(self) - + + self.settings.restore() + ed = self.controlById(self.IdEddLogger) + ed.document().setMaximumBlockCount(self.settings.value('MaxLines')) + + self.loggingHandler = self.MyLoggingHandler(self.addMessage) + logging.getLogger('').addHandler(self.loggingHandler) + + + def controlById(self, idControl): + return getattr(self, idControl) + + def addMessage(self, text): + print text, type(text) + + ed = self.controlById(self.IdEddLogger) + ed.append(text) + #********************************************************************************** # #********************************************************************************** @@ -36,7 +74,7 @@ def __init__(self): self._widget = None - + def displayName(self): return QtGui.QApplication.translate("ViewLogger", "Logger", None, QtGui.QApplication.UnicodeUTF8) @@ -51,7 +89,9 @@ if self._widget is None: self._widget = ViewLoggerWidget(parent) return self._widget - + + def close(self): + pass #********************************************************************************** # This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jU...@us...> - 2008-07-11 16:33:20
|
Revision: 574 http://fclient.svn.sourceforge.net/fclient/?rev=574&view=rev Author: jUrner Date: 2008-07-11 09:33:29 -0700 (Fri, 11 Jul 2008) Log Message: ----------- too many changes to list Modified Paths: -------------- trunk/fclient/src/fclient/Ui_ViewConnection.py Modified: trunk/fclient/src/fclient/Ui_ViewConnection.py =================================================================== --- trunk/fclient/src/fclient/Ui_ViewConnection.py 2008-07-11 16:33:24 UTC (rev 573) +++ trunk/fclient/src/fclient/Ui_ViewConnection.py 2008-07-11 16:33:29 UTC (rev 574) @@ -10,20 +10,18 @@ from . import Ui_View from .lib import fcp2 -from .lib.qt4ex import settingsbase - from .tpls.Ui_ViewConnectionWidgetTpl import Ui_ViewConnectionWidget #********************************************************************************** # #********************************************************************************** -class UserSettings(settingsbase.SettingsBase): - - KEY_SETTINGS = 'UserSettingsConnection' - SETTINGS = [ - ('AutoConnect', ['toBool', False]), - ('ConnectionHost', ['toString', fcp2.Client.DefaultFcpHost]), - ('ConnectionPort', ['toUInt', fcp2.Client.DefaultFcpPort]), - ] +class Settings(config.SettingsBase): + _key_ = config.IdViewConnectionWidget + _settings_ = ( + ('AutoConnect', 'Bool', False), + ('ConnectionHost', 'String', fcp2.Client.DefaultFcpHost), + ('ConnectionName', 'String', ''), #TODO: we need a python ansi string + ('ConnectionPort', 'UInt', fcp2.Client.DefaultFcpPort), + ) #*********************************************************************** # @@ -39,16 +37,27 @@ QtGui.QWidget.__init__(self, parent) self._isCreated = False + self.settings = Settings() - - self.cfg = config.Config(self) if cfg is None else cfg - self.userSettings = UserSettings() - - self.setupUi(self) + + self.settings.restore() config.ObjectRegistry.register(self) + def controlById(self, idControl): + return getattr(self, idControl) + + + def retranslateUi(self, w): + Ui_ViewConnectionWidget.retranslateUi(self, w) + bt = self.controlById(self.IdBtConnect) + if bt.isChecked(): + bt.setText() + + ######################################### + ## events + ######################################### def showEvent(self, event): QtGui.QWidget.showEvent(self, event) if self._isCreated: @@ -63,39 +72,24 @@ # setup host / port boxes edHost = self.controlById(self.IdEdConnectionHost) - edHost.setText(self.userSettings['ConnectionHost']) + edHost.setText(self.settings.value('ConnectionHost')) spinPort = self.controlById(self.IdSpinConnectionPort) #TODO: no idea if port range (0, 0xFFFF) this is reasonable spinPort.setRange(0, 0xFFFF) - spinPort.setValue(self.userSettings['ConnectionPort']) + spinPort.setValue(self.settings.value('ConnectionPort')) # autoconnect if desired - self.cfg.settings.readSettings(self, self.userSettings) - if self.userSettings['AutoConnect']: + self.settings.restore() + if self.settings.value('AutoConnect'): self.controlById(self.IdBtConnect).setChecked(True) self.onBtConnectClicked(True) + #XXX + self.settings.setValues(ConnectionName='abc') - def controlById(self, idControl): - return getattr(self, idControl) - - - def retranslateUi(self, w): - Ui_ViewConnectionWidget.retranslateUi(self, w) - bt = self.controlById(self.IdBtConnect) - if bt.isChecked(): - bt.setText() - ######################################### - ## events - ######################################### - def closeEvent(self, event): - self.cfg.settings.dumpSettings(self, self.userSettings) - - - ######################################### ## ######################################### def onBtConnectClicked(self, checked): @@ -113,7 +107,7 @@ def __init__(self): self._widget = None - + def displayName(self): return QtGui.QApplication.translate("ViewConnectionWidget", "Connection", None, QtGui.QApplication.UnicodeUTF8) @@ -129,17 +123,18 @@ self._widget = ViewConnectionWidget(parent) return self._widget - + def close(self): + pass + #********************************************************************************** # #********************************************************************************** if __name__ == '__main__': import sys - app = QtGui.QApplication(sys.argv) - - from . import Ui_ViewLogger + app = QtGui.QApplication(sys.argv) + w = Ui_View.ViewWidget(None) w.addViews(True, ViewConnection()) w.addViews(False, Ui_ViewLogger.ViewLogger()) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jU...@us...> - 2008-07-11 16:33:15
|
Revision: 573 http://fclient.svn.sourceforge.net/fclient/?rev=573&view=rev Author: jUrner Date: 2008-07-11 09:33:24 -0700 (Fri, 11 Jul 2008) Log Message: ----------- too many changes to list Modified Paths: -------------- trunk/fclient/src/fclient/Ui_View.py Modified: trunk/fclient/src/fclient/Ui_View.py =================================================================== --- trunk/fclient/src/fclient/Ui_View.py 2008-07-11 16:32:57 UTC (rev 572) +++ trunk/fclient/src/fclient/Ui_View.py 2008-07-11 16:33:24 UTC (rev 573) @@ -1,4 +1,12 @@ - +#FIXES +#*************************************************************************** +# [0001] +# +# QTabWidget.closeEvent() does not seem to propagate close events +# to child widgets +# +# +#*************************************************************************** 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__)] @@ -9,17 +17,14 @@ from . import config from .lib import fcp2 -from .lib.qt4ex import settingsbase from .tpls.Ui_ViewWidgetTpl import Ui_ViewWidget - #********************************************************************************** # #********************************************************************************** -class UserSettings(settingsbase.SettingsBase): - - KEY_SETTINGS = 'UserSettingsView' - SETTINGS = [ - ] +class Settings(config.SettingsBase): + _key_ = config.IdViewWidget + _settings_ = ( + ) #*********************************************************************** # @@ -31,15 +36,15 @@ - def __init__(self, parent, cfg=None): + def __init__(self, parent): QtGui.QWidget.__init__(self, parent) - self.cfg = config.Config(self) if cfg is None else cfg - self.userSettings = UserSettings() + self.settings = Settings() self.views = {} self.setupUi(self) config.ObjectRegistry.register(self) + self.settings.restore() tabTop = self.controlById(self.IdTabTop) tabTop.removeTab(0) @@ -68,7 +73,10 @@ def setCurrentView(self, view): index, tab, view = view - + def closeEvent(self, event): + for i, tab, view in self.views.values(): + view.close() + #********************************************************************************** # #********************************************************************************** @@ -105,6 +113,9 @@ note: if the widget is not already created _now_ is the right time to create it """ raise NotImplemetedError() + + def close(self): + """called when the view is about to be closed""" #********************************************************************************** # This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jU...@us...> - 2008-07-11 16:32:50
|
Revision: 572 http://fclient.svn.sourceforge.net/fclient/?rev=572&view=rev Author: jUrner Date: 2008-07-11 09:32:57 -0700 (Fri, 11 Jul 2008) Log Message: ----------- too many changes to list Modified Paths: -------------- trunk/fclient/src/fclient/Ui_PrefsGlobal.py Modified: trunk/fclient/src/fclient/Ui_PrefsGlobal.py =================================================================== --- trunk/fclient/src/fclient/Ui_PrefsGlobal.py 2008-07-11 16:32:39 UTC (rev 571) +++ trunk/fclient/src/fclient/Ui_PrefsGlobal.py 2008-07-11 16:32:57 UTC (rev 572) @@ -15,14 +15,10 @@ #********************************************************************************** class PrefsGlobalWidget(QtGui.QWidget, Ui_PrefsGlobalWidget): - def __init__(self, parent, cfg=None): + def __init__(self, parent): QtGui.QWidget.__init__(self, parent) - - - self.cfg = config.Config(self) if cfg is None else cfg - - self.setupUi(self) + #*********************************************************************** # #*********************************************************************** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jU...@us...> - 2008-07-11 16:32:32
|
Revision: 571 http://fclient.svn.sourceforge.net/fclient/?rev=571&view=rev Author: jUrner Date: 2008-07-11 09:32:39 -0700 (Fri, 11 Jul 2008) Log Message: ----------- too many changes to list Modified Paths: -------------- trunk/fclient/src/fclient/config.py Modified: trunk/fclient/src/fclient/config.py =================================================================== --- trunk/fclient/src/fclient/config.py 2008-07-09 08:39:05 UTC (rev 570) +++ trunk/fclient/src/fclient/config.py 2008-07-11 16:32:39 UTC (rev 571) @@ -10,7 +10,7 @@ from PyQt4 import QtCore from .lib import fcp2 -from .lib.qt4ex import settingsbase +from .lib.qt4ex import settings #********************************************************************************** # #********************************************************************************** @@ -50,69 +50,42 @@ #********************************************************************************** # #********************************************************************************** -class ConfigSettings(settingsbase.SettingsBase): +class SettingsBase(settings.SettingsBase): + """application wide base class for settings""" - KEY_SETTINGS = 'ConfigSettings' - SETTINGS = [ - ('StoreSettingsLocally', ['UPyString', SettingsDir]), # if not None, settings are stored locally in the app folder - ] - - - -class Settings(settingsbase.Settings): - """customized settings class to allow to store settings locally""" + _config_settings_ = None - def __init__(self): - settingsbase.Settings.__init__(self, FclientOrgName, FclientAppName) - self.format = QtCore.QSettings.IniFormat - self.scope = QtCore.QSettings.UserScope - self.directory = None - - self.setStoreLocal(SettingsDir) - - - def setStoreLocal(self, directory=None): - """should the settings be stored locally? - - @param directory: (str) if None, the default location of the os is used to store settings, if a directory - setings are stored there - """ - if directory is None: - self.format = QtCore.QSettings.NativeFormat - self.scope = QtCore.QSettings.UserScope + #TODO: we have to notify all instances on changes. yuk + def settingsObject(self): + settingsDir = self._config_settings_.value('SettingsDir') + if settingsDir: + format = QtCore.QSettings.IniFormat + scope = QtCore.QSettings.UserScope + QtCore.QSettings.setPath(format, scope, settingsDir) else: - self.format = QtCore.QSettings.IniFormat - self.scope = QtCore.QSettings.UserScope - QtCore.QSettings.setPath(self.format, self.scope, directory) - self.directory = directory - - - def getObject(self, parent): - o = QtCore.QSettings(self.format, self.scope, self.orgName, self.appName, parent) - o.setFallbacksEnabled(False) - #print o.fileName() - return o + format = QtCore.QSettings.NativeFormat + scope = QtCore.QSettings.SystemScope + if self._config_settings_.value('SettingsAllUsers'): + scope = QtCore.QSettings.UserScope + settings = QtCore.QSettings(format, scope, FclientOrgName, FclientAppName, self.parent()) + settings.setFallbacksEnabled(False) + return settings + +class Settings(SettingsBase): + _key_ = 'ConfigSettings' + _settings_ = ( + ('SettingsDir', 'String', QtCore.QString(SettingsDir)), # if not None, settings are stored locally in the app folder + ('SettingsAllUsers', 'Bool', False), # store settings for all users? + ) + +SettingsBase._config_settings_ = Settings() #********************************************************************************** # #********************************************************************************** -class Config(object): - - def __init__(self, parent): - - self.fcpClient = fcp2.Client() # global fcp client - self.settings = Settings() # global settings class - self.configSettings = ConfigSettings() # settings of the config - - - self.settings.readSettings(None, self.configSettings) - self.settings.setStoreLocal(directory=self.configSettings['StoreSettingsLocally']) - - atexit.register(self.close) - - def close(self): - self.settings.dumpSettings(None, self.configSettings) - +fcpClient = fcp2.Client() # global fcp client +settings = Settings(None) # global settings class + #********************************************************************************** # #********************************************************************************** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jU...@us...> - 2008-07-09 08:38:57
|
Revision: 570 http://fclient.svn.sourceforge.net/fclient/?rev=570&view=rev Author: jUrner Date: 2008-07-09 01:39:05 -0700 (Wed, 09 Jul 2008) Log Message: ----------- dump settings on close Modified Paths: -------------- trunk/fclient/src/fclient/Ui_ViewConnection.py Modified: trunk/fclient/src/fclient/Ui_ViewConnection.py =================================================================== --- trunk/fclient/src/fclient/Ui_ViewConnection.py 2008-07-09 08:38:38 UTC (rev 569) +++ trunk/fclient/src/fclient/Ui_ViewConnection.py 2008-07-09 08:39:05 UTC (rev 570) @@ -89,14 +89,10 @@ bt.setText() ######################################### - ## view methods + ## events ######################################### - def displayName(self): - return QtGui.QApplication.translate("ViewConnectionWidget", "Connection", None, QtGui.QApplication.UnicodeUTF8) - - - def icon(self): - return QtGui.QIcon() + def closeEvent(self, event): + self.cfg.settings.dumpSettings(self, self.userSettings) ######################################### This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jU...@us...> - 2008-07-09 08:38:29
|
Revision: 569 http://fclient.svn.sourceforge.net/fclient/?rev=569&view=rev Author: jUrner Date: 2008-07-09 01:38:38 -0700 (Wed, 09 Jul 2008) Log Message: ----------- 'toUInt' was broken. fixed Modified Paths: -------------- trunk/fclient/src/fclient/lib/qt4ex/README trunk/fclient/src/fclient/lib/qt4ex/settingsbase.py Modified: trunk/fclient/src/fclient/lib/qt4ex/README =================================================================== --- trunk/fclient/src/fclient/lib/qt4ex/README 2008-07-08 18:00:50 UTC (rev 568) +++ trunk/fclient/src/fclient/lib/qt4ex/README 2008-07-09 08:38:38 UTC (rev 569) @@ -4,10 +4,21 @@ Version history: + ******************************************************************* 0.1.0 ******************************************************************* news: + x. + +bugfixes: + x. settingsbase/SettingsBase 'toUInt' did not work as expected. instead of an UInt a tuple(UInt, bool) was returned. fixed + + +******************************************************************* +0.1.0 +******************************************************************* +news: x. initial release bugfixes: Modified: trunk/fclient/src/fclient/lib/qt4ex/settingsbase.py =================================================================== --- trunk/fclient/src/fclient/lib/qt4ex/settingsbase.py 2008-07-08 18:00:50 UTC (rev 568) +++ trunk/fclient/src/fclient/lib/qt4ex/settingsbase.py 2008-07-09 08:38:38 UTC (rev 569) @@ -163,7 +163,7 @@ value = getattr(v, settingsType)() # TODO: more chekcs for valid types here - if settingsType == 'toInt': + if settingsType in ('toInt', 'toUInt'): value, ok = value if not ok: continue This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jU...@us...> - 2008-07-08 18:01:38
|
Revision: 568 http://fclient.svn.sourceforge.net/fclient/?rev=568&view=rev Author: jUrner Date: 2008-07-08 11:00:50 -0700 (Tue, 08 Jul 2008) Log Message: ----------- plugin views into the gui seems to work as expected Modified Paths: -------------- trunk/fclient/src/fclient/Ui_View.py trunk/fclient/src/fclient/Ui_ViewConnection.py trunk/fclient/src/fclient/Ui_ViewLogger.py Modified: trunk/fclient/src/fclient/Ui_View.py =================================================================== --- trunk/fclient/src/fclient/Ui_View.py 2008-07-08 16:52:34 UTC (rev 567) +++ trunk/fclient/src/fclient/Ui_View.py 2008-07-08 18:00:50 UTC (rev 568) @@ -52,14 +52,14 @@ return getattr(self, idControl) - def addViews(top=True, *views): - tab = self.controlById(self.IdTabTop) if top else self.controlById(self.IdTabBottom) + def addViews(self, toTop, *views): + tab = self.controlById(self.IdTabTop) if toTop 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) + ido = str(view.objectName()) + if ido in self.views: + raise ValueError('view is already present: %s' % ido) + i = tab.addTab(view.widget(tab), view.icon(), view.displayName()) + self.views[ido] = (i, tab, view) def viewFromUuid(self, uuid): @@ -72,27 +72,39 @@ #********************************************************************************** # #********************************************************************************** +#NOTE: to self. no need to register views to config.ObjectRegistry. they are just +# opaque objects private to ViewWidget class View(object): - """base class for views""" + """base class for views handled by L{ViewWidget}""" - UUID = '' - def __init__(self): - pass + raise NotImplemetedError() - def displayName(self): - return 'tab' + """should return the user visible name of the view + @return: (QString) + """ + raise NotImplemetedError() def icon(self): - pass - - def uuid(self): - return self.UUID - + """should return the icon associated to the view + @return: (QIcon) + """ + raise NotImplemetedError() + + def objectName(self): + """should return the internally used id of the view + @return: (str) id + """ + raise NotImplemetedError() + def widget(self, parent): - pass - + """should return the widget contained in the view + @param parent: (QWidget) parent + @return: (QWidget) + note: if the widget is not already created _now_ is the right time to create it + """ + raise NotImplemetedError() #********************************************************************************** # Modified: trunk/fclient/src/fclient/Ui_ViewConnection.py =================================================================== --- trunk/fclient/src/fclient/Ui_ViewConnection.py 2008-07-08 16:52:34 UTC (rev 567) +++ trunk/fclient/src/fclient/Ui_ViewConnection.py 2008-07-08 18:00:50 UTC (rev 568) @@ -7,10 +7,12 @@ from . import config +from . import Ui_View + from .lib import fcp2 from .lib.qt4ex import settingsbase + from .tpls.Ui_ViewConnectionWidgetTpl import Ui_ViewConnectionWidget - #********************************************************************************** # #********************************************************************************** @@ -75,9 +77,7 @@ self.controlById(self.IdBtConnect).setChecked(True) self.onBtConnectClicked(True) - - - + def controlById(self, idControl): return getattr(self, idControl) @@ -88,7 +88,17 @@ if bt.isChecked(): bt.setText() + ######################################### + ## view methods + ######################################### + def displayName(self): + return QtGui.QApplication.translate("ViewConnectionWidget", "Connection", None, QtGui.QApplication.UnicodeUTF8) + + def icon(self): + return QtGui.QIcon() + + ######################################### ## ######################################### @@ -103,11 +113,41 @@ #********************************************************************************** # #********************************************************************************** +class ViewConnection(Ui_View.View): + + def __init__(self): + self._widget = None + + def displayName(self): + return QtGui.QApplication.translate("ViewConnectionWidget", "Connection", None, QtGui.QApplication.UnicodeUTF8) + + def icon(self): + return QtGui.QIcon() + + def objectName(self): + return 'ViewConnection' + + + def widget(self, parent): + if self._widget is None: + self._widget = ViewConnectionWidget(parent) + return self._widget + + +#********************************************************************************** +# +#********************************************************************************** if __name__ == '__main__': import sys + app = QtGui.QApplication(sys.argv) - app = QtGui.QApplication(sys.argv) - w = ViewConnectionWidget(None) + + from . import Ui_ViewLogger + + w = Ui_View.ViewWidget(None) + w.addViews(True, ViewConnection()) + w.addViews(False, Ui_ViewLogger.ViewLogger()) + w.show() res = app.exec_() sys.exit(res) Modified: trunk/fclient/src/fclient/Ui_ViewLogger.py =================================================================== --- trunk/fclient/src/fclient/Ui_ViewLogger.py 2008-07-08 16:52:34 UTC (rev 567) +++ trunk/fclient/src/fclient/Ui_ViewLogger.py 2008-07-08 18:00:50 UTC (rev 568) @@ -8,6 +8,8 @@ from . import config +from . import Ui_View + from .tpls.Ui_ViewLoggerWidgetTpl import Ui_ViewLoggerWidget #********************************************************************************** # @@ -30,6 +32,30 @@ #********************************************************************************** # #********************************************************************************** +class ViewLogger(Ui_View.View): + + def __init__(self): + self._widget = None + + def displayName(self): + return QtGui.QApplication.translate("ViewLogger", "Logger", None, QtGui.QApplication.UnicodeUTF8) + + def icon(self): + return QtGui.QIcon() + + def objectName(self): + return 'ViewLogger' + + + def widget(self, parent): + if self._widget is None: + self._widget = ViewLoggerWidget(parent) + return self._widget + + +#********************************************************************************** +# +#********************************************************************************** if __name__ == '__main__': import sys This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jU...@us...> - 2008-07-08 16:53:28
|
Revision: 567 http://fclient.svn.sourceforge.net/fclient/?rev=567&view=rev Author: jUrner Date: 2008-07-08 09:52:34 -0700 (Tue, 08 Jul 2008) Log Message: ----------- clean up Modified Paths: -------------- trunk/fclient/src/fclient/config.py Modified: trunk/fclient/src/fclient/config.py =================================================================== --- trunk/fclient/src/fclient/config.py 2008-07-08 16:49:12 UTC (rev 566) +++ trunk/fclient/src/fclient/config.py 2008-07-08 16:52:34 UTC (rev 567) @@ -1,4 +1,5 @@ -"""""" +"""global application config +""" 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__)] @@ -17,7 +18,6 @@ FclientAppName = 'fclient' SettingsDir = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'settings') - #********************************************************************************** # looks like QObject.findChild() does not always work. docs mention troubles # with MSVC 6 where you should use qFindChild(). can not test this. so keep @@ -98,17 +98,13 @@ #********************************************************************************** class Config(object): - _UiObjRegistry = weakref.WeakValueDictionary() - - def __init__(self, parent): - - + self.fcpClient = fcp2.Client() # global fcp client self.settings = Settings() # global settings class self.configSettings = ConfigSettings() # settings of the config + - self.settings.readSettings(None, self.configSettings) self.settings.setStoreLocal(directory=self.configSettings['StoreSettingsLocally']) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jU...@us...> - 2008-07-08 16:50:08
|
Revision: 566 http://fclient.svn.sourceforge.net/fclient/?rev=566&view=rev Author: jUrner Date: 2008-07-08 09:49:12 -0700 (Tue, 08 Jul 2008) Log Message: ----------- experimental ..add a global object registry Modified Paths: -------------- trunk/fclient/src/fclient/Ui_View.py trunk/fclient/src/fclient/Ui_ViewConnection.py trunk/fclient/src/fclient/Ui_ViewLogger.py Modified: trunk/fclient/src/fclient/Ui_View.py =================================================================== --- trunk/fclient/src/fclient/Ui_View.py 2008-07-08 16:47:26 UTC (rev 565) +++ trunk/fclient/src/fclient/Ui_View.py 2008-07-08 16:49:12 UTC (rev 566) @@ -39,6 +39,7 @@ self.views = {} self.setupUi(self) + config.ObjectRegistry.register(self) tabTop = self.controlById(self.IdTabTop) tabTop.removeTab(0) Modified: trunk/fclient/src/fclient/Ui_ViewConnection.py =================================================================== --- trunk/fclient/src/fclient/Ui_ViewConnection.py 2008-07-08 16:47:26 UTC (rev 565) +++ trunk/fclient/src/fclient/Ui_ViewConnection.py 2008-07-08 16:49:12 UTC (rev 566) @@ -28,15 +28,11 @@ #*********************************************************************** class ViewConnectionWidget(QtGui.QWidget, Ui_ViewConnectionWidget): - UUID = '{2339cfb0-5e84-44eb-9c8d-00965b5bb460}' - - IdBtConnect = 'btConnect' IdEdConnectionHost = 'edConnectionHost' IdSpinConnectionPort = 'spinConnectionPort' - - + def __init__(self, parent, cfg=None): QtGui.QWidget.__init__(self, parent) @@ -46,7 +42,9 @@ self.cfg = config.Config(self) if cfg is None else cfg self.userSettings = UserSettings() + self.setupUi(self) + config.ObjectRegistry.register(self) def showEvent(self, event): @@ -100,10 +98,8 @@ bt.setText(QtGui.QApplication.translate("ViewConnectionWidget", "Disconnect", None, QtGui.QApplication.UnicodeUTF8)) else: bt.setText(QtGui.QApplication.translate("ViewConnectionWidget", "Connect", None, QtGui.QApplication.UnicodeUTF8)) - - - + #********************************************************************************** # #********************************************************************************** Modified: trunk/fclient/src/fclient/Ui_ViewLogger.py =================================================================== --- trunk/fclient/src/fclient/Ui_ViewLogger.py 2008-07-08 16:47:26 UTC (rev 565) +++ trunk/fclient/src/fclient/Ui_ViewLogger.py 2008-07-08 16:49:12 UTC (rev 566) @@ -25,6 +25,7 @@ self.setupUi(self) + config.ObjectRegistry.register(self) #********************************************************************************** # This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jU...@us...> - 2008-07-08 16:49:04
|
Revision: 565 http://fclient.svn.sourceforge.net/fclient/?rev=565&view=rev Author: jUrner Date: 2008-07-08 09:47:26 -0700 (Tue, 08 Jul 2008) Log Message: ----------- experimental ..add a global object registry Modified Paths: -------------- trunk/fclient/src/fclient/config.py Modified: trunk/fclient/src/fclient/config.py =================================================================== --- trunk/fclient/src/fclient/config.py 2008-07-08 15:58:43 UTC (rev 564) +++ trunk/fclient/src/fclient/config.py 2008-07-08 16:47:26 UTC (rev 565) @@ -5,6 +5,7 @@ import atexit import os +import weakref from PyQt4 import QtCore from .lib import fcp2 @@ -16,7 +17,37 @@ FclientAppName = 'fclient' SettingsDir = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'settings') + #********************************************************************************** +# looks like QObject.findChild() does not always work. docs mention troubles +# with MSVC 6 where you should use qFindChild(). can not test this. so keep +# a dict for lookups... +#********************************************************************************** +IdViewWidget = 'ViewWidget' +IdViewLoggerWidget = 'ViewLoggerWidget' +IdViewConnectionWidget = 'ViewConnectionWidget' + + +class ObjectRegistry(weakref.WeakValueDictionary): + """global object registry + + use the registry to register and retrieve ui objects previously registerd by their object ids (Id*). + ObjectRegistry is actually a WeakValueDictionary. so use as a dict + """ + + def register(self, obj): + """regisdters an object in the registry + @param obj: (QObject) object to register + @note: QObject.objectName() is taken as id. ids have to be unique throughout the runtime of the gui + """ + ido = str(obj.objectName()) + if ido in self: + raise ValueError('ui object already registered: %s' % ido) + self[ido] = obj + + +ObjectRegistry = ObjectRegistry() +#********************************************************************************** # #********************************************************************************** class ConfigSettings(settingsbase.SettingsBase): @@ -67,8 +98,12 @@ #********************************************************************************** class Config(object): + _UiObjRegistry = weakref.WeakValueDictionary() + + def __init__(self, parent): - + + self.fcpClient = fcp2.Client() # global fcp client self.settings = Settings() # global settings class self.configSettings = ConfigSettings() # settings of the config @@ -79,15 +114,12 @@ atexit.register(self.close) - def close(self): self.settings.dumpSettings(None, self.configSettings) - +#********************************************************************************** +# +#********************************************************************************** + - -s = Config(None) - - - This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jU...@us...> - 2008-07-08 15:59:19
|
Revision: 564 http://fclient.svn.sourceforge.net/fclient/?rev=564&view=rev Author: jUrner Date: 2008-07-08 08:58:43 -0700 (Tue, 08 Jul 2008) Log Message: ----------- ... Modified Paths: -------------- trunk/fclient/src/fclient/Ui_Prefs.py Modified: trunk/fclient/src/fclient/Ui_Prefs.py =================================================================== --- trunk/fclient/src/fclient/Ui_Prefs.py 2008-07-08 15:56:38 UTC (rev 563) +++ trunk/fclient/src/fclient/Ui_Prefs.py 2008-07-08 15:58:43 UTC (rev 564) @@ -39,7 +39,7 @@ #********************************************************************************** # #********************************************************************************** -class DlgPrefs(dlgpreferences.DlgPreferencesFlatTree): +class PrefsDlg(dlgpreferences.DlgPreferencesFlatTree): def __init__(self, parent): @@ -61,7 +61,7 @@ import sys app = QtGui.QApplication(sys.argv) - w = DlgPrefs(None) + w = PrefsDlg(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. |
From: <jU...@us...> - 2008-07-08 15:57:08
|
Revision: 563 http://fclient.svn.sourceforge.net/fclient/?rev=563&view=rev Author: jUrner Date: 2008-07-08 08:56:38 -0700 (Tue, 08 Jul 2008) Log Message: ----------- ... Modified Paths: -------------- trunk/fclient/src/fclient/Ui_View.py trunk/fclient/src/fclient/tpls/Ui_ViewWidgetTpl.py trunk/fclient/src/fclient/tpls/ViewWidgetTpl.ui Modified: trunk/fclient/src/fclient/Ui_View.py =================================================================== --- trunk/fclient/src/fclient/Ui_View.py 2008-07-08 15:54:29 UTC (rev 562) +++ trunk/fclient/src/fclient/Ui_View.py 2008-07-08 15:56:38 UTC (rev 563) @@ -10,7 +10,7 @@ from . import config from .lib import fcp2 from .lib.qt4ex import settingsbase -from .tpls.Ui_ViewTpl import Ui_ViewTpl +from .tpls.Ui_ViewWidgetTpl import Ui_ViewWidget #********************************************************************************** # @@ -24,7 +24,7 @@ #*********************************************************************** # #*********************************************************************** -class ViewWidget(QtGui.QWidget, Ui_ViewTpl): +class ViewWidget(QtGui.QWidget, Ui_ViewWidget): IdTabTop = 'tabTop' IdTabBottom = 'tabBottom' Modified: trunk/fclient/src/fclient/tpls/Ui_ViewWidgetTpl.py =================================================================== --- trunk/fclient/src/fclient/tpls/Ui_ViewWidgetTpl.py 2008-07-08 15:54:29 UTC (rev 562) +++ trunk/fclient/src/fclient/tpls/Ui_ViewWidgetTpl.py 2008-07-08 15:56:38 UTC (rev 563) @@ -1,25 +1,25 @@ # -*- coding: utf-8 -*- -# Form implementation generated from reading ui file '/home/me/src/proj/fclient/trunk/fclient/src/fclient/tpls/ViewTpl.ui' +# Form implementation generated from reading ui file '/home/me/src/proj/fclient/trunk/fclient/src/fclient/tpls/ViewWidgetTpl.ui' # -# Created: Tue Jul 8 12:13:15 2008 +# Created: Tue Jul 8 17:55:38 2008 # by: PyQt4 UI code generator 4.3.3 # # WARNING! All changes made in this file will be lost! from PyQt4 import QtCore, QtGui -class Ui_ViewTpl(object): - def setupUi(self, ViewTpl): - ViewTpl.setObjectName("ViewTpl") - ViewTpl.resize(QtCore.QSize(QtCore.QRect(0,0,530,629).size()).expandedTo(ViewTpl.minimumSizeHint())) +class Ui_ViewWidget(object): + def setupUi(self, ViewWidget): + ViewWidget.setObjectName("ViewWidget") + ViewWidget.resize(QtCore.QSize(QtCore.QRect(0,0,530,629).size()).expandedTo(ViewWidget.minimumSizeHint())) - self.gridlayout = QtGui.QGridLayout(ViewTpl) + self.gridlayout = QtGui.QGridLayout(ViewWidget) self.gridlayout.setMargin(0) self.gridlayout.setSpacing(0) self.gridlayout.setObjectName("gridlayout") - self.splitter = QtGui.QSplitter(ViewTpl) + self.splitter = QtGui.QSplitter(ViewWidget) self.splitter.setOrientation(QtCore.Qt.Vertical) self.splitter.setObjectName("splitter") @@ -62,23 +62,23 @@ self.gridlayout2.addWidget(self.tabBottom,0,0,1,1) self.gridlayout.addWidget(self.splitter,0,0,1,1) - self.retranslateUi(ViewTpl) + self.retranslateUi(ViewWidget) self.tabTop.setCurrentIndex(0) self.tabBottom.setCurrentIndex(0) - QtCore.QMetaObject.connectSlotsByName(ViewTpl) + QtCore.QMetaObject.connectSlotsByName(ViewWidget) - def retranslateUi(self, ViewTpl): - ViewTpl.setWindowTitle(QtGui.QApplication.translate("ViewTpl", "Form", None, QtGui.QApplication.UnicodeUTF8)) - self.tabTop.setTabText(self.tabTop.indexOf(self.tab_3), QtGui.QApplication.translate("ViewTpl", "Tab 1", None, QtGui.QApplication.UnicodeUTF8)) - self.tabBottom.setTabText(self.tabBottom.indexOf(self.tab_5), QtGui.QApplication.translate("ViewTpl", "Tab 1", None, QtGui.QApplication.UnicodeUTF8)) + def retranslateUi(self, ViewWidget): + ViewWidget.setWindowTitle(QtGui.QApplication.translate("ViewWidget", "Form", None, QtGui.QApplication.UnicodeUTF8)) + self.tabTop.setTabText(self.tabTop.indexOf(self.tab_3), QtGui.QApplication.translate("ViewWidget", "Tab 1", None, QtGui.QApplication.UnicodeUTF8)) + self.tabBottom.setTabText(self.tabBottom.indexOf(self.tab_5), QtGui.QApplication.translate("ViewWidget", "Tab 1", None, QtGui.QApplication.UnicodeUTF8)) if __name__ == "__main__": import sys app = QtGui.QApplication(sys.argv) - ViewTpl = QtGui.QWidget() - ui = Ui_ViewTpl() - ui.setupUi(ViewTpl) - ViewTpl.show() + ViewWidget = QtGui.QWidget() + ui = Ui_ViewWidget() + ui.setupUi(ViewWidget) + ViewWidget.show() sys.exit(app.exec_()) Modified: trunk/fclient/src/fclient/tpls/ViewWidgetTpl.ui =================================================================== --- trunk/fclient/src/fclient/tpls/ViewWidgetTpl.ui 2008-07-08 15:54:29 UTC (rev 562) +++ trunk/fclient/src/fclient/tpls/ViewWidgetTpl.ui 2008-07-08 15:56:38 UTC (rev 563) @@ -1,6 +1,6 @@ <ui version="4.0" > - <class>ViewTpl</class> - <widget class="QWidget" name="ViewTpl" > + <class>ViewWidget</class> + <widget class="QWidget" name="ViewWidget" > <property name="geometry" > <rect> <x>0</x> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |