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


Python Tk.update方法代码示例

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


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

示例1: __init__

# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import update [as 别名]
  class Dashboard:
    """
    Dashboard class created, is launched in a new thread.
    """
    def __init__(self, labels, nb_digits, queue):
      self.root = Tk()
      self.root.title('Dashboard')
      self.root.resizable(width=False, height=False)
      self.first_column = labels
      self.nb_digits = nb_digits
      self.c2 = []
      self.queue = queue
      # Creating the first and second column. Second column will be updated.
      for row_index, first_column in enumerate(self.first_column):
        Label(self.root, text=first_column, borderwidth=15,
              font=("Courier bold", 48)).grid(row=row_index, column=0)
        self.c2.append(
          Label(self.root, text='', borderwidth=15, font=("Courier bold", 48)))
        self.c2[row_index].grid(row=row_index, column=1)
      self.i = 0
      while True:
        self.update()

    def update(self):
      """
      Method to update the output window.
      """
      values = self.queue.get()
      for row, text in enumerate(values):
        self.c2[row].configure(text='%.{}f'.format(self.nb_digits) % text)
      self.root.update()
开发者ID:LaboratoireMecaniqueLille,项目名称:crappy,代码行数:33,代码来源:dashboard.py

示例2: Wall

# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import update [as 别名]
class Wall(object):
    MIN_RED = MIN_GREEN = MIN_BLUE = 0x0
    MAX_RED = MAX_GREEN = MAX_BLUE = 0xFF

    PIXEL_WIDTH = 96

    def __init__(self, width, height):
        self.width = width
        self.height = height
        self._tk_init()
        self.pixels = [(0, 0, 0) for i in range(self.width * self.height)]

    def _tk_init(self):
        self.root = Tk()
        self.root.title("ColorWall %d x %d" % (self.width, self.height))
        self.root.resizable(0, 0)
        self.frame = Frame(self.root, bd=5, relief=SUNKEN)
        self.frame.pack()

        self.canvas = Canvas(self.frame,
                             width=self.PIXEL_WIDTH * self.width,
                             height=self.PIXEL_WIDTH * self.height,
                             bd=0, highlightthickness=0)
        self.canvas.pack()
        self.root.update()

    def set_pixel(self, x, y, hsv):
        self.pixels[self.width * y + x] = hsv

    def get_pixel(self, x, y):
        return self.pixels[self.width * y + x]

    def draw(self):
        self.canvas.delete(ALL)
        for x in range(len(self.pixels)):
            x_0 = (x % self.width) * self.PIXEL_WIDTH
            y_0 = (x / self.width) * self.PIXEL_WIDTH
            x_1 = x_0 + self.PIXEL_WIDTH
            y_1 = y_0 + self.PIXEL_WIDTH
            hue = "#%02x%02x%02x" % self._get_rgb(self.pixels[x])
            self.canvas.create_rectangle(x_0, y_0, x_1, y_1, fill=hue)
        self.canvas.update()

    def clear(self):
        for i in range(self.width * self.height):
            self.pixels[i] = (0, 0, 0)

    def _hsv_to_rgb(self, hsv):
        rgb = colorsys.hsv_to_rgb(*hsv)
        red = self.MAX_RED * rgb[0]
        green = self.MAX_GREEN * rgb[1]
        blue = self.MAX_BLUE * rgb[2]
        return (red, green, blue)

    def _get_rgb(self, hsv):
        red, green, blue = self._hsv_to_rgb(hsv)
        red = int(float(red) / (self.MAX_RED - self.MIN_RED) * 0xFF)
        green = int(float(green) / (self.MAX_GREEN - self.MIN_GREEN) * 0xFF)
        blue = int(float(blue) / (self.MAX_BLUE - self.MIN_BLUE) * 0xFF)
        return (red, green, blue)
开发者ID:Ray-SunR,项目名称:colorwall,代码行数:62,代码来源:wall.py

示例3: get_file

# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import update [as 别名]
 def get_file(self):
     root = Tk()
     root.withdraw()
     root.update()
     input_file = tkFileDialog.askopenfilename(parent=root)
     root.destroy()
     return input_file
开发者ID:hongtron,项目名称:braintree-refunder,代码行数:9,代码来源:input_helper.py

示例4: main

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

    end = False
    rulesFile = None
    outDir = "GenCode"

    if argv is None:
        argv = sys.argv
    for arg in argv:
        if arg.startswith('-rulesFile='):
            rulesFile = arg[11:]
        elif arg.startswith('-outDir='):
            outDir = arg[8:]
        elif arg.startswith('-?'):
            print "python GenPyCode.py [OPTIONS]"
            print "    -?                 Options Help"
            print "    -rulesFile=        Name of the rules file to use as input"
            print "    -outDir=           Output directory of generated code"
            end = True
    if end:
        return 0
    
    root = Tk()
    gui = GuiFrame(root, rulesFile, outDir)
    root.wm_protocol ("WM_DELETE_WINDOW", gui.gui_exit)
    while not gui.exit:
        root.update()
        time.sleep(.1)
    return (0)
开发者ID:Shifter1,项目名称:open-pinball-project,代码行数:31,代码来源:GenPyCode.py

示例5: main

# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import update [as 别名]
def main():
    root = Tk()
    # w, h = root.winfo_screenwidth(), root.winfo_screenheight()
    w, h = 960, 540
    # get value from arduino
    # ser = serial.Serial('/dev/tty.usbserial', 9600)
    pos = 0
    root.overrideredirect(1)
    root.focus_set()
    root.bind("<Escape>", lambda e: e.widget.quit())
    root.geometry("%dx%d+300+300" % (w, h))
    canvas = Canvas(root, width=w, height=h, background="black")
    rect0 = canvas.create_rectangle(w/2-75, h/2-20, w/2+75, h/2+20, fill="#05f", outline="#05f")
    rect1 = canvas.create_rectangle(w/2-20, h/2-75, w/2+20, h/2+75, fill="#05f", outline="#05f")
    canvas.pack() 
    
    while (True):
        # gets angle and moves accordingly
        # pos = ser.readline()
        canvas.move(rect0, 1, 0)
        canvas.move(rect1, 1, 0)
        root.update()
        root.after(30)
      
    app = App(root)
    time.sleep(0.5)
    root.mainloop()  
开发者ID:KTanous,项目名称:DriverHUD,代码行数:29,代码来源:SteeringIndicator.py

示例6: failure

# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import update [as 别名]
def failure(reason, cur_dir):
    """
    Displays a "submission failure" picture and emails
    a bug report to maintenance.
    """
    bugmail = {"email": "[email protected]"}
    send_email(bugmail, "QR Code Submission Failure", reason, None)
    root = Tk()
    root.focus_set()
    # Get the size of the screen and place the splash screen in the center
    gif = Image.open(str(cur_dir) + '/Images/Failure.gif')
    width = gif.size[0]
    height = gif.size[1]
    flog = (root.winfo_screenwidth()/2-width/2)
    blog = (root.winfo_screenheight()/2-height/2)
    root.overrideredirect(1)
    root.geometry('%dx%d+%d+%d' % (width*1, height + 44, flog, blog))
    # Pack a canvas into the top level window.
    # This will be used to place the image
    failure_canvas = Canvas(root)
    failure_canvas.pack(fill = "both", expand = True)
    # Open the image
    imgtk = PhotoImage(gif)
    # Get the top level window size
    # Need a call to update first, or else size is wrong
    root.update()
    cwidth = root.winfo_width()
    cheight =  root.winfo_height()
    # create the image on the canvas
    failure_canvas.create_image(cwidth/2, cheight/2.24, image=imgtk)
    Button(root, text = str(
        reason), width = 50, height = 2, command = root.destroy).pack()
    root.after(5000, root.destroy)
    root.mainloop()
开发者ID:mikefenton,项目名称:UCDAssignmentSubmission,代码行数:36,代码来源:Submit.py

示例7: expired

# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import update [as 别名]
def expired(cur_dir, amount):
    """
    Displays a "deadline expired" picture
    """
    root = Tk()
    root.focus_set()
    # Get the size of the screen and place the splash screen in the center
    img = Image.open(str(cur_dir) + '/Images/Expired.gif')
    width = img.size[0]
    height = img.size[1]
    flog = root.winfo_screenwidth()/2-width/2
    blog = root.winfo_screenheight()/2-height/2
    root.overrideredirect(True)
    root.geometry('%dx%d+%d+%d' % (width*1, height + 44, flog, blog))
    # Pack a canvas into the top level window.
    # This will be used to place the image
    expired_canvas = Canvas(root)
    expired_canvas.pack(fill="both", expand=True)
    # Open the image
    imgtk = PhotoImage(img)
    # Get the top level window size
    # Need a call to update first, or else size is wrong
    root.update()
    cwidth = root.winfo_width()
    cheight =  root.winfo_height()
    # create the image on the canvas
    expired_canvas.create_image(cwidth/2, cheight/2.1, image=imgtk)
    Button(root, text='Deadline Expired by ' + str(amount
          ) + '. Assignment Submitted, time '\
          'noted', width=80, height=2, command=root.destroy).pack()
    root.after(5000, root.destroy)
    root.mainloop()
开发者ID:mikefenton,项目名称:UCDAssignmentSubmission,代码行数:34,代码来源:Submit.py

示例8: success

# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import update [as 别名]
def success(cur_dir):
    """
    Displays a "successful submission" picture
    """
    root = Tk()
    root.focus_set()
    # Get the size of the screen and place the splash screen in the center
    img = Image.open(str(cur_dir) + '/Images/Success.gif')
    width = img.size[0]
    height = img.size[1]
    flog = (root.winfo_screenwidth()/2-width/2)
    blog = (root.winfo_screenheight()/2-height/2)
    root.overrideredirect(1)
    root.geometry('%dx%d+%d+%d' % (width, height, flog, blog))
    # Pack a canvas into the top level window.
    # This will be used to place the image
    success_canvas = Canvas(root)
    success_canvas.pack(fill = "both", expand = True)
    # Open the image
    imgtk = PhotoImage(img)
    # Get the top level window size
    # Need a call to update first, or else size is wrong
    root.update()
    cwidth = root.winfo_width()
    cheight =  root.winfo_height()
    # create the image on the canvas
    success_canvas.create_image(cwidth/2, cheight/2, image = imgtk)
    root.after(4000, root.destroy)
    root.mainloop()
开发者ID:mikefenton,项目名称:UCDAssignmentSubmission,代码行数:31,代码来源:Submit.py

示例9: main

# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import update [as 别名]
def main():
    root = Tk()
    root.geometry('800x600')
    root.title('Inventory Manager')
    root.update()
    root.minsize(root.winfo_width(), root.winfo_height())
    root.maxsize(root.winfo_width(), root.winfo_height())
    App(root).pack(fill='both', side='top', expand=True)
    root.mainloop()
开发者ID:terimater2,项目名称:Inventory-Controller,代码行数:11,代码来源:Inventory_Controller.py

示例10: __init__

# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import update [as 别名]
class GameGUI:

  def __init__(self):
    self.app = Tk()
    self.app.title('Tic Tac Toe A.I')
    self.app.resizable(width=False, height=False)
    self.board = GameAI()
    self.font = Font(family = "Arial", size = 28)
    self.buttons = {}
    for x,y in self.board.fields:
     handler = lambda x = x, y = y: self.move(x,y)
     button = Button(self.app, command = handler, font = self.font, width = 2,height = 1)
     button.grid(row = y, column = x)
     self.buttons[x,y] = button
    handler = lambda: self.reset()
    button = Button(self.app,text = 'reset',command = handler)
    button.grid(row = self.board.dim+1, column = 0, columnspan = self.board.dim,sticky="WE")
    self.quit = Button(self.app,text = 'quit', command = self.app.quit)
    self.quit.grid(row = self.board.dim+2, column = 0, columnspan = self.board.dim,sticky="WE")
    print "Dear Player, to mave a move click on any button and wait for A.I..."

  def reset(self):
    self.board = GameAI()
    self.update()

  def move(self,x,y):
    self.app.config(cursor = "watch")
    self.app.update()
    self.board = self.board.move(x,y)
    self.update()
    move = self.board.best()
    if move:
     self.board = self.board.move(*move)
     self.update()
    self.app.config(cursor = "")

  def update(self):
   for (x,y) in self.board.fields:
     text = self.board.fields[x,y]
     self.buttons[x,y]['text'] = text
     self.buttons[x,y]['disabledforeground'] = 'black'
     if text == self.board.empty:
       self.buttons[x,y]['state'] = 'normal'
     else:
       self.buttons[x,y]['state'] = 'disabled'
     winning = self.board.won()
     if winning:
      for x,y in winning:
       self.buttons[x,y]['disabledforeground'] = 'red'
      for x,y in self.buttons:
       self.buttons[x,y]['state']= 'disabled'
      for (x,y) in self.board.fields:
       self.buttons[x,y].update()

  def mainloop(self):
    self.app.mainloop()
开发者ID:DachiCoding,项目名称:tictactoe,代码行数:58,代码来源:tictactoe.py

示例11: __init__

# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import update [as 别名]
class GUI:

  def __init__(self):
    self.app = Tk()
    self.app.title('TicTacToe')
    self.app.resizable(width=False, height=False)
    self.board = Board()
    self.font = Font(family="Helvetica", size=32)
    self.buttons = {}
    for x,y in self.board.fields:
      handler = lambda x=x,y=y: self.move(x,y)
      button = Button(self.app, command=handler, font=self.font, width=2, height=1)
      button.grid(row=y, column=x)
      self.buttons[x,y] = button
    handler = lambda: self.reset()
    button = Button(self.app, text='reset', command=handler)
    button.grid(row=self.board.size+1, column=0, columnspan=self.board.size, sticky="WE")
    self.update()

  def reset(self):
    self.board = Board()
    self.update()

  def move(self,x,y):
    self.app.config(cursor="watch")
    self.app.update()
    self.board = self.board.move(x,y)
    self.update()
    move = self.board.best()
    if move:
      self.board = self.board.move(*move)
      self.update()
    self.app.config(cursor="")

  def update(self):
    for (x,y) in self.board.fields:
      text = self.board.fields[x,y]
      self.buttons[x,y]['text'] = text
      self.buttons[x,y]['disabledforeground'] = 'black'
      if text==self.board.empty:
        self.buttons[x,y]['state'] = 'normal'
      else:
        self.buttons[x,y]['state'] = 'disabled'
    winning = self.board.won()
    if winning:
      for x,y in winning:
        self.buttons[x,y]['disabledforeground'] = 'red'
      for x,y in self.buttons:
        self.buttons[x,y]['state'] = 'disabled'
    for (x,y) in self.board.fields:
      self.buttons[x,y].update()

  def mainloop(self):
    self.app.mainloop()
开发者ID:c0ns0le,项目名称:Pythonista,代码行数:56,代码来源:ttt.py

示例12: copy_command_to_clipboard

# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import update [as 别名]
 def copy_command_to_clipboard(command):
     try:
         from Tkinter import Tk
         r = Tk()
         r.withdraw()
         r.clipboard_clear()
         r.clipboard_append(command)
         r.update()
         r.destroy()
     except ImportError:
         pass
开发者ID:01org,项目名称:intelRSD,代码行数:13,代码来源:update.py

示例13: display

# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import update [as 别名]
class display(object):
	def __init__(self,image):
		self.data = np.array(image, dtype=int)
	
		self.root = Tk()
		self.frame = Tkinter.Frame(self.root, width=self.data.shape[1], height=self.data.shape[0])
		self.frame.pack()
		self.canvas = Tkinter.Canvas(self.frame, width=self.data.shape[1], height=self.data.shape[0])
		self.canvas.place(x=-2,y=-2)		
		self.im = Image.fromstring('L', (self.data.shape[1], self.data.shape[0]), self.data.astype('b').tostring())
		self.photo = ImageTk.PhotoImage(image=self.im)
		self.canvas.create_image(0,0,image=self.photo,anchor=Tkinter.NW)
		self.root.update()		
开发者ID:aasensio,项目名称:pyAndres,代码行数:15,代码来源:tv.py

示例14: __init__

# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import update [as 别名]
class GUI:
    def __init__(self):
        self.app = Tk()
        self.app.title('War Game')
        self.app.resizable(width=False, height=False)
        self.font = Font(family="Helvetica", size=32)
        self.buttons = {}
        self.board = Board('./boards/Smolensk.txt')
        self.size = SIZE

        for y in xrange(1, self.size + 1):
            for x in xrange(1, self.size + 1):
                handler = lambda x=x, y=y: self.move(x, y)
                button = Button(self.app, command=handler, font=self.font, width=3, height=1, text=self.board.values[y, x], background='gray')
                button.grid(row=y, column=x)
                self.buttons[x, y] = button

        handler = lambda: self.auto_move()
        button = Button(self.app, text='Start AI', command=handler)
        button.grid(row=self.size + 1, column=1, columnspan=self.size, sticky="WE")

    def auto_move(self):
        while self.board.nodes_left > 0:
            if self.board.player == 1:
                cost, (y, x) = self.board.root_negalphabeta()
            else:
                cost, (y, x) = self.board.root_negalphabeta()

            print 'Player: {} Heuristic {}'.format(self.board.player, cost)
            self.move(x, y)
            print 'Score: {}'.format(self.board.score)

    def move(self, x, y):
        self.app.config(cursor="watch")
        self.app.update()
        self.board.move(x, y)
        self.update(x, y)
        self.app.config(cursor="")

    def update(self, x, y):
        self.buttons[x, y]['state'] = 'disabled'
        for y in xrange(1, self.size + 1):
            for x in xrange(1, self.size + 1):
                self.buttons[x, y]['background'] = COLORS[self.board.colors[y, x]]
                self.buttons[x, y].update()

    def mainloop(self):
        self.app.mainloop()
开发者ID:aqiu384,项目名称:cs440,代码行数:50,代码来源:tic2.py

示例15: __init__

# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import update [as 别名]
    def __init__(self):
        from Tkinter import Tk, Text
        from Tkconstants import BOTH
        root = Tk()
        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()
开发者ID:8848,项目名称:Pymol-script-repo,代码行数:19,代码来源:CallTipWindow.py


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