Python tkinter.simpledialog.askstring() Examples
The following are 30
code examples of tkinter.simpledialog.askstring().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
tkinter.simpledialog
, or try the search function
.
Example #1
Source File: graphic.py From ibllib with MIT License | 9 votes |
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
Example #2
Source File: root.py From nordpy with GNU General Public License v3.0 | 8 votes |
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
Example #3
Source File: dialog.py From guizero with BSD 3-Clause "New" or "Revised" License | 7 votes |
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)
Example #4
Source File: tksupport.py From Safejumper-for-Desktop with GNU General Public License v2.0 | 6 votes |
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')
Example #5
Source File: base_file_browser.py From thonny with MIT License | 6 votes |
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()
Example #6
Source File: turtle.py From android_universal with MIT License | 5 votes |
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)
Example #7
Source File: turtle.py From Carnets with BSD 3-Clause "New" or "Revised" License | 5 votes |
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)
Example #8
Source File: game1-tk.py From code-jam-5 with MIT License | 5 votes |
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])
Example #9
Source File: game1-tk.py From code-jam-5 with MIT License | 5 votes |
def voting(self): players = [player.name for player in self.players] while True: if self.root: eliminate = simpledialog.askstring(title=f'{self.active}', prompt='Who to remove? ') else: eliminate = input('who to remove?') try: player = players.index(eliminate) except (ValueError, TypeError): print('Not an option') continue break self.players[player].eliminated = True
Example #10
Source File: base_file_browser.py From thonny with MIT License | 5 votes |
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)
Example #11
Source File: turtle.py From odoo13-x64 with GNU General Public License v3.0 | 5 votes |
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)
Example #12
Source File: turtle.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 5 votes |
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)
Example #13
Source File: mainwindow.py From pydiff with MIT License | 5 votes |
def __goToLine(self): line = askstring('Go to line', 'Enter line number:') if line: try: linenumber = int(line) self.__main_window_ui.leftFileTextArea.see(float(linenumber) + 5) except: pass
Example #14
Source File: video_sources.py From OpenCV-Video-Label with GNU General Public License v3.0 | 5 votes |
def init(self): self.parent.first_frame = True self.stream = str( simpledialog.askstring("Enter the IP address of your stream", "Enter the IP address of your stream:", initialvalue="http://192._._._:8080")) + "/shot.jpg" # calculates the new resize values to maintain aspect ratio when resizes input images
Example #15
Source File: pdfviewer.py From pdfviewer with MIT License | 5 votes |
def _extract_text(self): if self.pdf is None: return if not self.canvas.draw: self.canvas.draw = True self.canvas.configure(cursor='cross') return self.canvas.draw = False self.canvas.configure(cursor='') rect = self.canvas.get_rect() if rect is None: return self._clear() rect = self._reproject_bbox(rect) page = self.pdf.pages[self.pageidx - 1] words = page.extract_words() min_x = 1000000 r = None for word in words: diff = abs(float(word['x0'] - rect[0])) + abs(float(word['top'] - rect[1])) \ + abs(float(word['x1'] - rect[2])) + abs(float(word['bottom'] - rect[3])) if diff < min_x: min_x = diff r = word image = page.to_image(resolution=int(self.scale * 80)) image.draw_rect(r) image = image.annotated.rotate(self.rotate) self.canvas.update_image(image) simpledialog.askstring("Extract Text", "Text Extracted:", initialvalue=r['text'])
Example #16
Source File: pdfviewer.py From pdfviewer with MIT License | 5 votes |
def _search_text(self): if self.pdf is None: return text = simpledialog.askstring('Search Text', 'Enter text to search:') if text == '' or text is None: return page = self.pdf.pages[self.pageidx - 1] image = page.to_image(resolution=int(self.scale * 80)) words = [w for w in page.extract_words() if text.lower() in w['text'].lower()] image.draw_rects(words) image = image.annotated.rotate(self.rotate) self.canvas.update_image(image)
Example #17
Source File: turtle.py From ironpython3 with Apache License 2.0 | 5 votes |
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)
Example #18
Source File: gui.py From ddash with MIT License | 5 votes |
def nfocoin_context(self): if not self.ready: return self.context="nfocoin" root.geometry('{}x{}'.format(800, 750)) address_label.grid() address_entry.grid() balance_label.grid() nfocoin_balance_label.grid() buy_nfocoin_label.grid() buy_nfocoin_entry.grid() sell_nfocoin_label.grid() sell_nfocoin_entry.grid() sell_nfocoin_button.grid() send_nfocoin_label.grid() send_nfocoin_amount_entry.grid() send_nfocoin_button.grid() intranet_nfocoin_radio.grid() internet_nfocoin_radio.grid() gas_label.grid() gas_entry.grid() account_label.grid() new_account_button.grid() unlock_account_button.grid() top_frame.grid() center_frame.grid() transaction_frame.grid() network_frame.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() buy_nfocoin_button.grid() if not self.ethereum_acc_pass: answer = simpledialog.askstring("DDASH","Enter your Ethereum account password: ") self.ethereum_acc_pass = answer
Example #19
Source File: gui.py From ddash with MIT License | 5 votes |
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()
Example #20
Source File: gui.py From ddash with MIT License | 5 votes |
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()
Example #21
Source File: gui.py From ddash with MIT License | 5 votes |
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)
Example #22
Source File: gui.py From ddash with MIT License | 5 votes |
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)
Example #23
Source File: tksupport.py From learn_python3_spider with MIT License | 5 votes |
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')
Example #24
Source File: turtle.py From Imogen with MIT License | 5 votes |
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)
Example #25
Source File: turtle.py From Fluid-Designer with GNU General Public License v3.0 | 5 votes |
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)
Example #26
Source File: credentials.py From nordpy with GNU General Public License v3.0 | 5 votes |
def askVPNPassword(): """ Asks VPN password by a window dialog :return: the password inserted """ return simpledialog.askstring("Password NordVPN", "Enter password:", show="*")
Example #27
Source File: EditorWindow.py From ironpython3 with Apache License 2.0 | 4 votes |
def open_module(self, event=None): # XXX Shouldn't this be in IOBinding? try: name = self.text.get("sel.first", "sel.last") except TclError: name = "" else: name = name.strip() name = tkSimpleDialog.askstring("Module", "Enter the name of a Python module\n" "to search on sys.path and open:", parent=self.text, initialvalue=name) if name: name = name.strip() if not name: return # XXX Ought to insert current file's directory in front of path try: spec = importlib.util.find_spec(name) except (ValueError, ImportError) as msg: tkMessageBox.showerror("Import error", str(msg), parent=self.text) return if spec is None: tkMessageBox.showerror("Import error", "module not found", parent=self.text) return if not isinstance(spec.loader, importlib.abc.SourceLoader): tkMessageBox.showerror("Import error", "not a source-based module", parent=self.text) return try: file_path = spec.loader.get_filename(name) except AttributeError: tkMessageBox.showerror("Import error", "loader does not support get_filename", parent=self.text) return if self.flist: self.flist.open(file_path) else: self.io.loadfile(file_path) return file_path
Example #28
Source File: EditorWindow.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 4 votes |
def open_module(self, event=None): # XXX Shouldn't this be in IOBinding? try: name = self.text.get("sel.first", "sel.last") except TclError: name = "" else: name = name.strip() name = tkSimpleDialog.askstring("Module", "Enter the name of a Python module\n" "to search on sys.path and open:", parent=self.text, initialvalue=name) if name: name = name.strip() if not name: return # XXX Ought to insert current file's directory in front of path try: spec = importlib.util.find_spec(name) except (ValueError, ImportError) as msg: tkMessageBox.showerror("Import error", str(msg), parent=self.text) return if spec is None: tkMessageBox.showerror("Import error", "module not found", parent=self.text) return if not isinstance(spec.loader, importlib.abc.SourceLoader): tkMessageBox.showerror("Import error", "not a source-based module", parent=self.text) return try: file_path = spec.loader.get_filename(name) except AttributeError: tkMessageBox.showerror("Import error", "loader does not support get_filename", parent=self.text) return if self.flist: self.flist.open(file_path) else: self.io.loadfile(file_path) return file_path
Example #29
Source File: EditorWindow.py From Fluid-Designer with GNU General Public License v3.0 | 4 votes |
def open_module(self, event=None): # XXX Shouldn't this be in IOBinding? try: name = self.text.get("sel.first", "sel.last") except TclError: name = "" else: name = name.strip() name = tkSimpleDialog.askstring("Module", "Enter the name of a Python module\n" "to search on sys.path and open:", parent=self.text, initialvalue=name) if name: name = name.strip() if not name: return # XXX Ought to insert current file's directory in front of path try: spec = importlib.util.find_spec(name) except (ValueError, ImportError) as msg: tkMessageBox.showerror("Import error", str(msg), parent=self.text) return if spec is None: tkMessageBox.showerror("Import error", "module not found", parent=self.text) return if not isinstance(spec.loader, importlib.abc.SourceLoader): tkMessageBox.showerror("Import error", "not a source-based module", parent=self.text) return try: file_path = spec.loader.get_filename(name) except AttributeError: tkMessageBox.showerror("Import error", "loader does not support get_filename", parent=self.text) return if self.flist: self.flist.open(file_path) else: self.io.loadfile(file_path) return file_path
Example #30
Source File: credentials.py From nordpy with GNU General Public License v3.0 | 4 votes |
def askVPNUsername(): """ Asks VPN username by a dialog window :return: the username inserted """ return simpledialog.askstring("Username NordVPN", "Enter username:")