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


Python Gui.quit方法代码示例

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


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

示例1: __init__

# 需要导入模块: from gui import Gui [as 别名]
# 或者: from gui.Gui import quit [as 别名]

#.........这里部分代码省略.........
            if not self.alpha in range(4):
                raise "train: illigal value for alpha: %d" %self.alpha

            self.passw.append(chr(char))
            i += 1

        self.callback(0,0)

    def callback(self, *args):
        if args[1] == 0:
            if args[0] < self.passw.__len__():
                self.gui.display_passw(self.passw, args[0], args[0]+1)
                upt, var = self.options["uptime"]
                total = upt + self.rnd.randint(-1*var, var)
                self.gui.tk_callback(total*10, self.callback, args[0], 1)
            else:    
                self.ready = 1
        else:
            self.gui.display_passw(self.passw,0,0)
            delay, var = self.options["delay"]
            total = delay + self.rnd.randint(-1*var, var)
            self.gui.tk_callback(total*10, self.callback, args[0]+1, 0)

    def user_completed(self):
        mistakes = self.passw.__len__() - self.user_input.__len__()
        for i in range(self.user_input.__len__()):
             if self.passw.__len__() <= i:
                 mistakes += 1
             else:
                if ord(self.user_input[i])!= ord(self.passw[i]):
                    mistakes += 1

        user = join(self.user_input,"")
        pw = join(self.passw, "")
        show = join((pw, user, str(mistakes)))
        self.gui.display_passw(show, 0, show.__len__())
        self.gui.newline()
        self.training = 0
        self.ready = 0
            
    def key_event_handler(self, event):
        k = event.keysym
        if k in ("F1", "F2", "F3", "F4", "F5", "F6", "F7", "F8", "F9", "F10", "F11", "F12", "Up", "Down", "Left", "Right"):
            self.handle_options(k)
        else:
            self.handle_user_input(k)
        
    def handle_options(self, k):
        if k == "F2":
            self.option = "amount"
        elif k == "F3":
            self.option = "uptime"
        elif k == "F4":
            self.option = "delay"
	elif k == "F5":
	    self.option = "alphas"
        elif k in ("Up", "Down", "Left", "Right"):
	    if self.option in ("amount", "uptime", "delay"):
                a,b = self.options[self.option]
                if (k=="Up"):
                    a = a + 1
                elif (k=="Down"):
                    if (a>1):
                        a = a - 1
                elif (k=="Right"):
                     b = b + 1
                elif (k=="Left"):
                    if (b>0):
                        b = b - 1
                self.options[self.option] = (a,b)
	    elif self.option == "alphas":
               if (k=="Up"):
		   if self.alpha < self.alphas.__len__() - 1:
                       self.alpha += 1
               elif (k=="Down"):
		   if self.alpha > 0:
		       self.alpha -= 1
               self.options[self.option] = self.alphas[self.alpha]

            apply(self.gui.display_option,(),{self.option:self.options[self.option]})
        else:
            pass

    def handle_user_input(self, k):
     	if k == "Escape":
	    self.gui.quit()
	elif k == "Return":
            if self.training == 0:
                self.train()
            if self.ready == 1:
                self.user_completed()
        elif k == "BackSpace":
            if self.training == 1:
		self.user_input=[]
                self.callback(0,0)
        elif k in ("Shift_R", "Shift_L", "Tab", "Next", "Prior", "Control_L", "Control_R", "CapsLock", "Alt_L", "Alt_R", "Mode_switch", "Menu", "SuperL", "Delete", "Insert", "Print"):
            pass
        else:
            if self.ready:
                self.user_input.append(k)
开发者ID:copton,项目名称:spytrain,代码行数:104,代码来源:engine.py


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