本文整理汇总了Python中tkinter.Tk.update_idletasks方法的典型用法代码示例。如果您正苦于以下问题:Python Tk.update_idletasks方法的具体用法?Python Tk.update_idletasks怎么用?Python Tk.update_idletasks使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tkinter.Tk
的用法示例。
在下文中一共展示了Tk.update_idletasks方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import update_idletasks [as 别名]
def main():
root = Tk()
root.title("Paddle Game")
root.resizable(0, 0)
root.wm_attributes("-topmost", 1)
canvas = Canvas(root, width=500, height=400, bd=0, highlightthickness=0)
canvas.pack()
root.update()
paddle = Paddle(canvas, "blue")
ball = Ball(canvas, paddle, "red")
while True:
if not ball.hit_bottom:
ball.draw()
paddle.draw()
root.update_idletasks()
root.update()
time.sleep(0.01)
示例2: playScreen
# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import update_idletasks [as 别名]
def playScreen():
"""Draw a dark bg."""
print("*** Drawing the PlayScreen ***")
ps = Tk()
ps.title("Playing...")
ps.attributes('-fullscreen', True)
ps.configure(bg='black')
lb = Label(ps, text="Playing...", bg='black', fg='grey')
lb.pack()
ps.update_idletasks()
return(ps)
示例3: run
# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import update_idletasks [as 别名]
def run(*args):
# Create the GUI for the program
window = Tk()
window.wm_title("pesto_check") # change the window title to pesto_check
text = Text(window, height=3, width=65, bg="black", padx=5, pady=5,
highlightthickness=1)
text.pack()
# Tag configs for green/red font color
text.tag_config("green", foreground="green")
text.tag_config("red", foreground="red")
# Set GUI position on screen (we'll put it on the upper-right hand corner)
window.update_idletasks() # make sure that the width is up to date
width = window.winfo_screenwidth()
size = tuple(int(_) for _ in window.geometry().split('+')[0].split('x'))
x = width - size[0]
window.geometry("%dx%d+%d+%d" % (size + (x, 0)))
"""Searches specified websites for pesto and outputs the results."""
# The path to the PhantomJS executable (shown below) will need to be changed on your system
# Example path: /Users/owenjow/pesto_check/phantomjs/bin/phantomjs
driver = webdriver.PhantomJS("[PATH-TO-phantomjs]") ### CHANGE THIS ###
driver.wait = WebDriverWait(driver, 5)
# Search UCB dining hall menus
search_and_output(driver, "http://goo.gl/VR8HpB", text, "DC", False)
# Search the Cheese Board weekly menu
search_cheeseboard_and_output(driver, text)
# Search the Sliver weekly menu
search_sliver_and_output(driver, text)
# Bring the Tkinter window to the front
window.lift()
window.attributes("-topmost", True)
text.configure(state="disabled") # there's no need to allow user input!
mainloop()
driver.quit()
示例4: Config
# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import update_idletasks [as 别名]
#.........这里部分代码省略.........
line = "URL1L=" + self.URL1L
f.write(line+"\n")
line = "URL2L=" + self.URL2L
f.write(line+"\n")
line = "URL3L=" + self.URL3L
f.write(line+"\n")
line = "URL4L=" + self.URL4L
f.write(line+"\n")
line = "URL5L=" + self.URL5L
f.write(line+"\n")
line = "OUT=" + self.OUT
f.write(line+"\n")
line = "OPT=" + self.OPT
f.write(line+"\n")
f.close()
if self.checkConf():
self.toggleUrl(self.player)
self.readConf()
self.root.destroy()
#---------------------------------------------------------------------#
def toggleUrl(self, player):
"""Enable / disable url buttons"""
if self.URL1:
s = NORMAL
player.URL1L.set(self.URL1L)
else:
s = DISABLED
player.URL1L.set("N/A")
player.ui_buturl1.configure(state=s)
player.ui_buturl1.update_idletasks()
if self.URL2:
s = NORMAL
player.URL2L.set(self.URL2L)
else:
s = DISABLED
player.URL2L.set("N/A")
player.ui_buturl2.configure(state=s)
player.ui_buturl2.update_idletasks()
if self.URL3:
s = NORMAL
player.URL3L.set(self.URL3L)
else:
s = DISABLED
player.URL3L.set("N/A")
player.ui_buturl3.configure(state=s)
player.ui_buturl3.update_idletasks()
if self.URL4:
s = NORMAL
player.URL4L.set(self.URL4L)
else:
s = DISABLED
player.URL4L.set("N/A")
player.ui_buturl4.configure(state=s)
player.ui_buturl4.update_idletasks()
if self.URL5:
s = NORMAL
player.URL5L.set(self.URL5L)
else:
s = DISABLED
player.URL5L.set("N/A")
player.ui_buturl5.configure(state=s)
player.ui_buturl5.update_idletasks()
示例5: __init__
# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import update_idletasks [as 别名]
class AppEventLoop:
""" An event loop
tk specific application event loop
"""
def __init__(self, app=None):
if app is None:
self.app = Tk()
self.outputs = []
self.events = curio.UniversalQueue()
self.app.bind('<Key>', self.keypress)
def set_event_queue(self, events):
self.events = events
def keypress(self, event):
""" Take tk events and stick them in a curio queue """
self.events.put(event.char)
return True
async def flush(self):
""" Wait for an event to arrive in the queue.
"""
while True:
event = await self.queue.get()
self.app.update_idletasks()
self.app.update()
async def poll(self):
# Experiment with sleep to keep gui responsive
# but not a cpu hog.
event = 0
nap = 0.05
while True:
# FIXME - have Qt do the put when it wants refreshing
await self.put(event)
event += 1
nap = await self.naptime(nap)
# FIXME should do away with the poll loop and just schedule
# for some time in the future.
await curio.sleep(nap)
async def naptime(self, naptime=None):
""" Return the time to nap
FIXME: make this adaptive, but keep it responsive
The idea would be to see how many events each poll produces.
So, if there are a lot of events, shorten the naps.
If there are not so many take a longer nap
This should take into account how fast events are taking to arrive and
how long they are taking to process and balance the two.
And don't sleep too long, in case some other task wakes up and starts talking.
Better still, might be to have something else managing nap times.
For now, keep it simple.
"""
if naptime is None:
nap = 0.05
return naptime
示例6: Tk
# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import update_idletasks [as 别名]
return self.right()
self.canvas.move(self.id, -self.vecx, self.vecy)
return self.left
root = Tk()
root.title("Blobs")
root.resizable(0, 0)
frame = Frame(root, bd=10, relief=SUNKEN)
frame.pack()
canvas = Canvas(frame, width=500, height=300, bd=0, highlightthickness=0)
canvas.pack()
speed = 0.0003
dy = 1
items = [
Ball(canvas, (0, 10), "red", 0.101, 0.020)
]
root.update() # fix geometry
# loop over items
try:
while 1:
for i in range(len(items)):
items[i] = items[i]()
root.update_idletasks() # redraw
time.sleep(.001)
root.update() # process events
except RuntimeError:
pass # to avoid errors when the window is closed
示例7: Tk
# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import update_idletasks [as 别名]
root = Tk()
root.title('KSP Controller')
root.configure(background = "black")
root.geometry('{0}x{1}'.format(c_screen_size_x,c_screen_size_y) + c_screen_pos)
# Instatiate the GUI
app = Application(root, data_array, msgQ)
stage_prev = None
frame_time = time()
# Loop the window, calling an update then refreshing the window
while 1:
if time() > frame_time + 0.250:
frame_time = time()
if app.game_connected == False or app.vessel_connected == False:
app.connect(msgQ)
elif app.conn.krpc.current_game_scene == app.conn.krpc.current_game_scene.flight:
if app.vessel.control.current_stage is not stage_prev:
app.update_streams()
stage_prev = app.vessel.control.current_stage
app.update(data_array, msgQ)
root.update()
root.update_idletasks()
frame_delta = time() - frame_time
if frame_delta > 0.25:
print ('{0:0f}ms'.format(frame_delta*1000))
示例8: Tk
# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import update_idletasks [as 别名]
from tkinter import Tk, Canvas, PhotoImage
import time
import numpy as np
tk = Tk()
canvas = Canvas(tk, width=1000, height=1000)
canvasicon = Canvas(tk, width=300, height=300)
canvaslogo = Canvas(tk, width=300, height=300)
canvasstat = Canvas(tk, width=300, height=300)
canvas.grid(column=0, row=0)
canvasicon.grid(column=1, row=0)
canvaslogo.place(x=1000, y=0)
canvasstat.place(x=1000, y=700)
tk.update_idletasks()
tk.update()
contact_bool = False
launch_bool = False
body_landed = None
dist_body_landed = None
closest_body = None
crash = False
center_shiftx = 0
center_shifty = 0
total_shiftx = 0
total_shifty = 0
contact_number = 0
gravity_constant = 6.67384 * (10**-11)
orbital_velocity_text = canvasstat.create_text(155, 100, text=None, font=('Courier', 10))
velocity_text = canvasstat.create_text(80, 150, text=None, font=('Courier', 10))
name_text = canvasstat.create_text(97, 50, text=None, font=('Courier', 10))
logo = PhotoImage(file='logo.gif')
示例9: Xls2kml
# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import update_idletasks [as 别名]
#.........这里部分代码省略.........
self.pb.grid(row=2, column=0, columnspan=6, padx=5, pady=5, sticky=EW)
# Mainloop -----------------------------------------------------
self.master.mainloop()
def __callback(self): # "Abrir EXEL..." button handler ------------
'''
None -> None
Opens a new window (filedialog.askopenfilename) to choose the
EXCEL file that is necessary to make the KMZ file.
'''
title = 'Selecciona um ficheiro Excel'
message = 'Ficheiro EXCEL carregado em memória.\nTransforma-o em KMZ!'
self.file_name = filedialog.askopenfilename(title=title,
initialdir=self.last_dir)
self.last_dir = self.file_name[:self.file_name.rfind('/')]
if self.file_name[self.file_name.rfind('.')+1:] != 'xls' and \
self.file_name[self.file_name.rfind('.')+1:] != 'xlsx':
message = self.file_name + ' não é um ficheiro Excel válido!'
self.message.set(message)
def __callback_2(self): # "Gravar KMZ" button handler ---------------
'''
None -> None
Calls the function self.__threat()
'''
sleep(1)
message = 'Ficheiro EXCEL carregado em memória.\nTransforma-o em KMZ!'
if self.message.get() != message:
self.message.set("\nEscolhe um ficheiro EXCEL primeiro")
self.master.update_idletasks()
else:
self.message.set("\nA processar...")
self.master.update_idletasks()
sleep(1)
self.__threads()
def __callback_3(self): # "Sair" button handler ---------------------
'''
None -> None
Kills the window
'''
self.master.destroy()
def __threads(self):
'''
None -> MyTread() objects
Creates two threads to run at the same time the functions:
self.__create_kmz()
self.__progressbar()
'''
funcs = [self.__create_kmz, self.__progressbar]
threads = []
nthreads = list(range(len(funcs)))
for i in nthreads:
t = MyThread(funcs[i], (), funcs[i].__name__)
threads.append(t)
for i in nthreads:
threads[i].start()