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


Python tkinter.Tk类代码示例

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


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

示例1: getFileInput

def getFileInput():
	root = Tk()
	root.withdraw()
	wordFile = filedialog.askopenfile(title="Open Word File", mode="r", parent=root)
	if wordFile is None:
		raise SystemExit
	return wordFile
开发者ID:nalexander50,项目名称:Daily-Programmer,代码行数:7,代码来源:Hacking.py

示例2: goodUser

def goodUser():
    errorMsg = Tk()

    goodCRN = Label(errorMsg, text="Please enter a valid Villanova username")

    goodCRN.pack()
    errorMsg.mainloop()
开发者ID:Plonski,项目名称:ClassSelect-Villanova,代码行数:7,代码来源:front.py

示例3: enable

    def enable(self, app=None):
        """Enable event loop integration with Tk.

        Parameters
        ----------
        app : toplevel :class:`Tkinter.Tk` widget, optional.
            Running toplevel widget to use.  If not given, we probe Tk for an
            existing one, and create a new one if none is found.

        Notes
        -----
        If you have already created a :class:`Tkinter.Tk` object, the only
        thing done by this method is to register with the
        :class:`InputHookManager`, since creating that object automatically
        sets ``PyOS_InputHook``.
        """
        if app is None:
            try:
                from tkinter import Tk  # Py 3
            except ImportError:
                from Tkinter import Tk  # Py 2
            app = Tk()
            app.withdraw()
            self.manager.apps[GUI_TK] = app
            return app
开发者ID:MovingAverage,项目名称:ipython,代码行数:25,代码来源:inputhook.py

示例4: main

def main():

    root = Tk()
    ex = Janela(root)
    root.geometry("300x250+300+300")
    center(root)
    root.mainloop()
开发者ID:vpperego,项目名称:vagasGenerator,代码行数:7,代码来源:VagasGenerator.py

示例5: main

def main():
    root = Tk()
    f1 = tkinter.Frame(width=200, height=200)
    ex = Example(root)
    f1.pack(fill="both", expand=True, padx=20, pady=20)
    ex.place(in_=f1, anchor="c", relx=.5, rely=.5)
    root.mainloop()
开发者ID:KittyMcSnuggles,项目名称:reddit,代码行数:7,代码来源:client.py

示例6: __init__

 def __init__(self, app, kind='', icon_file=None, center=True):
     self.findIcon()
     Tk.__init__(self)
     if center:
         pass
     self.__app = app
     self.configBorders(app, kind, icon_file)
开发者ID:minghu6,项目名称:minghu6_py,代码行数:7,代码来源:windows.py

示例7: interactive_ask_ref

    def interactive_ask_ref(self, code, imagefn, testid):
        from os import environ
        if 'UNITTEST_INTERACTIVE' not in environ:
            return True

        from tkinter import Tk, Label, LEFT, RIGHT, BOTTOM, Button
        from PIL import Image, ImageTk

        self.retval = False

        root = Tk()

        def do_close():
            root.destroy()

        def do_yes():
            self.retval = True
            do_close()

        image = Image.open(imagefn)
        photo = ImageTk.PhotoImage(image)
        Label(root, text='The test %s\nhave no reference.' % testid).pack()
        Label(root, text='Use this image as a reference ?').pack()
        Label(root, text=code, justify=LEFT).pack(side=RIGHT)
        Label(root, image=photo).pack(side=LEFT)
        Button(root, text='Use as reference', command=do_yes).pack(side=BOTTOM)
        Button(root, text='Discard', command=do_close).pack(side=BOTTOM)
        root.mainloop()

        return self.retval
开发者ID:kivy,项目名称:kivy,代码行数:30,代码来源:common.py

示例8: TkWindowMainLoop

class TkWindowMainLoop(Thread):
    '''class for thread that handles Tk window creation and main loop''' 
    
    def __init__(self, client):
        Thread.__init__(self)
        
        self.window = None
        self.canvas = None
        self.client = client
        
        self.start()

    
    def callbackDeleteWindow(self):
        self.client.stop()
        
    def stop(self):
        self.window.quit()
        
    
    def run(self):
        self.window = Tk()
        self.canvas = Canvas(self.window, width=1024, height=768)
        self.canvas.pack()
        
        self.window.protocol("WM_DELETE_WINDOW", self.callbackDeleteWindow)
        
        self.window.mainloop()

    def getWindow(self):
        return self.window
    
    def getCanvas(self):
        return self.canvas
开发者ID:IwfY,项目名称:TkStein3d,代码行数:34,代码来源:tkwindowmainloop.py

示例9: save

    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,代码行数:27,代码来源:celestia.py

示例10: __init__

    def __init__(self,root):
        Tk.__init__(self,root)
        self.root = root

        self.MAX_F = 12

        self.info = StringVar()
        self.sliders = []
        self.parameters = []
        self.filters = []
        self.isAdvancedMode = False

        self.isWritting = False

        self.configFile = "config.xml"

        self.cw = ConfigWritter(self.configFile)
        if not isfile(self.configFile): self._createConfigFile()
        self.cp = ConfigParser(self.configFile)
        self._parseConfigFile()


        self.canvas = Canvas()
        self.canvas.pack(expand=YES,fill=BOTH)

        self.initialize()
开发者ID:Gorgorot38,项目名称:Sonotone-RICM4,代码行数:26,代码来源:gui.py

示例11: _calltip_window

def _calltip_window(parent):  # htest #
    import re
    from tkinter import Tk, Text, LEFT, BOTH

    root = Tk()
    root.title("Test calltips")
    width, height, x, y = list(map(int, re.split('[x+]', parent.geometry())))
    root.geometry("+%d+%d"%(x, y + 150))

    class MyEditWin: # conceptually an editor_window
        def __init__(self):
            text = self.text = Text(root)
            text.pack(side=LEFT, fill=BOTH, expand=1)
            text.insert("insert", "string.split")
            root.update()
            self.calltip = CallTip(text)

            text.event_add("<<calltip-show>>", "(")
            text.event_add("<<calltip-hide>>", ")")
            text.bind("<<calltip-show>>", self.calltip_show)
            text.bind("<<calltip-hide>>", self.calltip_hide)

            text.focus_set()
            root.mainloop()

        def calltip_show(self, event):
            self.calltip.showtip("Hello world", "insert", "end")

        def calltip_hide(self, event):
            self.calltip.hidetip()

    MyEditWin()
开发者ID:5outh,项目名称:Databases-Fall2014,代码行数:32,代码来源:CallTipWindow.py

示例12: __init__

 def __init__(self, title="", message="", button="Ok", image=None,
              checkmessage="", style="clam", **options):
     """
         Create a messagebox with one button and a checkbox below the button:
             parent: parent of the toplevel window
             title: message box title
             message: message box text
             button: message displayed on the button
             image: image displayed at the left of the message
             checkmessage: message displayed next to the checkbox
             **options: other options to pass to the Toplevel.__init__ method
     """
     Tk.__init__(self, **options)
     self.resizable(False, False)
     self.title(title)
     s = Style(self)
     s.theme_use(style)
     if image:
         Label(self, text=message, wraplength=335,
               font="Sans 11", compound="left",
               image=image).grid(row=0, padx=10, pady=(10, 0))
     else:
         Label(self, text=message, wraplength=335,
               font="Sans 11").grid(row=0, padx=10, pady=(10, 0))
     b = Button(self, text=button, command=self.destroy)
     b.grid(row=2, padx=10, pady=10)
     self.var = BooleanVar(self)
     c = Checkbutton(self, text=checkmessage, variable=self.var)
     c.grid(row=1, padx=10, pady=0, sticky="e")
     self.grab_set()
     b.focus_set()
     self.wait_window(self)
开发者ID:j4321,项目名称:Sudoku-Tk,代码行数:32,代码来源:custom_messagebox.py

示例13: ingresarUsuario

	def ingresarUsuario(cls):
		
		cls.nombre=""
		
		def salir():
			root.quit()
	
		def cargarArchivo():
			cls.nombre=a.get()
			root.destroy()
	
		def obtenerN():
			n=a.get()
			return (n)
		
		root = Tk()
		root.title('CargarDatos')
		a = StringVar()
		atxt = Entry(root, textvariable=a,width=20)
		cargar = Button(root, text="Cargar Archivo", command=cargarArchivo,width=15)
		salirB= Button(root, text ="Salir", command=root.destroy, width=10)
		atxt.grid(row=0, column=0)
		cargar.grid(row=1, column=0)
		salirB.grid(row=1,column=1)
		root.mainloop()
		return (obtenerN())
开发者ID:jupmorenor,项目名称:201210-pygroup-advanced,代码行数:26,代码来源:generales.py

示例14: main

def main():
    q = Queue()

    root = Tk()
    root.geometry("400x350+300+300")
    Example(root, q)
    root.mainloop()
开发者ID:chengyi818,项目名称:kata,代码行数:7,代码来源:1_calculating_pi.py

示例15: main

def main():
    #abort shutdown
    abortShutdown()
    #load the application
    root = Tk()
    app = FullScreenApp(root)
    root.mainloop()
开发者ID:ilmeo,项目名称:python-homeTheater,代码行数:7,代码来源:homeTheater.py


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