如何平稳地从tkinter小部件到tkinter.ttk小部件而没有太多麻烦[封闭,但可以回答,如果需要时可以回答]
我已经使用通常的TK小部件编码了TKINTER应用程序。我了解到tkinter.ttk小部件具有更现代的外观,并使一切变得更好。但是现在我的代码大量不起作用。 这是一个很小的,我不明白为什么。
差异是项目的类型……我只将project类型
放在选项中,也没有显示它(而是如何显示)我可以想要预设它)。 这是TK代码:
om1str = StringVar()
om1str.set('Type of Project')
om1list = ['Photo Editing', 'Video Editing']
om1 = OptionMenu(new, om1str, *om1list, command = Create_New.more_options)
和TTK代码:
om1str = StringVar()
om1list = ['Type of Project', 'Photo Editing', 'Video Editing']
om1 = OptionMenu(new, om1str, *om1list, command = Create_New.more_options)
这是另一个示例。从TKINTER交换到TKINTER.TTK之前,此代码有效,但现在不行。 (我有适用于照片编辑选项两个的完全相同的代码)
if choice == 'Video Editing':
print('hi')
for widgets in new.winfo_children():
if widgets.winfo_class() == 'Frame' or widgets.winfo_class() == 'Button':
widgets.destroy()
,现在发生了这种情况(该名称不重复,因为它不在相同的def
create_new.new.more_options())
我如何能够删除帧和按钮,而无需删除tk.toplevel()
我知道如何设置BG和FG 的所有内容经过一些快速的Google搜索后,颜色(真的很困惑)。
是否有任何平稳的方法可以从TKINTER到TKINTER.TTK小部件样式,而无需做2个工作。
I have coded a tkinter application using the usual tk widgets. I have learned that the tkinter.ttk widgets have a more modern look and make everything better. But now alot of my code does not work. Here is a small one which I don't understand why.
The difference is Type of Project is not there... I got around this by just putting Type of Project
in the options it doesn't show it either(But how would I be able to like preset it).
Here is tk code:
om1str = StringVar()
om1str.set('Type of Project')
om1list = ['Photo Editing', 'Video Editing']
om1 = OptionMenu(new, om1str, *om1list, command = Create_New.more_options)
And ttk code:
om1str = StringVar()
om1list = ['Type of Project', 'Photo Editing', 'Video Editing']
om1 = OptionMenu(new, om1str, *om1list, command = Create_New.more_options)
Here is another example. Before swapping from tkinter to tkinter.ttk this piece of code worked but now does not. (I had this exact same code for the photo editing option two)
if choice == 'Video Editing':
print('hi')
for widgets in new.winfo_children():
if widgets.winfo_class() == 'Frame' or widgets.winfo_class() == 'Button':
widgets.destroy()
And now this kinda happens (The name does not duplicate because it is not in the same def
Create_New.more_options()
)
How would I be able to delete the frame and the button without removing all contents of the tk.Toplevel()
I know how to set the bg and fg color(was really confused) after some quick google searches.
Is there any smooth way to go from tkinter to the tkinter.ttk widget styles without having to do a little 2 much work.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论