tkinter - 如何使用 grid_columnconfigure Tkinter 为每一行配置不同的列?
问题描述
class RenameFrame():
def __init__(self):
pass
def createRenameFrame(self, win):
width = ((win.winfo_screenwidth() // 2) - 30)
height = win.winfo_screenheight() - 105
R_Frame = Frame(win, width=width, height=height, bg='#222222', highlightcolor='white',relief='solid')
R_Frame.grid(row = 1, column = 0)
R_Frame.grid_propagate(0)
Grid.columnconfigure(R_Frame, 0, weight = 1)
Grid.rowconfigure(R_Frame, 0, weight = 1)
# The update() and update_idletask() methods are useful for processing any pending or idle tasks
win.update_idletasks()
R_FrameContent = LabelFrame(R_Frame, text='Bunch Renamer', width=width, height = height, bg='#222222', fg='white',
font=('Flux Regular', 20, 'bold'))
R_FrameContent.grid(padx=10, pady=10, ipady=20, ipadx=20)
R_FrameContent.grid_propagate(0)
# R_FrameContet configurations
Grid.columnconfigure(R_FrameContent, 1, weight = 2)
# First Row start
lb = Label(R_FrameContent, text='Selected Folder: ',bg='#222222', fg='white', font=('Flux Regular', 10, 'bold'),
width='15')
lb.grid(row=0, column=0, pady=5, padx=2)
pathVal = StringVar()
pathVal.set("No Folder Selected")
entry = Entry(R_FrameContent, textvariable=pathVal, state='disabled', bd=0, relief = 'solid')
entry.grid(row=0, column=1, padx=2, ipadx=5, ipady=2 , sticky="ew")
# entry.grid_propagate(0)
browseButton = Button(R_FrameContent, text = 'Browse', activebackground='tomato', activeforeground='white', bd=0, relief='solid',
bg='tomato',fg='white', highlightbackground='tomato', font=('Flux Regular', 10, 'bold'), width=10 )
browseButton.grid(row=0, column=2, pady=5, padx=2)
# First Row end
# Second Row start
actionSelectionFrame = LabelFrame(R_FrameContent, text = 'Select Action', labelanchor = 'n', bg='#222222', fg='white',
font=('Flux Regular', 10, 'bold'))
actionSelectionFrame.grid(row = 1, column = 0, columnspan = 3, padx=15, pady= 5)
status = IntVar()
rb1 = Radiobutton(actionSelectionFrame, text='Default Prefix', variable=status, font=('Flux Regular', 10, 'bold'), value= 1)
rb1.grid(row=0, column=0, ipady=5, ipadx=5, padx=5, pady=(10, 10))
rb2 = Radiobutton(actionSelectionFrame, text='Custom Prefix', variable=status, font=('Flux Regular', 10, 'bold'), value= 1)
rb2.grid(row=0, column=1, ipady=5, ipadx=5, padx=5, pady=(10, 10))
rb3 = Radiobutton(actionSelectionFrame, text='Custom File Name ', variable=status, font=('Flux Regular', 10, 'bold'), value= 1)
rb3.grid(row=0, column=2, ipady=5, ipadx=5, padx=5, pady=(10, 10))
# Second Row end
return R_Frame
此代码从另一个文件中取胜,并使用该窗口显示当前的[R_Frame]帧。我想配置R_FrameContent Frame 的第二列。所以基本上我希望第二列 选择操作列展开。
如果有人可以向我解释有关 grid_rowconfigure 和 grid_columnconfigure 的信息,那将非常有帮助。
非常感谢您的帮助。
解决方案
推荐阅读
- html - 将图形编辑器嵌入网页
- networking - 如何在mac上拦截应用程序的网络流量以进行检查?
- reactjs - 用于将 React SEPARATE 中的道具传播到 JavaScript 表达式上下文中的传播运算符的三点语法是否?
- c++ - 如何使用 C++ 获取输入字符串的十六进制值?
- spring - 控制器级别日志中未显示跟踪 ID(Spring 引导、Jaeger 配置)
- docker - Kibana UI 未启动,但容器已启动并正在运行
- elasticsearch - 搜索相隔不到 X 分钟的 2 个 ES 条目
- linux - Authenticate to Azure with certificate from Linux
- python - 为什么静态变量会改变?
- python - ModuleNotFoundError:没有名为“my_module”的模块