当前位置: 首页>>代码示例>>Python>>正文


Python Tk.winfo_screenwidth方法代码示例

本文整理汇总了Python中tkinter.Tk.winfo_screenwidth方法的典型用法代码示例。如果您正苦于以下问题:Python Tk.winfo_screenwidth方法的具体用法?Python Tk.winfo_screenwidth怎么用?Python Tk.winfo_screenwidth使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在tkinter.Tk的用法示例。


在下文中一共展示了Tk.winfo_screenwidth方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: draw_gui

# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import winfo_screenwidth [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
开发者ID:knigophil,项目名称:KindleWisper,代码行数:16,代码来源:kindlewisper.py

示例2: main

# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import winfo_screenwidth [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.')
开发者ID:nishimaomaoxiong,项目名称:pyDEA,代码行数:35,代码来源:main_gui.py

示例3: __init__

# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import winfo_screenwidth [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)
开发者ID:wil93,项目名称:pentomino-cover-game,代码行数:35,代码来源:game.py

示例4: main

# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import winfo_screenwidth [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()
开发者ID:fieryzig,项目名称:sumo,代码行数:19,代码来源:racing.py

示例5: choice

# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import winfo_screenwidth [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))
开发者ID:valdecar,项目名称:faceRepresentWithHoG,代码行数:12,代码来源:gui.py

示例6: main

# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import winfo_screenwidth [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)
开发者ID:valdecar,项目名称:faceRepresentWithHoG,代码行数:13,代码来源:gui.py

示例7: main

# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import winfo_screenwidth [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()
开发者ID:VrishtiDutta,项目名称:EGUANA_Python,代码行数:15,代码来源:EGUANA.py

示例8: add_transaction

# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import winfo_screenwidth [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()
开发者ID:SenlisO,项目名称:PerDiemCalculator,代码行数:52,代码来源:GUI.py

示例9: main

# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import winfo_screenwidth [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")
开发者ID:klaxa,项目名称:utagumo-client,代码行数:20,代码来源:TkClient.py

示例10: run

# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import winfo_screenwidth [as 别名]
def run(*args):
    # Create the GUI for the program
    window = Tk()
    window.wm_title("pesto_check") # change the window title to pesto_check
    text = Text(window, height=3, width=65, bg="black", padx=5, pady=5, 
            highlightthickness=1)
    text.pack()
    
    # Tag configs for green/red font color
    text.tag_config("green", foreground="green")
    text.tag_config("red", foreground="red")
    
    # Set GUI position on screen (we'll put it on the upper-right hand corner)
    window.update_idletasks() # make sure that the width is up to date
    width = window.winfo_screenwidth()
    size = tuple(int(_) for _ in window.geometry().split('+')[0].split('x'))
    x = width - size[0]
    window.geometry("%dx%d+%d+%d" % (size + (x, 0)))
    
    """Searches specified websites for pesto and outputs the results."""
    # The path to the PhantomJS executable (shown below) will need to be changed on your system
    # Example path: /Users/owenjow/pesto_check/phantomjs/bin/phantomjs
    driver = webdriver.PhantomJS("[PATH-TO-phantomjs]") ### CHANGE THIS ###
    driver.wait = WebDriverWait(driver, 5)
    
    # Search UCB dining hall menus
    search_and_output(driver, "http://goo.gl/VR8HpB", text, "DC", False)
    # Search the Cheese Board weekly menu
    search_cheeseboard_and_output(driver, text)
    # Search the Sliver weekly menu
    search_sliver_and_output(driver, text)
    
    # Bring the Tkinter window to the front
    window.lift()
    window.attributes("-topmost", True)
    
    text.configure(state="disabled") # there's no need to allow user input!
    mainloop()
    driver.quit()
开发者ID:ohjay,项目名称:pesto_check,代码行数:41,代码来源:search.py

示例11: __init__

# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import winfo_screenwidth [as 别名]
from tkinter import Tk

from guiUtils import GUIManager

_ = lambda s: s

class Application:
    def __init__(self, root):
        self.guiManger = GUIManager(self, root)
        self.guiManger.mainView()

if __name__ == '__main__':
    root = Tk()
    root.geometry('{}x{}'.format(root.winfo_screenwidth(), 600))
    root.title(_("METHODS OF SCIENTIFIC COMPUTING"))
    Application(root)
    root.mainloop()
开发者ID:SilvioMessi,项目名称:CustomJPEGCompression,代码行数:19,代码来源:__main__.py

示例12: clock

# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import winfo_screenwidth [as 别名]
      startTime = clock()
      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.
开发者ID:CyanogenCX,项目名称:Python,代码行数:33,代码来源:AutomaticAnt.py

示例13: dist

# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import winfo_screenwidth [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
开发者ID:krishnagadde23,项目名称:AI,代码行数:32,代码来源:TravelingSaleman.py

示例14: createWidgets

# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import winfo_screenwidth [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()
开发者ID:edwardsCam,项目名称:Python-Scripts,代码行数:32,代码来源:LinSys.py

示例15: main

# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import winfo_screenwidth [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.')
开发者ID:ticky,项目名称:desktop-decorator,代码行数:65,代码来源:decorator.py


注:本文中的tkinter.Tk.winfo_screenwidth方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。