當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。