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


Python Utilities.show_message方法代码示例

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


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

示例1: GenerateDrupalSchema

# 需要导入模块: from mforms import Utilities [as 别名]
# 或者: from mforms.Utilities import show_message [as 别名]
def GenerateDrupalSchema(catalog):
  output = ''

  # Add all schema.
  for schema in catalog.schemata :
    hook_created = False
    comment_replace = {}

    # Collect the comment replacement strings.
    for table in schema.tables :
      comment_replace[(' %s table ' % table.name)] = ' {%s} table ' % table.name
      comment_replace[(' %s table.' % table.name)] = ' {%s} table.' % table.name

      for column in table.columns :
        comment_replace[(' %s.%s ' % (table.name, column.name))] = ' {%s}.%s ' % (table.name, column.name)
        comment_replace[(' %s.%s.' % (table.name, column.name))] = ' {%s}.%s.' % (table.name, column.name)

    # Add all tables.
    for table in schema.tables :
      if len(table.columns) > 0 :
        if not hook_created :
          ''' Create the hook '''
          if len(output) > 0 :
            output += "\n\n"

          output += "/**\n"
          output += " * Implements hook_schema().\n"
          output += " */\n"
          output += "function %s_schema() {\n" % re.sub(r'([^a-z0-9_]+|^[^a-z]+)', '', schema.name.lower().replace(' ', '_'))
          output += "  $schema = array();\n\n"
          hook_created = True

        ''' Add the table '''
        output += generateTableDefinition(table, comment_replace)
        output += "\n"

    if hook_created :
      ''' Close the hook '''
      output += "  return $schema;\n"
      output += '}'

  if len(output) > 0 :
    # Should the output be copied to the clipboard?
    answer = Utilities.show_message('Copy to clipboard?', "Would you like to copy the schema to your clipboard?\nIt can also be viewed in the output window.", 'Yes', 'No', '')
    if answer == mforms.ResultOk :
      grt.modules.Workbench.copyToClipboard(output)

    # MySQL specific fields warning.
    if "'mysql_type' => '" in output :
      Utilities.show_message('MySQL specific fields used', 'Note that the schema definition contains MySQL specific fields!', 'OK', '', '')

    print output
  else :
    Utilities.show_warning('No valid tables found', 'The schema was not generated because no valid tables were found.', 'OK', '', '')

  return 0
开发者ID:matthijs-va,项目名称:mysql-workbench-drupal-schema-generator,代码行数:58,代码来源:wb_drupal_schema.py

示例2: get_string_value_from_control

# 需要导入模块: from mforms import Utilities [as 别名]
# 或者: from mforms.Utilities import show_message [as 别名]
    def get_string_value_from_control(self, ctrl):
      #ctrl is a tupple from map
      value = ""

      tag = ctrl[0]
      def control(idx):
        return ctrl[1][idx]

      is_multiple = False
      control_name = control(1).get_name()
      if control_name == "Multiple":
        is_multiple = True

      if tag == "txt":
        value = (control(1).get_string_value(),)
      elif tag == "spn":
        # (enabled, te, unitcontrol, unit_items)). Note! unitcontrol and unit_items may be None
        value = control(1).get_string_value().strip(" \r\n\t")

        if control(2) is not None:
            value += control(2).get_string_value()
      elif tag == "drp":
        value = control(1).get_string_value()
      elif tag == "dir":
        value = control(1).get_string_value()
        if is_multiple:
          value = value.split(';')
      elif tag == "chk":
        value = (control(0).get_active(),)

      # Here we detect if value has signs of multi line option.
      # For example, user entered separator char.
      # It is enough to ensure that the first item in tuple is string
      is_string = False  # We only can detect multi-line in strings (rework is scheduled for 5.3)
      has_separator = False
      if type(value) is tuple:
        value_len = len(value)
        if value_len == 1: # Check only single item tuples
          is_string = type(value[0]) is str or type(value[0]) is unicode
          if is_string:
            has_separator = value[0].find(multi_separator) > 0
      else:
        is_string = type(value) is str or type(value) is unicode
        has_separator = value.find(multi_separator) > 0

      if is_multiple == False and is_string and has_separator and not self.loading:
        answer = Utilities.show_message("Confirm"
            ,"Multi-line option format entered. Would you like to convert option to multi-line?"
            , "Convert", "Skip", "")
        if answer == mforms.ResultOk:
          control(1).set_name("Multiple")

      # some controls return values in form of one-item tuples
      # so we need to extract that item for processing below
      if has_separator and is_string:
        if type(value) is tuple:
          if len(value) == 1:     # Only extract values from one-item tuples
            value = value[0]      # If tuple has more items it already has been converted to multi-line

        # skip multi line values - no need to convert. Also skip non-string option values
        if type(value) is not tuple:
          value = map(lambda x: x.strip(multi_separator), value.split(multi_separator))

      if type(value) is not list and type(value) is not tuple:   
        value = (value,)

      return value
开发者ID:Arrjaan,项目名称:Cliff,代码行数:69,代码来源:wb_admin_config_file_ui.py


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