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


Python simpledialog.askstring方法代码示例

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


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

示例1: question

# 需要导入模块: from tkinter import simpledialog [as 别名]
# 或者: from tkinter.simpledialog import askstring [as 别名]
def question(title, question, initial_value=None, master=None):
    """
    Display a question box which can accept a text response.

    If Ok is pressed the value entered into the box is returned.

    If Cancel is pressed `None` is returned.

    :param string title:
        The title to be displayed on the box.
    :param string text:
        The text to be displayed on the box.
    :param string initial_value:
        The default value for the response box.
    :param App master:
        Optional guizero master which the popup will be placed over. Defaults
        to `None`.
    :return:
        The value entered or `None`.
    """
    return askstring(title, question, initialvalue=initial_value, parent=None if master is None else master.tk) 
开发者ID:lawsie,项目名称:guizero,代码行数:23,代码来源:dialog.py

示例2: change_tab_name

# 需要导入模块: from tkinter import simpledialog [as 别名]
# 或者: from tkinter.simpledialog import askstring [as 别名]
def change_tab_name():
    name = askstring('修改标签','新的标签名字') # 简单弹窗请求字符串数据
    if name is not None:
        _select = nb.select()
        oname = nb_names[_select]['name']
        cname = name
        allname = [val['name'] for val in nb_names.values()]
        idx = 0
        while True:
            if cname in allname:
                idx += 1
                cname = '{}_{}'.format(name,idx)
            else:
                break
        # name不能重复,因为需要作为字典的key持久化
        nb_names[_select]['name'] = cname
        if oname in config['set']:
            config['set'][cname] = config['set'].pop(oname)
        nb.tab(_select, text=cname) 
开发者ID:cilame,项目名称:vrequest,代码行数:21,代码来源:tab.py

示例3: ask_root_password

# 需要导入模块: from tkinter import simpledialog [as 别名]
# 或者: from tkinter.simpledialog import askstring [as 别名]
def ask_root_password(parent=None):
    """
    Shows a window dialog that asks for the root password
    :return: the correct root password if inserted correctly, None otherwise
    """

    if parent is None:
        root_password = simpledialog.askstring("Password", "Enter root password:", show='*')
    else:
        root_password = simpledialog.askstring("Password", "Enter root password:", parent=parent, show='*')

    if root_password is None:
        return None

    while root_password is None or not test_root_password(root_password):
        wrong_root_password()
        root_password = simpledialog.askstring("Password", "Enter root password:", show='*')

        if root_password is None:
            return None

    return root_password 
开发者ID:morpheusthewhite,项目名称:nordpy,代码行数:24,代码来源:root.py

示例4: mkdir

# 需要导入模块: from tkinter import simpledialog [as 别名]
# 或者: from tkinter.simpledialog import askstring [as 别名]
def mkdir(self):
        parent = self.get_selected_path()
        if parent is None:
            parent = self.current_focus
        else:
            if self.get_selected_kind() == "file":
                # dirname does the right thing even if parent is Linux path and runnning on Windows
                parent = os.path.dirname(parent)

        name = simpledialog.askstring(
            "New directory", "Enter name for new directory under\n%s" % parent
        )
        if not name or not name.strip():
            return

        self.perform_mkdir(parent, name.strip())
        self.refresh_tree() 
开发者ID:thonny,项目名称:thonny,代码行数:19,代码来源:base_file_browser.py

示例5: _mid_phase

# 需要导入模块: from tkinter import simpledialog [as 别名]
# 或者: from tkinter.simpledialog import askstring [as 别名]
def _mid_phase(self, amount=3):
        options = []
        for _ in range(amount):
            card = self.cards.pop()
            self.discarded.append(card)
            options.append(card)
        prompt = '\n'.join(options)+'\nEnact 1, 2 or 3: '
        while True:
            try:
                if self.root:
                    enact = int(simpledialog.askstring(title='Executive Order', prompt=prompt))
                else:
                    enact = int(input(prompt))
                if enact not in [1, 2, 3]:
                    raise ValueError
            except (ValueError, TypeError):
                continue
            break
        self.enacted.append(options[int(enact) - 1]) 
开发者ID:python-discord,项目名称:code-jam-5,代码行数:21,代码来源:game1-tk.py

示例6: create_new_file

# 需要导入模块: from tkinter import simpledialog [as 别名]
# 或者: from tkinter.simpledialog import askstring [as 别名]
def create_new_file(self):
        selected_node_id = self.get_selected_node()

        if selected_node_id:
            selected_path = self.tree.set(selected_node_id, "path")
            selected_kind = self.tree.set(selected_node_id, "kind")

            if selected_kind == "dir":
                parent_path = selected_path
            else:
                parent_id = self.tree.parent(selected_node_id)
                parent_path = self.tree.set(parent_id, "path")
        else:
            parent_path = self.current_focus

        name = askstring("File name", "Provide filename", initialvalue="")

        if not name:
            return

        path = self.join(parent_path, name)

        if name in self._cached_child_data[parent_path]:
            # TODO: ignore case in windows
            messagebox.showerror("Error", "The file '" + path + "' already exists")
        else:
            self.open_file(path) 
开发者ID:thonny,项目名称:thonny,代码行数:29,代码来源:base_file_browser.py

示例7: strinput

# 需要导入模块: from tkinter import simpledialog [as 别名]
# 或者: from tkinter.simpledialog import askstring [as 别名]
def strinput(title, prompt, default='COM', nullable=False):
    """
    Example:
    >>> strinput("RIG CONFIG", "Insert RE com port:", default="COM")
    """
    import tkinter as tk
    from tkinter import simpledialog
    root = tk.Tk()
    root.withdraw()
    ans = simpledialog.askstring(title, prompt, initialvalue=default)
    if (ans is None or ans == '' or ans == default) and not nullable:
        return strinput(title, prompt, default=default, nullable=nullable)
    else:
        return ans 
开发者ID:int-brain-lab,项目名称:ibllib,代码行数:16,代码来源:graphic.py

示例8: getPassword

# 需要导入模块: from tkinter import simpledialog [as 别名]
# 或者: from tkinter.simpledialog import askstring [as 别名]
def getPassword(prompt = '', confirm = 0):
    while 1:
        try1 = tkSimpleDialog.askstring('Password Dialog', prompt, show='*')
        if not confirm:
            return try1
        try2 = tkSimpleDialog.askstring('Password Dialog', 'Confirm Password', show='*')
        if try1 == try2:
            return try1
        else:
            tkMessageBox.showerror('Password Mismatch', 'Passwords did not match, starting over') 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:12,代码来源:tksupport.py

示例9: askVPNUsername

# 需要导入模块: from tkinter import simpledialog [as 别名]
# 或者: from tkinter.simpledialog import askstring [as 别名]
def askVPNUsername():
    """
    Asks VPN username by a dialog window
    :return: the username inserted
    """
    return simpledialog.askstring("Username NordVPN", "Enter username:") 
开发者ID:morpheusthewhite,项目名称:nordpy,代码行数:8,代码来源:credentials.py

示例10: askVPNPassword

# 需要导入模块: from tkinter import simpledialog [as 别名]
# 或者: from tkinter.simpledialog import askstring [as 别名]
def askVPNPassword():
    """
    Asks VPN password by a window dialog
    :return: the password inserted
    """
    return simpledialog.askstring("Password NordVPN", "Enter password:", show="*") 
开发者ID:morpheusthewhite,项目名称:nordpy,代码行数:8,代码来源:credentials.py

示例11: textinput

# 需要导入模块: from tkinter import simpledialog [as 别名]
# 或者: from tkinter.simpledialog import askstring [as 别名]
def textinput(self, title, prompt):
        """Pop up a dialog window for input of a string.

        Arguments: title is the title of the dialog window,
        prompt is a text mostly describing what information to input.

        Return the string input
        If the dialog is canceled, return None.

        Example (for a TurtleScreen instance named screen):
        >>> screen.textinput("NIM", "Name of first player:")

        """
        return simpledialog.askstring(title, prompt) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:16,代码来源:turtle.py

示例12: handle_new_account

# 需要导入模块: from tkinter import simpledialog [as 别名]
# 或者: from tkinter.simpledialog import askstring [as 别名]
def handle_new_account(self):
		password = None
		while not password:
			password = simpledialog.askstring("DDASH","Choose a password for your new account: ")
		print("Attempting to unlock account...")
		self.bci.web3.personal.newAccount(password) 
开发者ID:osmode,项目名称:ddash,代码行数:8,代码来源:gui.py

示例13: handle_unlock_account

# 需要导入模块: from tkinter import simpledialog [as 别名]
# 或者: from tkinter.simpledialog import askstring [as 别名]
def handle_unlock_account(self):
		password = None
		while not password:
			password = simpledialog.askstring("DDASH","Enter your Ethereum account password: ")

		self.ethereum_acc_pass=password
		self.ethereum_acc_pass = password
		self.bci.unlock_account(password)
		self.manifestointerface.unlock_account(password) 
开发者ID:osmode,项目名称:ddash,代码行数:11,代码来源:gui.py

示例14: nilometer_context

# 需要导入模块: from tkinter import simpledialog [as 别名]
# 或者: from tkinter.simpledialog import askstring [as 别名]
def nilometer_context(self):
		if not self.ready:
			return
		self.context = "nilometer"

		if not self.ethereum_acc_pass:
			answer = simpledialog.askstring("DDASH","Enter your Ethereum account password: ")
			self.ethereum_acc_pass = answer

		if not hasattr(self, 'nilometerinterface'):
			self.nilometerinterface = NilometerInterface(mainnet=False)
			self.nilometerinterface.load_contract(mainnet=False)
	
		root.geometry('{}x{}'.format(950, 800))
		self.nilometerinterface.unlock_account(self.ethereum_acc_pass)

		lake_nasser_label.grid()
		current_network_label.grid()
		current_network_label.config(text="Your are connected to "+self.network)
		gas_label.grid()
		gas_entry.grid()
		set_gas_button.grid()

		top_frame.grid()
		nilometer_frame.grid()
		network_frame.grid() 
开发者ID:osmode,项目名称:ddash,代码行数:28,代码来源:gui.py

示例15: manifesto_context

# 需要导入模块: from tkinter import simpledialog [as 别名]
# 或者: from tkinter.simpledialog import askstring [as 别名]
def manifesto_context(self):
		if not self.ready:
			return
		self.context = "manifesto"

		if not self.ethereum_acc_pass:
			answer = simpledialog.askstring("DDASH","Enter your Ethereum account password: ")
			self.ethereum_acc_pass = answer

		if not hasattr(self, 'manifestointerface'):
			self.manifestointerface = ManifestoInterface(mainnet=False)
			self.manifestointerface.load_contract(mainnet=False)
		root.geometry('{}x{}'.format(950, 800))
		self.manifestointerface.unlock_account(self.ethereum_acc_pass)

		manifesto_address_label.grid()
		manifesto_address_entry.grid()
		proposal_listbox.grid()
		new_proposal_label.grid()
		new_proposal_text.grid() 
		new_proposal_button.grid()
		vote_button.grid()
		current_network_label.grid()
		current_network_label.config(text="Your are connected to "+self.network)
		gas_label.grid()
		gas_entry.grid()
		set_gas_button.grid()
		tally_button.grid() 

		vote_yes_radio.grid()
		vote_no_radio.grid()

		top_frame.grid()
		manifesto_frame.grid()
		network_frame.grid() 
开发者ID:osmode,项目名称:ddash,代码行数:37,代码来源:gui.py


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