def __init__(self, iface, dialog_ui, bbox_tool): """ Constructor for the dialog tool :param iface: The QGIS Interface :param dialog_ui: The dialog GUI :param bbox_tool The bounding box tool :return: dialog tool """ QObject.__init__(self, None) self.iface = iface self.dialog_ui = dialog_ui self.bbox_tool = bbox_tool self.progress_bar = None self.progress_message_bar = None self.progress_message_bar_widget = None self.search_thread_pool = QThreadPool() self.search_lock = Lock() self.export_thread_pool = QThreadPool() self.export_lock = Lock() self.query = None self.previous_credentials = None self.export_file = None self.footprint_layer = None self.filters = CatalogFilters(self.dialog_ui) self.dialog_ui.aoi_button.clicked.connect(self.aoi_button_clicked) self.dialog_ui.reset_button.clicked.connect(self.reset_button_clicked) self.dialog_ui.export_button.clicked.connect( self.export_button_clicked) self.bbox_tool.released.connect(self.search) self.model = None
def __init__(self, parent=None): QObject.__init__(self, parent) self.process = QProcess() self.process.setProcessChannelMode(QProcess.MergedChannels) self.process.finished.connect(self.emit_finished) self.process.stateChanged.connect(self.emit_state) self.process_type = 0 # 0 process, 1 runnable self.threadpool = QThreadPool() self.worker = Worker() self.worker.signals.state.connect(self.emit_state) self.queue = None
def __init__(self, left, top, right, bottom, csv_filename, username, password, client_id, client_secret, days_to_query=60): self.left = left self.top = top self.right = right self.bottom = bottom self.csv_filename = csv_filename self.days_to_query = days_to_query self.begin_date = None self.end_date = None self.username = username self.password = password self.client_id = client_id self.client_secret = client_secret # throw up a progress dialog min_progress = 0.0 max_progress = ((self.right - self.left) / INCREMENTAL_INTERVAL) * \ ((self.top - self.bottom) / INCREMENTAL_INTERVAL) self.current_progress = min_progress self.progress_dialog = QProgressDialog("Building up CSV file", "Abort", int(min_progress), int(max_progress), None) self.progress_dialog.setCancelButton(None) self.progress_dialog.setWindowTitle("CSV Output") self.progress_dialog.setLabelText("Building up CSV file") self.progress_dialog.setMinimumDuration(0) self.progress_dialog.setValue(0) self.progress_dialog.show() self.csv_elements = [] self.csv_generator_object = CSVGeneratorObject(self) self.vector_header_dict = {} self.pool = QThreadPool() self.finished_submissions = False self.lock = Lock()
def start(self): self.idmap = {} self.entries = [] pool = QThreadPool() pool.setMaxThreadCount(1) for label in LABELS: feed = Feed(label, self) pool.start(feed) imap = Imap(label, self) pool.start(imap) pool.waitForDone() self.done.emit()
def __init__(self, iface, db, validation_dia, plugin_dir, params): self.iface = iface self.db = db self.params = params self.validation_dia = validation_dia self.app_root = plugin_dir self.open_image = QPixmap(os.path.join(self.app_root, "image", "folder_open_icon.png")) self.validation_dia.ui.openPushButton.setIcon(QIcon(self.open_image)) self.validation_dia.ui.openPushButton.setToolTip("Select File") self.export_globals = None self.validation_dk = None self.report_to_dialog = None self.re = QRegExp("CheckBox") self.check_boxes_names = [] self.long_task = QThreadPool(None).globalInstance() self.summary_tables = {} self.model_navigation() self.form_load() self.file_dialog = QFileDialog() self.summary_functions = {} self.report_file_path = None self.home_dir = os.path.expanduser('~') self.org_name = database.get_from_gaz_metadata(db, "owner") self.report = ExportValidationReport("roadNet Validation Report", self.org_name, self.db, self.iface, None) self.list_check_boxes = [] self.progress_win = QProgressDialog("", None, 0, 100, self.validation_dia) self.progress_win.setFixedSize(380, 100) self.progress_win.setModal(True) self.progress_win.setWindowTitle("Export Validation Report") self.summary_runnables = {'dupStreetCheckBox': [lambda: DupStreetDesc(), 0], 'notStreetEsuCheckBox': [lambda: StreetsNoEsuDesc(), 1], 'notType3CheckBox': [lambda: Type3Desc(False), 2], 'incFootPathCheckBox': [lambda: Type3Desc(True), 2], 'dupEsuRefCheckBox': [lambda: DupEsuRef(True), 3], 'notEsuStreetCheckBox': [lambda: NoLinkEsuStreets(), 4], 'invCrossRefCheckBox': [lambda: InvalidCrossReferences()], 'startEndCheckBox': [lambda: CheckStartEnd(), 8], 'tinyEsuCheckBox': [lambda: CheckTinyEsus("esu", 1)], 'notMaintReinsCheckBox': [lambda: CheckMaintReins()], 'asdStartEndCheckBox': [lambda: CheckAsdCoords()], 'notMaintPolysCheckBox': [lambda: MaintNoPoly(), 16], 'notPolysMaintCheckBox': [lambda: PolyNoMaint()], 'tinyPolysCheckBox': [lambda: CheckTinyEsus("rd_poly", 1)]}
def __init__(self, # A number *n* to create a pool of *n* simple threads, where each thread # lacks an event loop, so that it can emit but not receive signals. # This means that ``g`` may **not** be run in a thread of this pool, # without manually adding a event loop. If *n* < 1, the global thread pool # is used. maxThreadCount, # |parent| parent=None): super(AsyncPoolController, self).__init__(parent) if maxThreadCount < 1: self.threadPool = QThreadPool.globalInstance() else: self.threadPool = QThreadPool() self.threadPool.setMaxThreadCount(maxThreadCount)
def __init__(self, iface, parent=None): """Constructor.""" super(GridZoneGeneratorDialog, self).__init__(parent) # Set up the user interface from Designer. # After setupUI you can access any designer object by doing # self.<objectname>, and you can use autoconnect slots - see # http://qt-project.org/doc/qt-4.8/designer-using-a-ui-file.html # #widgets-and-dialogs-with-auto-connect self.setupUi(self) self.iface = iface self.crsLineEdit.setReadOnly(True) self.utmgrid = UtmGrid() self.setValidCharacters() self.setMask() self.threadpool = QThreadPool()
def start_testing(self): """Tests all servers by using various thread workers (QRunnables) in a thread pool. This way testing is done asynchronously, since some servers may take some time to answer, so the UI is not blocked until the process is done and we can show a progress bar. See: https://martinfitzpatrick.name/article/multithreading-pyqt-applications-with-qthreadpool/ https://nikolak.com/pyqt-threading-tutorial/ """ # A thread pool is a thread automatically hadling various tasks. self.threadpool = QThreadPool() self._n_tested = 0 for data in self.servers_to_test: worker = CLineTestWorker(*data) # When each worker is done, `end_testing` is called. worker.signals.finished.connect(self.end_testing) # Executing the thread worker within the pool. self.threadpool.start(worker)
def __init__(self, width, height, *args, **kwargs): super(PyQtPaint, self).__init__(*args, **kwargs) uic.loadUi('../ui/pyqtpaint.ui', self) self._paint_view = PaintView() self._paint_view.setRenderHints(QtGui.QPainter.HighQualityAntialiasing) self.paint_scene = PaintScene(0, 0, width, height, None) self._paint_view.setScene(self.paint_scene) # Numbers of layers self.num_layers = 0 self.old_layers = -1 # Timer to save images self.timer = QTimer() self.timer.setInterval(1000) self.timer.start() # Path to save imgs self.tmpFilepath = "../img/tmp/tmp.png" # Timer to predict shapes self.timer_predict = QTimer() self.timer_predict.setInterval(1000) self.timer_predict.start() # The app is not working on predict shapes self.working = False # Thread to run in background of paint self.threadpool = QThreadPool() # Setup all UI, and make the connctions between Signals & Slots self._setup_ui() self._create_actions() self._make_connections()
def __init__(self, font, parent=None): super(MainWindow, self).__init__(parent) self.font = font self.setWindowTitle("Meridien") central_widget = QtGui.QWidget(self) self.setCentralWidget(central_widget) #Center on screen resolution = QtGui.QDesktopWidget().screenGeometry() self.move((resolution.width() / 2) - (self.frameSize().width() / 2), (resolution.height() / 2) - (self.frameSize().height() / 2)) """ Setting up menu bar """ close_action = QtGui.QAction('Close', self) close_action.setShortcut("Ctrl+Q") close_action.setStatusTip('Leave the app') close_action.triggered.connect(lambda: self.close()) open_refinement_folder = QtGui.QAction('Open Refinement Folder', self) open_refinement_folder.triggered.connect(self.open_refinement_folder) self.mainMenu = self.menuBar() self.fileMenu = self.mainMenu.addMenu('&File') self.fileMenu.addAction(open_refinement_folder) self.fileMenu.addAction(close_action) self.refinement_folder = "" create_new_fsc_plot = QtGui.QAction('&New FSC plot', self) create_new_fsc_plot.triggered.connect( self.event_ontriggered_show_fsc_plot) create_new_overview_plot = QtGui.QAction( '&New resolution overview plot', self) create_new_overview_plot.triggered.connect( self.event_show_resolution_overview_plot) self.plotMenu = self.mainMenu.addMenu('&Plot') self.plotMenu.addAction(create_new_fsc_plot) self.plotMenu.addAction(create_new_overview_plot) """ Setup other components """ self.layout = QGridLayout(central_widget) self.setMenuBar(self.mainMenu) self.tree = QTreeWidget(self) self.tree.setHeaderHidden(True) self.layout.addWidget(self.tree, 1, 0) self.root_items_path_dictionary = {} # Threads self.threadpool = QThreadPool() self.thread_list = [] thr = QThread(self) thr.start() self.reader = DriverFileReader() self.reader.moveToThread(thr) self.thread_list.append(thr) self.timer = QTimer(self) # Connect signals self.reader.sig_sendfolders.connect(self.fill_tree) self.reader.sig_sendfsc.connect(self.show_dialog_fsc) self.tree.itemChanged.connect(self._event_select_deselect_all) self.sig_update_tree.connect(self.update_tree) self.sig_show_overview_plot.connect( self.event_show_resolution_overview_plot) self.show() self.open_refinement_folder() self.monitor = None
def __init__(self, parent=None, signalManager=None, name="Databases update", domains=None): OWWidget.__init__(self, parent, signalManager, name, wantMainArea=False) self.searchString = "" self.accessCode = "" self.domains = domains or DOMAINS self.serverFiles = serverfiles.ServerFiles() fbox = gui.widgetBox(self.controlArea, "Filter") self.completer = TokenListCompleter( self, caseSensitivity=Qt.CaseInsensitive) self.lineEditFilter = QLineEdit(textChanged=self.SearchUpdate) self.lineEditFilter.setCompleter(self.completer) fbox.layout().addWidget(self.lineEditFilter) box = gui.widgetBox(self.controlArea, "Files") self.filesView = QTreeWidget(self) self.filesView.setHeaderLabels( ["", "Data Source", "Update", "Last Updated", "Size"]) self.filesView.setRootIsDecorated(False) self.filesView.setUniformRowHeights(True) self.filesView.setSelectionMode(QAbstractItemView.NoSelection) self.filesView.setSortingEnabled(True) self.filesView.sortItems(1, Qt.AscendingOrder) self.filesView.setItemDelegateForColumn( 0, UpdateOptionsItemDelegate(self.filesView)) self.filesView.model().layoutChanged.connect(self.SearchUpdate) box.layout().addWidget(self.filesView) box = gui.widgetBox(self.controlArea, orientation="horizontal") self.updateButton = gui.button( box, self, "Update all", callback=self.UpdateAll, tooltip="Update all updatable files", ) self.downloadButton = gui.button( box, self, "Download all", callback=self.DownloadFiltered, tooltip="Download all filtered files shown" ) self.cancelButton = gui.button( box, self, "Cancel", callback=self.Cancel, tooltip="Cancel scheduled downloads/updates." ) self.retryButton = gui.button( box, self, "Reconnect", callback=self.RetrieveFilesList ) self.retryButton.hide() gui.rubber(box) gui.lineEdit(box, self, "accessCode", "Access Code", orientation="horizontal", callback=self.RetrieveFilesList) self.warning(0) box = gui.widgetBox(self.controlArea, orientation="horizontal") gui.rubber(box) self.infoLabel = QLabel() self.infoLabel.setAlignment(Qt.AlignCenter) self.controlArea.layout().addWidget(self.infoLabel) self.infoLabel.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed) self.updateItems = [] self.resize(800, 600) self.progress = ProgressState(self, maximum=3) self.progress.valueChanged.connect(self._updateProgress) self.progress.rangeChanged.connect(self._updateProgress) self.executor = ThreadExecutor( threadPool=QThreadPool(maxThreadCount=2) ) task = Task(self, function=self.RetrieveFilesList) task.exceptionReady.connect(self.HandleError) task.start() self._tasks = [] self._haveProgress = False
def __init__(self): self.thread_pool = None self._listener = {} self._worker = {} self.thread_pool = QThreadPool()
def __init__(self, parent=None): super().__init__(parent) # GUI box = gui.widgetBox(self.controlArea, "Info", addSpace=True) self.infoBox = gui.widgetLabel(box, "No data on input.") box = gui.widgetBox(self.controlArea, "Split by", addSpace=True) self.groupCombo = gui.comboBox(box, self, "selectedGroup", callback=self.onGroupSelection) gui.comboBox(self.controlArea, self, "selectedCenterMethod", box="Center Fold-change Using", items=[name for name, _ in self.CENTER_METHODS], callback=self.onCenterMethodChange, addSpace=True) gui.comboBox(self.controlArea, self, "selectedMergeMethod", box="Merge Replicates", items=[name for name, _ in self.MERGE_METHODS], tooltip="Select the method for replicate merging", callback=self.onMergeMethodChange, addSpace=True) box = gui.doubleSpin(self.controlArea, self, "zCutoff", 0.0, 3.0, 0.01, box="Z-Score Cutoff", callback=[self.replotMA, self.commitIf]) gui.separator(self.controlArea) box = gui.widgetBox(self.controlArea, "Ouput") gui.checkBox(box, self, "appendZScore", "Append Z-Scores", tooltip="Append calculated Z-Scores to output", callback=self.commitIf) gui.checkBox(box, self, "appendRIValues", "Append Log Ratio and Intensity values", tooltip="Append calculated Log Ratio and Intensity " "values to output data", callback=self.commitIf) gui.rubber(self.controlArea) gui.auto_commit(self.controlArea, self, "autoCommit", "Commit") self.graph = pg.PlotWidget(background="w") self.graph.getAxis("bottom").setLabel( "Intensity: log<sub>10</sub>(R*G)") self.graph.getAxis("left").setLabel("Log ratio: log<sub>2</sub>(R/G)") self.mainArea.layout().addWidget(self.graph) self.groups = [] self.split_data = None, None self.merged_splits = None, None self.centered = None, None self.changedFlag = False self.data = None self._executor = concurrent.ThreadExecutor(threadPool=QThreadPool( maxThreadCount=1))
def __init__(self, parent=None): super().__init__(parent) self.selectedDatabase = 0 self.uniqueRows = True gui.button(gui.widgetBox(self.controlArea, "Cache", addSpace=True), self, "Clear cache", tooltip="Clear saved query results", callback=self.clearCache) self.martsCombo = gui.comboBox( self.controlArea, self, "selectedDatabase", "Database", callback=self.setSelectedMart, addSpace=True) self.martsCombo.setMaximumWidth(250) self.datasetsCombo = gui.comboBox( self.controlArea, self, "selectedDataset", "Dataset", callback=self.setSelectedDataset, addSpace=True) self.datasetsCombo.setMaximumWidth(250) gui.rubber(self.controlArea) box = gui.widgetBox(self.controlArea, "Results") gui.checkBox( box, self, "uniqueRows", "Unique results only", tooltip="Return unique results only.",) self.commitButton = gui.button( box, self, "Get Results", callback=self.commit, tooltip="Query the BioMart server and output the results", autoDefault=True) self.commitButton.setEnabled(False) self.mainWidget = gui.widgetBox( self.mainArea, orientation=QStackedLayout()) self.mainTab = QTabWidget() self.mainWidget.layout().addWidget(self.mainTab) self.attributesConfigurationBox = gui.createTabPage(self.mainTab, "Attributes") if self.SHOW_FILTERS: # ?? self.filtersConfigurationBox = gui.createTabPage(self.mainTab, "Filters") self.error(0) self.setEnabled(False) self._executor = concurrent.ThreadExecutor( threadPool=QThreadPool(maxThreadCount=2) ) self._task = task = concurrent.Task(function=self._get_registry) task.resultReady.connect(self.setBioMartRegistry) task.exceptionReady.connect(self._handleException) self._executor.submit(task) self._afterInitQueue = [] try: from Bio import SeqIO self.hasBiopython = True except ImportError: self.warning(100, "Biopython package not found.\nTo retrieve FASTA sequence data from BioMart install Biopython.") self.hasBiopython = False