2014-07-07 39 views
7

Temel olarak, belirli bir Combobox'ı başka bir combobox'ın değerine göre devre dışı bırakmak istiyorum. Bu soruya bir cevap bulamadım, belki bir Combobox'a bunu yapmak çok nadirdir.Tkinter'da bir Combobox nasıl devre dışı bırakılır?

Ben az çok takip edin gibi bir kod var ...

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') 

...

def EnableDisableParamFields(self, event, count): 
    if self.cBox1Var.get()=='Combo box': #disable 'Entry format combo box' 
     #disable "self.cBox2" 
    else: 
     #enable "self.cBox2" 

Şimdiden teşekkürler

DÜZENLEME !!!!

ısrarlı sonra cevabını buldu ve oldukça basittir. ilginizi çekebilir edenler için , çözüm burada bulunabilir: http://www.tcl.tk/man/tcl8.5/TkCmd/ttk_combobox.htm

"devlet = 'özürlü', 'salt okunur' veya 'normal'" Sen state='disabled' ait Combobox seçeneği kullanmak isteyen

+1

MDK: Hatta Widget gizleyebilirsiniz - .grid_forget 'ile()' – furas

cevap

3

. tamamen işlevsel Combobox olduğunu

  • state='normal' şu şekildedir:

    state için üç seçenek vardır. bir değerle Combobox, ama (şirketinden) değiştirilemez

  • state='readonly'. Combobox ile etkileşim kurulamayan
  • state='disabled'.
İlgili konular