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


Python Tk.mainloop方法代码示例

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


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

示例1: main

# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import mainloop [as 别名]
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,代码行数:30,代码来源:drawer.py

示例2: main

# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import mainloop [as 别名]
def main():
    global cnx
    root = Tk()
    root.geometry("900x600+100+100")
    cnx = conectar()
    app = Example(root)
    root.mainloop()
开发者ID:rached193,项目名称:Caritas,代码行数:9,代码来源:caritas.py

示例3: interactive_ask_ref

# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import mainloop [as 别名]
    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,代码行数:32,代码来源:common.py

示例4: main

# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import mainloop [as 别名]
def main():
    app = "netconvert"
    appOptions = parse_help(app)
    # appOptions = []
    root = Tk()
    app = Launcher(root, app, appOptions)
    root.mainloop()
开发者ID:behrisch,项目名称:sumo,代码行数:9,代码来源:launcher.py

示例5: checkExit

# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import mainloop [as 别名]
def checkExit():
    root = Tk()
    root.geometry("200x90+300+300")
    app = Escape(root)
    root.mainloop()
    result = app.getStatus()
    return result
开发者ID:bradleyrobinson,项目名称:Food_Decision_Task,代码行数:9,代码来源:review.py

示例6: optionFilter

# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import mainloop [as 别名]
def optionFilter():
    global racine
    
    racine = Tk()   
    fenetre = filterswindow(racine)
    racine.geometry("500x300+200+0")
    racine.mainloop()    
开发者ID:IPGP,项目名称:DSM-Kernel,代码行数:9,代码来源:window2kernelinf.py

示例7: main

# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import mainloop [as 别名]
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-,代码行数:29,代码来源:cd_insertMenuitem.py

示例8: main

# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import mainloop [as 别名]
def main():

    root = Tk()
    app = App(root)
    root.geometry("610x610+100+200")

    root.mainloop()
开发者ID:fokoepxg,项目名称:CraftBuilder,代码行数:9,代码来源:test.py

示例9: demo

# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import mainloop [as 别名]
def demo():

    from Tkinter import Tk, Frame, Button, BOTH, LEFT

    root = Tk()
    root.title("wckCalendar")

    def echo():
        print (view.getselection())

    view = Calendar(root, font="verdana", background="white", command=echo)
    view.pack(fill=BOTH, expand=1)

    buttonbox = Frame(root)
    def previous():
        date = view.getdate()
        if date.month == 1:
            view.setdate(date.year-1, 12)
        else:
            view.setdate(date.year, date.month-1)
    def next():
        date = view.getdate()
        if date.month == 12:
            view.setdate(date.year+1, 1)
        else:
            view.setdate(date.year, date.month+1)
    b = Button(buttonbox, text="previous", command=previous, width=10)
    b.pack(side=LEFT)
    b = Button(buttonbox, text="next", command=next, width=10)
    b.pack(side=LEFT)
    buttonbox.pack(expand=1, padx=2, pady=2)

    root.mainloop()
开发者ID:beng92,项目名称:Statify,代码行数:35,代码来源:wckCalendar.py

示例10: main

# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import mainloop [as 别名]
def main():
    x_size = 0 
    y_size = 0
    gates = []
    ports = [] 
    root = Tk()
    layout_fl = open(os.path.dirname(os.path.abspath(__file__)) \
        + "/layout.txt","r")
    for ln in layout_fl:
        is_match = re.match(r"x_size(\d+)y_size(\d+)",ln)
        if (is_match):
            x_size = int(is_match.group(1))
            y_size = int(is_match.group(2))
        is_match = re.match(r"gatename(.+)x(\d+)y(\d+)",ln)
        if(is_match): 
            gate = is_match.group(1),\
            int(is_match.group(2)),\
            int(is_match.group(3))
            gates.append(gate)
        is_match = re.match(r"portname(.+)x(\d+)y(\d+)",ln)
        if(is_match): 
            port = is_match.group(1),\
            int(is_match.group(2)),\
            int(is_match.group(3))
            ports.append(port) 
    sz = ""
    sz = str(x_size*scale_c+2*margin) + "x" + \
        str(y_size*scale_c+2*margin) 
    #sz = "800x450"
    grid = x_size,y_size
    ex = Draw_Layout(root,grid,gates,ports)
    #root.bind('<Key>',key);
    root.geometry(sz)
    root.mainloop()  
开发者ID:k-langer,项目名称:HPC_VLSIPlacer_5640,代码行数:36,代码来源:draw_layout.py

示例11: main_tkinter

# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import mainloop [as 别名]
def main_tkinter(gen):
    from Tkinter import Tk
    t = TkinterTask.generator(gen)
    root = Tk()
    for s in "+-*/":
        t(s).start()
    root.mainloop()
开发者ID:pganti,项目名称:micheles,代码行数:9,代码来源:tk_mainloop.py

示例12: main

# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import mainloop [as 别名]
def main():

    root = Tk()
    app = PhyUI(root, 1000, 500)
    app.set_viewport(Vect2D(0, 0), Vect2D(200, 100))
  
    all_ = []

     
    # Four boundaries

    all_.append(simulate.Ball(
            radius = 20, shift = Vect2D(5 * 10 + 10, 2 * 10 + 10), 
            velo = Vect2D(0, 0), accel = Vect2D(0, 0), 
            mass = 5, app = app))
 
    all_.append(simulate.Ball(
            radius = 20, shift = Vect2D(0 * 10 + 10, 5 * 10 + 10), 
            velo = Vect2D(5, 0), accel = Vect2D(0, 0), 
            mass = 5, app = app))
 


    # Some balls for testing

    for i in all_:
        app.register_trigger(i, 5, 0.007)

    # Register in display callback

    root.mainloop()
开发者ID:Determinant,项目名称:simple_balls,代码行数:33,代码来源:d.py

示例13: demo

# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import mainloop [as 别名]
def demo():
    root = Tk()
    root.bind('<Control-q>', lambda e: root.destroy())

    table = Table(root, 'Word Synset Hypernym Hyponym'.split(),
                  column_weights=[0, 1, 1, 1], 
                  reprfunc=(lambda i,j,s: '  %s' % s))
    table.pack(expand=True, fill='both')

    from nltk.corpus import wordnet
    from nltk.corpus import brown
    for word, pos in sorted(set(brown.tagged_words()[:500])):
        if pos[0] != 'N': continue
        word = word.lower()
        for synset in wordnet.synsets(word):
            hyper = (synset.hypernyms()+[''])[0]
            hypo = (synset.hyponyms()+[''])[0]
            table.append([word,
                          getattr(synset, 'definition', '*none*'),
                          getattr(hyper, 'definition', '*none*'),
                          getattr(hypo, 'definition', '*none*')])

    table.columnconfig('Word', background='#afa')
    table.columnconfig('Synset', background='#efe')
    table.columnconfig('Hypernym', background='#fee')
    table.columnconfig('Hyponym', background='#ffe')
    for row in range(len(table)):
        for column in ('Hypernym', 'Hyponym'):
            if table[row, column] == '*none*':
                table.itemconfig(row, column, foreground='#666',
                                 selectforeground='#666')
    root.mainloop()
开发者ID:aboSamoor,项目名称:nltk,代码行数:34,代码来源:table.py

示例14: test

# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import mainloop [as 别名]
def test():
    from Tkinter import Tk, Text
    root = Tk()
    class MyEditWin:
        def __init__(self, text):
            self.text = text
            self.flist = None
            self.text.bind("<Control-o>", self.open)
            self.text.bind("<Control-s>", self.save)
            self.text.bind("<Alt-s>", self.save_as)
            self.text.bind("<Alt-z>", self.save_a_copy)
        def get_saved(self): return 0
        def set_saved(self, flag): pass
        def reset_undo(self): pass
        def open(self, event):
            self.text.event_generate("<<open-window-from-file>>")
        def save(self, event):
            self.text.event_generate("<<save-window>>")
        def save_as(self, event):
            self.text.event_generate("<<save-window-as-file>>")
        def save_a_copy(self, event):
            self.text.event_generate("<<save-copy-of-window-as-file>>")
    text = Text(root)
    text.pack()
    text.focus_set()
    editwin = MyEditWin(text)
    io = IOBinding(editwin)
    root.mainloop()
开发者ID:8848,项目名称:Pymol-script-repo,代码行数:30,代码来源:IOBinding.py

示例15: main

# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import mainloop [as 别名]
def main():

    root = Tk()
    root.geometry("500x350+300+300")
    app = Example(root)
    
    root.mainloop()
开发者ID:Bhawna4tech,项目名称:Smart-Audio-Book-Reader,代码行数:9,代码来源:main.py


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