Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/329.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_Tkinter - Fatal编程技术网

Python 如何设置窗扇的最大移动量

Python 如何设置窗扇的最大移动量,python,tkinter,Python,Tkinter,嗨,我有一个代码如下所示: from tkinter import * from tkinter import ttk import socket, time, datetime class UI: def __init__(self): self.root = Tk() self.root.title("Chating App") self.root.geometry("500x500")

嗨,我有一个代码如下所示:

from tkinter import *
from tkinter import ttk
import socket, time, datetime


class UI:
    def __init__(self):
        self.root = Tk()
        self.root.title("Chating App")
        self.root.geometry("500x500")

    def widgets(self):
        self.m1 = PanedWindow(self.root, sashrelief=RAISED, width=10)
        self.m1.pack(fill=BOTH, expand=1)
        self.main_frame_1 = Frame(self.m1)
        self.m1.add(self.main_frame_1)
        
        Label(self.main_frame_1, text="hello worlds").pack()


        self.m2 = PanedWindow(self.m1, orient=VERTICAL)
        self.m1.add(self.m2)
        self.label2 = Label(self.m2, text="top")
        self.m2.add(self.label2)


    def run(self):
        self.widgets()
        mainloop()

UI().run()

我的问题是如何设置要拖动的窗扇的最大距离?这样用户就可以拖动窗扇而不必完全收缩另一个窗格。抱歉,如果我拼写错误:)

当您将项目添加到
窗格窗口时,您可以设置其最小大小

self.m1.add(..., minsize=100)
如果使用
水平方向
方向,则它将用作最小
宽度

如果使用垂直方向,则它将用作最小高度


文件:


工作代码:

import tkinter as tk  # PEP8: `import *` is not preferred
from tkinter import ttk

class UI:
    def __init__(self):
        self.root = tk.Tk()
        self.root.title("Chating App")
        self.root.geometry("500x500")

    def widgets(self):
        self.m1 = tk.PanedWindow(self.root, width=10, sashrelief='raised')
        self.m1.pack(fill='both', expand=True)
        
        self.main_frame_1 = tk.Frame(self.m1)
        self.m1.add(self.main_frame_1, minsize=100)
        
        self.label_hello = tk.Label(self.main_frame_1, text="hello worlds")
        self.label_hello.pack()

        self.m2 = tk.PanedWindow(self.m1, orient='vertical', sashrelief='raised')
        self.m1.add(self.m2, minsize=100)
        
        self.label_top = tk.Label(self.m2, text="top")
        self.m2.add(self.label_top, minsize=100)

        self.label_bottom = tk.Label(self.m2, text="bottom")
        self.m2.add(self.label_bottom, minsize=100)

    def run(self):
        self.widgets()
        self.root.mainloop()

UI().run()


self.m1.add(…,minsize=100)
。文档:谢谢,它的运行与我预期的一样:)