def test_manager(self): source = QObject() target = QObject() manager = BindingManager(submitPolicy=BindingManager.ManualSubmit) manager.bind((target, "target"), None).to((source, "source")) tbind = DynamicPropertyBinding(target, "target_copy") sbind = DynamicPropertyBinding(source, "source") schanged = [] sbind.changed[object].connect(schanged.append) manager.bind(tbind, None).to(sbind) source.setProperty("source", 1) self.assertEqual(len(schanged), 1) self.assertEqual(toPyObject(target.property("target")), None) manager.commit() self.assertEqual(toPyObject(target.property("target")), 1) self.assertEqual(toPyObject(target.property("target_copy")), 1) source.setProperty("source", 2) manager.setSubmitPolicy(BindingManager.AutoSubmit) self.assertEqual(toPyObject(target.property("target")), 2) self.assertEqual(toPyObject(target.property("target_copy")), 2)
def _about(self): trans = QObject() QMessageBox.about( None, trans.tr("Acerca de BrainApp"), trans. tr('<table>' '<tr>' '<td colspan=2 style="color:darkblue;font-size:20pt;font-weight:bold"> BrainApp</td>' '</tr>' '<tr>' '<td style="font-weight:bold">Versión:</td>' '<td style="color:red;">0.1</td>' '</tr>' '<tr>' '<td style="font-weight:bold;text-align:right">Autor:</td>' '<td>Alvaro Javier Fuentes Suárez</td>' '</tr>' '<tr>' '<td></td>' '<td style="color:darkgreen;">CIMCNI-UCLV</td>' '</tr>' '<tr>' '<td></td>' '<td><b>2012</b></td>' '</tr>' '<table>'))
def buildProgressText(self): text = "" if self.progressStatus == STATUS_MIRROR: text = QObject().tr("Mirroring wallet %1").arg(self.progressId) elif self.progressStatus == STATUS_SYNC: text = QObject().tr("Synchronizing wallet %1").arg(self.progressId) elif self.progressStatus == STATUS_IMPORTS: text = QObject().tr("Checking imports for wallet %1").arg( self.progressId) dotCount = self.counter % 5 self.counter += 1 dots = '.' * dotCount text += dots self.emit(SIGNAL('UpdateTextStatus'), text)
def test_expr(self): obj1 = QObject() obj1.setProperty("value", 1) obj1.setProperty("other", 2) result = DynamicPropertyBinding(obj1, "result") result.bindTo( PropertyBindingExpr( "value + other", locals={"value": binding_for(obj1, "value"), "other": binding_for(obj1, "other")} ) ) expr = PropertyBindingExpr( "True if value < 3 else False", dict(value=DynamicPropertyBinding(obj1, "result")) ) result_values = [] result.changed[object].connect(result_values.append) expr_values = [] expr.changed[object].connect(expr_values.append) self.assertEqual(result.get(), 3) self.assertEqual(expr.get(), False) obj1.setProperty("value", 0) self.assertEqual(result_values[-1], 2) self.assertEqual(expr_values[-1], True) self.assertEqual(result.get(), 2) self.assertEqual(expr.get(), True)
def __init__(self, sock, addr, mysql): QtCore.QThread.__init__(self) self.qtobj = QObject() self.name = "tcplink" self.sock = sock self.addr = addr self.mysql = mysql
def create_widget(self): """ Create the toolkit widget for the proxy object. This method is called during the top-down pass, just before the 'init_widget()' method is called. This method should create the toolkit widget and assign it to the 'widget' attribute. """ self.widget = QObject(self.parent_widget())
def openFile(): transObj = QObject() fName = QFileDialog.getOpenFileName( None, transObj.tr("Open media file"), home, transObj. tr("Media Files (*.mp4 *.avi *.mp3 *.wav *.ogg *.flv *.ogv *.m4v *.m4a *.aac *.flac *.webm *.mpg *.mpeg *.wmv *.wma *.mp2 *.mov *.oga *.aif *.aiff *.aifc *.ape *.mka *.asf *.3gp *.dv *.m2t *.mts *.ts *.divx *.nsv *.ogm)" )) if fName.isEmpty() == False: rootObject.sourceFilename(fName)
def __init__(self): ##@var _widget # Widget de la ventana principal self._widget = MainWindowWidget() ##@var _ui # Referecia a la interfaz de la vantana principal @see @ref MainWindow::_widget self._ui = self._widget.ui ui = self._ui ##@var _planes # Visualización inicial de la imagen según los tres planos del cuerpo self._planes = ThreePlanesVisualization(ui.threePlanes) ##@var _processed_planes # Visualización de la imagen procesada self._processed_planes = ThreePlanesVisualization(ui.threePlanesResult) #conección de señales de Qt ui.useImage.clicked.connect(self._update_image) ui.processImage.clicked.connect(self._processImage) ui.actionCargar_imagen.triggered.connect(self._load_image) ui.actionCargar_serie.triggered.connect(self._load_series) ui.actionGuardar.triggered.connect(self._save_image) ui.actionGuardar_2.triggered.connect(self._save_configuration) ui.actionCargar_configuraci_n.triggered.connect( self._load_configuration) ui.imagesList.itemSelectionChanged.connect(self._update_use_button) ui.actionAcerca_de.triggered.connect(self._about) ui.propertiesTree.itemChanged.connect(self._update_current_image_name) ##@var _images_ui_syncronyzer # Sincronizador de las propiedades de los filros self._images_ui_synchronizer = ImageUiSync(ui.propertiesTree, ui.imagesList) ##@var _filters_ui_synchronizer # Sincronizador de las propiedades de las imágenes self._filters_ui_synchronizer = FiltersUiSync(ui.filtersTree) ##@var _segmentation_data # Muestra la información de la segmentación self._segmentation_data = SegmentationData() self._widget.addDockWidget(Qt.TopDockWidgetArea, self._segmentation_data._widget) self._segmentation_data._widget.setFloating(True) icon = QIcon() icon.addPixmap(QPixmap(":/icons/seleccion/show_data.png"), QIcon.Normal, QIcon.Off) self._segmentation_data._widget.setWindowIcon(icon) self._segmentation_data._widget.toggleViewAction().trigger() action = self._segmentation_data._widget.toggleViewAction() action.setShortcut(QKeySequence(Qt.CTRL + Qt.Key_D)) action.setIcon(icon) trans = QObject() action.setToolTip(trans.tr("Datos de la segmentación")) action.setIconText(trans.tr("Datos de la segmentación")) action.setStatusTip( trans.tr("Mostrar/Ocultar los datos de la segmentación.")) ui.menuVer.addAction(action) ui.toolBar.addAction(action) ui.actionAyuda_de_BrainApp.triggered.connect(self._help)
def __init__(self, text=None, critical=False): super().__init__() self.obj = QObject() if text is None: text = self.obj.tr("Unknown generic Exception.") # Kurze Benachrichtigung der Ausnahme self.text = text self.critical = critical
def __init__(self, name, linestyle="-", marker="", color=(0.0, 0.0, 0.0), alpha=0.75, zorder=1, picker=None, visible=True): self._name = name self._linestyle = linestyle self._marker = marker self._color = color self._alpha = alpha self._is_visible = visible self._z_order = zorder self._picker = picker self.signal_handler = QObject()
def warning(parent, text): """ Standardisierte Dialogbox für die Mitteilung einer Warnung an den Benutzer. Eine Warnung wird auch auf der kommandozeile ausgegeben, wenn "verbose" aktiviert ist. """ if GlobalState.is_verbose: Shell.print_warning(text) obj = QObject() QMessageBox.warning(parent, obj.tr("Warning"), str(text))
def __init__(self, parent=None): QtCore.QThread.__init__(self) self.qtobj = QObject() self.mysql = ConMysql() self.mysql.setting('localhost', 'root', '443622796', 3306, 'utf8') self.mysql.open() self.mysql.start() self.s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) #self.s.bind(('192.168.1.107', 8899)) self.s.bind(('192.168.0.199', 8899)) #self.s.bind((socket.gethostbyname(socket.gethostname()), 8899)) self.s.listen(5)
def __init__(self): threading.Thread.__init__(self) self.qobj = QObject() self.avrdude = const.avrdude self.avrdude_conf = const.avrconf self.mcu = 'atmega328p' self.speed = "115200" self.protocol = "arduino" self.comport = "COM3" self.flash_bin = '' self.__buildUploadCmd()
def test_dyn(self): obj = QObject() changed = [] binding = DynamicPropertyBinding(obj, "test") binding.changed[object].connect(changed.append) self.assertIs(binding.get(), None) obj.setProperty("test", 1) self.assertEqual(binding.get(), 1) self.assertEqual(len(changed), 1) self.assertEqual(changed[-1], 1) binding.set(2) self.assertEqual(binding.get(), 2) self.assertEqual(len(changed), 2) self.assertEqual(changed[-1], 2) target = QObject() binding1 = DynamicPropertyBinding(target, "prop") binding1.bindTo(binding) self.assertEqual(binding1.get(), binding.get()) self.assertEqual(target.property("prop"), 2) binding.set("a string") self.assertEqual(binding1.get(), "a string") self.assertEqual(binding1.get(), binding.get()) self.assertEqual(target.property("prop"), "a string") binding1.unbind() binding.set(1) self.assertEqual(binding1.get(), "a string") self.assertEqual(target.property("prop"), "a string") self.assertEqual(binding.get(), 1) self.assertEqual(obj.property("test"), 1)
def walletComputation(\ self, mirrorList, syncList, importList, reportTextProgress): #mirror missing wallets for wltID in mirrorList: reportTextProgress(QObject().tr("Mirroring wallet %1").arg(wltID)) wlt = self.main.walletMap[wltID] rootEntry = wlt.addrMap['ROOT'] self.main.walletManager.duplicateWOWallet(\ rootEntry.binPublicKey65, rootEntry.chaincode,\ wlt.lastComputedChainIndex + 1) #synchronize wallets for wltID in syncList: reportTextProgress( QObject().tr("Synchronizing wallet %1").arg(wltID)) wlt = self.main.walletMap[wltID] self.main.walletManager.synchronizeWallet( wltID, wlt.lastComputedChainIndex) for wltID in importList: reportTextProgress( QObject().tr("Checking imports for wallet %1").arg(wltID)) wlt = self.main.walletMap[wltID] for importId in wlt.importList: scrAddr = wlt.linearAddr160List[importId] addrObj = wlt.addrMap[scrAddr] self.main.walletManager.setImport(\ wltID, importId, addrObj.getPubKey()) reportTextProgress('shutdown')
def error(parent, text, critical=False): """ Standardisierte Dialogbox für die Mitteilung eines Fehlers an den Benutzer. Ein Fehler wird auch auf der kommandozeile ausgegeben, wenn "verbose" aktiviert ist. \param critical=True macht daraus einen kritischen Fehler, bei welchem das Programm beendet werden muß. """ if GlobalState.is_verbose: Shell.print_error(text, critical=critical) obj = QObject() headline = obj.tr("Error") if critical: headline = obj.tr("Critical Error") QMessageBox.critical(parent, headline, str(text))
# -*- coding: utf-8 -*- ''' Created on 2015年2月24日 @author: kay ''' from PyQt4.QtCore import QObject, SIGNAL #global qtob #def printf_init(): qtob = QObject() def sprint(data): qtob.emit(SIGNAL("sprintf"), qtob.tr(data))
# -*- coding: utf-8 -*- # Creation of a PDF tree from gedcom and options import os.path from reportlab.lib.units import mm from reportlab.lib.pagesizes import A4 from lab.abstractLab import * from PyQt4.QtCore import QSettings, QObject, QString qo = QObject() tr = qo.tr class Tree: def __init__(self, gedcom): self.gedcom = gedcom self.options = QSettings("A3X", "pySequoia") self.max_generations = self.options.value("max_generations").toInt()[0] self.notes = [] self.counter = 0 def setProgressDialog(self, dialog): """Gives a ProgressDialog for displaying progression""" self.progressDialog = dialog def setProgression(self, progress): if hasattr(self, 'progressDialog'): self.progressDialog.setValue(progress)
import libSALOME_Swig sg = libSALOME_Swig.SALOMEGUI_Swig() #------------------------------------------------------------------------------- # Application modules #------------------------------------------------------------------------------- #------------------------------------------------------------------------------- # Global variables #------------------------------------------------------------------------------- CFD_Saturne = "Code_Saturne" CFD_Neptune = "NEPTUNE_CFD" # ObjectTR is a convenient object for traduction purpose ObjectTR = QObject() # Main variable for solver _CFD_Code = None #By default # True or false for log tracing _Trace = False #True # If True all stdout redirected to MassageWindow _LogModeOn = True #---Enumerations--- #Event type for indicate of case in process CaseInProcessStart = -1000 CaseInProcessEnd = -1001 UpdateScriptFolder = -1002
# it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License along # with this program; if not, write to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. from PyQt4.QtCore import (QObject) translator = QObject() class Writer(object): """ Generic base class for web map writers. Writers generate the HTML, JavaScript and collect other assets required for creation of a standalone web map. """ def __init__(self): self.written_files = [] self.preview_file = None # layer groups self.groups = {} # list of layers to write self.layers = []
# -*- coding: utf-8 -*- from PyQt4.QtCore import QObject, pyqtSignal, Qt, QUrl, QString, QTimer, SIGNAL, QSize from PyQt4.QtGui import QWidget, QSizePolicy, QFont, QLabel, QHBoxLayout, QSpacerItem, QVBoxLayout, QSpinBox, QLineEdit, \ QApplication from PyQt4.QtDeclarative import QDeclarativeView, QDeclarativeProperty, QDeclarativeItem import os import logging logger = logging.getLogger(__name__) try: from lib import global_vars except ImportError, e: logger.warn("Could not import global_vars: {}".format(e)) global_vars = QObject() global_vars.configuration = { "GENERAL": { "sleeptimerdigitalspinbox": False } } #use spinner #global_vars.configuration = {"GENERAL": {"sleeptimerdigitalspinbox":True}} #use spinbox cwd = os.path.dirname( os.path.realpath(__file__)) # gives the path, where the script is located class SleepTimer(QWidget): ''' A resizable Widget with two Spinboxes Labeled with "h" and "min", also a Time-bomb containing a countdownclock. If a spinbox is changed, start is triggered. After 2 Seconds, countdown is startet.
def __init__(self): threading.Thread.__init__(self) # self.setDaemon(True) self.qtobj = QObject() self.__terminate = False
def __init__(self): super(PythonTestRunner, self).__init__() self.settings = QSettings("Honeywell", "PythonTestRunner") if not self.settings.value("geometry") == None: self.restoreGeometry(self.settings.value("geometry")) if not self.settings.value("windowState") == None: self.restoreState(self.settings.value("windowState")) self.setupUi(self) #this creates the actual window' self.treeWidget.header().setResizeMode(0, QHeaderView.Stretch) self.testRunList = OrderedDict({}) self.registry = Reg_Access() self.about = AboutWindow.AboutWindow() self.testTimeRemaining = 0 #total time in seconds that the test has remaining self.totalTestTime = 0 #total time in seconds that the current test run has been going for self.HOUR = 0 #timer hour value self.MINUTE = 0 #timer minute value self.SECOND = 0 #time second value self.timeLabel = QLabel(None) self.statusbar.addPermanentWidget( self.timeLabel) #creates the bottom right timer display self.timeLabel.setText("Time Remaining: 00:00:00") self.timeNegative = False #the floor operation for the clock breaks on negative values, so I have it do abs math with a negative sign added. Negative state is tracked by this value. self.testingStarted = False #this value enables/disables the timer ticks. self.log_window = None #empty variable so I can enable access to the console log methods once it's instantiated later. self.expansionLock = False #if set, will disable the treeWidget from expanding when a selection is made, this maintains the expansion state when check states are changed self.testCount = 0 #Tracks the total number of tests loaded. self.selTestCount = 0 #tracks the total number of tests selected by the user. self.testsDoneCount = 0 #tracks the tests that have been finished in a particular run self.testsNotRunCount = 0 #tracks the tests not run. self.warningCount = 0 #tracks the number of warnings across all tests self.errorCount = 0 #tracks the total error count across all tests self.failureCount = 0 #tracks the total failure count across all tests. self.totalTimeSelected = 0 #sum of the total time in minutes that the selected tests report from their docstring. self.no_feature = None self.alt_window = None self.currentTestDir = "C:\\" #the default start point for the test folder, used when the registry hasn't been setup yet. self.sortToggle = True #Toggle value to tell the sort by name function which way to sort. #self.optionWindow = ConLogOption(self) self.icon = IconCollection.Icons() self.log_window = Console_Log.ConsoleLog(self) self.folderList = [] self.folderLevelNodes = [] self.initMainFolder() self.testResultList = OrderedDict({}) self.debug_test_list = [] self.rerunList = [] self.loopTestResults = OrderedDict({}) #self.thread_1 = None self.qt_object = QObject() self.stopTests = False self.loopTest = Loop_Test.Loop_Test() self.root = self.addNode(self.treeWidget, self.icon.getIcon(5), "Generic", "", False, True) self.treeWidget.itemChanged.connect(self.handleItemChanged) self.treeWidget.itemSelectionChanged.connect(self.showToolTip) self.alt_window = AdvancedLoadTests.AdvancedTestLoader(self) #QObject.connect(self.qt_object, SIGNAL("done"), self.rerunTests) self.mainFolderEdit.returnPressed.connect(self.useExistingFolder) #Database Information Objects #shouldn't need any of this to operate database now... #Menu Buttons #File Menu self.actionSave_Selected_Test.triggered.connect(self.saveSelectedTests) self.actionSave_Un_selected_Test.triggered.connect(self.noFeature) self.actionSave_Selected_Suite_Time.triggered.connect(self.noFeature) self.actionLoad_Test_List_To_Select.triggered.connect(self.noFeature) self.actionLoad_Test_List_to_Un_select.triggered.connect( self.noFeature) self.actionOpen_Test_Session.triggered.connect(self.noFeature) self.actionSave_Test_Session.triggered.connect(self.noFeature) #View Menu self.actionConsole_Log.triggered.connect(self.showConsoleLog) self.actionShow_Loop_Tests.triggered.connect(self.showLoopTestWindow) #Advanced Menu self.actionAdvanced_Load_Tests.triggered.connect( self.advancedTestLoader) self.actionSave_De_selected_Tests.triggered.connect(self.noFeature) self.actionDatabase_Override_Info.triggered.connect( self.noFeature) #self.overrideDatabaseWindow) #Help Menu self.actionHelp_Topics.triggered.connect(self.noFeature) self.actionAbout.triggered.connect(self.aboutWindow) #Window Buttons self.runBtn.clicked.connect(self.runBtnSwitch) self.folderBtn.clicked.connect(self.getFolder) #Right Click Context Menu #To add further right click menu options: In Qt Designer, View > Action Editor, click Add Action and set the name of the action self.treeWidget.addAction(self.actionSort_By_Suite_Name) self.treeWidget.addAction(self.actionSort_By_Time_Ascending) self.treeWidget.addAction(self.actionSort_By_Time_Descending) self.treeWidget.addAction(self.actionClose_All) self.treeWidget.addAction(self.actionExpand_All) self.treeWidget.addAction(self.actionUnselect_All) self.actionSort_By_Suite_Name.triggered.connect(self.sortByName) self.actionSort_By_Time_Ascending.triggered.connect(self.sortTimeAsc) self.actionSort_By_Time_Descending.triggered.connect(self.sortTimeDesc) self.actionClose_All.triggered.connect(self.closeAll) self.actionExpand_All.triggered.connect(self.expandAll) self.actionUnselect_All.triggered.connect(self.uncheckAll) #End Menu Buttons #Create the testing thread and connect it's signals. self.TestRunner = TestRunnerModule.TestInterface(self) #self.testing_thread = QThread() #self.TestRunner.moveToThread(self.testing_thread) self.TestRunner.start() self.TestRunner.endSignal.connect(self.endTestRun) self.TestRunner.resultSignal.connect(self.parseResults) QObject.connect(self.qt_object, SIGNAL("start"), self.TestRunner.startTests) self.commandLineCall()
def saveFile(filename): transObj = QObject() fName = QFileDialog.getSaveFileName(None, transObj.tr("Save media file"), filename, "") if fName.isEmpty() == False: rootObject.targetFilename(fName)
def emitter(ob): if ob not in _emitterCache: _emitterCache[ob] = QObject() return _emitterCache[ob]
def __init__(self, name, **kw): print "nexusDoor.__init__()", name self.call__init__(taurus.core.tango.sardana.macroserver.BaseDoor, name, **kw) ## Nexus scan directory self.scandir = "" ## Nexus file name self.filename = "" ## serial number self.serialno = 0 ## start position self.start = 0 ## stop position self.stop = 100 ## number of points self.np = 100 ## device aliases self.deviceAliases = {} ## cut device aliases self.cutDeviceAliases = {} ## dictionary with names to replace self.toReplace = {} ## configuration server self.cnfServer = None ## Nexus writer self.nexusWriter = None ## writing status self.writing = False ## signal emitter if PYQT: self.emitter = QObject() else: self.emitter = None ## component selection mode self.__ccmode = 'SARDANA_MODE' env = self.getEnvironment() if not env.has_key('NexusWriterDevice'): ## Nexus writer device name self.device = 'haso228k.desy.de:10000/p09/tdw/r228' self.setEnvironment('NexusWriterDevice', self.device) else: ## Nexus writer device name self.device = self.getEnvironment('NexusWriterDevice') if not env.has_key('ScanFinished'): self.setEnvironment('ScanFinished', 'True') env = self.getEnvironment() if not env.has_key('ConfigurationServerDevice'): ## configuration server device name self.cnfdevice = 'haso228k.desy.de:10000/p09/mcs/r228' self.setEnvironment('ConfigurationServerDevice', self.cnfdevice) else: ## configuration server device name self.cnfdevice = self.getEnvironment('ConfigurationServerDevice')
def __init__(self, parent=None, typeName=None, param=None): ''' NO DOCUMENTATION ''' QWidget.__init__(self, parent) self.o = QObject() self.param = param self.type = typeName
class SubmissionError(WebServiceError): def __init__(self, msg, code=0): WebServiceError.__init__(self, msg) self.code = code cparser = PuddleConfig() COVERDIR = cparser.get('tagsources', 'coverdir', join(CONFIGDIR, 'covers')) COVER_PATTERN = u'%artist% - %album%' SAVECOVERS = False mapping = {} status_obj = QObject() useragent = "puddletag/" + puddlestuff.version_string def get_encoding(page, decode=False, default=None): encoding = None match = re.search('<\?xml(.+)\?>', page) if match: enc = re.search('''encoding(?:\s*)=(?:\s*)["'](.+?)['"]''', match.group(), re.I) if enc: encoding = enc.groups()[0] if not encoding: parser = MetaProcessor() try:
def applyClicked(self): self.applyProperties(QObject().sender())
def __init__(self): threading.Thread.__init__(self) self.qtobj = QObject() self.__terminate = False