本文整理汇总了Python中tkinter.Toplevel.geometry方法的典型用法代码示例。如果您正苦于以下问题:Python Toplevel.geometry方法的具体用法?Python Toplevel.geometry怎么用?Python Toplevel.geometry使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tkinter.Toplevel
的用法示例。
在下文中一共展示了Toplevel.geometry方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: helpAbout
# 需要导入模块: from tkinter import Toplevel [as 别名]
# 或者: from tkinter.Toplevel import geometry [as 别名]
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)
示例2: toplevel
# 需要导入模块: from tkinter import Toplevel [as 别名]
# 或者: from tkinter.Toplevel import geometry [as 别名]
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
示例3: _color_delegator
# 需要导入模块: from tkinter import Toplevel [as 别名]
# 或者: from tkinter.Toplevel import geometry [as 别名]
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)
示例4: _replace_dialog
# 需要导入模块: from tkinter import Toplevel [as 别名]
# 或者: from tkinter.Toplevel import geometry [as 别名]
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()
示例5: _io_binding
# 需要导入模块: from tkinter import Toplevel [as 别名]
# 或者: from tkinter.Toplevel import geometry [as 别名]
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)
示例6: _color_delegator
# 需要导入模块: from tkinter import Toplevel [as 别名]
# 或者: from tkinter.Toplevel import geometry [as 别名]
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 = (
"if True: int ('1') # keyword, builtin, string, comment\n"
"elif False: print(0)\n"
"else: float(None)\n"
"if iF + If + IF: 'keyword matching must respect case'\n"
"if'': x or'' # valid string-keyword no-space combinations\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'\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"
"# Invalid combinations of legal characters should be half colored.\n"
"ur'x', ru'x', uf'x', fu'x', UR'x', ufr'x', rfu'x', xf'x', fx'x'"
)
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)
示例7: _io_binding
# 需要导入模块: from tkinter import Toplevel [as 别名]
# 或者: from tkinter.Toplevel import geometry [as 别名]
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)
示例8: __init__
# 需要导入模块: from tkinter import Toplevel [as 别名]
# 或者: from tkinter.Toplevel import geometry [as 别名]
class InfoWindow:
def __init__(self, model: World):
self.model = model
self.window = Toplevel()
self.window.title('Информация об объектах и мире')
self.window.geometry("640x600+250+200")
self._inner_init()
self.frame.pack()
self.window.mainloop()
def _inner_init(self):
self.frame = Frame(self.window,
width=640,
height=600,
bd=2)
self.frame.grid_bbox(2, 2)
self._about_world()
self._about_creatures()
def _about_world(self):
self.world_indo = self.model.info()
TEXT = "Кол-во объектов: {cr_count}\n" \
"Из них живые: {cr_alive}".format(**self.world_indo)
Label(self.frame,
text=TEXT).grid(row=1, column=1)
def _about_creatures(self):
lb = Listbox(self.frame,
height=15,
width=50,
selectmode=SINGLE)
lb.bind('<<ListboxSelect>>', self._onselect)
lb.grid(row=1, column=2)
items = self.model.creatures.items()
items = sorted(items, key=lambda k: k[0][0] * self.model.width + k[0][1])
for (x, y), creature in items:
lb.insert(END, [x, y, creature.life])
self.canvas = NeuroCanvas(self.frame, (2, 2), 400, 300)
def _onselect(self, evt):
w = evt.widget
index = int(w.curselection()[0])
value = w.get(index)
x, y, *_ = value[1:].split(",")
x = int(x)
y = int(y)
cr = self.model.creatures[(x, y)]
neuro = cr.genome
self.canvas.draw(neuro)
示例9: popWidget
# 需要导入模块: from tkinter import Toplevel [as 别名]
# 或者: from tkinter.Toplevel import geometry [as 别名]
def popWidget( self, function ):
_geo = self.parent.geometry()
_x = str( int( _geo.split('+')[1] ) + 200 )
_y = str( int( _geo.split('+')[2] ) + 200 )
return_val = list()
entry_root = Toplevel()
entry_root.geometry('+' + _x + '+' + _y )
entry_widget = EntryWidget( entry_root, function )
示例10: __init__
# 需要导入模块: from tkinter import Toplevel [as 别名]
# 或者: from tkinter.Toplevel import geometry [as 别名]
class MailListWindow:
def __init__(self, title, after_close):
self.win = Toplevel()
self.win.title(title)
self.win.geometry('400x200')
self.win.wm_attributes('-toolwindow', True)
self.win.protocol("WM_DELETE_WINDOW", after_close)
inner_frame = tk.Frame(self.win)#inner_frame = tk.Frame(canvas)
inner_frame.pack(side='left', fill='both', expand = 1)
scrollbar = tk.Scrollbar(self.win,orient="vertical",command=self.scrolly)
scrollbar.pack(side='right', fill='y')
self.btn_count = 0
self.btns = []
self.texts = []
self.callbacks = []
self.frame = inner_frame
self.scrollbar = scrollbar
self.btn_per_page = 4
self.first_btn = 0
self.scrolly('', '0.0')
def scrolly(self, cmd, pos, what=''):
if self.btn_per_page <= self.btn_count:
bar_len = self.btn_per_page/self.btn_count
else:
bar_len=1
self.first_btn = int(float(pos)*self.btn_count)
pos = str(self.getScrollPos())
self.scrollbar.set(pos, str(float(pos)+bar_len))
for i in range(len(self.btns)):
mail_index = i+self.first_btn
self.btns[i].config(text=self.texts[mail_index], command=self.callbacks[mail_index])
def insertButton(self, text, callback):
if self.btn_count < self.btn_per_page:
btn = tk.Button(self.frame, bg='#fafafa',text=text, command=callback)
btn.pack(fill='both', expand=1)
self.btns.append(btn)
self.btn_count += 1
self.texts.append(text)
self.callbacks.append(callback)
self.scrolly('', self.getScrollPos())
def getScrollPos(self):
if self.btn_per_page >= self.btn_count:
return 0.0
if self.btn_count == 0:
return 0.0
return self.first_btn/self.btn_count
def callback(self):
print('click')
def destroy(self):
self.win.destroy()
示例11: toolbox_window
# 需要导入模块: from tkinter import Toplevel [as 别名]
# 或者: from tkinter.Toplevel import geometry [as 别名]
def toolbox_window(self):
"""Creates the window which will host the toolbox buttons"""
toolbox_root = Toplevel()
toolbox_root.title("Toolbox")
toolbox_root.geometry("455x256")
toolbox_frame = Frame(toolbox_root)
toolbox_frame.pack(fill=BOTH)
示例12: lock
# 需要导入模块: from tkinter import Toplevel [as 别名]
# 或者: from tkinter.Toplevel import geometry [as 别名]
def lock(self):
if self.lock_label.get() == 'LOCKED':
window = Toplevel()
window.geometry('318x550')
self.keypad = Keypad(window, self, self.password)
else:
self.save_button.config(state='disabled')
self.edit.lock()
self.preferences.lock()
self.lock_label.set('LOCKED')
self.lock_button.config(image=self.locked_image)
示例13: on_post_merge_sql
# 需要导入模块: from tkinter import Toplevel [as 别名]
# 或者: from tkinter.Toplevel import geometry [as 别名]
def on_post_merge_sql(self, *args):
# Show post-merge-SQL dialog
_wdw = Toplevel()
_wdw.geometry('+400+400')
_wdw.e = TextExtension(_wdw, textvariable=self.post_execute_sql)
_wdw.e.pack()
_wdw.e.focus_set()
_wdw.transient(self.parent)
_wdw.grab_set()
self.parent.wait_window(_wdw)
_wdw.e.unhook()
del (_wdw)
示例14: splash
# 需要导入模块: from tkinter import Toplevel [as 别名]
# 或者: from tkinter.Toplevel import geometry [as 别名]
class splash():
# try:
def __init__(self):
moduleDir = dirname(__file__)
moduleDir = moduleDir.rsplit('\\',2)[0]
image = moduleDir+'\\resources\\sirbot\\splash.gif'
self.root = Tk()
self.root.withdraw()
self.loadingSplash = Toplevel()
splashimage = PhotoImage(file=image)
self.loading = ttk.Label(self.loadingSplash,image=splashimage)
self.loadingSplash.overrideredirect(True)
self.loading.pack()
h = self.loading.winfo_screenheight()
w = self.loading.winfo_screenwidth()
self.loadingSplash.wm_attributes('-alpha',0.75)
self.loadingSplash.update_idletasks()
self.loadingSplash.geometry('262x112+'+str(int(w/2)-131*1)+
'+'+str(int(h/2)-56*1))
self.loadingSplash.update_idletasks()
self.loadingSplash.update()
# except:
## #log
## loadingSplash = Tk()
## #myfont = tkFont.families()[0]
## loading = Label(loadingSplash,text='SirBot')
## loadingSplash.overrideredirect(True)
## loading.pack()
##
## h = loading.winfo_screenheight()
## w = loading.winfo_screenwidth()
##
## loadingSplash.wm_attributes('-alpha',0.75)
## loadingSplash.update_idletasks()
## loadingSplash.geometry('262x112+'+str(int(w/2)-131*1)+
## '+'+str(int(h/2)-56*1))
## loadingSplash.update_idletasks()
## loadingSplash.update()
def destroy(self):
try:
self.loadingSplash.destroy()
except:
#log
pass
def getroot(self):
return(self.root)
示例15: _object_browser
# 需要导入模块: from tkinter import Toplevel [as 别名]
# 或者: from tkinter.Toplevel import geometry [as 别名]
def _object_browser(parent): # htest #
import sys
from tkinter import Toplevel
top = Toplevel(parent)
top.title("Test debug object browser")
width, height, x, y = list(map(int, re.split('[x+]', parent.geometry())))
top.geometry("+%d+%d"%(x + 100, y + 175))
top.configure(bd=0, bg="yellow")
top.focus_set()
sc = ScrolledCanvas(top, bg="white", highlightthickness=0, takefocus=1)
sc.frame.pack(expand=1, fill="both")
item = make_objecttreeitem("sys", sys)
node = TreeNode(sc.canvas, None, item)
node.update()