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


Python tkSimpleDialog.askstring方法代码示例

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


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

示例1: direct_entry_pane

# 需要导入模块: import tkSimpleDialog [as 别名]
# 或者: from tkSimpleDialog import askstring [as 别名]
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") 
开发者ID:univ-of-utah-marriott-library-apple,项目名称:firmware_password_manager,代码行数:23,代码来源:Skeleton_Key.py

示例2: open_module

# 需要导入模块: import tkSimpleDialog [as 别名]
# 或者: from tkSimpleDialog import askstring [as 别名]
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 
开发者ID:dxwu,项目名称:BinderFilter,代码行数:24,代码来源:EditorWindow.py

示例3: interactive_save

# 需要导入模块: import tkSimpleDialog [as 别名]
# 或者: from tkSimpleDialog import askstring [as 别名]
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() 
开发者ID:NetEaseGame,项目名称:ATX,代码行数:19,代码来源:simple-ide.py

示例4: open_module

# 需要导入模块: import tkSimpleDialog [as 别名]
# 或者: from tkSimpleDialog import askstring [as 别名]
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 
开发者ID:aliyun,项目名称:oss-ftp,代码行数:35,代码来源:EditorWindow.py

示例5: getPassword

# 需要导入模块: import tkSimpleDialog [as 别名]
# 或者: from tkSimpleDialog 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

示例6: saveas_file

# 需要导入模块: import tkSimpleDialog [as 别名]
# 或者: from tkSimpleDialog import askstring [as 别名]
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) 
开发者ID:danielnyga,项目名称:pracmln,代码行数:10,代码来源:widgets.py

示例7: _save_crop

# 需要导入模块: import tkSimpleDialog [as 别名]
# 或者: from tkSimpleDialog import askstring [as 别名]
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) 
开发者ID:NetEaseGame,项目名称:ATX,代码行数:15,代码来源:tkgui.py

示例8: __goToLine

# 需要导入模块: import tkSimpleDialog [as 别名]
# 或者: from tkSimpleDialog import askstring [as 别名]
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 
开发者ID:yebrahim,项目名称:pydiff,代码行数:10,代码来源:mainwindow.py

示例9: grow_until

# 需要导入模块: import tkSimpleDialog [as 别名]
# 或者: from tkSimpleDialog import askstring [as 别名]
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) 
开发者ID:jsexauer,项目名称:networkx_viewer,代码行数:59,代码来源:graph_canvas.py

示例10: config_mnemonic

# 需要导入模块: import tkSimpleDialog [as 别名]
# 或者: from tkSimpleDialog import askstring [as 别名]
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) 
开发者ID:gurnec,项目名称:btcrecover,代码行数:44,代码来源:btcrseed.py


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