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


Python Dialog.form方法代码示例

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


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

示例1: float

# 需要导入模块: from dialog import Dialog [as 别名]
# 或者: from dialog.Dialog import form [as 别名]
                    string += obj.text()
                    string += "\n"
                d.msgbox(string)

        elif tag == "Add":
            code, tag = d.menu("Choose an object type.",
                               choices=[("Particle", "point charge")],
                               title="Add Menu")
            if code != d.OK:
                pass
            else:
                if tag == "Particle":
                    while "while true statements are dumb":
                        answers = d.form("Enter parameters:",
                                         elements=[("x position:", 1, 1, "0.0", 1, 13, 20, 0),
                                                   ("y position:", 2, 1, "0.0", 2, 13, 20, 0),
                                                   ("z position:", 3, 1, "0.0", 3, 13, 20, 0),
                                                   ("    charge:", 4, 1, "0.0", 4, 13, 20, 0)])

                        if answers[0] != d.OK:
                            break

                        try:
                            x = float(answers[1][0])
                            y = float(answers[1][1])
                            z = float(answers[1][2])
                            q = float(answers[1][3])
                            pos = Position(x, y, z)
                            q *= chargeUnit.multiplier()
                            objects.append(Particle(Position(x, y, z), q))
                            d.msgbox("Created particle.")
开发者ID:idajourney,项目名称:PhysTools,代码行数:33,代码来源:main.py

示例2: IotConsole

# 需要导入模块: from dialog import Dialog [as 别名]
# 或者: from dialog.Dialog import form [as 别名]

#.........这里部分代码省略.........
        interest = Interest(interestName)
        interest.setInterestLifetimeMilliseconds(3000)
        # self.face.makeCommandInterest(interest)
        self.face.expressInterest(
            interest,
            self._makeOnCommandListCallback(successCallback),
            self._makeOnCommandListTimeoutCallback(timeoutCallback),
        )

    def _makeOnCommandListTimeoutCallback(self, callback):
        def onCommandListTimeout(interest):
            self.ui.alert("Timed out waiting for services list")
            self.loop.call_soon(callback)

        return onCommandListTimeout

    def _makeOnCommandListCallback(self, callback):
        def onCommandListReceived(interest, data):
            try:
                commandInfo = json.loads(str(data.getContent()))
            except:
                self.ui.alert("An error occured while reading the services list")
                self.loop.call_soon(self.displayMenu)
            else:
                self.foundCommands = commandInfo
                self.loop.call_soon(callback)

        return onCommandListReceived

    def _showCommandList(self):
        try:
            commandList = []
            for capability, commands in self.foundCommands.items():
                commandList.append("\Z1{}:".format(capability))
                for info in commands:
                    signingStr = "signed" if info["signed"] else "unsigned"
                    commandList.append("\Z0\t{} ({})".format(info["name"], signingStr))
                commandList.append("")

            if len(commandList) == 0:
                # should not happen
                commandList = ["----NONE----"]
            allCommands = "\n".join(commandList)
            oldTitle = self.ui.title
            self.ui.title = "Available services"
            self.ui.alert(allCommands, preExtra=["--colors"])
            self.ui.title = oldTitle
            # self.ui.menu('Available services', commandList, prefix='', extras=['--no-cancel'])
        finally:
            self.loop.call_soon(self.displayMenu)

    #######
    # New device
    ######

    def pairDevice(self):
        self._scanForUnconfiguredDevices()

    def _enterPairingInfo(self, serial, pin="", newName=""):
        fields = [Dialog.FormField("PIN", pin), Dialog.FormField("Device name", newName)]
        (retCode, retList) = self.ui.form("Pairing device {}".format(serial), fields)
        if retCode == Dialog.DIALOG_OK:
            pin, newName = retList
            if len(pin) == 0 or len(newName) == 0:
                self.ui.alert("All fields are required")
                self.loop.call_soon(self._enterPairingInfo, serial, pin, newName)
开发者ID:RayneHwang,项目名称:ndn-pi,代码行数:70,代码来源:iot_console.py

示例3: write_and_display_results

# 需要导入模块: from dialog import Dialog [as 别名]
# 或者: from dialog.Dialog import form [as 别名]
      # simply add
      interfaces.addAdapter({
        'name': selected_iface,
        'auto': True,
        'addrFam': 'inet',
        'source': Constants.DHCP}, 0)

      write_and_display_results(interfaces, selected_iface)

    if tag == Constants.STATIC:
      while True:
        try:
          code, values = d.form(Constants.TXT_CONFIG_STATIC_TITLE, [
                                # title, row_1, column_1, field, row_1, column_20, field_length, input_length
                                ('IP Address', 1, 1, '192.168.0.10', 1, 20, 15, 15),
                                # title, row_2, column_1, field, row_2, column_20, field_length, input_length
                                ('Netmask', 2, 1, '255.255.255.0', 2, 20, 15, 15),
                                # title, row_3, column_1, field, row_3, column_20, field_length, input_length
                                ('Gateway', 3, 1, '192.168.0.1', 3, 20, 15, 15)
                                ], width=70)

          if (code == Dialog.CANCEL or code == Dialog.ESC):
            clearquit()

          code = d.infobox(Constants.TXT_MESSAGE_STATIC)
          # simply add
          interfaces.addAdapter({
            'name': selected_iface,
            'auto': True,
            'addrFam': 'inet',
            'source': Constants.STATIC,
            'address': values[0],
开发者ID:pragbits,项目名称:pydialog-interfaces,代码行数:34,代码来源:pydialog-interfaces.py


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