本文整理汇总了Python中tkinter.Toplevel方法的典型用法代码示例。如果您正苦于以下问题:Python tkinter.Toplevel方法的具体用法?Python tkinter.Toplevel怎么用?Python tkinter.Toplevel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tkinter
的用法示例。
在下文中一共展示了tkinter.Toplevel方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: popup
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import Toplevel [as 别名]
def popup(self, window, title, image, text, button_text, end_command=None):
popup = tk.Toplevel(window)
popup.resizable(False, False)
if MAIN_ICON != None:
if os.path.splitext(MAIN_ICON)[1].lower() == ".gif":
dummy = None
#popup.call('wm', 'iconphoto', popup._w, tk.PhotoImage(file=MAIN_ICON))
else:
popup.iconbitmap(MAIN_ICON)
popup.wm_title(title)
popup.tkraise(window)
def run_end():
popup.destroy()
if end_command != None:
end_command()
picture_label = tk.Label(popup, image=image)
picture_label.photo = image
picture_label.grid(column=0, row=0, rowspan=2, padx=10, pady=10)
tk.Label(popup, text=text, justify=tk.CENTER).grid(column=1, row=0, padx=10, pady=10)
tk.Button(popup, text=button_text, command=run_end).grid(column=1, row=1, padx=10, pady=10)
popup.wait_visibility()
popup.grab_set()
popup.wait_window()
示例2: video_invite_window
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import Toplevel [as 别名]
def video_invite_window(message, inviter_name):
invite_window = tkinter.Toplevel()
invite_window.geometry('300x100')
invite_window.title('Invitation')
label1 = tkinter.Label(invite_window, bg='#f0f0f0', width=20, text=inviter_name)
label1.pack()
label2 = tkinter.Label(invite_window, bg='#f0f0f0', width=20, text='invites you to video chat!')
label2.pack()
def accept_invite():
invite_window.destroy()
video_accept(message[message.index('INVITE') + 6:])
def refuse_invite():
invite_window.destroy()
Refuse = tkinter.Button(invite_window, text="Refuse", command=refuse_invite)
Refuse.place(x=60, y=60, width=60, height=25)
Accept = tkinter.Button(invite_window, text="Accept", command=accept_invite)
Accept.place(x=180, y=60, width=60, height=25)
示例3: __init__
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import Toplevel [as 别名]
def __init__(self, main_window, msg='Please enter a node:'):
tk.Toplevel.__init__(self)
self.main_window = main_window
self.title('Node Entry')
self.geometry('170x160')
self.rowconfigure(3, weight=1)
tk.Label(self, text=msg).grid(row=0, column=0, columnspan=2,
sticky='NESW',padx=5,pady=5)
self.posibilities = [d['dataG_id'] for n,d in
main_window.canvas.dispG.nodes_iter(data=True)]
self.entry = AutocompleteEntry(self.posibilities, self)
self.entry.bind('<Return>', lambda e: self.destroy(), add='+')
self.entry.grid(row=1, column=0, columnspan=2, sticky='NESW',padx=5,pady=5)
tk.Button(self, text='Ok', command=self.destroy).grid(
row=3, column=0, sticky='ESW',padx=5,pady=5)
tk.Button(self, text='Cancel', command=self.cancel).grid(
row=3, column=1, sticky='ESW',padx=5,pady=5)
# Make modal
self.winfo_toplevel().wait_window(self)
示例4: combineAction
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import Toplevel [as 别名]
def combineAction():
global course_json
other_course_dir = tk.filedialog.askdirectory(initialdir = ".", title = "Select second course directory")
if other_course_dir:
drawPlaceholder()
course1_json = copy.deepcopy(course_json) # Make copy so this isn't "permanent" in memory
course2_json = tgc_tools.get_course_json(other_course_dir)
course1_json = tgc_tools.merge_courses(course1_json, course2_json)
drawCourse(course1_json)
popup = tk.Toplevel()
popup.geometry("400x400")
popup.wm_title("Confirm course merge?")
label = ttk.Label(popup, text="Confirm course merge?")
label.pack(side="top", fill="x", pady=10)
B1 = ttk.Button(popup, text="Yes, Merge", command = partial(confirmCourse, popup, course1_json))
B1.pack()
B2 = ttk.Button(popup, text="No, Abandon Merge", command = partial(confirmCourse, popup, None))
B2.pack()
popup.mainloop()
示例5: make_figure_window
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import Toplevel [as 别名]
def make_figure_window(self):
self.figure_window = tk.Toplevel(self)
self.figure_window.wm_title('Preview')
screen_dpi = self.figure_window.winfo_fpixels('1i')
screen_width = self.figure_window.winfo_screenwidth() # in pixels
figure_width = screen_width / 2 / screen_dpi
figure_height = 0.75 * figure_width
self.figure = Figure(figsize=(figure_width, figure_height),
dpi=screen_dpi)
ax0 = self.figure.add_subplot(221)
axes = [self.figure.add_subplot(220 + i, sharex=ax0, sharey=ax0)
for i in range(2, 5)]
self.axes = np.array([ax0] + axes)
canvas = FigureCanvasTkAgg(self.figure, master=self.figure_window)
canvas.show()
canvas.get_tk_widget().pack(side=tk.TOP, fill=tk.BOTH, expand=1)
toolbar = NavigationToolbar2Tk(canvas, self.figure_window)
toolbar.update()
canvas._tkcanvas.pack(side=tk.TOP, fill=tk.BOTH, expand=1)
示例6: __init__
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import Toplevel [as 别名]
def __init__(self, loginQueue):
tk.Toplevel.__init__(self)
self.configure(pady=10, padx=20)
self.wm_attributes("-topmost", True)
self.wm_title("PyEveLiveDPS Awaiting Login")
try:
self.iconbitmap(sys._MEIPASS + '\\app.ico')
except Exception:
try:
self.iconbitmap("app.ico")
except Exception:
pass
self.geometry("200x50")
self.update_idletasks()
tk.Label(self, text='Waiting for you to login...').grid(row=1, column=1)
self.loginStatus = loginQueue.get()
self.destroy()
示例7: show
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import Toplevel [as 别名]
def show(self):
self.leave()
self.tip = tk.Toplevel(self.master)
self.tip.withdraw() # Don't show until we have the geometry
self.tip.wm_overrideredirect(True) # No window decorations etc.
if TkUtil.mac():
self.tip.tk.call("::tk::unsupported::MacWindowStyle",
"style", self.tip._w, "help", "none")
label = ttk.Label(self.tip, text=self.text, padding=1,
background=self.background, wraplength=480,
relief=None if TkUtil.mac() else tk.GROOVE,
font=tkfont.nametofont("TkTooltipFont"))
label.pack()
x, y = self.position()
self.tip.wm_geometry("+{}+{}".format(x, y))
self.tip.deiconify()
if self.master.winfo_viewable():
self.tip.transient(self.master)
self.tip.update_idletasks()
self.timerId = self.master.after(self.showTime, self.hide)
示例8: show_growth_chart
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import Toplevel [as 别名]
def show_growth_chart(self):
data = self.data_model.get_growth_by_lab()
max_x = max([x['day'] for x in data])
max_y = max([x['avg_height'] for x in data])
popup = tk.Toplevel()
chart = v.LineChartView(popup, 600, 300, 'day',
'centimeters', max_x, max_y)
chart.pack(fill='both', expand=1)
legend = {'A': 'green', 'B': 'blue', 'C': 'cyan',
'D': 'yellow', 'E': 'purple'}
chart.draw_legend(legend)
for lab, color in legend.items():
dataxy = [
(x['day'], x['avg_height'])
for x in data
if x['lab_id'] == lab]
chart.plot_line(dataxy, color)
示例9: show_yield_chart
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import Toplevel [as 别名]
def show_yield_chart(self):
popup = tk.Toplevel()
chart = v.YieldChartView(popup,
'Average plot humidity', 'Average Plot temperature',
'Yield as a product of humidity and temperature')
chart.pack(fill='both', expand=True)
data = self.data_model.get_yield_by_plot()
seed_colors = {'AXM477': 'red', 'AXM478': 'yellow',
'AXM479': 'green', 'AXM480': 'blue'}
for seed, color in seed_colors.items():
seed_data = [
(x['avg_humidity'], x['avg_temperature'], x['yield'])
for x in data if x['seed_sample'] == seed]
chart.draw_scatter(seed_data, color, seed)
示例10: showtip
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import Toplevel [as 别名]
def showtip(self, text):
"Display text in tooltip window"
self.text = text
if self.tipwindow or not self.text:
return
x, y, _, _ = self.widget.bbox("insert")
x = x + self.widget.winfo_rootx() + 27
y = y + self.widget.winfo_rooty()
self.tipwindow = tw = tk.Toplevel(self.widget)
tw.wm_overrideredirect(1)
tw.wm_geometry("+%d+%d" % (x, y))
try:
# For Mac OS
tw.tk.call("::tk::unsupported::MacWindowStyle",
"style", tw._w,
"help", "noActivates")
except tk.TclError:
pass
label = tk.Label(tw, text=self.text, justify=tk.LEFT,
background="#ffffe0", relief=tk.SOLID, borderwidth=1)
label.pack(ipadx=1)
示例11: _show
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import Toplevel [as 别名]
def _show(image, title):
"""Helper for the Image.show method."""
class UI(tkinter.Label):
def __init__(self, master, im):
if im.mode == "1":
self.image = BitmapImage(im, foreground="white", master=master)
else:
self.image = PhotoImage(im, master=master)
tkinter.Label.__init__(self, master, image=self.image,
bg="black", bd=0)
if not tkinter._default_root:
raise IOError("tkinter not initialized")
top = tkinter.Toplevel()
if title:
top.title(title)
UI(top, image).pack()
示例12: _show
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import Toplevel [as 别名]
def _show(image, title):
"""Helper for the Image.show method."""
class UI(tkinter.Label):
def __init__(self, master, im):
if im.mode == "1":
self.image = BitmapImage(im, foreground="white", master=master)
else:
self.image = PhotoImage(im, master=master)
super().__init__(master, image=self.image, bg="black", bd=0)
if not tkinter._default_root:
raise OSError("tkinter not initialized")
top = tkinter.Toplevel()
if title:
top.title(title)
UI(top, image).pack()
示例13: show_tip
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import Toplevel [as 别名]
def show_tip(self, tip_text):
"Display text in a tooltip window"
if self.tip_window or not tip_text:
return
x, y, _cx, cy = self.widget.bbox("insert") # get size of widget
x = x + self.widget.winfo_rootx() + 25 # calculate to display tooltip
y = y + cy + self.widget.winfo_rooty() + 25 # below and to the right
self.tip_window = tw = tk.Toplevel(self.widget) # create new tooltip window
tw.wm_overrideredirect(True) # remove all Window Manager (wm) decorations
# tw.wm_overrideredirect(False) # uncomment to see the effect
tw.wm_geometry("+%d+%d" % (x, y)) # create window size
label = tk.Label(tw, text=tip_text, justify=tk.LEFT,
background="#ffffe0", relief=tk.SOLID, borderwidth=1,
font=("tahoma", "8", "normal"))
label.pack(ipadx=1)
示例14: showtip
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import Toplevel [as 别名]
def showtip(self, text):
"Display text in tooltip window"
self.text = text
if self.tipwindow or not self.text:
return
x, y, _cx, cy = self.widget.bbox("insert")
x = x + self.widget.winfo_rootx() + 27
y = y + cy + self.widget.winfo_rooty() +27
self.tipwindow = tw = tk.Toplevel(self.widget)
tw.wm_overrideredirect(1)
tw.wm_geometry("+%d+%d" % (x, y))
label = tk.Label(tw, text=self.text, justify=tk.LEFT,
background="#ffffe0", relief=tk.SOLID, borderwidth=1,
font=("tahoma", "8", "normal"))
label.pack(ipadx=1)
示例15: showtip
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import Toplevel [as 别名]
def showtip(self, text):
"Display text in a ToolTip window"
self.text = text
if self.tipwindow or not self.text: return
try:
x, y, _cx, cy = self.widget.bbox("insert")
x = x + self.widget.winfo_rootx() + 25
y = y + cy + self.widget.winfo_rooty() +25
self.tipwindow = tw = tk.Toplevel(self.widget)
tw.wm_overrideredirect(1)
tw.wm_geometry("+%d+%d" % (x, y))
label = tk.Label(tw, text=self.text, justify=tk.LEFT,
background="#ffffe0", relief=tk.SOLID, borderwidth=1,
font=("tahoma", "8", "normal"))
label.pack(ipadx=1)
except: pass
开发者ID:PacktPublishing,项目名称:Python-GUI-Programming-Cookbook-Second-Edition,代码行数:18,代码来源:GUI_FallDown.py