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


Python Tk.quit方法代码示例

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


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

示例1: UrlDialog

# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import quit [as 别名]
class UrlDialog(threading.Thread):
    def __init__(self, thread=None):
        threading.Thread.__init__(self)
        self.controlThread=thread
        self.dialogRoot=Tk()
        
        if self.dialogRoot == None:
            pass
        
        self.dialogRoot.protocol('WM_DELETE_WINDOW', self.closeBtn)
        
        self.frame=GetUrlFrame(self.dialogRoot, self.controlThread)
        
        if self.frame == None:
            pass
        
    def closeBtn(self):
        self.controlThread.setStop()
        
        
    def closeDialog(self):
        self.dialogRoot.quit()
        self.dialogRoot.destroy()
        print("UrlDialog is terminated.")
 
    def run(self):
        
        print("UrlDialog is show up.")
        self.dialogRoot.mainloop()
开发者ID:fscnick,项目名称:RapidgatorDownloader,代码行数:31,代码来源:DialogThread.py

示例2: downloadsub

# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import quit [as 别名]
def downloadsub(root_window: tkinter.Tk) -> None:

    for current_path in get_selected_movie_paths():

        if not is_filetype_supported(current_path):
            tkinter.messagebox.showerror("Kipawa Sub Downloader", "This is not a supported movie file")
        else:

            try:
                if subdb_subtitles_exist(current_path):
                    try:
                        subdb.download_subtitles(current_path)
                        tkinter.messagebox.showinfo("Kipawa Sub Downloader", "Subtitles downloaded successfully!")
                    except SubtitlesNotAvailableException:
                        tkinter.messagebox.showinfo("Kipawa Sub Downloader", "Sorry ! Better subtitles not found")

                elif opensubtitles_subs_exist(current_path):
                    try:
                        opensub.downloadsub(current_path)
                        tkinter.messagebox.showinfo("Kipawa Sub Downloader", "Subtitles downloaded succesdfully!")
                    except SubtitlesNotAvailableException:
                        tkinter.messagebox.showinfo("Kipawa Sub Downloader", "Sorry ! Better subtitles not found")
                else:
                    try:
                        download_default_subtitles(current_path)
                        tkinter.messagebox.showinfo("Kipawa Sub Downloader", "Subtitles downloaded succesdfully!")
                    except SubtitlesNotAvailableException:
                        tkinter.messagebox.showinfo("Kipawa Sub Downloader", "Sorry, no subtitles were found")

            except DownloadException as e:
                tkinter.messagebox.showinfo("Kipawa Sub Downloader", "Error downloading subtitles: " + str(e))
            except ValueError as e:
                tkinter.messagebox.showinfo("Kipawa Sub Downloader", "There is a problem with this file: " + str(e))

    root_window.quit()
开发者ID:kipawa,项目名称:SubDownloaderLinux,代码行数:37,代码来源:subdwnld.py

示例3: TkTimerCore

# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import quit [as 别名]
class TkTimerCore(TimerCore):
    def __init__(self, *args, title, font_size, **kwargs):
        def close_handler(event):
            self.close()
        def clicked_handler(event):
            self.interact()

        self.master = Tk()
        self.master.wm_title(title)
        self.master.bind('<Destroy>', close_handler)
        self.label = Label(self.master, font='Sans {}'.format(int(font_size)))
        self.label.pack(expand=True)

        self.control = Toplevel()
        self.control.wm_title(title + ' (control)')
        self.control.minsize(150, 150)
        self.control.bind('<Destroy>', close_handler)
        self.button = Button(self.control, text='Start/Pause')
        self.button.bind('<ButtonRelease>', clicked_handler)
        self.button.pack(expand=True)

        self.timeout_running = False

        super().__init__(*args, **kwargs)

    def start_timeout(self):
        assert self.timeout_running is False
        def timeout_call():
            if self.timeout_running:
                self.update()
                self.master.after(25, timeout_call)
        self.timeout_running = True
        timeout_call()

    def stop_timeout(self):
        assert self.timeout_running is True
        self.timeout_running = False

    def mainloop(self):
        return self.master.mainloop()

    def shutdown(self):
        self.master.quit()

    def set_label_text(self, text, finished=False):
        self.label.config(text=text)
        if finished:
            self.label.config(fg='red')
开发者ID:tifv,项目名称:jtimer,代码行数:50,代码来源:tk.py

示例4: UpdateChooseGui

# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import quit [as 别名]
class UpdateChooseGui():
    optionChosen = -1
    optionValues = {}

    def __init__(self):
        self.choose_gui = None
        self.choose_listbox = None

    def get_option(self, choices):
        self.choose_gui = Tk()
        self.choose_gui.title("Choose file to use")
        self.choose_gui.minsize(500, 200)
        self.center(self.choose_gui)
        choose_gui_frame = tkinter.Frame(self.choose_gui)
        choose_gui_frame.pack(fill=tkinter.BOTH, expand=True)
        self.choose_listbox = tkinter.Listbox(choose_gui_frame)
        i = 0
        for choice in choices:
            self.choose_listbox.insert(i, choice["text"])
            self.optionValues[i] = choice["value"]
            i += 1
        self.choose_listbox.pack(side=tkinter.TOP, fill=tkinter.BOTH, expand=True)

        choose_button = tkinter.Button(choose_gui_frame, text="Use version", command=self.set_option)
        choose_button.pack(side=tkinter.BOTTOM, fill=tkinter.X)

        self.choose_gui.mainloop()

        if self.optionChosen > -1:
            return self.optionValues[self.optionChosen]
        else:
            return -1

    def set_option(self):
        self.optionChosen = self.choose_listbox.curselection()[0]
        self.choose_gui.quit()

    def center(self, toplevel):
        toplevel.update_idletasks()
        w = toplevel.winfo_screenwidth()
        h = toplevel.winfo_screenheight()
        size = tuple(int(_) for _ in toplevel.geometry().split('+')[0].split('x'))
        x = w/2 - size[0]/2
        y = h/2 - size[1]/2
        # noinspection PyStringFormat
        toplevel.geometry("%dx%d+%d+%d" % (size + (x, y)))
开发者ID:FliegendeWurst,项目名称:curseDownloader,代码行数:48,代码来源:updater.py

示例5: __init__

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

#.........这里部分代码省略.........
        # Runsheet path entry label
        runsheetPathEntryLabel = Label(self.root,
                                       text="Runsheet output location")
        runsheetPathEntryLabel.pack()

        # Runsheet path entry
        self.runsheetPathEntry = Entry(self.root)
        self.runsheetPathEntry.pack()

        # Runsheet path browse button
        self.runsheetPathBrowseButton = Button(self.root, text="Browse",
                                               command=self.getRunsheetPath)
        self.runsheetPathBrowseButton.pack()

        # Date label
        dateLabel = Label(self.root, text="Date")
        dateLabel.pack()

        # Date listbox
        self.dateListbox = Listbox(self.root)
        self.dateListbox.pack()

        # Confirm button
        self.confirmButton = Button(self.root, text="Create",
                                    command=self.complete)
        self.confirmButton.pack()

        # Disable window resizing
        self.root.resizable(0, 0)

        mainloop()

    def getCSVPath(self):
        self.root.csvPath = filedialog.askopenfilename(
            filetypes = (("Comma Separated Values files", ".csv"),
                         ("All files", "*")))
        # Set text of CSV path entry to CSV path
        self.csvPathEntry.delete(0, END)
        self.csvPathEntry.insert(0, self.root.csvPath)

        # Insert CSV file dates into date listbox
        self.insertDatesIntoDateListbox()

    def getRunsheetPath(self):
        self.root.runsheetPath = filedialog.askdirectory()

        # Set text of runsheet path entry to runsheet path
        self.runsheetPathEntry.delete(0, END)
        self.runsheetPathEntry.insert(0, self.root.runsheetPath)

    def insertDatesIntoDateListbox(self):
        csvFile = open(self.root.csvPath, 'r')

        # Reader for csvfile
        reader = csv.reader(csvFile, dialect=csv.excel)

        # Header row in CSV file
        HEADER_ROW = next(reader)

        # List of unique date strings from CSV file
        self.dateStrs = []

        # Column containing date strings
        DATE_COLUMN = HEADER_ROW.index("Date")
        # Fill array of unique date strings from CSV file
        for row in reader:
            if row[DATE_COLUMN] not in self.dateStrs:
                self.dateStrs.append(row[DATE_COLUMN])
                
        # Parts of a dateStr
        MONTH_INDEX = 0
        DAY_INDEX = 1
        YEAR_INDEX = 2
                
        # Add leading zeros for sorting where needed
        for i in range(len(self.dateStrs)):
            dateStrParts = self.dateStrs[i].split('/')
            if len(dateStrParts[MONTH_INDEX]) == 1:
                dateStrParts[MONTH_INDEX] = '0' + dateStrParts[MONTH_INDEX]
            if len(dateStrParts[DAY_INDEX]) == 1:
                dateStrParts[DAY_INDEX] = '0' + dateStrParts[1]
            self.dateStrs[i] = dateStrParts[MONTH_INDEX] + '/' + \
                               dateStrParts[DAY_INDEX] + '/' + \
                               dateStrParts[YEAR_INDEX]

        # Sort dates
        self.dateStrs.sort()

        # Insert dates into date listbox
        self.dateListbox.delete(0, END)
        for i in self.dateStrs:
            self.dateListbox.insert(END, i)

    def complete(self):
        currentDateSelectionList = self.dateListbox.curselection()
        currentDateSelectionIndex = currentDateSelectionList[0]
        date = self.dateStrs[currentDateSelectionIndex]
        self.output = (self.root.csvPath, self.root.runsheetPath, date)

        self.root.quit()
开发者ID:zbeach,项目名称:Runsheet-Generator,代码行数:104,代码来源:GUI.py

示例6: destroy

# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import quit [as 别名]
 def destroy(self):
     """
     关闭主窗体,默认退出程序,可重写
     """
     Tk.quit(self)  # exit app silently, redef if exit ops
开发者ID:liubiggun,项目名称:PP4E,代码行数:7,代码来源:windows.py

示例7: destroy

# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import quit [as 别名]
 def destroy(self):
     Tk.quit(self)
开发者ID:minghu6,项目名称:minghu6_py,代码行数:4,代码来源:windows.py

示例8: __init__

# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import quit [as 别名]
class Visualize:
    def __init__(self, solution):
        self.solution = solution
        self.time = 0
        self.full = solution.full

        self.shiftRight = 20
        self.shiftDown = 20
        self.separation = 90
        self.scale = 60
        self.textVShift = 10

        self.root = Tk()
        self.canvas = Canvas(self.root)
        self.canvas.pack(fill=BOTH, expand=YES)
        self.root.bind("<KeyRelease>", self.key_released)
        self.timeLabel = Label(self.root, text='time_lavel')
        self.timeLabel.pack(side=RIGHT)

        self.setup()
        self.draw()

        if self.full:
            mainloop()

    def key_released(self, event):
        if event.char == 'j':
            if self.time < self.solution.maxt:
                self.time = self.time + 1
                self.draw()
        elif event.char == 'k':
            if self.time > 0:
                self.time = self.time - 1
                self.draw()
        elif event.char == 'q':
            self.root.quit()

    def getBBox(self, v):
        return (self.shiftRight + self.separation*v[0],
                self.shiftDown + self.separation*v[1],
                self.shiftRight + self.separation*v[0] + self.scale,
                self.shiftDown + self.separation*v[1] + self.scale)

    def getCenter(self, v):
        return (self.shiftRight + self.separation*v[0] + self.scale / 2,
                self.shiftDown + self.separation*v[1] + self.scale / 2)

    def getStatusPos(self, v):
        (x,y) = self.getCenter(v)
        return (x,y - self.textVShift)

    def getDecisionPos(self, v):
        (x,y) = self.getCenter(v)
        return (x,y + self.textVShift)

    def getEdgePos(self, e):
        v0 = self.getCenter(e[0])
        v1 = self.getCenter(e[1])
        if v0[0] == v1[0]:
            if v0[1] < v1[1]:
                return (v0[0], v0[1] + self.scale / 2), (v1[0], v1[1] - self.scale / 2)
            else:
                return (v0[0], v0[1] - self.scale / 2), (v1[0], v1[1] + self.scale / 2)
        elif v0[1] == v1[1]:
            if v0[0] < v1[0]:
                return (v0[0] + self.scale / 2, v0[1]), (v1[0] - self.scale / 2, v1[1])
            else:
                return (v0[0] - self.scale / 2, v0[1]), (v1[0] + self.scale / 2, v1[1])
        return v0, v1

    def setup(self):
        self.nodeStatus = {}
        self.nodeDecision = {}
        for v in self.solution.nodes:
            self.canvas.create_oval(self.getBBox(v))
            self.nodeStatus[v] = self.canvas.create_text(self.getStatusPos(v), text="asfs")
            self.nodeDecision[v] = self.canvas.create_text(self.getDecisionPos(v), text="fs")
        self.edges = {}
        for e in self.solution.edges:
            self.canvas.create_line(self.getEdgePos(e), fill='gray')
            self.edges[e] = self.canvas.create_line(self.getEdgePos(e), arrow='last',
                    state=HIDDEN)

    def draw(self):
        # quick reference
        nstat = self.solution.nstat
        command = self.solution.command

        self.timeLabel.config(text = '%r' % self.time)
        t = self.time
        for v in self.solution.nodes:
            self.canvas.itemconfig(self.nodeStatus[v], text=nstat[v,self.time])
            self.canvas.itemconfig(self.nodeDecision[v], text=command[v,self.time])

        if not self.full:
            return

        occu = self.solution.occu
        for e in self.solution.edges:
            state = HIDDEN
#.........这里部分代码省略.........
开发者ID:karulont,项目名称:parking,代码行数:103,代码来源:visualize.py

示例9: destroy

# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import quit [as 别名]
 def destroy(self):                                       # exit app silently
     Tk.quit(self)                                        # redef if exit ops
开发者ID:KhalidEzzeldeen,项目名称:BitsAndBobs,代码行数:4,代码来源:windows.py

示例10: Gui

# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import quit [as 别名]
from gui import Gui
from time import sleep
from control import defaultControl, Control, Mover
from traceback import print_exc
import socket
from tkinter import Tk, E, W, S, N, Label
from tkinter.font import nametofont

root=Tk()
root.columnconfigure(0, weight=1)
root.rowconfigure(0, weight=1)
try:
    control=defaultControl()
    gui = Gui(control, root)
    gui.grid(sticky=E+W+S+N)
except (OSError, socket.error) as e:
    print_exc()
    root.configure(width=200, height=200)
    root.bind("<Escape>", lambda x: root.quit())
    l=Label(root, text="Нет связи")
    l.grid()
    nametofont(l["font"]).config(size=80)

root.mainloop() 
开发者ID:basilevs,项目名称:varfill,代码行数:26,代码来源:runGui.py

示例11: print

# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import quit [as 别名]
global liste
liste=np.array([[[randint(0,31),randint(0,31)],[1]],
                [[randint(0,31),randint(0,31)],[1]],
                [[randint(0,31),randint(0,31)],[1]],
                [[randint(0,31),randint(0,31)],[1]],
                [[randint(0,31),randint(0,31)],[1]],
                [[randint(0,31),randint(0,31)],[1]],
                [[randint(0,31),randint(0,31)],[1]]])
liste2=np.empty_like(liste)


fen1=Tk()
cadrillage=Canvas(fen1, bg='light grey', height=640, width=640)
cadrillage.pack()
fen1.quit()

fen1
i=0
k=0
while True:
    try:
        humain=liste[i]
        x=humain[0][0]*20
        y=humain[0][1]*20
        cadrillage.create_rectangle(x,y,x+20,y+20, fill="red", outline="black")
        fen1.update()
    except:
        print()
        k+=1
        if k>20:
开发者ID:Epidemie,项目名称:Epidemie,代码行数:32,代码来源:Test1.py

示例12: GUIProgram

# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import quit [as 别名]
class GUIProgram:
    """This is the main class that manages tkinter around the game logic.
    To run the program, instantiate this class and call the run method.
    >>> GUIProgram().run()
    """

    standard_button_dimensions = {
        'width': 2,
        'height': 1,
    }

    def __init__(self, *args):
        """Initialize core instance variables.  Note that args is not currently
        used.  It is simply available to remain consistent with the
        shell.ShellProgram class.
        """
        self.args = args
        self.app = Tk()
        self.game = None
        """:type: Game"""
        self.state = None
        """:type: Game.State"""

    # noinspection PyAttributeOutsideInit
    def run(self):
        """Begin running the GUI and initialize the game."""
        self.choose_player()
        self.window = Window(self, master=self.app)
        self.app.title('Tic Tac Toe')
        self.app.resizable(width=False, height=False)
        self.bring_to_front()
        self.app.mainloop()
        self.app.quit()

    def choose_player(self):
        """Hides the main app temporarily so the user can pick a player."""
        self.app.withdraw()
        ChoosePlayerDialog(self)

    def handle_player_choice(self, player: Player):
        """This is a callback used by the ChoosePlayerDialog class once the
        user has chosen a player.  Once executed, initializes the game and
        shows the main app to the user.
        """
        self.game = Game(player)
        self.app.deiconify()

    def handle_state(self):
        """Handle the game logic after the user has placed a move."""
        self.state = self.game.handle_state()
        if self.state in (Game.State.ComputerWins, Game.State.HumanWins):
            self.colorize_winner()
        else:
            self.window.update()

    def colorize_winner(self):
        """Highlight the buttons used to win the game."""
        player, play = self.game.get_winner_and_play()
        if player and play:
            for position in play:
                button = self.window.move_buttons[position]
                button.configure(highlightbackground='yellow')
                button.configure(background='yellow')
            self.window.update()

    def human_move(self, position):
        """Callback used by the Window class to handle moves."""
        self.game.move(self.game.human, position)

    @staticmethod
    def bring_to_front():
        """Unfortunately, OS X seems to place tkinter behind the terminal.
        Of all the methods out there, it seems like the best way to handle
        this is to make an OS call.
        """
        if sys.platform == 'darwin':
            apple_script = ('tell app "Finder" to set frontmost of process '
                            '"Python" to true')
            os.system("/usr/bin/osascript -e '{}'".format(apple_script))
开发者ID:carymrobbins,项目名称:Tic-Tac-Toe,代码行数:81,代码来源:gui.py

示例13: onCancel

# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import quit [as 别名]
 def onCancel(self):
     if self.threads == 0:
         Tk.quit()
     else:
         showinfo(self.title, "Cannot exit: %d threads running" %
                  self.threads)
开发者ID:abrarisme,项目名称:RandomPyCode,代码行数:8,代码来源:getfilegui.py


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