当前位置: 首页>>代码示例>>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: failure

# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import winfo_screenwidth [as 别名]
def failure(reason, cur_dir):
    """
    Displays a "submission failure" picture and emails
    a bug report to maintenance.
    """
    bugmail = {"email": "[email protected]"}
    send_email(bugmail, "QR Code Submission Failure", reason, None)
    root = Tk()
    root.focus_set()
    # Get the size of the screen and place the splash screen in the center
    gif = Image.open(str(cur_dir) + '/Images/Failure.gif')
    width = gif.size[0]
    height = gif.size[1]
    flog = (root.winfo_screenwidth()/2-width/2)
    blog = (root.winfo_screenheight()/2-height/2)
    root.overrideredirect(1)
    root.geometry('%dx%d+%d+%d' % (width*1, height + 44, flog, blog))
    # Pack a canvas into the top level window.
    # This will be used to place the image
    failure_canvas = Canvas(root)
    failure_canvas.pack(fill = "both", expand = True)
    # Open the image
    imgtk = PhotoImage(gif)
    # Get the top level window size
    # Need a call to update first, or else size is wrong
    root.update()
    cwidth = root.winfo_width()
    cheight =  root.winfo_height()
    # create the image on the canvas
    failure_canvas.create_image(cwidth/2, cheight/2.24, image=imgtk)
    Button(root, text = str(
        reason), width = 50, height = 2, command = root.destroy).pack()
    root.after(5000, root.destroy)
    root.mainloop()
开发者ID:mikefenton,项目名称:UCDAssignmentSubmission,代码行数:36,代码来源:Submit.py

示例2: expired

# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import winfo_screenwidth [as 别名]
def expired(cur_dir, amount):
    """
    Displays a "deadline expired" picture
    """
    root = Tk()
    root.focus_set()
    # Get the size of the screen and place the splash screen in the center
    img = Image.open(str(cur_dir) + '/Images/Expired.gif')
    width = img.size[0]
    height = img.size[1]
    flog = root.winfo_screenwidth()/2-width/2
    blog = root.winfo_screenheight()/2-height/2
    root.overrideredirect(True)
    root.geometry('%dx%d+%d+%d' % (width*1, height + 44, flog, blog))
    # Pack a canvas into the top level window.
    # This will be used to place the image
    expired_canvas = Canvas(root)
    expired_canvas.pack(fill="both", expand=True)
    # Open the image
    imgtk = PhotoImage(img)
    # Get the top level window size
    # Need a call to update first, or else size is wrong
    root.update()
    cwidth = root.winfo_width()
    cheight =  root.winfo_height()
    # create the image on the canvas
    expired_canvas.create_image(cwidth/2, cheight/2.1, image=imgtk)
    Button(root, text='Deadline Expired by ' + str(amount
          ) + '. Assignment Submitted, time '\
          'noted', width=80, height=2, command=root.destroy).pack()
    root.after(5000, root.destroy)
    root.mainloop()
开发者ID:mikefenton,项目名称:UCDAssignmentSubmission,代码行数:34,代码来源:Submit.py

示例3: success

# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import winfo_screenwidth [as 别名]
def success(cur_dir):
    """
    Displays a "successful submission" picture
    """
    root = Tk()
    root.focus_set()
    # Get the size of the screen and place the splash screen in the center
    img = Image.open(str(cur_dir) + '/Images/Success.gif')
    width = img.size[0]
    height = img.size[1]
    flog = (root.winfo_screenwidth()/2-width/2)
    blog = (root.winfo_screenheight()/2-height/2)
    root.overrideredirect(1)
    root.geometry('%dx%d+%d+%d' % (width, height, flog, blog))
    # Pack a canvas into the top level window.
    # This will be used to place the image
    success_canvas = Canvas(root)
    success_canvas.pack(fill = "both", expand = True)
    # Open the image
    imgtk = PhotoImage(img)
    # Get the top level window size
    # Need a call to update first, or else size is wrong
    root.update()
    cwidth = root.winfo_width()
    cheight =  root.winfo_height()
    # create the image on the canvas
    success_canvas.create_image(cwidth/2, cheight/2, image = imgtk)
    root.after(4000, root.destroy)
    root.mainloop()
开发者ID:mikefenton,项目名称:UCDAssignmentSubmission,代码行数:31,代码来源:Submit.py

示例4: main

# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import winfo_screenwidth [as 别名]
def main():
	global ROOT 
	ROOT = Tk()
	ROOT.protocol('WM_DELETE_WINDOW', terminateAll)
	w = ROOT.winfo_screenwidth()
	h = ROOT.winfo_screenheight()
	ROOT.geometry("%dx%d" % (w/1.6, h/3))
	app = Window(ROOT)
	ROOT = mainloop()
开发者ID:abbad,项目名称:NetProb,代码行数:11,代码来源:transmitter_GUI.py

示例5: main_root

# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import winfo_screenwidth [as 别名]
def main_root():
    iam_root = Tk()
    iam_root.title("Projet Python DIC1")
    w_ = iam_root.winfo_screenwidth()
    h = iam_root.winfo_screenheight()
    x = w_ / 2 - dimx_ / 2
    y = h / 2 - dimy_ / 2
    iam_root.geometry("%dx%d+%d+%d" % ((dimx_, dimy_) + (x, y)))
    iam_root.resizable(False, False)
    return iam_root
开发者ID:mourma10,项目名称:Projet_Algebre_DIC1,代码行数:12,代码来源:getroot.py

示例6: root_operation

# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import winfo_screenwidth [as 别名]
def root_operation(n, title):
    root_op = Tk()
    canvas = Canvas(root_op, width=200 * n - 100, height=100 * n - 50, bg="#cdd")
    w_ = root_op.winfo_screenwidth()
    h = root_op.winfo_screenheight()
    x = w_ / 2 - (200 * n - 100) / 2
    y = h / 2 - (100 * n - 50) / 2
    root_op.title(title)
    root_op.geometry("%dx%d+%d+%d" % ((200 * n - 100, 100 * n - 50) + (x, y)))
    root_op.resizable(False, False)
    return root_op, canvas
开发者ID:mourma10,项目名称:Projet_Algebre_DIC1,代码行数:13,代码来源:getroot.py

示例7: GUI

# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import winfo_screenwidth [as 别名]
class GUI(object):
    def __init__(self, world):
        self.ticks = 0
        self.world = world
        self.width = world.width
        self.height = world.height

        self.root = Tk()
        self.root.title("Mars Explorer")
        window_x, window_y = self._compute_window_coords()
        self.root.geometry('%dx%d+%d+%d' % (self.width, self.height,
                                            window_x, window_y))

        self.canvas = Canvas(self.root, width=self.width, height=self.height)
        self.canvas.pack()
        self.canvas.after(1, self._tick)

    def start(self):
        self.root.mainloop()

    def _tick(self):
        # Stop if done.
        if self.world.is_done():
            return

        self.world.tick()
        self._draw()

        self.ticks += 1
        self.canvas.after(1, self._tick)

    def _draw(self):
        self.canvas.delete('all')

        self.world.draw(self.canvas)
        for entity in self.world.entities:
            entity.draw(self.canvas)

        self.canvas.create_text(self.width - 20, 10, text=str(self.ticks))
        self.canvas.create_text(self.width - 70, 30,
                                text='Rocks in carriers: %d' % self.world.rocks_in_carriers())
        self.canvas.create_text(self.width - 70, 50, text='Rocks delivered: %d' % self.world.rocks_collected)
        self.canvas.create_text(self.width - 55, 70, text='Total rocks: %d' % self.world.num_rocks)

    def _compute_window_coords(self):
        # http://stackoverflow.com/a/14912644/742501
        screen_width = self.root.winfo_screenwidth()
        screen_height = self.root.winfo_screenheight()
        window_x = screen_width / 2 - self.width / 2
        window_y = screen_height / 2 - self.height / 2
        return window_x, window_y
开发者ID:mihneadb,项目名称:mars-explorer,代码行数:53,代码来源:gui.py

示例8: __init__

# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import winfo_screenwidth [as 别名]
 def __init__(self, length, row_length, led_size=DEFAULT_LED_SIZE):
     super(SimulationStrip, self).__init__(length)
     led_window = Tk()
     led_window.title('LED Simulator')
     MARGIN = 5
     led_size = min((led_window.winfo_screenwidth() - 2 * MARGIN) / row_length, led_size)
     num_rows = math.ceil(length / row_length)
     height = num_rows * led_size + (1 + num_rows) * MARGIN
     width = led_size * row_length + 2 * MARGIN
     self.canvas = Canvas(led_window, width=width, height=height)
     self.canvas.pack()
     self.leds = [] * length
     self.leds = [self.create_rectangle(i, row_length, led_size, MARGIN) for i in xrange(length)]
     self.canvas.update()
开发者ID:ncvc,项目名称:bar-lighting,代码行数:16,代码来源:Strip.py

示例9: main

# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import winfo_screenwidth [as 别名]
def main():
	binder = Binder()

	root = Tk()
	sw = root.winfo_screenwidth() /10
	sh = root.winfo_screenheight() /10

	root.geometry("200x170+{x:d}+{y:d}".format(x = 5*sw -100, y = 7*sh + 40))
	mainwin = MainFrame(root, binder)

	wpa = []
	for i in range(windowDuplication['points']):
		wpa.append(NumWindow(root, "Punti A", binder,
			"{w:d}x{h:d}+{x:d}+{y:d}".format(w = 3*sw, h = 3*sh, x = 2*sw, y = sh)))
	ta = PointTracker(foreacher(wpa, lambda i: i.setNum))
	ta.reset()
	mainwin.setA(ta.up, ta.down)
	binder.addBinding('c', ta.up)
	binder.addBinding('d', ta.down)

	wpb =[]
	for i in range(windowDuplication['points']):
		wpb.append(NumWindow(root, "Punti B", binder,
			"{w:d}x{h:d}+{x:d}+{y:d}".format(w = 3*sw, h = 3*sh, x = 5*sw, y = sh)))
	tb = PointTracker(foreacher(wpb, lambda i: i.setNum))
	tb.reset()
	mainwin.setB(tb.up, tb.down)
	binder.addBinding('m', tb.up)
	binder.addBinding('k', tb.down)

	wm = []
	for i in range(windowDuplication['time']):
		wm.append(NumWindow(root, "Minuti",  binder,
			"{w:d}x{h:d}+{x:d}+{y:d}".format(w = 3*sw, h = 3*sh, x = 2*sw, y = 4*sh + 20)))
	ws = []
	for i in range(windowDuplication['time']):
		ws.append(NumWindow(root, "Secondi", binder,
			"{w:d}x{h:d}+{x:d}+{y:d}".format(w = 3*sw, h = 3*sh, x = 5*sw, y = 4*sh + 20)))

	def updateTimer(mm, ss):
		for i in range(windowDuplication['time']):
			wm[i].setNum("{:02d}".format(mm))
			ws[i].setNum("{:02d}".format(ss))

	timer = Timer(updateTimer)
	mainwin.setStartStop(timer.startStop)
	binder.addBinding(' ', timer.startStop)
	mainwin.setReset(timer.reset)

	root.mainloop()
开发者ID:Tomfox91,项目名称:pytimer,代码行数:52,代码来源:timer.py

示例10: ask_company

# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import winfo_screenwidth [as 别名]
def ask_company(): 
    root = Tk()
    app = Example(root)
    wt = root.winfo_screenwidth()
    ht = root.winfo_screenheight()
    rootsize = (516, 102)
    x = wt/2 - rootsize[0]/2
    y = ht/2 - rootsize[1]/2
    root.geometry("%dx%d+%d+%d" % (rootsize + (x, y)))
    root.lift()
    root.mainloop()
    company = app.entry.get()
    app.quit()
    return(company)
开发者ID:leetncamp,项目名称:portal,代码行数:16,代码来源:ask.py

示例11: error_and_exit

# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import winfo_screenwidth [as 别名]
def error_and_exit(title, main_text):
    """
    Show a pop-up window and sys.exit() out of Python.

    :param title: the short error description
    :param main_text: the long error description
    """
    # NOTE: We don't want to load all of these imports normally.
    #       Otherwise we will have these unused GUI modules loaded in the main process.
    from Tkinter import Tk, Canvas, DISABLED, INSERT, Label, Text, WORD

    root = Tk()
    root.wm_title("Tribler: Critical Error!")
    root.wm_minsize(500, 300)
    root.wm_maxsize(500, 300)
    root.configure(background='#535252')

    # Place the window at the center
    root.update_idletasks()
    w = root.winfo_screenwidth()
    h = root.winfo_screenheight()
    size = tuple(int(_) for _ in root.geometry().split('+')[0].split('x'))
    x = w / 2 - 250
    y = h / 2 - 150
    root.geometry("%dx%d+%d+%d" % (size + (x, y)))

    Canvas(root, width=500, height=50, bd=0, highlightthickness=0, relief='ridge', background='#535252').pack()
    pane = Canvas(root, width=400, height=200, bd=0, highlightthickness=0, relief='ridge', background='#333333')
    Canvas(pane, width=400, height=20, bd=0, highlightthickness=0, relief='ridge', background='#333333').pack()
    Label(pane, text=title, width=40, background='#333333', foreground='#fcffff', font=("Helvetica", 11)).pack()
    Canvas(pane, width=400, height=20, bd=0, highlightthickness=0, relief='ridge', background='#333333').pack()

    main_text_label = Text(pane, width=45, height=6, bd=0, highlightthickness=0, relief='ridge', background='#333333',
                           foreground='#b5b5b5', font=("Helvetica", 11), wrap=WORD)
    main_text_label.tag_configure("center", justify='center')
    main_text_label.insert(INSERT, main_text)
    main_text_label.tag_add("center", "1.0", "end")
    main_text_label.config(state=DISABLED)
    main_text_label.pack()

    pane.pack()

    root.mainloop()

    # Exit the program
    sys.exit(1)
开发者ID:Tribler,项目名称:tribler,代码行数:48,代码来源:check_os.py

示例12: prompt_gui

# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import winfo_screenwidth [as 别名]
    def prompt_gui(self, name, propagate_exception = False):
        ''' Returns None if failed to load tkinter or open display.
        (unless propagate_exception == True).'''
        
        ''' I thought about caching and reusing the tkinter instance, but it might be hard
        to properly temporarily exit from mainloop and suspend the application.
        Anyway, it takes like 10ms to restart it.'''
        try:
            from Tkinter import Tk, Label, Frame, Entry, StringVar
            root = Tk()
        except:
            if propagate_exception:
                raise
            return None

        root.title('Enter value for \'%s\':' % name)
        frame = Frame(root)
        frame.pack(fill = 'y', expand = True)

        label = Label(frame, text='Enter value for \'%s\':' % name)
        label.pack(side='left')
        
        var = StringVar()
        entry = Entry(frame, textvariable = var)
        entry.pack(side='left')
        
        result = []
        root.bind('<Return>', lambda ev: (result.append(var.get()), root.destroy()))
        ws = root.winfo_screenwidth()
        hs = root.winfo_screenheight()
        root.geometry('+%d+%d' % (ws * 0.4, hs * 0.4))
        entry.focus()
        
        # If I don't do this then for some reason the window doesn't get focus
        # on the second and following invocations. 
        root.focus_force()

        root.mainloop()
        if not len(result):
            # mimic the behaviour of CLI version
            raise KeyboardInterrupt()
        return result[0]
开发者ID:Vlad-Shcherbina,项目名称:icfpc2013-follow-up,代码行数:44,代码来源:simple_settings.py

示例13: intro

# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import winfo_screenwidth [as 别名]
class intro(object):
    def __init__(self):

        self.master=Tk()

        self.x = (self.master.winfo_screenwidth()/3) - (self.master.winfo_width())
        self.y = (self.master.winfo_screenheight()/3) - (self.master.winfo_height())
        self.master.geometry("+%d+%d" % (self.x, self.y))
        self.master.overrideredirect(True)
        self.master.resizable(False,False)
        self.logointroimg=Image.open(r'img/Logo-introscreenmin.jpg')
        self.Tkimage3= ImageTk.PhotoImage(self.logointroimg)

        self.canvas = Canvas(self.master, height=378,width=672 )
        self.canvas.create_image(336,186, image=self.Tkimage3)
        self.canvas.pack()


        self.master.after(1250,self.master.destroy)

        self.master.mainloop()
开发者ID:riojano0,项目名称:Python_Scripts,代码行数:23,代码来源:login.py

示例14: _init_ui

# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import winfo_screenwidth [as 别名]
    def _init_ui(self):
        root = Tk()
        root.title("pylens")
        root.bind("<FocusOut>", self.close)
        root.bind("<Escape>", self.close)

        # center the window
        root.withdraw()
        root.update_idletasks()  # Update "requested size" from geometry manager
        x = (root.winfo_screenwidth() - root.winfo_reqwidth()) / 2
        y = (root.winfo_screenheight() - root.winfo_reqheight()) / 2
        root.geometry("+%d+%d" % (x, y))
        root.deiconify()

        text = Text(root)
        text.config(width=60, height=1)
        text.pack(side=LEFT, fill=Y)
        text.bind("<Return>", self.handle_query)
        text.focus_force()

        return root, text
开发者ID:patricklucas,项目名称:pylens,代码行数:23,代码来源:pylens.py

示例15: __init__

# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import winfo_screenwidth [as 别名]
class Windows:
    def __init__(self, titl, px, py, x, y):
        self.titl = titl
        self.w = x
        self.h = y
        self.frame = Tk()
        self.frame.geometry("%dx%d+%d+%d" % (x, y, px, py))
        self.frame.title(titl)

    def show_window(self, box):
        pass

    def change_title(self, tit):
        self.frame.title(tit)

    def move_to_center(self):
        sw = self.frame.winfo_screenwidth()
        sh = self.frame.winfo_screenheight()
        x = (sw - self.w) / 2
        y = (sh - self.h) / 2
        self.frame.geometry("%dx%d+%d+%d" % (self.w, self.h, x, y))
开发者ID:nnj1008,项目名称:silver-lining,代码行数:23,代码来源:P2010CS1007_Tkinter.py


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