标签:alignment tkinter ttk python
我想配置tkinter.ttk.Checkbutton的stylestyle.configure(‘TCheckbutton’,background = theme,前景=’white’,anchor = tkinter.W)以将该检查按钮向左对齐,因为现在它位于中心.非常感谢每个答案:)
解决方法:
您的问题还不清楚.
这是一些代码,用于说明左,右,无分配的数据包以及锚点e,w和无分配的信号.
这应该使您更好地了解如何使用pack vs锚以及何时使用它.
from tkinter import *
import tkinter.ttk as ttk
root = Tk()
packLabel = Label(root)
packLabel.pack(side = LEFT)
packLabel.config(text = "Packed LEFT")
pack2Label = Label(root)
pack2Label.pack()
pack2Label.config(text = "no Pack side")
pack3Label = Label(root)
pack3Label.pack(side = RIGHT)
pack3Label.config(text = "Packed RIGHT")
anchorLabel = ttk.Label(root,width = 50, background = "green", anchor = 'e')
anchorLabel.pack(side = BOTTOM)
anchorLabel.config(text = "anchor = 'e'")
anchor2Label = Label(root,width = 50, background = "orange", anchor = 'w')
anchor2Label.pack(side = BOTTOM)
anchor2Label.config(text = "anchor = 'w'")
anchor3Label = Label(root,width = 50, background = "black", fg = "white")
anchor3Label.pack(side = BOTTOM)
anchor3Label.config(text = "no anchor while packed BOTTOM")
checkButton = ttk.Checkbutton(root)
checkButton.config(text = "Checkbutton anchor = 'w'")
checkButton.pack(anchor = "w") # anchor the pack for ttk.
root.mainloop()
标签:alignment,tkinter,ttk,python
来源: https://codeday.me/bug/20191111/2018991.html
本站声明:
1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。