当前位置: 首页>>代码示例>>Python>>正文


Python MessageBox.warning方法代码示例

本文整理汇总了Python中opus_gui.main.controllers.dialogs.message_box.MessageBox.warning方法的典型用法代码示例。如果您正苦于以下问题:Python MessageBox.warning方法的具体用法?Python MessageBox.warning怎么用?Python MessageBox.warning使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在opus_gui.main.controllers.dialogs.message_box.MessageBox的用法示例。


在下文中一共展示了MessageBox.warning方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: init_for_variable

# 需要导入模块: from opus_gui.main.controllers.dialogs.message_box import MessageBox [as 别名]
# 或者: from opus_gui.main.controllers.dialogs.message_box.MessageBox import warning [as 别名]
    def init_for_variable(self, variable, validator, existing_variables):
        ''' Prepare the editor to edit a variable.
        @param variable The variable to edit (dict)
        @param validator A VariableValidator object used for data/syntax checking
        @param existing_variables a list of tuples with (dataset, variable name) for all existing
                                  variables. Used for checking for unique names.
        '''
        self.original_variable = variable # keep a reference to the original node...
        self.variable = variable.copy() # ...but manipulate a temporary variable
        self.validator = validator
        self.existing_variables = existing_variables or []

        self.leVarName.setText(variable['name'])
        self.le_var_def.document().setPlainText(variable['definition'])
        index = self.cboVarType.findText(variable['source'])
        if index < 0: # variable source was not in the combo box
            text = 'Failed to edit variable %s' % variable['name']
            details = ('Variable "%s" (dataset: %s) has an unknown type value (%s).\n'
                       'Please select a new type and update/save the variable.' %
                       (variable['name'], variable['dataset'], variable['source']))
            MessageBox.warning(self, text, details)
            
        # This triggers _update_variable_from_fields and hence requires
        # name and definition to be set already
        self.cboVarType.setCurrentIndex(index)

        if variable['use'] == 'model variable':
            self.rbUseModel.setChecked(True)
        elif variable['use'] == 'indicator':
            self.rbUseIndicator.setChecked(True)
        else:
            self.rbUseBoth.setChecked(True)
        self.leVarName.selectAll()
        self.leVarName.setFocus()
开发者ID:apdjustino,项目名称:DRCOG_Urbansim,代码行数:36,代码来源:variable_editor_savez.py

示例2: _scanForRuns

# 需要导入模块: from opus_gui.main.controllers.dialogs.message_box import MessageBox [as 别名]
# 或者: from opus_gui.main.controllers.dialogs.message_box.MessageBox import warning [as 别名]
 def _scanForRuns(self):
     data_path = self.project.data_path()
     if not os.path.exists(data_path):
         MessageBox.warning(mainwindow = self.base_widget,
                            text="Project data path %s doesn't exist. " % data_path + \
                            "Simulation runs in the Results tab cannot be updated." )
         return
     
     run_manager = get_run_manager()
     run_manager.clean_runs()
     self._sync_base_year_data(run_manager)        
     run_manager.close()
     
     added_runs, removed_runs = sync_available_runs(self.project)
     added_msg = removed_msg = None
     if len(added_runs) > 0:
         added_msg = ('The following simulation runs have been '
                      'automatically added to the results manager:\n\n%s'
                      % '\n'.join(added_runs))
     if len(removed_runs) > 0:
         removed_msg = ('The following simulation runs have been '
                      'automatically removed from the results manager:\n\n%s'
                      % '\n'.join(removed_runs))
     if added_msg or removed_msg:
         ## The idea is to leave the run information to services db & cache, and
         ## we don't need to save the newly added runs, once we set the temporary
         # self.project.dirty = True
         text = 'The list of simulation runs has been automatically updated.'
         detailed_text = '%s\n%s' % (added_msg or '', removed_msg or '')
         logger.log_status(text+'\n'+detailed_text)
开发者ID:apdjustino,项目名称:DRCOG_Urbansim,代码行数:32,代码来源:results_manager.py

示例3: runErrorFromThread

# 需要导入模块: from opus_gui.main.controllers.dialogs.message_box import MessageBox [as 别名]
# 或者: from opus_gui.main.controllers.dialogs.message_box.MessageBox import warning [as 别名]
 def runErrorFromThread(self,errorMessage):
     self.running = False
     self.paused = False
     self.pbnStartModel.setText(QString("Start Simulation Run..."))
     MessageBox.warning(mainwindow = self.mainwindow,
                       text = "There was a problem running the simulation.",
                       detailed_text = errorMessage)
开发者ID:christianurich,项目名称:VIBe2UrbanSim,代码行数:9,代码来源:simulation_gui_element.py

示例4: delete_run

# 需要导入模块: from opus_gui.main.controllers.dialogs.message_box import MessageBox [as 别名]
# 或者: from opus_gui.main.controllers.dialogs.message_box.MessageBox import warning [as 别名]
 def delete_run(self, run_node, force=False):
     '''
     Remove a run both from the services database and from the model.
     @param run_node (Element): the node to remove.
     '''
     # Prevent the user from removing base years
     cache_directory = run_node.find('cache_directory').text
     if cache_directory.endswith('base_year_data') and not force:
         msg = ('Removing the base year data directory is restricted from '
                'within OpusGUI since doing so will make it impossible to '
                'run any simulations or estimations.')
         MessageBox.warning(mainwindow = self.view,
                            text = 'Cannot remove base year data',
                            detailed_text  = msg)
         return
     try:
         run_manager = get_run_manager()
         run_id = run_node.get('run_id')
         try:
             run_id = int(run_id)
         except:
             run_id = -1
         run_manager.delete_everything_for_this_run(run_id, cache_directory)
         run_manager.close()
         self.project.delete_node(run_node)
         # self.model.remove_node(run_node)
     except Exception, ex: # TODO catch more specific error?
         MessageBox.warning(self.view, 'Could not remove run', str(ex))
开发者ID:christianurich,项目名称:VIBe2UrbanSim,代码行数:30,代码来源:xml_controller_results.py

示例5: on_buttonBox_accepted

# 需要导入模块: from opus_gui.main.controllers.dialogs.message_box import MessageBox [as 别名]
# 或者: from opus_gui.main.controllers.dialogs.message_box.MessageBox import warning [as 别名]
    def on_buttonBox_accepted(self):
        viz_params = self._get_viz_spec()

        if viz_params is None:
            self.close()
            return

        dataset_name = viz_params['dataset_name']
        viz_type = viz_params['visualization_type']

        close = True
        if (viz_type == 'mapnik_map' or viz_type == 'mapnik_animated_map') and dataset_name not in self.spatial_datasets:
            MessageBox.warning(mainwindow = self.mainwindow,
                      text = "That indicator cannot be visualized as a map.",
                      detailed_text = ('The dataset %s is either not spatial or cannot be '
                                       'rendered as a grid. If the latter, please try '
                                       'exporting to an external GIS tool.'%dataset_name))
            close = False

        else:
            self._update_xml_from_dict(self.base_node, viz_params)
            update_batch_indicator_visualization(self.base_node)

        if close:
            self.close()
开发者ID:christianurich,项目名称:VIBe2UrbanSim,代码行数:27,代码来源:configure_existing_batch_indicator_visualization.py

示例6: import_run

# 需要导入模块: from opus_gui.main.controllers.dialogs.message_box import MessageBox [as 别名]
# 或者: from opus_gui.main.controllers.dialogs.message_box.MessageBox import warning [as 别名]
 def import_run(self, cache_directory, run_info={}):
     run_manager = get_run_manager()
     retval, retmsg = run_manager.import_run_from_cache(cache_directory)
     if not retval:
         MessageBox.warning(mainwindow = self.base_widget,
                            text = retmsg,
                            detailed_text = '')
     else:
         sync_available_runs(self.project)
开发者ID:apdjustino,项目名称:DRCOG_Urbansim,代码行数:11,代码来源:results_manager.py

示例7: on_buttonBox_accepted

# 需要导入模块: from opus_gui.main.controllers.dialogs.message_box import MessageBox [as 别名]
# 或者: from opus_gui.main.controllers.dialogs.message_box.MessageBox import warning [as 别名]
 def on_buttonBox_accepted(self):
     path = str(self.lePath.text())
     if not os.path.exists(path):
         msg = 'Cannot import run from %s: path does not exist' % path
         logger.log_warning(msg)
         MessageBox.warning(mainwindow = self,
                         text = msg,
                         detailed_text = '')
     else:
         self.resultManagerBase.import_run(path)
     self.close()
开发者ID:apdjustino,项目名称:DRCOG_Urbansim,代码行数:13,代码来源:import_run_dialog.py

示例8: on_buttonBox_accepted

# 需要导入模块: from opus_gui.main.controllers.dialogs.message_box import MessageBox [as 别名]
# 或者: from opus_gui.main.controllers.dialogs.message_box.MessageBox import warning [as 别名]
    def on_buttonBox_accepted(self):
        path = str(self.lePath.text())
        if not os.path.exists(path):
            msg = 'Cannot import, %s does not exist' % path
            logger.log_warning(msg)
            MessageBox.warning(mainwindow = self,
                            text = msg,
                            detailed_text = '')
        else:
            cache_directory = path
            years = []

            for dir in os.listdir(cache_directory):
                if len(dir) == 4 and dir.isdigit():
                    years.append(int(dir))
            if years == []:
                msg = 'Cannot import, %s has no run data'%path
                logger.log_warning(msg)
                MessageBox.warning(mainwindow = self,
                                text = msg,
                                detailed_text = '')

            else:
                start_year = min(years)
                end_year = max(years)
                project_name = os.environ['OPUSPROJECTNAME']
                run_name = os.path.basename(path)

                server_config = ServicesDatabaseConfiguration()
                run_manager = RunManager(server_config)

                run_id = run_manager._get_new_run_id()
                resources = {
                     'cache_directory': cache_directory,
                     'description': '',
                     'years': (start_year, end_year),
                     'project_name': project_name
                }

                try:
                    run_manager.add_row_to_history(run_id = run_id,
                                                   resources = resources,
                                                   status = 'done',
                                                   run_name = run_name)
                    update_available_runs(self.project)
                    logger.log_status('Added run %s of project %s to run_activity table'%(run_name, project_name))
                except:
                    errorInfo = formatExceptionInfo()
                    logger.log_error(errorInfo)
                    MessageBox.error(mainwindow = self,
                                    text = 'Could not add run %s of project %s to run_activity table'%(run_name, project_name),
                                    detailed_text = errorInfo)
        self.close()
开发者ID:christianurich,项目名称:VIBe2UrbanSim,代码行数:55,代码来源:import_run_dialog.py

示例9: on_indicatorBox

# 需要导入模块: from opus_gui.main.controllers.dialogs.message_box import MessageBox [as 别名]
# 或者: from opus_gui.main.controllers.dialogs.message_box.MessageBox import warning [as 别名]
    def on_indicatorBox(self):
        indicator_name = str(self.diagnostic_indicator_name.currentText())
        dataset_name = self.diagnostic_dataset_name.currentText()
        indicator_type = str(self.diagnostic_indicator_type.currentText())
        year = str(self.diagnostic_year.currentText())
        if year == "":
            return
        year = int(year)

        if dataset_name not in self.spatial_datasets and indicator_type == "map":
            MessageBox.warning(
                mainwindow=self.mainwindow,
                text="That indicator cannot be visualized as a map.",
                detailed_text=(
                    "The dataset %s is either not spatial or cannot be "
                    "rendered as a grid. If the latter, please try "
                    "exporting to an external GIS tool." % dataset_name
                ),
            )
            return

        cache_directory = self.model.config["cache_directory"]
        params = {"indicators": [indicator_name]}
        if indicator_type == "table":
            indicator_type = "tab"
            params["output_type"] = "tab"
        # JLM > commented this out for when implemented animations
        #        else:
        #            indicator_type = 'mapnik_map'

        visualizations = [(indicator_type, str(dataset_name), params)]

        self.batch_processor = BatchProcessor(self.project)

        self.batch_processor.guiElement = self

        self.batch_processor.set_data(
            visualizations=visualizations,
            source_data_name=self.model.run_name,
            years=[year, year],
            cache_directory=cache_directory,
        )

        self.diagnosticThread = OpusGuiThread(
            parentThread=self.mainwindow, parentGuiElement=self, thread_object=self.batch_processor
        )

        # Use this signal from the thread if it is capable of producing its own status signal
        QObject.connect(self.diagnosticThread, SIGNAL("runFinished(PyQt_PyObject)"), self.visualizationsCreated)
        QObject.connect(self.diagnosticThread, SIGNAL("runError(PyQt_PyObject)"), self.runErrorFromThread)

        self.diagnosticThread.start()
开发者ID:apdjustino,项目名称:DRCOG_Urbansim,代码行数:54,代码来源:simulation_gui_element.py

示例10: load_table

# 需要导入模块: from opus_gui.main.controllers.dialogs.message_box import MessageBox [as 别名]
# 或者: from opus_gui.main.controllers.dialogs.message_box.MessageBox import warning [as 别名]
    def load_table(self, visualization, limit = 10000):

        storage = StorageFactory().get_storage(
                       type = '%s_storage'%visualization.output_type,
                       storage_location = visualization.storage_location)
        table_data = storage.load_table(
                                table_name = visualization.table_name)

        try:
            primary_keys = visualization.indicators[0].primary_keys
        except:
            primary_keys = []

        keys = primary_keys + [key for key in table_data.keys()
                                   if key not in primary_keys]
        num_rows = min(len(table_data[keys[0]]), limit)
        num_cols = len(keys)

        self.tableWidget.clear()
        self.tableWidget.setColumnCount(num_cols)
        self.tableWidget.setRowCount(num_rows)

        j = 0
        for key in keys:
            col = QTableWidgetItem()
            col.setText(QString(key))
            self.tableWidget.setHorizontalHeaderItem(j,col)
            j += 1

        self.tableWidget.resizeColumnsToContents()

        order = sorted(enumerate(table_data[keys[0]]), lambda (i,v),(j,v2): int(v*100)-int(v2*100))

        for i, (idx,v) in enumerate(order):
            row = QTableWidgetItem()
            self.tableWidget.setVerticalHeaderItem(i,row)
            j = 0
            for key in keys:
                item = QTableWidgetItem()
                item.setText(QString(str(table_data[key][idx])))
                self.tableWidget.setItem(i,j,item)
                j += 1
            if i > limit:
                msg = 'The table %s has been truncated to %i rows because of memory limitations.'%(visualization.table_name,limit)
                detailed_msg = '<qt>To view the full results, open the following file:<br><br><small>%s</small></qt>'%visualization.get_file_path()
                MessageBox.warning(mainwindow = self,
                                  text = msg,
                                  detailed_text = detailed_msg)
                break
开发者ID:christianurich,项目名称:VIBe2UrbanSim,代码行数:51,代码来源:view_table_form.py

示例11: _validate_names

# 需要导入模块: from opus_gui.main.controllers.dialogs.message_box import MessageBox [as 别名]
# 或者: from opus_gui.main.controllers.dialogs.message_box.MessageBox import warning [as 别名]
    def _validate_names(self, show_error_message = False):
        ''' go through all nest and equation names and ensure that there are no collisions.
        Returns True if all the names are valid and False otherwise.
        If @param show_error_message is True an error message of the name errors is displayed.'''
        # Check for colliding names among the nest and equations
        colliding_names = set()
        nodes_to_inspect = self.submodel_node.findall('.//nest')
        nodes_to_inspect.extend(self.submodel_node.findall('.//equation'))
        for inspected_node in nodes_to_inspect:
            # get all sibling names with the same tag
            sibling_names = [node.get('name') for node in inspected_node.getparent() if
                             node is not inspected_node and node.tag == inspected_node.tag]
            # if there is a name collision, add the name to the set of found colliding names
            if inspected_node.get('name') in sibling_names:
                parent_node = inspected_node.getparent()
                if parent_node.tag == 'nest':
                    desc = '&lt;%s&gt;/%s' % (parent_node.get('name'), inspected_node.get('name'))
                else:
                    desc = '%s' % inspected_node.get('name')
                colliding_names.add(desc)

        # the concept of colliding names might be confusing so we want to be clear on what is
        # happening and (more importantly) how to solve it
        if colliding_names:
            if not show_error_message:
                return False
            str_collide_list = ''.join(['<li>%s</li>\n' % name for name in colliding_names])
            short_msg = 'Name collisions found.'
            longer_msg = ''' <qt> Colliding names:
            <b> <ul> %s </ul> </b>
            <p>A name collision is when there are two items with the same name, the same type and the same level.</p>
            For example:
            <ul>
                <li>MY_NEST</li>
                <li><ul><li>MY_EQUATION</li><li>MY_EQUATION</li></ul></li>
            </ul>
            <p>will cause a name collision, while this example;</p>
            <ul>
                <li>MY_NEST</li>
                <li><ul><li>MY_EQUATION</li></ul></li>
                <li>MY_OTHER_NEST</li> <li>
                <ul><li>MY_EQUATION</li></ul></li>
            </ul>
            <p>is fine since the two equations with the same name are on different levels.</p>
            <p>To correct this error please give unique names for the above mentioned equations
            and/or nests.</p></qt>'''% str_collide_list
            MessageBox.warning(self, short_msg, longer_msg)
            return False
        return True
开发者ID:christianurich,项目名称:VIBe2UrbanSim,代码行数:51,代码来源:submodel_editor.py

示例12: check_variable

# 需要导入模块: from opus_gui.main.controllers.dialogs.message_box import MessageBox [as 别名]
# 或者: from opus_gui.main.controllers.dialogs.message_box.MessageBox import warning [as 别名]
    def check_variable(self, check = 'syntax'):
        '''
        validate the variable and display the result in i dialog box
        if check_syntax is True a syntax check is performed, otherwise a data
        check is performed.
        '''
        if check == 'syntax':
            func = batch_check_syntax
        elif check == 'data':
            func = batch_check_data
        else:
            raise ValueError('check_variable() got an unknown value for argument "check"; "%s"' % check)

        self._update_variable_from_fields()
        dummy, result, msgs = func([self.variable,], self.validator)[0]
        if result is True:
            text = '%s check OK' % check
            MessageBox.information(mainwindow = self, text = text)
        else:
            text = 'Encountered a %s error' % check
            MessageBox.warning(mainwindow = self, text = text, detailed_text = '\n '.join(msgs))
开发者ID:apdjustino,项目名称:DRCOG_Urbansim,代码行数:23,代码来源:variable_editor_savez.py

示例13: _sync_base_year_data

# 需要导入模块: from opus_gui.main.controllers.dialogs.message_box import MessageBox [as 别名]
# 或者: from opus_gui.main.controllers.dialogs.message_box.MessageBox import warning [as 别名]
    def _sync_base_year_data(self, run_manager=None):
        """
        synchronize base_year_data information in xml_configuration with 
        run_activity table.  Information in xml_configuration takes 
        precedent, because we assume users don't directly modify data in
        serivecs.run_activity table  
        """

        # TODO baseyear_dir is somewhat hard-coded; it would be better to read
        # from xml_configuration instead, but there is no such node currently
        run_name = 'base_year_data'
        baseyear_dir = os.path.join(self.project.data_path(), run_name)
        baseyear_dir = os.path.normpath(baseyear_dir)
        if not os.path.exists(baseyear_dir):
            MessageBox.warning(mainwindow = self.base_widget,
                               text="base_year_data directory %s doesn't exist. " % baseyear_dir
                               )
            return
        
        import glob
        years = [int(os.path.basename(year_dir)) for year_dir in 
                           glob.glob(os.path.join(baseyear_dir, '[0-9][0-9][0-9][0-9]'))]
        
        if not years:
            MessageBox.warning(mainwindow = self.base_widget,
                               text="base_year_data directory %s doesn't contain any year sub-directory. " % baseyear_dir
                               )
            return
        
        start_year = min(years)
        end_year = max(years)
        base_year = end_year # default to the last year in baseyear_dir
        # and update it with information found in scenario_manager
        scenario_manager_node = self.project.find('scenario_manager')
        for base_year_node in scenario_manager_node.findall('.//base_year'):
            try:
                base_year = int(base_year_node.text.strip())
                break
            except (TypeError, ValueError):
                continue
            
        resources = {
             'cache_directory': baseyear_dir,
             'description': 'base year data',
             'base_year': base_year,
             'years': (start_year, end_year)
        }
        
        if run_manager is None: run_manager = get_run_manager()
        base_year_data_db = run_manager.get_runs(run_name=run_name, 
                                                 process_name=get_host_name())
        
        if len(base_year_data_db) == 0:
            run_id = run_manager._get_new_run_id()
        elif len(base_year_data_db) >= 1:
            for idx, row in enumerate(base_year_data_db):
                if idx==0:
                    run_id = row[0]
                else:
                    run_manager.delete_everything_for_this_run(row[0])
            resources_db = run_manager.get_resources_for_run_id_from_history(run_id)
            if resources_db.get('cache_directory', '') == baseyear_dir and \
                    resources_db.get('base_year', -1) == base_year:
                #all good, we don't need to do anything
                return
            else:
                resources_db.merge(resources)
                resources = resources_db
        
        run_manager.add_row_to_history(run_id = run_id,
                                       resources = resources,
                                       status = 'done',
                                       run_name = run_name)
开发者ID:apdjustino,项目名称:DRCOG_Urbansim,代码行数:75,代码来源:results_manager.py

示例14: runErrorFromThread

# 需要导入模块: from opus_gui.main.controllers.dialogs.message_box import MessageBox [as 别名]
# 或者: from opus_gui.main.controllers.dialogs.message_box.MessageBox import warning [as 别名]
 def runErrorFromThread(self,errorMessage):
     MessageBox.warning(mainwindow = self.mainwindow,
                       text = "There was a problem running the batch.",
                       detailed_text = errorMessage)
开发者ID:christianurich,项目名称:VIBe2UrbanSim,代码行数:6,代码来源:indicator_batch_run_form.py


注:本文中的opus_gui.main.controllers.dialogs.message_box.MessageBox.warning方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。