Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/user-interface/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 定位物体_Python_User Interface_Tkinter - Fatal编程技术网

Python 定位物体

Python 定位物体,python,user-interface,tkinter,Python,User Interface,Tkinter,我正在尝试使用tkinter在python中创建一个简单的接口,这就是我需要的: 我尝试使用以下代码: from tkinter import * class Fullscreen: def __init__(self): self.window = Tk() self.window.attributes('-fullscreen', True) self.fullScreenState = False self.wi

我正在尝试使用tkinter在python中创建一个简单的接口,这就是我需要的:

我尝试使用以下代码:

from tkinter import *


class Fullscreen:
    def __init__(self):
        self.window = Tk()
        self.window.attributes('-fullscreen', True)
        self.fullScreenState = False
        self.window.bind("<F11>", self.toggleFullScreen)
        self.window.bind("<Escape>", self.quitFullScreen)
        left = Label(self.window, text="hello ovest").grid(sticky=W+N)
        right = Label(self.window, text="hello est").grid(sticky=E+N)
        bottom = Label(self.window, text="hello bottom").grid(sticky=S)

        self.window.mainloop()

    def toggleFullScreen(self, event):
        self.fullScreenState = not self.fullScreenState
        self.window.attributes("-fullscreen", self.fullScreenState)

    def quitFullScreen(self, event):
        self.fullScreenState = False
       self.window.attributes("-fullscreen", self.fullScreenState)


app = Fullscreen()
从tkinter导入*
全屏上课:
定义初始化(自):
self.window=Tk()
self.window.attributes('-fullscreen',True)
self.fullScreenState=False
self.window.bind(“,self.toggleFullScreen)
self.window.bind(“,self.quit全屏)
左=标签(self.window,text=“hello ovest”).grid(粘性=W+N)
右=标签(self.window,text=“hello est”).grid(sticky=E+N)
底部=标签(self.window,text=“hello bottom”).grid(sticky=S)
self.window.mainloop()
def切换全屏(自身、事件):
self.fullScreenState=非self.fullScreenState
self.window.attributes(“-fullscreen”,self.fullScreenState)
def全屏显示(自身、事件):
self.fullScreenState=False
self.window.attributes(“-fullscreen”,self.fullScreenState)
app=全屏()
这就是我得到的:

您需要指定用于构建网格的行和列,例如:

Label(self.window, text="Left").grid(row=0, column=0, sticky="nws")
Label(self.window, text="Right").grid(row=0, column=1, sticky="nse")
Label(self.window, text="Bottom").grid(row=1, column=0, columnspan=2, sticky="wes")
您还需要告诉几何图形管理器如何分配附加空间:

self.window.grid_columnconfigure(0, weight=1)
self.window.grid_columnconfigure(1, weight=1)
self.window.grid_rowconfigure(0, weight=1)

有关栅格几何图形管理器工作原理的详细信息,请参见。

pack
是此类布局的最简单选择

left = Label(self.window, text="hello ovest")
right = Label(self.window, text="hello est")
bottom = Label(self.window, text="hello bottom")

bottom.pack(side="bottom", fill="x")
left.pack(side="left", fill="both", expand=True)
right.pack(side="right", fill="both", expand=True)