本文整理汇总了Python中tkinter.Tk.winfo_screenheight方法的典型用法代码示例。如果您正苦于以下问题:Python Tk.winfo_screenheight方法的具体用法?Python Tk.winfo_screenheight怎么用?Python Tk.winfo_screenheight使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tkinter.Tk
的用法示例。
在下文中一共展示了Tk.winfo_screenheight方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: draw_gui
# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import winfo_screenheight [as 别名]
def draw_gui(self):
main = Tk()
main.title('KindleButler ' + __version__)
main.resizable(0, 0)
main.wm_attributes('-toolwindow', 1)
x = (main.winfo_screenwidth() - main.winfo_reqwidth()) / 2
y = (main.winfo_screenheight() - main.winfo_reqheight()) / 2
main.geometry('+%d+%d' % (x, y))
progressbar = ttk.Progressbar(orient='horizontal', length=200, mode='determinate')
progressbar.grid(row=0)
style = ttk.Style()
style.configure('BW.TLabel', foreground='red')
label = ttk.Label(style='BW.TLabel')
return main, progressbar, label
示例2: main
# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import winfo_screenheight [as 别名]
def main():
''' Runs main application GUI.
'''
logger = get_logger()
logger.info('pyDEA started as a GUI application.')
root = Tk()
root.report_callback_exception = show_error
# load logo
if "nt" == os.name:
iconfile = pkg_resources.resource_filename(PACKAGE, 'pyDEAlogo.ico')
root.wm_iconbitmap(bitmap=iconfile)
else:
iconfile = pkg_resources.resource_filename(PACKAGE, 'pyDEAlogo.gif')
img = PhotoImage(file=iconfile)
root.tk.call('wm', 'iconphoto', root._w, img)
# change background color of all widgets
s = Style()
s.configure('.', background=bg_color)
# run the application
app = MainFrame(root)
root.protocol("WM_DELETE_WINDOW", (lambda: ask_quit(app)))
center_window(root,
root.winfo_screenwidth() - root.winfo_screenwidth()*0.15,
root.winfo_screenheight() - root.winfo_screenheight()*0.15)
root.mainloop()
logger.info('pyDEA exited.')
示例3: __init__
# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import winfo_screenheight [as 别名]
def __init__(self, num_rows, num_cols, best_possible):
self.rows = num_rows
self.cols = num_cols
self.expectedBest = best_possible
# create the root and the canvas
root = Tk()
# local function to bind/unbind events
self.bind = root.bind
self.unbind = root.unbind
# local function to change title
self.updateTitle = root.title
# local function to change cursor
self.updateCursor = lambda x: root.config(cursor=x)
# local function to start game
self.start = root.mainloop
# get screen width and height
ws = root.winfo_screenwidth()
hs = root.winfo_screenheight()
# fix scaling for higher resolutions
if max(self.canvasWidth / ws, self.canvasHeight / hs) < 0.45:
self.scale = 2
self.canvas = Canvas(root, width=self.canvasWidth, height=self.canvasHeight)
self.canvas.pack()
# calculate position x, y
x = (ws - self.canvasWidth) // 2
y = (hs - self.canvasHeight) // 2
root.geometry('%dx%d+%d+%d' % (self.canvasWidth, self.canvasHeight, x, y))
root.resizable(width=0, height=0)
self.init()
# set up keypress events
root.bind("<Key>", self.keyPressed)
示例4: main
# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import winfo_screenheight [as 别名]
def main(sumocfg="racing/racing.sumocfg", egoID="ego"):
root = Tk()
root.geometry('180x100+0+0')
frame = Frame(root)
Button(frame, text="Click here.\nControl with arrow keys").grid(row=0)
root.bind('<Left>', leftKey)
root.bind('<Right>', rightKey)
root.bind('<Up>', upKey)
root.bind('<Down>', downKey)
root.winfo_screenwidth()
root.winfo_screenheight()
frame.pack()
RacingClient(root, sumocfg, egoID)
root.mainloop()
示例5: choice
# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import winfo_screenheight [as 别名]
def choice(self):
self.childResultList = []
root = Tk()
child1 = CreateSets(root)
child1.parentWindow = self
h = 400
w = 400
x = root.winfo_screenwidth()
y = root.winfo_screenheight()
root.geometry('%dx%d+%d+%d' % (w, h, x/2-30, y/2-30))
示例6: main
# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import winfo_screenheight [as 别名]
def main():
root = Tk()
h = root.winfo_height()
w = root.winfo_width()
x = root.winfo_screenwidth()
y = root.winfo_screenheight()
root.geometry('%dx%d+%d+%d' % (w, h, x/2, y/2))
app = Tool(root)
# root.mainloop()
return(root)
示例7: main
# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import winfo_screenheight [as 别名]
def main():
global app
global root
root = Tk()
sw = root.winfo_screenwidth()
sh = root.winfo_screenheight()
root.geometry('%dx%d+%d+%d' % (sw, sh, 0, 0))
app = Example(root)
root.mainloop()
示例8: add_transaction
# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import winfo_screenheight [as 别名]
def add_transaction(self):
# create a new window
root = Tk()
root.title("Add a Transaction")
main_frame = Frame(root)
w = 280 # width for the Tk root
h = 120 # height for the Tk root
# get screen width and height
ws = root.winfo_screenwidth() # width of the screen
hs = root.winfo_screenheight() # height of the screen
# calculate x and y coordinates for the Tk root window
x = (ws/2) - (w/2)
y = (hs/2) - (h/2)
# set the dimensions of the screen
# and where it is placed
root.geometry('%dx%d+%d+%d' % (w, h, x, y))
# create all objects
date_label = Label(main_frame, text = "Date:")
name_label = Label(main_frame, text = "Name:")
amount_label = Label(main_frame, text = "Amount:")
remarks_label = Label(main_frame, text = "Remarks:")
self.date_entry = Entry(main_frame)
self.name_entry = Entry(main_frame)
self.amount_entry = Entry(main_frame)
self.remarks_entry = Entry(main_frame)
submit_button = Button(main_frame, text = "Submit", command = self.submit_transaction(root))
cancel_button = Button(main_frame, text = "Cancel", command = root.destroy)
date_label.grid(row = 0, column = 0)
self.date_entry.grid(row= 0, column = 1)
name_label.grid(row = 1, column = 0)
self.name_entry.grid(row = 1, column = 1)
amount_label.grid(row = 2, column = 0)
self.amount_entry.grid(row = 2, column = 1)
remarks_label.grid(row = 3, column = 0)
self.remarks_entry.grid(row = 3, column = 1)
submit_button.grid(row = 4, column = 0)
cancel_button.grid(row = 4, column = 1)
main_frame.pack()
root.mainloop()
示例9: main
# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import winfo_screenheight [as 别名]
def main():
root = Tk()
root.title("Utagumo")
root.resizable(width=FALSE, height=FALSE)
ws = root.winfo_screenwidth()
hs = root.winfo_screenheight()
root.geometry('+%d+%d' % (ws/2, hs/2))
app = UtaGUI(root)
def shutdown():
app.cleanup()
root.destroy()
root.protocol("WM_DELETE_WINDOW", shutdown)
logging.info("Running")
root.mainloop()
logging.info("Dying")
示例10: Config
# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import winfo_screenheight [as 别名]
#.........这里部分代码省略.........
self.ui_dblbl = Label(self.ui_midframe, text="Database name",
justify=LEFT, anchor=W, font=font )
self.ui_dblbl.grid(row=3, column=0, padx=2, pady=2)
self.ui_db = Entry(self.ui_midframe, font=font)
self.ui_db.grid(row=3, column=1, padx=2, pady=2)
# OUT
self.ui_outlbl = Label(self.ui_midframe, text="Audio output (local/hdmi)",
justify=LEFT, anchor=W, font=font )
self.ui_outlbl.grid(row=4, column=0, padx=2, pady=2)
self.ui_out = Entry(self.ui_midframe, font=font)
self.ui_out.grid(row=4, column=1, padx=2, pady=2)
# OPT
self.ui_optlbl = Label(self.ui_midframe, text="Omxplayer extra options",
justify=LEFT, anchor=W, font=font )
self.ui_optlbl.grid(row=5, column=0, padx=2, pady=2)
self.ui_opt = Entry(self.ui_midframe, font=font)
self.ui_opt.grid(row=5, column=1, padx=2, pady=2)
# URL1L
self.ui_url1llbl = Label(self.ui_midframe, text="Url 1 name",
justify=LEFT, anchor=W, font=font )
self.ui_url1llbl.grid(row=6, column=0, padx=2, pady=2)
self.ui_url1l = Entry(self.ui_midframe, font=font)
self.ui_url1l.grid(row=6, column=1, padx=2, pady=2)
# URL1
self.ui_url1lbl = Label(self.ui_midframe, text="Url 1",
justify=LEFT, anchor=W, font=font )
self.ui_url1lbl.grid(row=7, column=0, padx=2, pady=2)
self.ui_url1 = Entry(self.ui_midframe, font=font)
self.ui_url1.grid(row=7, column=1, padx=2, pady=2)
# URL2L
self.ui_url2llbl = Label(self.ui_midframe, text="Url 2 name",
justify=LEFT, anchor=W, font=font )
self.ui_url2llbl.grid(row=8, column=0, padx=2, pady=2)
self.ui_url2l = Entry(self.ui_midframe, font=font)
self.ui_url2l.grid(row=8, column=1, padx=2, pady=2)
# URL2
self.ui_url2lbl = Label(self.ui_midframe, text="Url 2",
justify=LEFT, anchor=W, font=font )
self.ui_url2lbl.grid(row=9, column=0, padx=2, pady=2)
self.ui_url2 = Entry(self.ui_midframe, font=font)
self.ui_url2.grid(row=9, column=1, padx=2, pady=2)
# URL3L
self.ui_url3llbl = Label(self.ui_midframe, text="Url 3 name",
justify=LEFT, anchor=W, font=font )
self.ui_url3llbl.grid(row=10, column=0, padx=2, pady=2)
self.ui_url3l = Entry(self.ui_midframe, font=font)
self.ui_url3l.grid(row=10, column=1, padx=2, pady=2)
# URL3
self.ui_url3lbl = Label(self.ui_midframe, text="Url 3",
justify=LEFT, anchor=W, font=font )
self.ui_url3lbl.grid(row=11, column=0, padx=2, pady=2)
self.ui_url3 = Entry(self.ui_midframe, font=font)
self.ui_url3.grid(row=11, column=1, padx=2, pady=2)
# URL4L
self.ui_url4llbl = Label(self.ui_midframe, text="Url 4 name",
justify=LEFT, anchor=W, font=font )
self.ui_url4llbl.grid(row=12, column=0, padx=2, pady=2)
self.ui_url4l = Entry(self.ui_midframe, font=font)
self.ui_url4l.grid(row=12, column=1, padx=2, pady=2)
# URL4
self.ui_url4lbl = Label(self.ui_midframe, text="Url 4",
justify=LEFT, anchor=W, font=font )
self.ui_url4lbl.grid(row=13, column=0, padx=2, pady=2)
self.ui_url4 = Entry(self.ui_midframe, font=font)
self.ui_url4.grid(row=13, column=1, padx=2, pady=2)
# URL5L
self.ui_url5llbl = Label(self.ui_midframe, text="Url 5 name",
justify=LEFT, anchor=W, font=font )
self.ui_url5llbl.grid(row=14, column=0, padx=2, pady=2)
self.ui_url5l = Entry(self.ui_midframe, font=font)
self.ui_url5l.grid(row=14, column=1, padx=2, pady=2)
# URL5
self.ui_url5lbl = Label(self.ui_midframe, text="Url 5",
justify=LEFT, anchor=W, font=font )
self.ui_url5lbl.grid(row=15, column=0, padx=2, pady=2)
self.ui_url5 = Entry(self.ui_midframe, font=font)
self.ui_url5.grid(row=15, column=1, padx=2, pady=2)
# Bottom Frame (buttons group)
self.ui_botframe = Frame(self.root, borderwidth=2)
self.ui_botframe.pack(anchor='s')
# Button Save
self.ui_butsave = Button(self.ui_botframe, text="Save",
command=self.save, font=font)
self.ui_butsave.grid(row=1, column=0, padx=2, pady=2)
# Button Close
self.ui_butquit = Button(self.ui_botframe, text="Close",
command=self.root.destroy, font=font)
self.ui_butquit.grid(row=1, column=1, padx=2, pady=2)
# Window position
self.root.update_idletasks()
w = self.root.winfo_reqwidth()
h = self.root.winfo_reqheight()
ws = self.root.winfo_screenwidth()
hs = self.root.winfo_screenheight()
x = (ws/2) - (w/2)
y = (hs/2) - (h/2)
self.root.geometry('%dx%d+%d+%d' % (w, h, x, y))
self.root.minsize(w, h)
self.root.maxsize(w, h)
return(True)
示例11: __init__
# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import winfo_screenheight [as 别名]
class LoginFrame:
def __init__(self, url):
self.url = url
self.root = Tk()
self.root.title("验证码")
while True:
try:
image_bytes = urlopen(self.url).read()
break
except socket.timeout:
print('获取验证码超时:%s\r\n重新获取.' % (self.url))
continue
except urllib.error.URLError as e:
if isinstance(e.reason, socket.timeout):
print('获取验证码超时:%s\r\n重新获取.' % (self.url))
continue
# internal data file
data_stream = io.BytesIO(image_bytes)
# open as a PIL image object
self.pil_image = Image.open(data_stream)
# convert PIL image object to Tkinter PhotoImage object
self.tk_image = ImageTk.PhotoImage(self.pil_image)
self.label = Label(self.root, image=self.tk_image, background='brown')
self.label.pack(padx=5, pady=5)
self.button = Button(self.root, text="刷新验证码", command=self.refreshImg)
self.button.pack(padx=5, pady=5)
randCodeLable = Label(self.root, text="验证码:")
randCodeLable.pack(padx=5, pady=5)
self.randCode = Entry(self.root)
self.randCode.pack(padx=5, pady=5)
self.loginButton = Button(self.root, text="登录", default=tkinter.ACTIVE)
self.loginButton.pack(padx=5, pady=5)
def refreshImg(self):
url = self.url
while True:
try:
image_bytes = urlopen(url).read()
data_stream = io.BytesIO(image_bytes)
self.pil_image = Image.open(data_stream)
self.tk_image = ImageTk.PhotoImage(self.pil_image)
self.label.configure(image=self.tk_image)
break
except socket.timeout:
print('获取验证码超时:%s\r\n重新获取.' % (self.url))
continue
except urllib.error.URLError as e:
if isinstance(e.reason, socket.timeout):
print('获取验证码超时:%s\r\n重新获取.' % (self.url))
continue
# 显示URL地址指定图片
def show(self):
w, h = self.pil_image.size
# 窗体居中
width = w + 100
height = h + 160
ws = self.root.winfo_screenwidth()
hs = self.root.winfo_screenheight()
x = int((ws / 2) - (width / 2))
y = int((hs / 2) - (height / 2))
self.root.geometry('{}x{}+{}+{}'.format(width, height, x, y))
# 禁止窗体改变大小
self.root.resizable(False, False)
self.root.mainloop()
def quit(self):
self.root.destroy()
示例12: range
# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import winfo_screenheight [as 别名]
for n in range(STEPS):
move(ant)
modifyColors(ant,matrix)
if n%SPEED_INC == 0:
canvas.update()
canvas.update()
displayStatistics(startTime)
from tkinter import Tk, Canvas, YES, BOTH
from time import clock
from random import choice
root=Tk()
canvas=setUpCanvas(root)
#--Below the numbers have been chosen to all be divisible by 5, since each "point" is a 5x5 pixel square.
SCREEN_WIDTH=root.winfo_screenwidth()//5*5-15
SCREEN_HEIGHT=root.winfo_screenheight()//5*5-90
ANT_START_ROW=SCREEN_WIDTH//(5*2)*5
ANT_START_COL=SCREEN_HEIGHT//(5*2)*5
STEPS=20000
SPEED_INC=20
COLORS=('WHITE','RED','BLUE','YELLOW','GREEN','CYAN','MAGENTA','GRAY','PINK')
HEADING_RULE=(0,1)
#HEADING_RULE = (0,1,1,0) # also (0,0,1,1,0,0). Are there others? This may be useful in Part II.
assert len(HEADING_RULE)<len(COLORS)
NUMBER_OF_COLORS = len(HEADING_RULE)
def main():
ant, matrix = createPixelWorld()
makeTheAntsJourney(ant,matrix)
root.mainloop() #required for graphics.
示例13: dist
# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import winfo_screenheight [as 别名]
def dist(cityA, cityB):
return hypot(cityA[1]-cityB[1], cityA[2] - cityB[2])
#====================================<GLOBAL CONSTANTS and GLOBAL IMPORTS>========Traveling Salesman Problem==
from tkinter import Tk, Canvas, YES, BOTH
from operator import itemgetter
from itertools import permutations
from copy import deepcopy
from random import shuffle
from time import clock
from math import hypot
root = Tk()
canvas = setUpCanvas(root)
START_TIME = clock()
SCREEN_WIDTH = root.winfo_screenwidth() //5*5 - 15 # adjusted to exclude task bars on my PC.
SCREEN_HEIGHT = root.winfo_screenheight()//5*5 - 90 # adjusted to exclude task bars on my PC.
fileName = "tsp0038.txt" # My file name will be different from yours
#==================================================< MAIN >=======================Traveling Salesman Problem==
def greedy(city):
newCity = []
newCity.append(city[0])
for count in range(len(city)):
bestDistance = 1000000
minCity = 0
for x in range(count + 1, len(city)):
currentDist = dist(city[count], city[x])
if currentDist < bestDistance:
minCity = x
bestDistance = currentDist
newCity.append(city[minCity])
示例14: createWidgets
# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import winfo_screenheight [as 别名]
self.chek_fullscrn.grid(row=1, column=1)
def createWidgets(self):
self.incThickYN = False
self.reverseThick = False
self.style = RIDGE
self.startingPoint = (20, 20)
self.generated = False
self.fileOptions()
self.makeMenuBar()
self.makeInputFrame()
self.makeCanvasFrame()
self.makeIgnitionFrame()
root = Tk()
root.title("Lindenmayer Systems")
padx = 50
pady = 100
window_width = root.winfo_screenwidth() - padx
window_height = root.winfo_screenheight() - pady
input_frame_width = 300
ignition_frame_width = 500
ignition_frame_height = 100
canvas_width = window_width - input_frame_width - padx
canvas_height = window_height - ignition_frame_height
input_frame_height = canvas_height
dimensions = "{0}x{1}+0+0".format(window_width, window_height)
root.geometry(dimensions)
#root.wm_iconbitmap('icon.ico')
Application(master=root).mainloop()
示例15: main
# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import winfo_screenheight [as 别名]
def main():
import argparse
parser = argparse.ArgumentParser(description='Optimise wallpaper images for a particular screen resolution.', epilog='Which is how you do it.')
cli_required = parser.add_argument_group('Required Arguments')
cli_required.add_argument('image', metavar='image', type=str, nargs='+', help='source image file')
cli_output = parser.add_argument_group('Output Options')
cli_output.add_argument('-x', '--width', metavar='width', type=int, help='change desired width of wallpapers (default: detect desktop resolution)')
cli_output.add_argument('-y', '--height', metavar='height', type=int, help='change desired height of wallpapers (default: detect desktop resolution)')
cli_output.add_argument('-u', '--upscale', action='store_true', help='allow images to be scaled up, rather than only down')
cli_output.add_argument('-o', '--output', metavar='output', type=str, default='output-images', help='allow images to be scaled up, rather than only down')
cli_iproc = parser.add_argument_group('Image Processing Options')
cli_iproc.add_argument('-m', '--mask', action='store_true', help='enable centre masking (forces feature detection to focus on edges)')
cli_iproc.add_argument('-g', '--gradient-mask', action='store_true', help='use gradient centre masking (requires -m)')
cli_iproc.add_argument('-t', '--threshold', metavar='threshold', type=int, default=166, choices=range(256), help='change the threshold for feature detection, must be between 0 and 255 (default: 166)')
cli_other = parser.add_argument_group('Other Options')
cli_other.add_argument('-v', '--verbose', action='store_true', help='show verbose (debug) output')
cli_args = parser.parse_args()
# Detect desktop resolution via Tk if we don't have them specified
if cli_args.width == None or cli_args.height == None:
tk = Tk()
cli_args.width = tk.winfo_screenwidth()
cli_args.height = tk.winfo_screenheight()
del tk
target_ratio = Fraction(cli_args.width, cli_args.height)
if not os.path.exists(cli_args.output):
os.makedirs(cli_args.output)
print('Desktop Decorator')
print('=================')
print('Attempting to optimise wallpapers for a display at %sw @ %s...' % (cli_args.width, ratio_string(target_ratio)))
for filename in cli_args.image:
try:
image = Image.open(filename)
except IOError:
image = None
print('* "%s" is being ignored...' % os.path.splitext(os.path.basename(filename))[0])
if type(image) != type(None):
print('* Processing "%s"...' % os.path.basename(filename))
image = smart_crop(image, cli_args.width, cli_args.height, cli_args.upscale, cli_args.threshold, cli_args.mask, cli_args.gradient_mask, cli_args.verbose)
image.save(os.path.join(cli_args.output, '%s-%[email protected]%s.%s' % (os.path.splitext(os.path.basename(filename))[0], cli_args.width, ratio_string(target_ratio), os.path.splitext(os.path.basename(filename))[-1][1:])))
print('Processing Complete.')