基本上,我想根据另一个组合框的值禁用某个Combobox.我找不到这个问题的答案,也许是因为这对组合框很常见.
我有一个或多或少的代码如下...
self.cBox1Var=tki.StringVar()
self.cBox1=ttk.Combobox(self.mframe, width=16, textvariable=self.cBox1Var, state='readonly',values=['Text entry','Combo box','Check button'])
self.cBox1.grid(row=0,column=1,sticky=tki.W)
self.cBox1Var.set('Text entry')
self.cBox1Var.bind("<<ComboboxSelected>>", lambda event, count=count: self.EnableDisableParamFields(event, count))
self.cBox2Var=tki.StringVar()
self.cBox2=ttk.Combobox(self.mframe, width=16, textvariable=self.cBox2Var, state='readonly',values=['String','Integer','Float'])
self.cBox2.grid(row=0,column=2,sticky=tki.W)
self.cBox2Var.set('String')
Run Code Online (Sandbox Code Playgroud)
...
def EnableDisableParamFields(self, event, count):
if self.cBox1Var.get()=='Combo box': #disable 'Entry format combo box'
#disable "self.cBox2"
else:
#enable "self.cBox2"
Run Code Online (Sandbox Code Playgroud)
提前致谢
编辑!!!!
坚持下去,找到了答案,这很简单.对于那些可能感兴趣的人,可以在这里找到解决方案:http://www.tcl.tk/man/tcl8.5/TkCmd/ttk_combobox.htm
"state ='禁用','只读'或'正常'"
我知道如何在"主"显示屏上全屏显示一个窗口,但即使将我的应用程序窗口移动到连接到我的电脑的辅助显示器,当我打电话时:
self.master.attributes('-fullscreen', True)
Run Code Online (Sandbox Code Playgroud)
为了全屏显示该窗口,它在"主"显示屏中显示,而不是在辅助显示屏中显示(应用程序的窗口从辅助显示屏中消失,并立即显示在"主屏幕"中,全屏显示).
如何在辅助显示屏中全屏显示?
Gretings!
我想更改使用ttk.Notebook创建的选项卡标题中显示的颜色.在搜索了一段时间之后,我发现要改变ttk小部件的样式,我们可以使用ttk.样式,因为笔记本显然没有配置选项来改变它的颜色.但是,我只找到了如何更改NoteBook对象的背景和前景,而不是如何配置"标题页",其背景为白色(选中时)或灰色(未选中时).
有谁可以帮我这个?
这是我现在的代码,与我正在尝试的内容有关
import Tkinter as tki
import ttk
...
##Other code. Not relevant here
...
#create tabs and associate the apropriate frames to it
tabs = ttk.Notebook(parent.master)
ttk.Style().configure("TNotebook", background=mainWcolor, foreground='green') #configure "tabs" background color
paramsFrame = tki.Frame(tabs, bg=mainWcolor) #frame with control parameters
comsFrame = tki.Frame(tabs, bg=mainWcolor) #frame with communication parameters.
ssInfoFrame = tki.Frame(tabs, bg=mainWcolor) #frame with start and stop messages and procedures
tabs.add(paramsFrame, text = "Control")
tabs.add(comsFrame, text = "Communications")
tabs.add(ssInfoFrame, text = "Start & Stop info")
tabs.pack() …Run Code Online (Sandbox Code Playgroud)