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


Python Tk.destroy方法代码示例

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


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

示例1: tkinter_clipboard_get

# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import destroy [as 别名]
def tkinter_clipboard_get():
    """ Get the clipboard's text using Tkinter.

    This is the default on systems that are not Windows or OS X. It may
    interfere with other UI toolkits and should be replaced with an
    implementation that uses that toolkit.
    """
    try:
        from tkinter import Tk, TclError  # Py 3
    except ImportError:
        try:
            from Tkinter import Tk, TclError  # Py 2
        except ImportError:
            raise TryNext("Getting text from the clipboard on this platform "
                          "requires Tkinter.")
    root = Tk()
    root.withdraw()
    try:
        text = root.clipboard_get()
    except TclError:
        raise ClipboardEmpty
    finally:
        root.destroy()
    text = py3compat.cast_unicode(text, py3compat.DEFAULT_ENCODING)
    return text
开发者ID:mattvonrocketstein,项目名称:smash,代码行数:27,代码来源:clipboard.py

示例2: output

# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import destroy [as 别名]
    def output(self, reportfile):
        fp = open(reportfile, "w")
        fp.write("<?xml version=\"1.0\" ?>\n")
        fp.write("<UIMacro>\n")

        r = Tk()
        r.withdraw()
        r.clipboard_clear()    

        items = ["Build", "Benchmark", "Scenario", "Test", "Index", "Key", "ResponseTime", "FPS"]
        actions = self._Data.findall("UIAction")
        for action in actions:
            s = "    <UIAction"
            for item in items:
                s += " %s=\"%s\"" %(item , action.get(item))
            s += "/>\n"
            fp.write(s)

            #Send the data to the clipboard
            line=action.get(items[0])
            for item in items[1:]:
                line += "\t" + action.get(item)
            line += "\n"
            r.clipboard_append(line)

        r.destroy()

        fp.write("</UIMacro>")
        fp.close()
开发者ID:Junch,项目名称:Scripts,代码行数:31,代码来源:CommandPreview.py

示例3: __init__

# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import destroy [as 别名]
class FileChooser:
    def __init__(self):
        self.filechooser = Tk()
        self.filechooser.geometry('500x500+0+0')
        self.button  = Button(self.filechooser,text="Add Directory",command=self.addDir)
        self.listview = Listbox(self.filechooser)
        self.closebutton = Button(self.filechooser,text="Scan",command=self.Done)
        self.listview.pack(fill="both")
        self.button.pack(fill='x')
        helptext = """Select directories by pressing the "Add Directory" Button, then press Scan.
                        \n When the file tree appears, red text means the file or folder is a duplicate.
                        \n purple means the folder contains duplicates but itself is not a duplicate.
                        \n Double Click on red text entries to view matches"""
        self.instructions = Label(self.filechooser, text=helptext)
        self.instructions.pack(fill='both')
        self.closebutton.pack()


        self.filechooser.mainloop()
    def Done(self):
        self.filechooser.destroy()
    def addDir(self):
        dir = askdirectory()
        if os.path.isdir(dir):
            dirlist.append(dir)
            self.listview.insert('end',str(dir))
开发者ID:bretttjohnson1,项目名称:Duplicate_Discoverer,代码行数:28,代码来源:main.py

示例4: TestBase

# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import destroy [as 别名]
class TestBase(unittest.TestCase):

    def setUp(self):
        self.root = Tk()

    def tearDown(self):
        self.root.destroy()
开发者ID:LesyaMazurevich,项目名称:python-1,代码行数:9,代码来源:test_variables.py

示例5: getFilename

# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import destroy [as 别名]
def getFilename(title, types, initialdir=None):
    root = Tk()
    root.withdraw()
    filename = filedialog.askopenfilename(title=title, filetypes=types,
                                          initialdir=initialdir)
    root.destroy()
    return filename
开发者ID:fedebarabas,项目名称:LabNanofisica,代码行数:9,代码来源:utils.py

示例6: get

# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import destroy [as 别名]
	def get():
		r = Tk()
		r.withdraw()
		returnValue = r.selection_get(selection = "CLIPBOARD")
		r.destroy()

		return returnValue if returnValue else ''
开发者ID:klesun,项目名称:storyspace,代码行数:9,代码来源:Clipboard.py

示例7: test_DefaultCategoriesAndDMUModifier

# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import destroy [as 别名]
def test_DefaultCategoriesAndDMUModifier():
    current_categories = []
    cells = []
    parent = Tk()
    data = []
    observer = DefaultCategoriesAndDMUModifier(cells, current_categories)
    for i in range(4):
        cells.append([])
        for j in range(5):
            entry = SelfValidatingEntry(parent, data, cells)
            entry.observers.append(observer)
            cells[i].append(entry)
            entry.grid(row=i + 2, column=j + 1)

    cells[1][1].text_value.set('5')
    assert cells[1][0].text_value.get() == 'DMU1'
    assert cells[0][1].text_value.get() == 'Category0'

    cells[3][4].text_value.set('some value')
    assert cells[3][0].text_value.get() == 'DMU3'
    assert cells[0][4].text_value.get() == 'Category3'
    val = 'new category name'
    cells[0][1].text_value.set(val)
    cells[3][1].text_value.set('10')
    assert cells[0][1].text_value.get() == val
    val = '   '
    cells[0][1].text_value.set(val)
    cells[3][1].text_value.set('10')
    assert cells[0][1].text_value.get() == 'Category0'
    parent.destroy()
开发者ID:nishimaomaoxiong,项目名称:pyDEA,代码行数:32,代码来源:test_gui_classes_of_table_frame.py

示例8: add

# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import destroy [as 别名]
	def add(str): # TODO: for linux adds some bad data, that breaks program (breaks even editor), but for windows worked
		if _platform == "win32" or _platform == "win64":
			r = Tk()
			r.withdraw()
			r.clipboard_clear()
			r.clipboard_append('i can has clipboardz?')
			r.destroy()
开发者ID:klesun,项目名称:storyspace,代码行数:9,代码来源:Clipboard.py

示例9: add_extra_content_to_data_table

# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import destroy [as 别名]
    def add_extra_content_to_data_table(self, data_table):

        # Read in multiple data tables
        data_table_names = []
        # while True:
        #     data_table_name = input("Which database tables are you going to pull data from (press Enter to end): ")
        #     if data_table_name == "":
        #         break
        #     data_table_names.append(data_table_name)
        root = Tk()
        root.withdraw()

        data_table_name = simpledialog.askstring("Action",
                                                 "Add datatable name for this template. Press cancel to end inputting")

        while True:
            if data_table_name is None:
                break
            data_table_names.append(data_table_name)
            data_table_name = simpledialog.askstring("Action",
                                                     "Add another datatable name for this template. Press cancel to end inputting")

        root.destroy()
        content = ["", data_table.DATA_TABLE_KEY] + data_table_names
        data_table.content.append(content)
        self.source.data_table_names = data_table_names
开发者ID:rrlittle,项目名称:rocket,代码行数:28,代码来源:wtp2ndar.py

示例10: savePreset

# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import destroy [as 别名]
def savePreset(main, filename=None):

    if filename is None:
        root = Tk()
        root.withdraw()
        filename = simpledialog.askstring(title='Save preset',
                                          prompt='Save config file as...')
        root.destroy()

    if filename is None:
        return

    config = configparser.ConfigParser()
    fov = 'Field of view'
    config['Camera'] = {
        'Frame Start': main.frameStart,
        'Shape': main.shape,
        'Shape name': main.tree.p.param(fov).param('Shape').value(),
        'Horizontal readout rate': str(main.HRRatePar.value()),
        'Vertical shift speed': str(main.vertShiftSpeedPar.value()),
        'Clock voltage amplitude': str(main.vertShiftAmpPar.value()),
        'Frame Transfer Mode': str(main.FTMPar.value()),
        'Cropped sensor mode': str(main.cropParam.value()),
        'Set exposure time': str(main.expPar.value()),
        'Pre-amp gain': str(main.PreGainPar.value()),
        'EM gain': str(main.GainPar.value())}

    with open(os.path.join(main.presetDir, filename), 'w') as configfile:
        config.write(configfile)

    main.presetsMenu.addItem(filename)
开发者ID:fedebarabas,项目名称:tormenta,代码行数:33,代码来源:guitools.py

示例11: getFilenames

# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import destroy [as 别名]
def getFilenames(title, types=[], initialdir=None):
    root = Tk()
    root.withdraw()
    filenames = filedialog.askopenfilenames(title=title, filetypes=types,
                                            initialdir=initialdir)
    root.destroy()
    return root.tk.splitlist(filenames)
开发者ID:fedebarabas,项目名称:LabNanofisica,代码行数:9,代码来源:utils.py

示例12: save

# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import destroy [as 别名]
    def save():
        """This function will save the file.
        It will also save the day, too!

        You just might be safe with this one!"""
        from tkinter import Tk
        import tkinter.filedialog
        root = Tk()
        root.withdraw()
        fd = tkinter.filedialog.FileDialog(master=root,title='Project Celestia')
        savefile = fd.go()
        if savefile != None:
            import os.path, tkinter.dialog
            if os.path.exists(savefile):
                if os.path.isdir(savefile):
                    tkinter.filedialog.FileDialog.master.bell()
                    return savefile
                d = tkinter.dialog.Dialog(master=None,title='Hold your horses!',
                                          text='Are you sure you want to rewrite this file?'
                                          '\nI mean, I have already seen the file before...\n'
                                          '\n-Twilight Sparkle',
                                          bitmap='questhead',default=0,strings=('Eeyup','Nah'))
                if d.num != 1:
                    return savefile
        else:
            FlashSentry.save_error()
        root.destroy()
开发者ID:JaredMFProgramming,项目名称:ProjectCelestia,代码行数:29,代码来源:celestia.py

示例13: UrlDialog

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

示例14: main

# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import destroy [as 别名]
def main() :
    """Code to read a file and assess its adherence to standards"""
    global fileDict
    
    fileDict = {}
    print("\nOpening a file—look for dialog box:")
    sys.stdout.flush()
    win = Tk() # root window for tkinter file dialog
    win.attributes('-topmost', True)
    win.withdraw() # hide root window
    win.lift() # move to front
    filename = filedialog.askopenfilename(parent=win) # get file name
    #            message="Pick a Python file to check") # label on dialog box
    win.destroy() # get rid of root window
    print("Opening file %s, assumed to be a Python file\n" % filename)
    analyzeFile(filename)

    if DEBUG_LEVEL > 0 :
        tokenParts = set(name for name in dir(tokenize) if name.isupper() 
                 and type(eval("tokenize." + name))==int) # tokenize constants
        tokenCodes = sorted([(eval("tokenize." + name),name) for 
                 name in tokenParts]) # codes corresponding to tokenParts
        print("\nTable of token codes")    
        for code, name in tokenCodes:
            print("%5d %s" % (code, name))
                                                         
    showTermination()
    return
开发者ID:jmding0714,项目名称:uiowapythonproj,代码行数:30,代码来源:checkstdandard2.py

示例15: before_write_instru_info

# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import destroy [as 别名]
    def before_write_instru_info(self, instru_info: InstruInfoComponent):
        super().before_write_instru_info(instru_info)
        root = Tk()
        root.withdraw()

        name = simpledialog.askstring("Action", "Enter NDAR instrument name (without version and not case sensitive)")
        version = simpledialog.askstring("Action", "Enter NDAR instrument version")
        respondent = simpledialog.askstring("Action", "Enter the respondent for this instrument. (e.g, twin, cotwin)")

        if name is not None:
            # No input check right now
            name = name.lower()
            instru_info.instru_info.instru_name = name
            self.instru_info.instru_name = name

        if version is not None:
            # A '0' is added to the version string because NDAR requires
            # single digit versions numbers to have a leading '0'
            if len(version) == 1:
                version = "0" + version
            instru_info.instru_info.version = version
            self.instru_info.version = version

        if respondent is not None:
            instru_info.instru_info.respondent = respondent
            self.instru_info.respondent = respondent

        root.destroy()
开发者ID:rrlittle,项目名称:rocket,代码行数:30,代码来源:wtp2ndar.py


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