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


Python Tkinter.Tk类代码示例

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


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

示例1: main

def main():
    global drawing_area

    root = Tk()
    root.title("Drawer")
    drawing_area = Canvas(root, width=300, height=300, bg="white")

    # Binding Events to the canvas
    drawing_area.bind("<B1-Motion>", drag)
    drawing_area.bind("<ButtonRelease-1>", drag_end)
    drawing_area.pack()

    # Buttons
    # Quit Button
    b1 = Button(root, text="Quit")
    b1.pack()
    b1.bind("<Button-1>", quit)

    # Clear Button
    b2 = Button(root, text="Clear")
    b2.pack()
    b2.bind("<Button-1>", clear)

    # Save Button
    b3 = Button(root, text="Save")
    b3.pack()
    b3.bind("<Button-1>", save)
    root.mainloop()
开发者ID:ahmedadelhassan,项目名称:CharacterRecognition,代码行数:28,代码来源:drawer.py

示例2: main

def main():
    tk = Tk()

    menuBar = Pmw.MainMenuBar(tk)

    def command():
        print('Pressed')

    menuBar.addmenu('File', 'File')

    menuBar.addmenuitem(
        'File', 'command', 'Close',
        command=command,
        label='Close'
    )

    insertmenuitem(
        menuBar,
        'File', 'command', 'Open',
        command=command,
        index=0,
        label='Open'
    )

    tk.configure(menu=menuBar)

    tk.mainloop()
开发者ID:autodataming,项目名称:perl-,代码行数:27,代码来源:cd_insertMenuitem.py

示例3: main

def main(posts = Search.FrontPage()):
	
	#main window
	root = Tk()
	root.geometry("600x300+300+300")
	app = GUI(root,posts)
	root.mainloop()
开发者ID:codedone,项目名称:FinalProject,代码行数:7,代码来源:gui.py

示例4: main

def main(): 
    queue = Queue.Queue()
    parent = Tk()
    musicplayer1 = musicplayer.MusicPlayer()    
    gui = Example(parent, queue, musicplayer1)
    #client.endApplication()
    parent.mainloop()  
开发者ID:Freelectry,项目名称:RPi_pic,代码行数:7,代码来源:guiexample.py

示例5: main

def main():

	root=Tk()
	root.geometry("250x150+300+300")
	app=GUI(root)
	app.mainloop()
	pass
开发者ID:AbhijeetDixit,项目名称:MyAdventuresWithPython,代码行数:7,代码来源:GUI1.py

示例6: main

 def main():
     global self, root
   
     root = Tk()
     root.geometry("800x800+0+0")
     self = at_graph(root)
     self.pack(fill=BOTH, expand=1)
开发者ID:pigboysid,项目名称:myat,代码行数:7,代码来源:canvas.py

示例7: ColonistGame

class ColonistGame(object):
    def __init__(self):
        pass

    def initialize_game(self):
        #initialize model instances
        print "initialize game"
        self.model_instance = GameModel()
        for colonist in self.model_instance.colonistlist:
            print colonist.get_name()

        self.root = Tk()
        self.app = GameScreen(self.root, game_instance)
        self.root.mainloop()
        self.app.update_screen()

    def next_turn(self):
        """
        Model update
        """
        self.model_instance.resolve_turn_phase()

        """
        Screen update
        """
        self.app.update_screen()

        print "Next turn"
开发者ID:Nihamawassa,项目名称:colonista,代码行数:28,代码来源:colonist_main.py

示例8: TK_Framework

class TK_Framework(object):
    def __init__(self):
        self.root = Tk()

        # list of open windows
        self.windows = {'main':self.root}

        # setup the overall style of the gui
        self.style = Style()
        self.style.theme_use('clam')

    def get_window(self,name):
        return self.windows[name]

    def create_window(self, name):
        self.windows[name] = Toplevel()
    
    
    @staticmethod
    def open_file(init_dir):
        filename = askopenfilename(initialdir=init_dir)
        return filename

    def hide_root(self):
        """Hides the root window"""
        self.root.withdraw()

    def get_root(self):
        return self.root
开发者ID:ncsurobotics,项目名称:acoustics,代码行数:29,代码来源:gui_lib.py

示例9: __init__

    def __init__(self):

        Tk.__init__(self)

        self.geometry('%dx%d+500+500' % (WIDTH,HEIGHT))
        self.title('GooMPy')

        self.canvas = Canvas(self, width=WIDTH, height=HEIGHT)

        self.canvas.pack()

        self.bind("<Key>", self.check_quit)
        self.bind('<B1-Motion>', self.drag)
        self.bind('<Button-1>', self.click)

        self.label = Label(self.canvas)

        self.radiogroup = Frame(self.canvas)
        self.radiovar = IntVar()
        self.maptypes = ['OSM', 'GoogleSatellite', 'Satellite']
        self.add_radio_button('OSM',  0)
        self.add_radio_button('GoogleSatellite', 1)
        self.add_radio_button('Satellite',    2)

        self.zoom_in_button  = self.add_zoom_button('+', +1)
        self.zoom_out_button = self.add_zoom_button('-', -1)

        self.zoomlevel = ZOOM

        maptype_index = 0
        self.radiovar.set(maptype_index)

        self.goompy = GooMPy(WIDTH, HEIGHT, LATITUDE, LONGITUDE, ZOOM, MAPTYPE)

        self.restart()
开发者ID:victorgau,项目名称:GooMPy-Modified,代码行数:35,代码来源:example.py

示例10: TestBase

class TestBase(unittest.TestCase):

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

    def tearDown(self):
        self.root.destroy()
开发者ID:aevitas,项目名称:wotsdk,代码行数:7,代码来源:test_tkintertest_variables.py

示例11: interactive_ask_diff

    def interactive_ask_diff(self, code, tmpfn, reffn, testid):
        from os import environ
        if 'UNITTEST_INTERACTIVE' not in environ:
            return False

        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()

        phototmp = ImageTk.PhotoImage(Image.open(tmpfn))
        photoref = ImageTk.PhotoImage(Image.open(reffn))
        Label(root, text='The test %s\nhave generated an different'
              'image as the reference one..' % testid).pack()
        Label(root, text='Which one is good ?').pack()
        Label(root, text=code, justify=LEFT).pack(side=RIGHT)
        Label(root, image=phototmp).pack(side=RIGHT)
        Label(root, image=photoref).pack(side=LEFT)
        Button(root, text='Use the new image -->',
               command=do_yes).pack(side=BOTTOM)
        Button(root, text='<-- Use the reference',
               command=do_close).pack(side=BOTTOM)
        root.mainloop()

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

示例12: 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:Coffelius,项目名称:kivy,代码行数:30,代码来源:common.py

示例13: checkExit

def checkExit():
    root = Tk()
    root.geometry("200x90+300+300")
    app = Escape(root)
    root.mainloop()
    result = app.getStatus()
    return result
开发者ID:bradleyrobinson,项目名称:Food_Decision_Task,代码行数:7,代码来源:review.py

示例14: main

def main():
    app = "netconvert"
    appOptions = parse_help(app)
    # appOptions = []
    root = Tk()
    app = Launcher(root, app, appOptions)
    root.mainloop()
开发者ID:behrisch,项目名称:sumo,代码行数:7,代码来源:launcher.py

示例15: __init__

class WelcomeDialog:
	"""Manages the window and initialization for creating a the V.I.O.L.A.S. welcome
	   box."""

##### Initialization ####################################################################

	def __init__( self ):
		"""Initializes the welcome window."""
		self.root = Tk()
		self.root.title('Welcome')
		self.root.geometry('515x350')
		w = tk.Message(self.root, anchor='center',
					text=	"			   Welcome to V.I.O.L.A.S.!\n\n" + 
							"		Visual Information Observation, Logging and Analysis System\n\n" +
							"  Key Features Include:\n\n" +
							"	*Ability to Read in any CSV File\n" +
							"	*Made to Order Graphical Representations\n" +
							"	*Quick and Easy Statistical Computation\n\n" +
							"  How to Use V.I.O.L.A.S:\n\n" +
							"	*Step 1: Under the file menu, use Open to import any csv file. The\n" + 
							"		data will be presented in an easy to read format in the\n" + 
							"		terminal.\n\n" +
							"	*Step 2: Under the graphs menu, one can create either a histogram, a\n" +
							"		scatterplot (4D,3D,2D), or a box plot. Each type of graphical\n" +
							"		representation takes user input in order to create the graph.\n\n" +
							"	*Step 3: Under the calculations menu, one can calculate the mean,\n" +
							"		median, mode, standard deviation, and the range depending on \n" +
							"		the user's wants. \n\n" +
							"	*Step 4: Have fun and immerse yourself in the wonders of \n" +
							"		graphical analysis that this program has to offer!\n\n",
						background='blue', foreground='white', border=0, width=550, font='courier 12 bold')
		w.pack()
开发者ID:TheTourer,项目名称:VIOLASv2,代码行数:32,代码来源:dialogPop.py


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