Python tkSimpleDialog.askstring() Examples

The following are 14 code examples of tkSimpleDialog.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 tkSimpleDialog , or try the search function .
Example #1
Source File: Skeleton_Key.py    From firmware_password_manager with MIT License 6 votes vote down vote up
def direct_entry_pane(self):
        """
        Directly enter fwpw.
        """
        self.logger.info("%s: activated" % inspect.stack()[0][3])

        self.current_key = tkSimpleDialog.askstring("FW Password", "Enter firmware password:", show='*', parent=self.root)

        if self.current_key:
            self.keys_loaded = True
            self.calculate_hash()
            self.status_string.set('Keys loaded successfully.')
            self.keys_label['image'] = self.key_icon_photoimage
            self.keys_loaded_string.set('Keys in memory.')
            self.change_state_btn.configure(state="normal")

        else:
            self.flush_keys()
            self.status_string.set('Blank password entered.')
            self.logger.error('Direct enter blank password.')
            self.change_state_btn.configure(state="disabled") 
Example #2
Source File: EditorWindow.py    From BinderFilter with MIT License 6 votes vote down vote up
def open_module(self, event=None):
        # XXX Shouldn't this be in IOBinding or in FileList?
        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:
            (f, file, (suffix, mode, type)) = _find_module(name)
        except (NameError, ImportError), msg:
            tkMessageBox.showerror("Import error", str(msg), parent=self.text)
            return 
Example #3
Source File: tksupport.py    From Safejumper-for-Desktop with GNU General Public License v2.0 6 votes vote down vote up
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 #4
Source File: simple-ide.py    From ATX with Apache License 2.0 6 votes vote down vote up
def interactive_save(image):
    img_str = cv2.imencode('.png', image)[1].tostring()
    imgpil = Image.open(StringIO(img_str))

    root = Tkinter.Tk()
    root.geometry('{}x{}'.format(400, 400))
    imgtk = ImageTk.PhotoImage(image=imgpil)
    panel = Tkinter.Label(root, image=imgtk) #.pack()
    panel.pack(side="bottom", fill="both", expand="yes")
    Tkinter.Button(root, text="Hello!").pack()
    save_to = tkSimpleDialog.askstring("Save cropped image", "Enter filename")
    if save_to:
        if save_to.find('.') == -1:
            save_to += '.png'
        print 'Save to:', save_to
        cv2.imwrite(save_to, image)
    root.destroy() 
Example #5
Source File: EditorWindow.py    From oss-ftp with MIT License 5 votes vote down vote up
def open_module(self, event=None):
        # XXX Shouldn't this be in IOBinding or in FileList?
        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:
            (f, file_path, (suffix, mode, mtype)) = _find_module(name)
        except (NameError, ImportError) as msg:
            tkMessageBox.showerror("Import error", str(msg), parent=self.text)
            return
        if mtype != imp.PY_SOURCE:
            tkMessageBox.showerror("Unsupported type",
                "%s is not a source module" % name, parent=self.text)
            return
        if f:
            f.close()
        if self.flist:
            self.flist.open(file_path)
        else:
            self.io.loadfile(file_path)
        return file_path 
Example #6
Source File: tksupport.py    From learn_python3_spider with MIT License 5 votes vote down vote up
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 #7
Source File: widgets.py    From pracmln with BSD 2-Clause "Simplified" License 5 votes vote down vote up
def saveas_file(self):
        oldfname = self.selected_file.get().strip()
        res = tkSimpleDialog.askstring('Save as', "Enter a filename", initialvalue=oldfname.strip('*'))
        if res is None: return
        elif res:
            if not res.endswith(self.fsettings.get('extension')):
                res = res + self.fsettings.get('extension')
            self.update_file(oldfname, new=res) 
Example #8
Source File: tkgui.py    From ATX with Apache License 2.0 5 votes vote down vote up
def _save_crop(self):
        print self._bounds
        if self._bounds is None:
            return
        bounds = self._fix_bounds(self._bounds)
        print bounds
        save_to = tkSimpleDialog.askstring("Save cropped image", "Enter filename")
        if save_to:
            if save_to.find('.') == -1:
                save_to += '.png'
            print('Save to:', save_to)
            self._image.crop(bounds).save(save_to)
            # cv2.imwrite(save_to, image) 
Example #9
Source File: mainwindow.py    From pydiff with MIT License 5 votes vote down vote up
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 #10
Source File: EditorWindow.py    From Splunking-Crime with GNU Affero General Public License v3.0 5 votes vote down vote up
def open_module(self, event=None):
        # XXX Shouldn't this be in IOBinding or in FileList?
        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:
            (f, file_path, (suffix, mode, mtype)) = _find_module(name)
        except (NameError, ImportError) as msg:
            tkMessageBox.showerror("Import error", str(msg), parent=self.text)
            return
        if mtype != imp.PY_SOURCE:
            tkMessageBox.showerror("Unsupported type",
                "%s is not a source module" % name, parent=self.text)
            return
        if f:
            f.close()
        if self.flist:
            self.flist.open(file_path)
        else:
            self.io.loadfile(file_path)
        return file_path 
Example #11
Source File: tksupport.py    From python-for-android with Apache License 2.0 5 votes vote down vote up
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 #12
Source File: tksupport.py    From BitTorrent with GNU General Public License v3.0 5 votes vote down vote up
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 #13
Source File: graph_canvas.py    From networkx_viewer with GNU General Public License v3.0 4 votes vote down vote up
def grow_until(self, disp_node, stop_condition=None, levels=0):

        # Find condition to stop growing
        if stop_condition is None:
            stop_condition = tkd.askstring("Stop Condition", "Enter lambda "
                "function which returns True when stop condition is met.\n"
                "Parameters are:\n  - u, the node's name, and \n  "
                "- d, the data dictionary.\n\nExample: "
                "d['color']=='red' \nwould grow until a red node is found.")

            if stop_condition is None: return

        data_node = self.dispG.node[disp_node]['dataG_id']
        existing_data_nodes = set([ v['dataG_id']
                                    for k,v in self.dispG.node.items() ])

        max_iters = 10
        stop_node = None    # Node which met stop condition
        grow_nodes = set([data_node])   # New nodes
        # Iterate until we find a node that matches the stop condition (or,
        #  worst case, we reach max iters)
        for i in range(1,max_iters+1):
            old_grow_nodes = grow_nodes.copy()
            grow_nodes.clear()
            for n in old_grow_nodes:
                grow_graph = self._neighbors(n, levels=i)
                grow_nodes = grow_nodes.union(set(grow_graph.nodes())) - \
                             existing_data_nodes - old_grow_nodes
            if len(grow_nodes) == 0:
                # Start out next iteration with the entire graph
                grow_nodes = existing_data_nodes.copy()
                continue
            for u in grow_nodes:
                d = self.dataG.node[u]
                try:
                    stop = eval(stop_condition, {'u':u, 'd':d})
                except Exception as e:
                    tkm.showerror("Invalid Stop Condition",
                                  "Evaluating the stop condition\n\n" +
                                  stop_condition + "\n\nraise the following " +
                                  "exception:\n\n" + str(e))
                    return
                if stop:
                    stop_node = u
                    break
            if stop_node is not None:
                break
        if stop_node is None:
            tkm.showerror("Stop Condition Not Reached", "Unable to find a node "
            "which meet the stop condition within %d levels."%i)
            return

        ## Grow the number of times it took to find the node
        #self.grow_node(disp_node, i)

        # Find shortest path to stop_node
        self.plot_path(data_node, stop_node, levels=levels, add_to_exsting=True) 
Example #14
Source File: btcrseed.py    From btcrecover with GNU General Public License v2.0 4 votes vote down vote up
def config_mnemonic(cls, mnemonic_guess = None, closematch_cutoff = 0.65):
        # If a mnemonic guess wasn't provided, prompt the user for one
        if not mnemonic_guess:
            init_gui()
            mnemonic_guess = tkSimpleDialog.askstring("Electrum seed",
                "Please enter your best guess for your Electrum seed:")
            if not mnemonic_guess:
                sys.exit("canceled")

        mnemonic_guess = str(mnemonic_guess)  # ensures it's ASCII

        # Convert the mnemonic words into numeric ids and pre-calculate similar mnemonic words
        global mnemonic_ids_guess, close_mnemonic_ids
        mnemonic_ids_guess = ()
        # close_mnemonic_ids is a dict; each dict key is a mnemonic_id (int), and each
        # dict value is a tuple containing length 1 tuples, and finally each of the
        # length 1 tuples contains a single mnemonic_id which is similar to the dict's key
        close_mnemonic_ids = {}
        for word in mnemonic_guess.lower().split():
            close_words = difflib.get_close_matches(word, cls._words, sys.maxint, closematch_cutoff)
            if close_words:
                if close_words[0] != word:
                    print("'{}' was in your guess, but it's not a valid Electrum seed word;\n"
                          "    trying '{}' instead.".format(word, close_words[0]))
                mnemonic_ids_guess += cls._word_to_id[close_words[0]],
                close_mnemonic_ids[mnemonic_ids_guess[-1]] = tuple( (cls._word_to_id[w],) for w in close_words[1:] )
            else:
                print("'{}' was in your guess, but there is no similar Electrum seed word;\n"
                      "    trying all possible seed words here instead.".format(word))
                mnemonic_ids_guess += None,

        global num_inserts, num_deletes
        num_inserts = max(12 - len(mnemonic_ids_guess), 0)
        num_deletes = max(len(mnemonic_ids_guess) - 12, 0)
        if num_inserts:
            print("Seed sentence was too short, inserting {} word{} into each guess."
                  .format(num_inserts, "s" if num_inserts > 1 else ""))
        if num_deletes:
            print("Seed sentence was too long, deleting {} word{} from each guess."
                  .format(num_deletes, "s" if num_deletes > 1 else ""))

    # Produces a long stream of differing and incorrect mnemonic_ids guesses (for testing)