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


Python Tk.quit方法代码示例

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


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

示例1: show_msgbox

# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import quit [as 别名]
def show_msgbox(title, msg, msgtype='info'):
    localRoot = Tk()
    localRoot.withdraw()
    localRoot.option_add('*font', 'Helvetica -12')
    localRoot.quit()
    if msgtype == 'info':
        return tkinter_msgbox.showinfo(title, msg)
    elif msgtype == 'error':
        return tkinter_msgbox.showerror(title, msg)
开发者ID:dougmassay,项目名称:addibooksxml-sigil-plugin,代码行数:11,代码来源:plugin.py

示例2: askForApacheDir

# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import quit [as 别名]
def askForApacheDir(apachediroptions):
    # try to ask for Apache directory
    if len(apachediroptions) > 0:
        # get the most recent version...
        versionnames = apachediroptions.keys()
        versionnames.sort()
        initialdir = apachediroptions[versionnames[-1]]
    else:
        initialdir = "C:/Program Files/Apache Group/Apache2"
    # TODO: let the user select the name from a list, or click browse to choose...
    try:
        from tkFileDialog import askdirectory
        from Tkinter import Tk

        root = Tk()
        root.withdraw()
        path = askdirectory(title="Where is Apache installed?", initialdir=initialdir, mustexist=1, master=root)
        root.quit()
        root.destroy()
        return path
    except ImportError:
        try:
            from win32com.shell import shell

            pidl, displayname, imagelist = shell.SHBrowseForFolder(0, None, "Where is Apache installed?")
            path = shell.SHGetPathFromIDList(pidl)
            return path
        except ImportError:
            return ""
开发者ID:Musbell,项目名称:mod_python,代码行数:31,代码来源:win32_postinstall.py

示例3: __init__

# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import quit [as 别名]
class Tkgui:
    """A Tkinter-based gui interface"""
    def __init__(self):
        """This opens a gui interface if one is available"""
        # this code just hides the default Tk window
        from Tkinter import Tk
        self.root = Tk()
        self.root.withdraw()

    def choosedirectory(self, title, initialdir):
        """asks the user for a directory"""
        from tkFileDialog import askdirectory
        path = askdirectory(title=title, initialdir=initialdir, mustexist=1)
        return path

    def askyesno(self, title, message):
        """asks the user a yes-no question"""
        import tkMessageBox
        return tkMessageBox.askyesno(title, message)

    def displaymessage(self, title, message):
        """displays a message for the user"""
        import tkMessageBox
        tkMessageBox.showinfo(title, message)

    def close(self):
        """closes the gui"""
        if self.root is not None:
            self.root.quit()
            self.root.destroy()
            self.root = None

    def __del__(self):
        """make sure we're closed..."""
        self.close()
开发者ID:cc-archive,项目名称:jtoolkit,代码行数:37,代码来源:installgui.py

示例4: stopProtocol

# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import quit [as 别名]
 def stopProtocol(self):
     """
     Call when datagram protocol stops. Need to clear global connection if
     exits from here
    """
     reactor.callFromThread(reactor.stop)
     logger.info('client protocol stopped')
     root = Tk()
     root.withdraw()
     tkMessageBox.showinfo("Message", "Switch not connected or not Start , try later")
     root.quit()
开发者ID:umayanga123,项目名称:scpp_python_node,代码行数:13,代码来源:miner.py

示例5: copy_to_clipboard

# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import quit [as 别名]
def copy_to_clipboard(text):
    """Copy text to the clipboard."""
    if platform.system() == 'Darwin':
        subprocess.Popen(["pbcopy", "w"], stdin=subprocess.PIPE).communicate(text.encode('utf8'))
    elif platform.system() == 'Linux':
        subprocess.Popen(["xclip", "-selection", "clipboard"], stdin=subprocess.PIPE).communicate(text.encode('utf8'))
    else:
        r = Tk()
        r.withdraw()
        r.clipboard_clear()
        r.clipboard_append(text)
        r.quit()
开发者ID:mcho421,项目名称:pkanji,代码行数:14,代码来源:pkanji.py

示例6: fileChooser

# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import quit [as 别名]
def fileChooser():
    localRoot = Tk()
    localRoot.withdraw()
    file_opt = {}
    file_opt['parent'] = None
    file_opt['title']= 'Select iBooks XML file'
    file_opt['defaultextension'] = '.xml'
    # retrieve the initialdir from JSON prefs
    file_opt['initialdir'] = unicode_str(prefs['use_file_path'], 'utf-8')
    file_opt['multiple'] = False
    file_opt['filetypes'] = [('XML Files', ('.xml'))]
    localRoot.quit()
    return tkinter_filedialog.askopenfilename(**file_opt)
开发者ID:dougmassay,项目名称:addibooksxml-sigil-plugin,代码行数:15,代码来源:plugin.py

示例7: TkMonitor

# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import quit [as 别名]
class TkMonitor(Monitor):
    """
    An interface over a dictionary {taskno: scrolledtext widget}, with
    methods add_listener, del_listener, notify_listener and start/stop.
    """
    def __init__(self, name, queue=None):
        Monitor.__init__(self, name, queue)
        self.widgets = {}

    @plac_core.annotations(taskno=('task number', 'positional', None, int))
    def add_listener(self, taskno):
        "There is a ScrolledText for each task"
        st = ScrolledText(self.root, height=5)
        st.insert('end', 'Output of task %d\n' % taskno)
        st.pack()
        self.widgets[taskno] = st

    @plac_core.annotations(taskno=('task number', 'positional', None, int))
    def del_listener(self, taskno):
        del self.widgets[taskno]

    @plac_core.annotations(taskno=('task number', 'positional', None, int))
    def notify_listener(self, taskno, msg):
        w = self.widgets[taskno]
        w.insert('end', msg + '\n')
        w.update()

    def start(self):
        'Start the mainloop'
        self.root = Tk()
        self.root.title(self.name)
        self.root.wm_protocol("WM_DELETE_WINDOW", self.stop)
        self.root.after(0, self.read_queue)
        try:
            self.root.mainloop()
        except KeyboardInterrupt:
            print >> sys.stderr, 'Process %d killed by CTRL-C' % os.getpid()
        except TerminatedProcess:
            pass

    def stop(self):
        self.root.quit()

    def read_queue(self):
        try:
            cmd_args = self.queue.get_nowait()
        except Queue.Empty:
            pass
        else:
            getattr(self, cmd_args[0])(*cmd_args[1:])
        self.root.after(100, self.read_queue)
开发者ID:viksit,项目名称:plac,代码行数:53,代码来源:plac_tk.py

示例8: dialog

# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import quit [as 别名]
def dialog():
    r'''Opens the input and output file dialogs, then calls the parse() function.
    '''
    from Tkinter import Tk
    import tkFileDialog
    root = Tk()
    root.withdraw()
    
    from sys import stdin, stdout
    
    stdout.write('Path to the input WBXML file: ')

    binary = tkFileDialog.askopenfilename(
        master = root,
        title = 'Open WBXML File',
        filetypes = [('Wireless Binary XML', '.wbxml'), ('All Files', '*')]
    )

    if binary == '':
        root.quit()
        return

    stdout.write(binary + '\n\n')

    stdout.write('Path to the output plain-text XML file: ')

    plain = tkFileDialog.asksaveasfilename(
        master = root,
        title = "Save Plain-Text XML File",
        defaultextension = ".xml",
        filetypes = [('Plain-Text XML', '.xml'), ('All Files', '*')]
    )

    if plain == '':
        root.quit()
        return

    stdout.write(plain + '\n\n')
    
    root.quit()
    
    stdout.write('Decoding WBXML file... ')

    parse(binary, plain)
    
    stdout.write('Done.')
    stdin.read()
开发者ID:ghiewa,项目名称:py-eas-client,代码行数:49,代码来源:dewbxml.py

示例9: main

# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import quit [as 别名]
def main():
    """Set up the stopwatch and the buttons/keyboard shortcuts to control it"""
    root = Tk()

    # Add stopwatch frame
    stopwatch = StopWatch(root)
    stopwatch.pack(side=TOP)

    # Add buttons
    Button(root, text='Start/Stop',
           command=stopwatch.start_stop, takefocus=False).pack(side=LEFT)
    Button(root, text='Reset',
           command=stopwatch.reset, takefocus=False).pack(side=LEFT)
    Button(root, text='Quit',
           command=root.quit, takefocus=False).pack(side=LEFT)

    # Add keyboard shurtcuts
    root.bind("<space>", lambda x: stopwatch.start_stop())
    root.bind("<BackSpace>", lambda x: stopwatch.reset())
    root.bind("<Escape>", lambda x: root.quit())

    root.focus_set()
    root.mainloop()
开发者ID:pR0Ps,项目名称:PyStopwatch,代码行数:25,代码来源:stopwatch.py

示例10: Gui

# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import quit [as 别名]
class Gui(object):
    """
        This is a single-transaction dialog box for characterizing
        entries that could not be definitively classified by rule.
    """

    BORDER = 5
    ACCT_WID = 20
    DESC_WID = 40
    PADDING = 5

    def __init__(self, statement, entry):
        """
            instantiate a transaction window
        """
        self.rules = statement.rules

        self.root = Tk()
        self.root.title("Manual Annotation")
        t = Frame(self.root, bd=2 * self.BORDER)

        # top stack: input file name
        f = Frame(t)
        caption = "File: " + statement.filename + ", line: " + str(statement.file_line)
        Label(f, text=caption).pack()
        f.pack(pady=self.PADDING)

        # middle stack: entry details
        f = Frame(t)
        f1 = LabelFrame(f, text="Date")
        self.date = Label(f1, text=entry.date)
        self.date.pack(padx=self.PADDING, pady=self.PADDING)
        f1.pack(side=LEFT, padx=self.PADDING)

        f1 = LabelFrame(f, text="Amount")
        self.amount = Label(f1, text=entry.amount)
        self.amount.pack(padx=self.PADDING, pady=self.PADDING)
        f1.pack(side=LEFT, padx=self.PADDING)

        f1 = LabelFrame(f, text="Account")
        self.acct = Text(f1, height=1, width=self.ACCT_WID)
        if entry.account is not None:
            self.acct.insert(END, entry.account)
        self.acct.pack(padx=self.PADDING, pady=self.PADDING)
        f1.pack(side=LEFT, padx=self.PADDING)

        f1 = LabelFrame(f, text="Description")
        self.desc = Text(f1, height=1, width=self.DESC_WID)
        self.desc.insert(END, entry.description)
        self.desc.pack(padx=self.PADDING, pady=self.PADDING)
        f1.pack(side=LEFT, padx=self.PADDING)
        f.pack(pady=self.PADDING)

        # bottom stack: action buttons
        f = Frame(t)
        b = Button(f, text="Accept", command=self.accept)
        b.pack(side=LEFT, padx=self.PADDING)

        # account selection menu
        self.account = StringVar(f)
        self.account.set(entry.account)
        m = OptionMenu(f, self.account, *sorted(statement.acc_list), command=self.chooseAcct)
        m.pack(side=LEFT, padx=self.PADDING)

        # aggregate description selection menu
        self.description = StringVar(f)
        self.menu = OptionMenu(f, self.description, *sorted(statement.agg_list), command=self.chooseDesc)
        self.menu.pack(side=LEFT, padx=self.PADDING)

        b = Button(f, text="Delete", command=self.delete)
        b.pack(side=LEFT, padx=self.PADDING)
        f.pack(padx=self.PADDING, pady=self.PADDING)

        # finalize
        t.pack(side=TOP)
        self.entry = entry  # default: return what we got

    def accept(self):
        """
            Accept button action - create Entry w/current description
        """
        date = self.date.cget("text")
        amount = self.amount.cget("text")
        acct = self.account.get()
        if acct == "None":
            acct = None
        descr = self.desc.get(1.0, END).replace("\n", "")
        self.entry = Entry.Entry(date, amount, acct, descr)
        self.root.destroy()
        self.root.quit()

    def delete(self):
        """
            Delete button action - return a null Entry
        """
        self.entry = None
        self.root.destroy()
        self.root.quit()

    def chooseAcct(self, selection):
#.........这里部分代码省略.........
开发者ID:markkampe,项目名称:Financial,代码行数:103,代码来源:Gui.py

示例11: GUI

# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import quit [as 别名]
class GUI(object):
    def __init__(self, logger):
        self.logger = logger
        self.root = Tk()
        self.canvas = Canvas(self.root, width=800, height=800)
        self.canvas.pack()
        self.root.after(33, self.update)
        self.pos = (0,0)
        self.circle = self.canvas.create_oval(-10,-10,10,10,fill='black')
        self.gestures = [
            lambda t,x,y,s: ((sin(t*2*pi*0.5)*300 + 400,
                              abs(cos(t*2*pi*0.2)*300) + 200),
                             s),
            lambda t,x,y,s: ((sin(t*2*pi*1)*300 + 400,
                              cos(t*2*pi*1)*300 + 400),
                             s),
            lambda t,x,y,s: ((sin(t*2*pi*0.75)*300 + 400,
                              -abs(cos(t*2*pi*0.75)*300) + 400),
                             s),
            lambda t,x,y,s: ((x+(s[0] - x)*0.1,
                              y+(s[1] - y)*0.1),
                             (uniform(100,700)*(t%1<0.05) + (t%1>0.05)*s[0],
                              uniform(100,700)*(t%1<0.05) + (t%1>0.05)*s[1])),
            lambda t,x,y,s: ((400, y+s[1] if y < 700 else 700-s[1]),
                             (0, (10 + s[1])*(-0.5 if y>700 else 1))),
            ]
        self.state = [0,0]
        self.current_gesture = -1
        self.last_gesture_time = time.time()
        self.next_gesture(self.last_gesture_time)
        self.waiting = True
        self.root.bind('<space>', self.on_space)
        self.logger.set_tag('waiting')

    def on_space(self, *args):
        self.waiting = False
        self.last_gesture_time = time.time()

    def run(self):
        self.root.mainloop()

    def next_gesture(self, t):
        self.current_gesture += 1
        if self.current_gesture >= len(self.gestures):
            self.root.quit()
            self.logger.set_done()
            return True
        else:
            self.last_gesture_time = t
            gestureID = 'gesture%d'%self.current_gesture
            self.logger.set_tag(gestureID)
            print gestureID

    def update(self):
        if not self.waiting:
            t = time.time()
            if (t - self.last_gesture_time) > SECONDS_PER_GESTURE:
                if self.next_gesture(t):
                    return
            pos, self.state = self.gestures[self.current_gesture](t,self.pos[0],self.pos[1],self.state)
            delta = pos[0] - self.pos[0], pos[1] - self.pos[1]
            self.canvas.move(self.circle, delta[0], delta[1])
            self.pos = pos
        self.root.after(33, self.update)
开发者ID:malloch,项目名称:emergeData,代码行数:66,代码来源:gesture_recorder.py

示例12: EngineGui

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

#.........这里部分代码省略.........
        self.currentVoice = StringVar(self.tkRoot)
        self.currentVoice.set(self.communicationProtocal.CurrentVoiceName)

        engine = pyttsx.init()
        voices = engine.getProperty("voices")
        voiceNames = list()
        for x in xrange(0, len(voices)):
            voiceNames.append(voices[x].name)
        self.optionMenuVoices = OptionMenu(frame, self.currentVoice, *tuple(voiceNames), command=self.CallBackOptionMenuVoices)
        self.optionMenuVoices.config(width=500)
        self.optionMenuVoices.grid(sticky=W, row = 12, column = 1)
     
        #hide if close button is clicked
        self.tkRoot.protocol("WM_DELETE_WINDOW", self.HideGui)
        self.tkRoot.after(1000/32, self.Update)
        self.tkRoot.mainloop()  

    def Update(self):
        wordLocation = self.communicationProtocal.OnWordStartLocation
        wordLength = self.communicationProtocal.OnWordLength
        wordTotal = self.communicationProtocal.OnWordTotal

        if wordLocation:
            self.labelStart.configure(text=wordLocation)
        else:
            self.labelStart.configure(text="0")
        self.labelLength.configure(text=wordLength)
        if wordLength != 0 and wordTotal == 0:
            self.labelTotal.configure(text="Introduce")    
        else:
            self.labelTotal.configure(text=wordTotal)

        if len(self.communicationProtocal.SpeakQueue) != 0:
            if (wordLocation < 25):
                self.labelSentenceLeft.configure(text=str(self.communicationProtocal.SpeakQueue[0])[0:wordLocation])
            else:
                self.labelSentenceLeft.configure(text=str(self.communicationProtocal.SpeakQueue[0])[wordLocation-25:wordLocation])
            self.labelSentenceSpoken.configure(text=str(self.communicationProtocal.SpeakQueue[0])[wordLocation:wordLocation+wordLength])
            if (wordTotal - wordLocation - wordLength < 25):
                self.labelSentenceRight.configure(text=str(self.communicationProtocal.SpeakQueue[0])[wordLocation+wordLength:wordTotal])
            else:
                self.labelSentenceRight.configure(text=str(self.communicationProtocal.SpeakQueue[0])[wordLocation+wordLength:wordLocation+wordLength+25])
        else:
            self.labelSentenceLeft.configure(text="...")
            self.labelSentenceSpoken.configure(text="...")
            self.labelSentenceRight.configure(text="...")

        if (self.communicationProtocal.SpeakQueue != None and self.listboxQueueToSpeak.size() != len(self.communicationProtocal.SpeakQueue)):
            self.listboxQueueToSpeak.delete(0,self.listboxQueueToSpeak.size())
            for x in xrange(0,len(self.communicationProtocal.SpeakQueue)):
                self.listboxQueueToSpeak.insert(x, str(x)+": "+self.communicationProtocal.SpeakQueue[x])

        if (self.currentVoice.get() != self.communicationProtocal.CurrentVoiceName):
            self.currentVoice.set(self.communicationProtocal.CurrentVoiceName)

        if self.speedValue != self.communicationProtocal.CurrentRate:
            self.intVarSpeed.set(self.communicationProtocal.CurrentRate) 
            self.speedValue = self.communicationProtocal.CurrentRate

        if self.recoverActionLabelText != self.communicationProtocal.recoveryTask:
            self.recoverActionLabelText = self.communicationProtocal.recoveryTask
            self.labelRecoverAction.configure(text=self.recoverActionLabelText)

        if self.GUIVisible != self.communicationProtocal.GUIVisible:
            # self.GUIVisible ? self.HideGui : self.ShowGui
            self.HideGui() if self.GUIVisible else self.ShowGui()
            
        self.tkRoot.after(1000/32,self.Update)

    def OnValidateEntrySpeakSpeed(self, d, i, P, s, S, v, V, W):
        try :
            int(S)
            return True
        except ValueError:
            return False

    def CallBackSetSpeed(self):
        self.communicationProtocal.handleSetSpeed(self.intVarSpeed.get())

    def CallBackReturnSay(self, event):
        self.CallBackButtonSay()

    def CallBackButtonSay(self):
        self.communicationProtocal.handleSay(self.stringVarTextToSay.get())
        
    def CallBackOptionMenuVoices(self, selectedItem):
        self.communicationProtocal.handleSetVoice(selectedItem)

    def Close(self):
        self.tkRoot.quit()
        
    def HideGui(self):
        self.GUIVisible = False
        self.communicationProtocal.GUIVisible = False
        self.tkRoot.withdraw()
        
    def ShowGui(self):
        self.GUIVisible = True
        self.communicationProtocal.GUIVisible = True
        self.tkRoot.deiconify()
开发者ID:tjanpool,项目名称:myDragonflyScripts,代码行数:104,代码来源:Engine.py

示例13: __init__

# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import quit [as 别名]
class GUI:
    def __init__(self, model, title='PyCX Simulator', interval=0, stepSize=1,
            param_gui_names=None):
        self.model = model
        self.titleText = title
        self.timeInterval = interval
        self.stepSize = stepSize
        self.param_gui_names = param_gui_names
        if param_gui_names is None:
            self.param_gui_names = {}
        self.param_entries = {}
        self.statusStr = ""
        self.running = False
        self.modelFigure = None
        self.currentStep = 0

        self.initGUI()

    def initGUI(self):
        #create root window
        self.rootWindow = Tk()
        self.statusText = StringVar(value=self.statusStr)
        self.setStatusStr("Simulation not yet started")

        self.rootWindow.wm_title(self.titleText)
        self.rootWindow.protocol('WM_DELETE_WINDOW', self.quitGUI)
        self.rootWindow.geometry('550x700')
        self.rootWindow.columnconfigure(0, weight=1)
        self.rootWindow.rowconfigure(0, weight=1)

        self.frameSim = Frame(self.rootWindow)

        self.frameSim.pack(expand=YES, fill=BOTH, padx=5, pady=5, side=TOP)
        self.status = Label(self.rootWindow, width=40, height=3, relief=SUNKEN,
                            bd=1, textvariable=self.statusText)
        self.status.pack(side=TOP, fill=X, padx=1, pady=1, expand=NO)

        self.runPauseString = StringVar()
        self.runPauseString.set("Run")
        self.buttonRun = Button(self.frameSim, width=30, height=2,
                                textvariable=self.runPauseString,
                                command=self.runEvent)
        self.buttonRun.pack(side=TOP, padx=5, pady=5)

        self.showHelp(self.buttonRun,
                      "Runs the simulation (or pauses the running simulation)")
        self.buttonStep = Button(self.frameSim, width=30, height=2,
                                 text="Step Once", command=self.stepOnce)
        self.buttonStep.pack(side=TOP, padx=5, pady=5)
        self.showHelp(self.buttonStep, "Steps the simulation only once")
        self.buttonReset = Button(self.frameSim, width=30, height=2,
                                  text="Reset", command=self.resetModel)
        self.buttonReset.pack(side=TOP, padx=5, pady=5)
        self.showHelp(self.buttonReset, "Resets the simulation")

        for param in self.model.params:
            var_text = self.param_gui_names.get(param, param)
            can = Canvas(self.frameSim)
            lab = Label(can, width=25, height=1 + var_text.count('\n'),
                        text=var_text, anchor=W, takefocus=0)
            lab.pack(side='left')
            ent = Entry(can, width=11)
            val = getattr(self.model, param)
            if isinstance(val, bool):
                val = int(val)  # Show 0/1 which can convert back to bool
            ent.insert(0, str(val))
            ent.pack(side='left')
            can.pack(side='top')
            self.param_entries[param] = ent
        if self.param_entries:
            self.buttonSaveParameters = Button(self.frameSim, width=50,
                    height=1, command=self.saveParametersCmd,
                    text="Save parameters to the running model", state=DISABLED)
            self.showHelp(self.buttonSaveParameters,
                    "Saves the parameter values.\n" +
                    "Not all values may take effect on a running model\n" +
                    "A model reset might be required.")
            self.buttonSaveParameters.pack(side='top', padx=5, pady=5)
            self.buttonSaveParametersAndReset = Button(self.frameSim, width=50,
                    height=1, command=self.saveParametersAndResetCmd,
                    text="Save parameters to the model and reset the model")
            self.showHelp(self.buttonSaveParametersAndReset,
                    "Saves the given parameter values and resets the model")
            self.buttonSaveParametersAndReset.pack(side='top', padx=5, pady=5)

        can = Canvas(self.frameSim)
        lab = Label(can, width=25, height=1, text="Step size ", justify=LEFT,
                anchor=W, takefocus=0)
        lab.pack(side='left')
        self.stepScale = Scale(can, from_=1, to=500, resolution=1,
                               command=self.changeStepSize, orient=HORIZONTAL,
                               width=25, length=150)
        self.stepScale.set(self.stepSize)
        self.showHelp(self.stepScale,
                "Skips model redraw during every [n] simulation steps\n" +
                "Results in a faster model run.")
        self.stepScale.pack(side='left')
        can.pack(side='top')

        can = Canvas(self.frameSim)
#.........这里部分代码省略.........
开发者ID:thaije,项目名称:intro_comp_science,代码行数:103,代码来源:pycx_gui.py

示例14: Tk

# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import quit [as 别名]
#start program with dialog box, which will lead to either just terminating
#or making a game box
if __name__ == "__main__":
    player_dlg = Tk();
    player_dlg.geometry("%dx%d+%d+%d" % 
        (INIT_WINDOW_WIDTH, INIT_WINDOW_HEIGHT, X_POS, Y_POS))
    # TODO: make dialog box show up in the middle of the screen based on
    # screen resolution
    player_dlg.title("How many players?")
    msg = Message(player_dlg, text="How many players will be playing this time?");
    msg.pack()
    player_count = Entry(player_dlg)
    player_count.pack()
    ethan_eyes_var = IntVar()
    ethan_eyes_check = Checkbutton(player_dlg, \
                                   text="enable Ethan Eyes", \
                                   var=ethan_eyes_var)
    ethan_eyes_check.pack()
    confirm_button = Button(player_dlg, text="OK", \
                            command=lambda: generate_main(player_dlg, \
                                                          player_count, \
                                                          ethan_eyes_var) );
    confirm_button.pack();
    cancle_button = Button(player_dlg, text="Cancel", \
                            command=lambda: player_dlg.quit() );
    cancle_button.pack();
    player_dlg.mainloop();



    
开发者ID:hamburgerbun,项目名称:ethan_tk,代码行数:29,代码来源:ethan_tk.py

示例15: Cap

# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import quit [as 别名]
class Cap(Frame):
	def __init__(self):
		' set defaults, create widgets, bind callbacks, start live view '
		self.root = Tk()
		# menu:
		self.menu = Menu(self.root)
		self.root.config(menu=self.menu)
		# bind global keypresses:
		self.root.bind('q', lambda e: self.root.quit())
		self.root.bind('x', lambda e: self.root.quit())
		self.root.bind('<Destroy>', self.do_stop_video)
		self.root.bind('<space>', self.do_single_shot)
		self.root.bind('<Return>', self.do_single_shot)
		self.root.bind('<Button-3>', self.do_single_shot)
		self.root.bind('<Left>', lambda e: self.degree.set(-90))
		self.root.bind('<Right>', lambda e: self.degree.set(90))
		self.root.bind('<Up>', lambda e: self.degree.set(0))
		self.root.bind('a', lambda e: self.autocontrast.set(not self.autocontrast.get()))
		self.root.bind('e', lambda e: self.equalize.set(not self.equalize.get()))
		self.root.bind('g', lambda e: self.grayscale.set(not self.grayscale.get()))
		self.root.bind('i', lambda e: self.invert.set(not self.invert.get()))
		self.root.bind('s', lambda e: self.solarize.set(not self.solarize.get()))
		# config:
		self.config = RawConfigParser()
		self.config.read('filmroller.conf')
		if not self.config.has_section('global'):
			self.config.add_section('global')
		self.video = None
		self.invert = BooleanVar(name='invert')
		self.invert.set(self.config_get('invert', True))
		self.invert.trace('w', self.do_configure)
		self.grayscale = BooleanVar(name='grayscale')
		self.grayscale.set(self.config_get('grayscale', False))
		self.grayscale.trace('w', self.do_configure)
		self.autocontrast = BooleanVar(name='autocontrast')
		self.autocontrast.set(self.config_get('autocontrast', True))
		self.autocontrast.trace('w', self.do_configure)
		self.equalize = BooleanVar(name='equalize')
		self.equalize.set(self.config_get('equalize', False))
		self.equalize.trace('w', self.do_configure)
		self.solarize = BooleanVar(name='solarize')
		self.solarize.set(self.config_get('solarize', False))
		self.solarize.trace('w', self.do_configure)
		self.degree = IntVar(name='degree')
		self.degree.set(0)
		self.filename = StringVar(name='filename')
		self.videodevice = StringVar(name='videodevice')
		dev_names = sorted(['/dev/{}'.format(x) for x in listdir('/dev') if x.startswith('video')])
		d = self.config_get('videodevice', dev_names[-1])
		if not d in dev_names:
			d = dev_names[-1]
		self.videodevice.set(d)
		self.videodevice.trace('w', self.do_configure)
		#
		self.path = 'filmroller'
		if not exists(self.path):
			makedirs(self.path)
		# create gui:
		Frame.__init__(self, self.root)
		self.grid()
		self.x_canvas = Canvas(self, width=640, height=640, )
		self.x_canvas.pack(side='top')
		self.x_canvas.bind('<Button-1>', self.do_change_rotation)
		Checkbutton(self, text='Invert', variable=self.invert).pack(side='left')
		Checkbutton(self, text='Gray', variable=self.grayscale).pack(side='left')
		Checkbutton(self, text='Auto', variable=self.autocontrast).pack(side='left')
		OptionMenu(self, self.videodevice, *dev_names, command=self.restart_video).pack(side='left')
		Button(self, text='First role', command=self.do_first_role).pack(side='left')
		Label(self, textvariable=self.filename).pack(side='left')
		Button(self, text='Next role', command=self.do_inc_role).pack(side='left')
		Button(self, text='Take!', command=self.do_single_shot).pack(side='right')
		#filemenu = Menu(self.menu)
		#self.menu.add_cascade(label=self.videodevice.get(), menu=filemenu, )
		#for n in dev_names:
		#	filemenu.add_command(label=n, )
		#filemenu.add_separator()
		# start operation:
		self.do_first_role()
		self.do_start_video()

	def do_change_rotation(self, event):
		' determine where the image was clicked and turn that to the top '
		if event.x < 200:
			self.degree.set(-90)
		elif event.x > 640 - 200:
			self.degree.set(90)
		else:
			self.degree.set(0)

	def config_get(self, name, default):
		' read a configuration entry, fallback to default if not already stored '
		if not self.config.has_option('global', name):
			return default
		if isinstance(default, bool):
			return self.config.getboolean('global', name)
		else:
			return self.config.get('global', name)

	def do_configure(self, name, mode, cbname):
		' change a configuration entry '
#.........这里部分代码省略.........
开发者ID:JimmyDurandWesolowski,项目名称:python-v4l2capture,代码行数:103,代码来源:filmroller.py


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