本文整理汇总了Python中tkinter.Tk.title方法的典型用法代码示例。如果您正苦于以下问题:Python Tk.title方法的具体用法?Python Tk.title怎么用?Python Tk.title使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tkinter.Tk
的用法示例。
在下文中一共展示了Tk.title方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import title [as 别名]
def __init__(self, title):
root = Tk()
root.title(title)
root.focus_set()
root.rowconfigure(0, weight=0)
root.columnconfigure(0, weight=1)
root.rowconfigure(1, weight=1)
self._root = root
self.menubar = Frame(root)
self.menubar.grid(row=0, column=0, sticky=(W, E))
self.menubar['takefocus'] = False
quit_button = Button(self.menubar, text='Quit', command=self.quit)
quit_button.grid(row=0, column=0)
self._menucolumn = 1
self.views = list()
self.paned_win = PanedWindow(root, orient=HORIZONTAL)
self.paned_win.grid(row=1, column=0, sticky=(N, S, W, E))
self._query = None
self._accept_func = None
self.sidebar_views = dict()
self.sidebar_count = 0
self.sidebar = PanedWindow(self.paned_win)
self.paned_win.add(self.sidebar, weight=1)
self.tabs = Notebook(self.paned_win)
self.tabs.enable_traversal()
self.paned_win.add(self.tabs, weight=5)
self.root = self.tabs
示例2: main
# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import title [as 别名]
def main():
'''runs the program'''
square_width = 64
num_cols = 7
num_rows = 6
canvas_width = (num_cols+1)*square_width
canvas_height = (num_rows+1)*square_width
window = Tk()
window.configure(background='black')
window.title("DynaBLASTER")
window.resizable(0,0) #removes maximize option
#window.iconbitmap('icon.ico')
#window.tk.call('tk', 'scaling', 20.0)
canvas = Canvas(window, width=canvas_width, highlightthickness=0,
height=canvas_height, background='#717171')
canvas.grid(row=1,column=0, columnspan=5)
graphics = Graphics(canvas, num_rows, num_cols, square_width, window)
board = Board(canvas, square_width, num_rows, num_cols,
canvas_width, canvas_height)
col=0
row=0
player1 = Player(canvas, board, square_width, graphics, col, row)
col = graphics.cols - 3
row = graphics.rows - 3
player2 = Player(canvas, board, square_width, graphics, col, row)
# Import settings from bindings file
bindings_file = open('bindings.json')
p1_bindings, p2_bindings, gen_bindings = json.load(bindings_file)
window.bind(key_release_of(p1_bindings["Up"]), lambda event:player1.key_release('Up'))
window.bind(key_release_of(p1_bindings["Down"]), lambda event:player1.key_release('Down'))
window.bind(key_release_of(p1_bindings["Left"]), lambda event:player1.key_release('Left'))
window.bind(key_release_of(p1_bindings["Right"]), lambda event:player1.key_release('Right'))
window.bind(p1_bindings["Up"], lambda event:player1.key_press('Up'))
window.bind(p1_bindings["Down"],lambda event:player1.key_press('Down'))
window.bind(p1_bindings["Left"], lambda event:player1.key_press('Left'))
window.bind(p1_bindings["Right"], lambda event:player1.key_press('Right'))
window.bind(p1_bindings["Bomb"], player1.place_bomb)
window.bind(key_release_of(p2_bindings["Up"]), lambda event:player2.key_release('Up'))
window.bind(key_release_of(p2_bindings["Down"]), lambda event:player2.key_release('Down'))
window.bind(key_release_of(p2_bindings["Left"]), lambda event:player2.key_release('Left'))
window.bind(key_release_of(p2_bindings["Right"]), lambda event:player2.key_release('Right'))
window.bind(p2_bindings["Up"], lambda event:player2.key_press('Up'))
window.bind(p2_bindings["Down"], lambda event:player2.key_press('Down'))
window.bind(p2_bindings["Left"], lambda event:player2.key_press('Left'))
window.bind(p2_bindings["Right"], lambda event:player2.key_press('Right'))
window.bind(p2_bindings["Bomb"], player2.place_bomb)
window.bind(gen_bindings["Pause"], lambda event:pause_game(player1, player2, graphics))
window.mainloop()
示例3: to_be_edited
# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import title [as 别名]
def to_be_edited(number, edit):
edit.destroy()
##################
each = contact_list[number]
top = Tk()
top.title('Add Contact')
# Box 1
Label(top, text="Enter your name:").pack(side=TOP)
ent = Entry(top)
ent.insert(INSERT, each['name']) #pre populates the field
ent.pack(side=TOP)
#Box 2
Label(top, text="Enter your number:").pack(side=TOP)
ent2 = Entry(top)
ent2.insert(INSERT, each['number'])
ent2.pack(side=TOP)
# Button 1
btn = Button(top, text="Submit", command=(lambda: saveContact(number,ent.get(), ent2.get())))
btn.pack(side=LEFT)
btn2 = Button(top, text="Exit", command=(lambda: top.destroy()))
btn2.pack(side=LEFT)
def saveContact(place, name, number):
temp_dict = {"name": name, "number": number}
contact_list[place] = temp_dict
showinfo(title='Success', message='Contact Edited!')
del temp_dict
top.mainloop()
####################
tkinter_edit()
示例4: add_contact
# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import title [as 别名]
def add_contact(contact_list, main):
main.destroy()
top = Tk()
top.title('Add Contact')
# Box 1
Label(top, text="Enter your name:").pack(side=TOP)
ent = Entry(top)
ent.pack(side=TOP)
#Box 2
Label(top, text="Enter your number:").pack(side=TOP)
ent2 = Entry(top)
ent2.pack(side=TOP)
# Button 1
btn = Button(top, text="Submit", command=(lambda: saveContact(ent.get(), ent2.get())))
btn.pack(side=LEFT)
btn2 = Button(top, text="Exit", command=(lambda: top.destroy()))
btn2.pack(side=LEFT)
def saveContact(name, number):
temp_dict = {"name": name, "number": number}
contact_list.append(temp_dict)
showinfo(title='Success', message='Contact Added!')
del temp_dict
top.mainloop()
main_menu(contact_list)
示例5: run_pinballview
# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import title [as 别名]
def run_pinballview(width, height, configuration):
"""
Changed from original Pierre-Luc Bacon implementation to reflect
the visualization changes in the PinballView Class.
"""
width, height = float(width), float(height)
master = Tk()
master.title('RLPY Pinball')
screen = Canvas(master, width=500.0, height=500.0)
screen.configure(background='LightGray')
screen.pack()
environment = PinballModel(configuration)
environment_view = PinballView(screen, width, height, environment)
actions = [
PinballModel.ACC_X,
PinballModel.DEC_Y,
PinballModel.DEC_X,
PinballModel.ACC_Y,
PinballModel.ACC_NONE]
done = False
while not done:
user_action = np.random.choice(actions)
environment_view.blit()
if environment.episode_ended():
done = True
if environment.take_action(user_action) == environment.END_EPISODE:
done = True
environment_view.blit()
screen.update()
示例6: deckCreation
# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import title [as 别名]
def deckCreation(self):
from tkinter import Tk
fenetre = Tk()
fenetre.title('Clic to add a monster to deck _ close this windows to end deck creation')
from deck_creation import DeckCreator
a=DeckCreator(fenetre,self.blocked_decks)
fenetre.mainloop()
示例7: main_menu
# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import title [as 别名]
def main_menu(contact_list):
main = Tk()
main.title('Contact List')
Label(main, text="Contact and Adress Book", font = "bold").pack(side=TOP,padx=tk_padx,pady=tk_pady, fill = X)
btn = Button(main, text="Show All/ Edit", command= lambda: show_all(contact_list, main))
btn.pack(side=TOP,padx=tk_padx,pady=tk_pady, fill = X)
btn1 = Button(main, text="Add Contact", command= lambda: add_contact(contact_list, main))
btn1.pack(side=TOP,padx=tk_padx,pady=tk_pady, fill = X)
btn2 = Button(main, text="Delete Contact",command = lambda: delete_contact(contact_list, main))
btn2.pack(side=TOP,padx=tk_padx,pady=tk_pady, fill = X)
btn3 = Button(main, text="Edit Contact", command= lambda: edit_contact(contact_list, main))
btn3.pack(side=TOP,padx=tk_padx,pady=tk_pady, fill = X)
btn4 = Button(main, text="Search Contacts", command= lambda: search_contacts(contact_list, main))
btn4.pack(side=TOP,padx=tk_padx,pady=tk_pady, fill = X)
btn5 = Button(main, text="Format and Sort Contacts", command =lambda: format_contacts(contact_list,main))
btn5.pack(side=TOP,padx=tk_padx,pady=tk_pady, fill = X)
btn6 = Button(main, text="Make A Printable List", command =lambda: printable(contact_list,main))
btn6.pack(side=TOP,padx=tk_padx,pady=tk_pady, fill = X)
btn7 = Button(main,bg = "red", text="Exit Contacts", command= lambda: exit_list(contact_list, main))
btn7.pack(side=TOP,padx=tk_padx,pady=tk_pady, fill = X)
btn8 = Button(main,text="About AppGui", command= lambda: about(main))
btn8.pack(side=TOP,padx=tk_padx,pady=tk_pady, fill = X)
main.mainloop()
示例8: main
# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import title [as 别名]
def main():
'''Main function.'''
root_window = Tk()
root_window.title("Card Hand Widget Demo")
# Set default options
use_large_images = False
num_cards = 3
# Override with specified options from command line, if any
for arg in sys.argv:
if arg.lower() == 'large':
use_large_images = True
else:
try:
num_arg = int(arg)
if num_arg > 0 and num_arg < 8:
num_cards = num_arg
except ValueError:
pass
# Create and pack widget, then run main Tk loop.
demo_window = DemoWindow(root_window,
use_large_images=use_large_images,
num_cards=num_cards)
demo_window.pack(side=TOP)
root_window.mainloop()
示例9: main
# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import title [as 别名]
def main():
log = logging.getLogger()
log.setLevel(logging.ERROR)
parser = argparse.ArgumentParser(description='Run stuff')
parser.add_argument('--server', action='store_true', default=False)
parser.add_argument('--debug', action='store_true', default=False)
parser.add_argument('--file_root', default=os.path.expanduser('~'))
parser.add_argument('--full', action='store_true', default=False)
args = parser.parse_args()
if args.debug:
log.setLevel(logging.DEBUG)
root = Tk()
config = Config()
config.full_screen = args.full
config.set_file_root(os.path.expanduser(args.file_root))
s = Style()
s.configure('Treeview', rowheight=config.tree_item_height)
s.configure('TButton', font='Helvetica 16')
s.configure('Vertical.TScrollbar', arrowsize=config.sb_size)
if args.server:
fs = FileServer(config.web_port, config)
fs.run(debug=True)
else:
root.title('copilot')
app = HomeFrame(root, config)
root.mainloop()
示例10: setUpCanvas
# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import title [as 别名]
def setUpCanvas():
from tkinter import Tk, Canvas, YES, BOTH
root = Tk()
root.title("A Tk/Python Graphics Program")
canvas = Canvas(root, width = 1270, height = 780, bg = 'black')
canvas.pack(expand = YES, fill = BOTH)
return canvas, root
示例11: show_captcha
# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import title [as 别名]
def show_captcha(self,img_file):
dialogRoot = Tk()
dialogRoot.title("Input text.")
img = PhotoImage(file=img_file)
frame = Frame(dialogRoot)
imal = Label(frame, image=img)
imal.pack()
label = Label(frame)
label['text'] = "Your Input:"
label.pack(side=LEFT)
inputEntry = Entry(frame)
inputEntry["width"] = 50
inputEntry.pack(side=LEFT)
def getInputText():
'''callback of button'''
# global inputEntry, dialogRoot
if inputEntry.get().strip() == "":
print("Please enter a message.")
else:
self.captcha_ans = inputEntry.get().strip()
dialogRoot.destroy()
button = Button(frame, text="Submit", command=getInputText)
button.pack(side=LEFT)
frame.pack()
dialogRoot.mainloop()
示例12: ingresarUsuario
# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import title [as 别名]
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())
示例13: open_main
# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import title [as 别名]
def open_main():
btn_dims = int(settings["gui"]["btn_dims"])
_xt_root = Tk()
if settings["gui"]["bypass_wm"] == "1":
_xt_root.overrideredirect(1)
_xt_root.title("Xtouchy Toolbox")
_xt_root.maxsize(btn_dims * 3, btn_dims * 3)
root_frame = ttk.Frame(_xt_root, padding="0 0 0 0", width=btn_dims * 3, height=btn_dims * 3)
root_frame.grid(column=1, row=0, sticky=("N", "W", "E", "S"))
# Screen orientation
wrkbtn = ttk.Button(root_frame, width=2, text="↑", command=lambda: rotate(0, _xt_root))
wrkbtn.place(x=btn_dims, y=0, width=btn_dims, height=btn_dims)
wrkbtn = ttk.Button(root_frame, width=2, text="↓", command=lambda: rotate(2, _xt_root))
wrkbtn.place(x=btn_dims, y=btn_dims * 2, width=btn_dims, height=btn_dims)
wrkbtn = ttk.Button(root_frame, width=2, text="←", command=lambda: rotate(1, _xt_root))
wrkbtn.place(x=0, y=btn_dims, width=btn_dims, height=btn_dims)
wrkbtn = ttk.Button(root_frame, width=2, text="→", command=lambda: rotate(3, _xt_root))
wrkbtn.place(x=btn_dims * 2, y=btn_dims, width=btn_dims, height=btn_dims)
# Close/Move button
mvbtn = ttk.Button(root_frame, width=2, text="⇱")
mvbtn.bind("<B1-Motion>", lambda x: move(x, _xt_root))
mvbtn.place(x=0, y=0, width=btn_dims, height=btn_dims)
ttk.Button(root_frame, width=2, text="X", command=lambda: reset_and_exit(_xt_root)).place(
x=btn_dims * 2, y=0, width=btn_dims, height=btn_dims
)
# Toggle virtual keyboard
tvkbtn = ttk.Button(root_frame, width=2, text="K")
tvkbtn.bind("<B1-Motion>", lambda x: move_vkeyboard(x, _xt_root))
tvkbtn.place(x=0, y=btn_dims * 2, width=btn_dims, height=btn_dims)
_xt_root.mainloop()
示例14: Application
# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import title [as 别名]
class Application(object):
def __init__(self):
self.helper = YouDaoHelper()
self.window = Tk()
self.window.title(u'知了词典')
self.window.geometry("280x350+700+300")
# 输入框
self.entry = Entry(self.window)
self.entry.place(x=10, y=10, width=200, height=25)
# 提交按钮
self.submit_btn = Button(self.window, text=u'查询', command=self.submit)
self.submit_btn.place(x=220, y=10, width=50, height=25)
# 翻译结果标题
self.title_label = Label(self.window, text=u'翻译结果:')
self.title_label.place(x=10, y=55)
# 翻译结果
self.result_text = Text(self.window, background='#ccc')
self.result_text.place(x=10, y=75, width=260, height=265)
def submit(self):
# 1. 从输入框中获取用户输入的值
content = self.entry.get()
# 2. 把这个值发送给有道的服务器,进行翻译
result = self.helper.crawl(content)
# 3. 把结果放在底部的Text控件中
self.result_text.delete(1.0,END)
self.result_text.insert(END,result)
def run(self):
self.window.mainloop()
示例15: ua_win_tk
# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import title [as 别名]
def ua_win_tk(url, pipe = None):
from tkinter import Tk, Frame, Label, Entry, StringVar, BOTH, Button, RIGHT
import sys
sys.stdout.flush()
instructions = "Visit the following URL to authorize the application:"
response = {"x": False}
root = Tk()
root.title("oAuth2 Authorization Required")
webbox = Frame(root)
instructions = Label(webbox, text = instructions)
instructions.pack(padx = 5, pady = 5)
urlstr = StringVar(value = url)
urlbox = Entry(webbox, textvariable = urlstr, state = "readonly")
urlbox.pack(padx = 5, pady = 5)
def open_browser():
from subprocess import Popen
p = Popen(["sensible-browser", url])
browserbutton = Button(webbox, text = "Open in web browser", command = open_browser)
browserbutton.pack(padx = 5, pady = 5)
webbox.pack(fill = BOTH, expand = 1)
if pipe:
def poll():
if pipe.poll():
root.destroy()
#Mutability ftw... wat
response["x"] = True
else:
root.after(300, poll)
root.after(300, poll)
cancelbutton = Button(root, text = "Cancel", command = root.destroy)
cancelbutton.pack(side = RIGHT, padx = 5, pady = 5)
root.mainloop()
return response["x"]