本文整理汇总了Python中Tkinter.Tk.winfo_rootx方法的典型用法代码示例。如果您正苦于以下问题:Python Tk.winfo_rootx方法的具体用法?Python Tk.winfo_rootx怎么用?Python Tk.winfo_rootx使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tkinter.Tk
的用法示例。
在下文中一共展示了Tk.winfo_rootx方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: PokerMachine
# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import winfo_rootx [as 别名]
#.........这里部分代码省略.........
# Two different tables, one for easy mode, one for normal
# mode, so be prepared to show either one.
wte = {2500: "Royal Flush", 250: "Straight Flush",
100: "Four of a Kind", 50: "Full House", 20: "Flush",
15: "Straight", 4: "Three of a Kind", 3: "Two Pair",
2: "Jacks or Higher"}
wtn = {800: "Royal Flush", 50: "Straight Flush", 25: "Four of a Kind",
9: "Full House", 6: "Flush", 4: "Straight",
3: "Three of a Kind", 2: "Two Pair", 1: "Jacks or Higher"}
wtxt = wte if self.game_easy else wtn
row = 5
for key in sorted(wtxt.keys(), reverse=True):
lbl = Label(self.root, text=wtxt[key])
lbl.grid(row=row, column=1, columnspan=2, sticky=W)
lbl = Label(self.root, text="{0} : 1".format(key))
lbl.grid(row=row, column=3, sticky=E)
row += 1
lbl = Label(self.root, text="")
lbl.grid(row=row, column=0, columnspan=5, pady=15)
# pylint: enable=W0201
def help_about(self):
"""Shows an 'about' modal dialog.
Callback method called by tk.
"""
about_win = Toplevel(self.root)
# Set up dialog
lbl = Label(about_win, text="Video Poker")
lbl.grid(row=0, column=0, padx=10, pady=(10, 0), sticky=W + N)
lbl = Label(about_win, text="by Paul Griffiths")
lbl.grid(row=1, column=0, padx=10, pady=(0, 7), sticky=W + N)
lbl = Label(about_win, text="Written in Python, with tkinter.")
lbl.grid(row=2, column=0, padx=10, pady=7, sticky=W + N)
lbl = Label(about_win, text="Copyright 2013 Paul Griffiths")
lbl.grid(row=4, column=0, padx=10, pady=(7, 0), sticky=W + N)
lbl = Label(about_win, text="Email: [email protected]")
lbl.grid(row=5, column=0, padx=10, pady=(0, 21), sticky=W + N)
lbl = Label(about_win, text="This program is free software: you can " +
"redistribute it and/or modify it under the terms")
lbl.grid(row=6, column=0, columnspan=2,
padx=10, pady=0, sticky=W + N)
lbl = Label(about_win, text="of the GNU General Public License as " +
"published by the Free Software Foundation, either")
lbl.grid(row=7, column=0, columnspan=2,
padx=10, pady=(0, 0), sticky=W + N)
lbl = Label(about_win, text="version 3 of the License, or " +
"(at your option) any later version.")
lbl.grid(row=8, column=0, columnspan=2,
padx=10, pady=(0, 21), sticky=W + N)
lbl = Label(about_win, text="This program is distributed in " +
"the hope that it will be useful, but WITHOUT ANY WARRANTY;")
lbl.grid(row=9, column=0, columnspan=2,
padx=10, pady=0, sticky=W + N)
lbl = Label(about_win, text="without even the implied " +
"warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR")
lbl.grid(row=10, column=0, columnspan=2,
padx=10, pady=(0, 0), sticky=W + N)
lbl = Label(about_win, text="PURPOSE. See the " +
"GNU General Public License for more details.")
lbl.grid(row=11, column=0, columnspan=2,
padx=10, pady=(0, 21), sticky=W + N)
lbl = Label(about_win, text="You should have received a " +
"copy of the GNU General Public License along with this")
lbl.grid(row=12, column=0, columnspan=2,
padx=10, pady=(0, 0), sticky=W + N)
lbl = Label(about_win, text="program. If not, see " +
"<http://www.gnu.org/licenses/>.")
lbl.grid(row=13, column=0, columnspan=2,
padx=10, pady=(0, 21), sticky=W + N)
img = PhotoImage(file="{0}27.gif".format(self.gifdir))
lbl = Label(about_win, image=img)
lbl.grid(row=0, column=1, rowspan=5, padx=10, pady=10, sticky=N + E)
btn = Button(about_win, text="OK", command=about_win.quit)
btn.grid(row=14, column=0, columnspan=2,
padx=0, pady=(0, 10), ipadx=30, ipady=3)
# Show dialog
about_win.transient(self.root)
about_win.parent = self.root
about_win.protocol("WM_DELETE_WINDOW", about_win.destroy)
about_win.geometry("+{0}+{1}".format(self.root.winfo_rootx() + 50,
self.root.winfo_rooty() + 50))
about_win.title("About Video Poker")
about_win.focus_set()
about_win.grab_set()
about_win.mainloop()
about_win.destroy()
示例2: BaseForm
# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import winfo_rootx [as 别名]
class BaseForm(object):
# input first set of points
firstPointsSet = True
points = [[], [], []]
def __init__(self, _width = 600, _height = 400):
self.root = Tk()
self.width = _width
self.height = _height
self.root.title("Construction of triangulation")
self.root.minsize(width = _width, height = _height)
self.root.maxsize(width = _width, height = _height)
self.canvas = Canvas(self.root, width = _width, height = _height, bg = "white")
self.canvas.pack()
self.root.bind('<Button-1>', self.ClickMouse)
self.b1 = Button(self.root, bg = "white", fg = "black", text = "Second points set", command = self.SecondPointsSet)
self.b1.place(x = 50, y = _height - 50)
self.b2 = Button(self.root, bg = "white", fg = "black", text = "Triangulation", command = self.Run)
self.b2.place(x = 200, y = _height - 50)
self.b3 = Button(self.root, bg = "white", fg = "black", text = "Experiment", command = self.Experiment)
self.b3.place(x = 325, y = _height - 50)
self.b4 = Button(self.root, bg = "white", fg = "black", text = "Errors", command = self.FindErrors)
self.b4.place(x = 425, y = _height - 50)
self.b5 = Button(self.root, bg = "white", fg = "black", text = "Time", command = self.ExperimentTime)
self.b5.place(x = 500, y = _height - 50)
def ClickMouse(self, event):
if not self.preprocessingDone:
getX = event.x_root
getY = event.y_root
posRootX = self.root.winfo_rootx()
posRootY = self.root.winfo_rooty()
x = getX - posRootX
y = getY - posRootY
p = [x, y]
self.points[not self.firstPointsSet].append(p)
draw.Point(self.canvas, p, "black", 3, not self.firstPointsSet)
def SecondPointsSet(self):
self.firstPointsSet = False
def Run(self):
raise NotImplementedError('This function must be implemented within child class!')
def Experiment(self):
raise NotImplementedError('This function must be implemented within child class!')
def FindErrors(self):
raise NotImplementedError('This function must be implemented within child class!')
def ExperimentTime(self):
raise NotImplementedError('This function must be implemented within child class!')