本文整理汇总了Python中tkinter.Toplevel类的典型用法代码示例。如果您正苦于以下问题:Python Toplevel类的具体用法?Python Toplevel怎么用?Python Toplevel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Toplevel类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, master, text, *args, **kwargs):
self.master = master
Toplevel.__init__(self, master, *args, **kwargs)
# Setup text box.
self.text = Text(self, width=60, height=20, wrap=NONE)
self.text.insert("1.0", text)
self.text["state"] = "disabled"
self.text.grid(row=0, column=0, sticky="NESW")
# Create a vertical scrollbar.
scrolly = Scrollbar(self, orient="vertical",
command=self.text.yview)
scrolly.grid(row=0, column=1, sticky="NS")
# Create a horizontal scrollbar.
scrollx = Scrollbar(self, orient="horizontal",
command=self.text.xview)
scrollx.grid(row=1, column=0, columnspan=2, sticky="EW")
# Add the scroll bars.
self.text.configure(yscrollcommand=scrolly.set,
xscrollcommand=scrollx.set)
# Setup special configurings.
self.transient(master)
self.protocol("WM_DELETE_WINDOW", self.cancel)
self.grab_set()
self.focus_set()
self.wait_window(self)
开发者ID:I8087,项目名称:GratiotIDE,代码行数:30,代码来源:Error.py
示例2: __init__
def __init__(self, parent, filename, title):
Toplevel.__init__(self, parent)
self.wm_title(title)
self.protocol("WM_DELETE_WINDOW", self.destroy)
HelpFrame(self, filename).grid(column=0, row=0, sticky='nsew')
self.grid_columnconfigure(0, weight=1)
self.grid_rowconfigure(0, weight=1)
开发者ID:whqkdhfh13,项目名称:sswp,代码行数:7,代码来源:help.py
示例3: __init__
def __init__(self, client):
# Basic setup
super(Preferences, self).__init__()
self.client = client
# Setup the variables used
self.echo_input = BooleanVar()
self.echo_input.set(self.client.config['UI'].getboolean('echo_input'))
self.echo_input.trace("w", self.echo_handler)
self.logging = BooleanVar()
self.logging.set(self.client.config['logging'].getboolean('log_session'))
self.logging.trace('w', self.logging_handler)
self.log_dir = self.client.config['logging']['log_directory']
# Build the actual window and widgets
prefs = Toplevel(self)
prefs.wm_title("Preferences")
echo_input_label = Label(prefs, text="Echo Input:")
logging_label = Label(prefs, text='Log to file:')
echo_checkbox = Checkbutton(prefs, variable=self.echo_input)
logging_checkbox = Checkbutton(prefs, variable=self.logging)
logging_button_text = 'Choose file...' if self.log_dir == "" else self.log_dir
logging_button = Button(prefs, text=logging_button_text, command=self.logging_pick_location)
# Pack 'em in.
echo_input_label.grid(row=0, column=0)
echo_checkbox.grid(row=0, column=1)
logging_label.grid(row=1, column=0)
logging_checkbox.grid(row=1, column=1)
logging_button.grid(row=1, column=2)
开发者ID:Errorprone85,项目名称:TEC-Client,代码行数:30,代码来源:preferences.py
示例4: _io_binding
def _io_binding(parent): # htest #
from tkinter import Toplevel, Text
from idlelib.configHandler import idleConf
root = Toplevel(parent)
root.title("Test IOBinding")
width, height, x, y = list(map(int, re.split('[x+]', parent.geometry())))
root.geometry("+%d+%d"%(x, y + 150))
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)
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>>")
text = Text(root)
text.pack()
text.focus_set()
editwin = MyEditWin(text)
IOBinding(editwin)
开发者ID:BCSharp,项目名称:ironpython3,代码行数:27,代码来源:IOBinding.py
示例5: helpAbout
def helpAbout(self):
print("Digital Cookbook v1.0 - Theodore Lindsey")
aboutDialog = Toplevel()
aboutDialog.geometry("200x100+300+300")
aboutDialog.title("About Digital Cookbook")
Message(aboutDialog, text="Digital Cookbook v1.0\nTheodore Lindsey").pack(side=TOP, fill=BOTH, expand=1)
Button(aboutDialog, text="Ok", command=aboutDialog.destroy).pack(side=TOP)
开发者ID:RagingRoosevelt,项目名称:RecipeManagerV2,代码行数:7,代码来源:gui.py
示例6: __init__
def __init__(self, parent, title, message, *, _htest=False, _utest=False): # Call from override.
"""Create popup, do not return until tk widget destroyed.
Additional subclass init must be done before calling this.
title - string, title of popup dialog
message - string, informational message to display
_htest - bool, change box location when running htest
_utest - bool, leave window hidden and not modal
"""
Toplevel.__init__(self, parent)
self.configure(borderwidth=5)
self.resizable(height=FALSE, width=FALSE)
self.title(title)
self.transient(parent)
self.grab_set()
self.bind("<Key-Return>", self.ok)
self.protocol("WM_DELETE_WINDOW", self.cancel)
self.parent = parent
self.message = message
self.create_widgets()
self.update_idletasks()
# needs to be done here so that the winfo_reqwidth is valid
self.withdraw() # Hide while configuring, especially geometry.
self.geometry(
"+%d+%d"
% (
parent.winfo_rootx() + (parent.winfo_width() / 2 - self.winfo_reqwidth() / 2),
parent.winfo_rooty()
+ ((parent.winfo_height() / 2 - self.winfo_reqheight() / 2) if not _htest else 150),
)
) # centre dialog over parent (or below htest box)
if not _utest:
self.deiconify() # geometry set, unhide
self.wait_window()
开发者ID:xulukai,项目名称:cpython,代码行数:35,代码来源:query.py
示例7: __init__
def __init__(self, master, **options):
""" créer le Toplevel 'À propos de Sudoku-Tk' """
Toplevel.__init__(self, master, class_="Sudoku-Tk", **options)
self.title(_("About Sudoku-Tk"))
self.transient(master)
self.grab_set()
# set_icon(self)
self.image = open_image(ICONE_48)
Label(self, image=self.image).grid(row=0, columnspan=2, pady=10)
Label(self,
text=_("Sudoku-Tk %(version)s")
% ({"version": VERSION})).grid(row=1, columnspan=2)
Label(self, text=_("Sudoku games and puzzle solver")).grid(row=2, columnspan=2, padx=10)
Label(self, text="Copyright (C) Juliette Monsel 2016-2018").grid(row=3, columnspan=2)
Label(self, text="[email protected]").grid(row=4, columnspan=2)
Button(self, text=_("License"), command=self._license).grid(row=5, column=0, pady=(20, 10), padx=(10,4))
Button(self, text=_("Close"), command=self._quitter).grid(row=5, column=1, pady=(20, 10), padx=(4,10))
self.initial_focus = self
self.protocol("WM_DELETE_WINDOW", self._quitter)
self.resizable(0, 0)
self.initial_focus.focus_set()
self.wait_window(self)
开发者ID:j4321,项目名称:Sudoku-Tk,代码行数:26,代码来源:about.py
示例8: toplevel
def toplevel(parent, title):
t = Toplevel(parent, borderwidth=8)
t.title(title)
x = parent.winfo_rootx()
y = parent.winfo_rooty()
t.geometry('+{}+{}'.format(x+4, y+4))
return t
开发者ID:zapfsaeulius,项目名称:zephyrus,代码行数:7,代码来源:gui.py
示例9: __init__
def __init__(self, parent, case, val_ou_pos, **options):
""" créer le Toplevel 'À propos de Bracelet Generator' """
Toplevel.__init__(self, parent, **options)
self.withdraw()
self.type = val_ou_pos # clavier pour rentrer une valeur ou une possibilité
self.overrideredirect(True)
self.case = case
self.transient(self.master)
self.style = Style(self)
self.style.configure("clavier.TButton", font="Arial 12")
self.boutons = [[Button(self, text="1", width=2, style="clavier.TButton", command=lambda: self.entre_nb(1)),
Button(self, text="2", width=2, style="clavier.TButton", command=lambda: self.entre_nb(2)),
Button(self, text="3", width=2, style="clavier.TButton", command=lambda: self.entre_nb(3))],
[Button(self, text="4", width=2, style="clavier.TButton", command=lambda: self.entre_nb(4)),
Button(self, text="5", width=2, style="clavier.TButton", command=lambda: self.entre_nb(5)),
Button(self, text="6", width=2, style="clavier.TButton", command=lambda: self.entre_nb(6))],
[Button(self, text="7", width=2, style="clavier.TButton", command=lambda: self.entre_nb(7)),
Button(self, text="8", width=2, style="clavier.TButton", command=lambda: self.entre_nb(8)),
Button(self, text="9", width=2, style="clavier.TButton", command=lambda: self.entre_nb(9))]]
for i in range(3):
for j in range(3):
self.boutons[i][j].grid(row=i, column=j)
self.protocol("WM_DELETE_WINDOW", self.quitter)
self.resizable(0, 0)
self.attributes("-topmost", 0)
开发者ID:j4321,项目名称:Sudoku-Tk,代码行数:25,代码来源:clavier.py
示例10: _replace_dialog
def _replace_dialog(parent): # htest #
from tkinter import Toplevel, Text
from tkiter.ttk import Button
box = Toplevel(parent)
box.title("Test ReplaceDialog")
x, y = map(int, parent.geometry().split('+')[1:])
box.geometry("+%d+%d" % (x, y + 175))
# mock undo delegator methods
def undo_block_start():
pass
def undo_block_stop():
pass
text = Text(box, inactiveselectbackground='gray')
text.undo_block_start = undo_block_start
text.undo_block_stop = undo_block_stop
text.pack()
text.insert("insert","This is a sample sTring\nPlus MORE.")
text.focus_set()
def show_replace():
text.tag_add(SEL, "1.0", END)
replace(text)
text.tag_remove(SEL, "1.0", END)
button = Button(box, text="Replace", command=show_replace)
button.pack()
开发者ID:Darkness0ut,项目名称:cpython,代码行数:30,代码来源:replace.py
示例11: __init__
def __init__(self):
Toplevel.__init__(self)
self.focus_set()
self.grab_set()
self.result = None
self.module_data = None
self.mod_applis = None
self.title(ugettext("Instance editor"))
self.grid_columnconfigure(0, weight=1)
self.grid_rowconfigure(0, weight=1)
self.ntbk = ttk.Notebook(self)
self.ntbk.grid(row=0, column=0, columnspan=1, sticky=(N, S, E, W))
self.frm_general = Frame(self.ntbk, width=350, height=150)
self.frm_general.grid_columnconfigure(0, weight=0)
self.frm_general.grid_columnconfigure(1, weight=1)
self._general_tabs()
self.ntbk.add(self.frm_general, text=ugettext('General'))
self.frm_database = Frame(self.ntbk, width=350, height=150)
self.frm_database.grid_columnconfigure(0, weight=0)
self.frm_database.grid_columnconfigure(1, weight=1)
self._database_tabs()
self.ntbk.add(self.frm_database, text=ugettext('Database'))
btnframe = Frame(self, bd=1)
btnframe.grid(row=1, column=0, columnspan=1)
Button(btnframe, text=ugettext("OK"), width=10, command=self.apply).grid(
row=0, column=0, sticky=(N, S, E))
Button(btnframe, text=ugettext("Cancel"), width=10, command=self.destroy).grid(
row=0, column=1, sticky=(N, S, W))
开发者ID:povtux,项目名称:core,代码行数:33,代码来源:lucterios_gui.py
示例12: __init__
def __init__(self, parent, title=None, *, _htest=False, _utest=False):
"""Create popup, do not return until tk widget destroyed.
parent - parent of this dialog
title - string which is title of popup dialog
_htest - bool, change box location when running htest
_utest - bool, don't wait_window when running unittest
"""
Toplevel.__init__(self, parent)
self.configure(borderwidth=5)
# place dialog below parent if running htest
self.geometry("+%d+%d" % (
parent.winfo_rootx()+30,
parent.winfo_rooty()+(30 if not _htest else 100)))
self.bg = "#bbbbbb"
self.fg = "#000000"
self.create_widgets()
self.resizable(height=False, width=False)
self.title(title or
f'About IDLE {python_version()} ({build_bits()} bit)')
self.transient(parent)
self.grab_set()
self.protocol("WM_DELETE_WINDOW", self.ok)
self.parent = parent
self.button_ok.focus_set()
self.bind('<Return>', self.ok) # dismiss dialog
self.bind('<Escape>', self.ok) # dismiss dialog
self._current_textview = None
self._utest = _utest
if not _utest:
self.deiconify()
self.wait_window()
开发者ID:1st1,项目名称:cpython,代码行数:33,代码来源:help_about.py
示例13: __init__
def __init__(self, parent):
Toplevel.__init__(self, parent)
self.configure(borderwidth=0)
self.geometry("+%d+%d" % (
parent.winfo_rootx()+30,
parent.winfo_rooty()+30))
self.vbar = Scrollbar(self)
self.text = Text(self, wrap='word', borderwidth='0p')
self.vbar['command'] = self.text.yview
self.vbar.pack(side=RIGHT, fill='y')
self.text['yscrollcommand'] = self.vbar.set
self.text.pack(expand=1, fill="both")
try:
f = open(README_PATH)
self.text.delete(1.0)
self.text.insert(1.0, f.read())
self.text.delete('end - 1 chars')
except:
showerror("Error", "Cannot load README!")
self.text.config(state='disabled')
self.title('README')
self.protocol("WM_DELETE_WINDOW", self.close)
self.parent = parent
self.bind('<Escape>', self.close)
开发者ID:ZanderBrown,项目名称:Tiborcim,代码行数:26,代码来源:cim.py
示例14: destroy
def destroy(self):
registry.delete(self)
Toplevel.destroy(self)
# If this is Idle's last window then quit the mainloop
# (Needed for clean exit on Windows 98)
if not registry.dict:
self.quit()
开发者ID:Eyepea,项目名称:cpython,代码行数:7,代码来源:window.py
示例15: display_image
def display_image(title,image):
win = Toplevel(root)
photo = ImageTk.PhotoImage(image)
win.title(title)
label = Label(win,image=photo)
label.image = photo #Kludge: keep a reference to avoid garbage collection!
label.pack()
开发者ID:cmarch314,项目名称:PythonProjects,代码行数:7,代码来源:pildemo.py
示例16: _io_binding
def _io_binding(parent): # htest #
from tkinter import Toplevel, Text
root = Toplevel(parent)
root.title("Test IOBinding")
x, y = map(int, parent.geometry().split('+')[1:])
root.geometry("+%d+%d" % (x, y + 175))
class MyEditWin:
def __init__(self, text):
self.text = text
self.flist = None
self.text.bind("<Control-o>", self.open)
self.text.bind('<Control-p>', self.print)
self.text.bind("<Control-s>", self.save)
self.text.bind("<Alt-s>", self.saveas)
self.text.bind('<Control-c>', self.savecopy)
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 print(self, event):
self.text.event_generate("<<print-window>>")
def save(self, event):
self.text.event_generate("<<save-window>>")
def saveas(self, event):
self.text.event_generate("<<save-window-as-file>>")
def savecopy(self, event):
self.text.event_generate("<<save-copy-of-window-as-file>>")
text = Text(root)
text.pack()
text.focus_set()
editwin = MyEditWin(text)
IOBinding(editwin)
开发者ID:3lnc,项目名称:cpython,代码行数:35,代码来源:iomenu.py
示例17: __init__
def __init__(self, parent=None, title="", message="", button="Ok", image=None, **options):
"""
Create a message box with one button:
parent: parent of the toplevel window
title: message box title
message: message box text
button: message displayed on the button
image: image displayed at the left of the message
**options: other options to pass to the Toplevel.__init__ method
"""
Toplevel.__init__(self, parent, **options)
self.transient(parent)
self.resizable(False, False)
self.title(title)
if image:
Label(self, text=message, wraplength=335,
font="Sans 11", compound="left", image=image).grid(row=0, padx=10, pady=10)
else:
Label(self, text=message, wraplength=335,
font="Sans 11").grid(row=0, padx=10, pady=10)
b = Button(self, text=button, command=self.destroy)
b.grid(row=1, padx=10, pady=10)
self.grab_set()
b.focus_set()
self.wait_window(self)
开发者ID:j4321,项目名称:Sudoku-Tk,代码行数:25,代码来源:custom_messagebox.py
示例18: __init__
def __init__(self, string_var, *args, **kwargs):
Toplevel.__init__(self, *args, **kwargs)
self.wm_title('SUDO Password')
Label(master = self,
text = 'Root password:').pack()
self._input = input = Entry(master = self,
show = '*')
def set_pass(*args, **kwargs):
string_var.set(input.get())
self.destroy()
input.bind('<KeyRelease-Return>', set_pass)
#input.pack(side=TOP, fill=BOTH, expand=True)
input.pack()
input.focus_set()
Button(master = self,
text = 'Cancel',
command = self.destroy).pack()
Button(master = self,
text = 'OK',
command = set_pass).pack()
开发者ID:kitchenbudapest,项目名称:vr,代码行数:27,代码来源:plastey.py
示例19: _color_delegator
def _color_delegator(parent): # htest #
from tkinter import Toplevel, Text
from idlelib.percolator import Percolator
top = Toplevel(parent)
top.title("Test ColorDelegator")
x, y = map(int, parent.geometry().split('+')[1:])
top.geometry("700x250+%d+%d" % (x + 20, y + 175))
source = ("# Following has syntax errors\n"
"if True: then int 1\nelif False: print 0\nelse: float(None)\n"
"if iF + If + IF: 'keywork matching must respect case'\n"
"# All valid prefixes for unicode and byte strings should be colored\n"
"'x', '''x''', \"x\", \"\"\"x\"\"\"\n"
"r'x', u'x', R'x', U'x', f'x', F'x', ur'is invalid'\n"
"fr'x', Fr'x', fR'x', FR'x', rf'x', rF'x', Rf'x', RF'x'\n"
"b'x',B'x', br'x',Br'x',bR'x',BR'x', rb'x'.rB'x',Rb'x',RB'x'\n")
text = Text(top, background="white")
text.pack(expand=1, fill="both")
text.insert("insert", source)
text.focus_set()
color_config(text)
p = Percolator(text)
d = ColorDelegator()
p.insertfilter(d)
开发者ID:1st1,项目名称:cpython,代码行数:25,代码来源:colorizer.py
示例20: __init__
def __init__(self,parent):
Toplevel.__init__(self)
self.transient(parent)
self.focus()
sw = parent.winfo_screenwidth()
sh = parent.winfo_screenheight()
self.geometry('%dx%d+%d+%d' % (sw/2, sh/2, sw/4, sh/4))
self.grab_set()
self.title("Settings")
self.modeNotebook = Notebook(self)
self.modeNotebook.pack(fill=BOTH, expand=True)
self.addFrame = AddSettingsFrame(self.modeNotebook, self)
self.addFrame.pack(fill=BOTH, expand=True)
self.editFrame = EditSettingsFrame(self.modeNotebook, self)
self.editFrame.pack(fill=BOTH, expand=True)
self.deleteFrame = DeleteSettingsFrame(self.modeNotebook, self)
self.deleteFrame.pack(fill=BOTH, expand=True)
self.modeNotebook.add(self.addFrame, text='Add')
self.modeNotebook.add(self.editFrame, text='Edit')
self.modeNotebook.add(self.deleteFrame, text='Delete')
self.addFrame.setupFrame()
self.editFrame.setupFrame()
self.wait_window()
开发者ID:RohanBali,项目名称:EGUANA_Python,代码行数:31,代码来源:settingsPopup.py
注:本文中的tkinter.Toplevel类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论