0

tcl/tk の専門家が、 Tix CheckList Hlist Headerに関するこの超ニッチな質問に答えてくれることを願っています。私がしたいのは、背景色を醜い灰色から白に変更することだけです。

tix で何にでも使用できるオプション (cnf={}または) を知ることさえ非常に難しいと思います。**kw私は、self.checklist.hlist.config().keys()どのリターンができるかを発見しました:

['background', 'bd', 'bg', 'borderwidth', 'browsecmd', 'columns', 'command',
 'cursor', 'dragcmd', 'drawbranch', 'dropcmd', 'fg', 'font', 'foreground',
 'gap', 'header', 'height', 'highlightbackground', 'highlightcolor',
 'highlightthickness', 'indent', 'indicator', 'indicatorcmd', 'itemtype',
 'padx', 'pady', 'relief', 'selectbackground', 'selectborderwidth',
 'selectforeground', 'selectmode', 'separator', 'sizecmd', 'takefocus',
 'wideselection', 'width', 'xscrollcommand', 'yscrollcommand']

どのオプションが利用可能かを確認するために、実際のヘッダー オブジェクトに対してこれを行う方法がわかりません。

これは次のようになります。

Tix CheckList Hlist ヘッダー

これを作成するコードは次のとおりです。

import tkinter as tk
from tkinter import tix

class whatever(tk.Frame):
  def __init__(self, parent):
    super(whatever, self).__init__(parent)
    self.parent = parent

    self.checklist = tix.CheckList(self.parent, browsecmd=self.selectItem,
                                   options='hlist.columns 1', highlightthickness=1,
                                   highlightcolor='#B7D9ED')
    self.checklist.grid(sticky='ew', padx=20)

    self.checklist.hlist.config(bg='white', bd=0, selectmode='none', selectbackground='white',
                                selectforeground='black', drawbranch=True, pady=5, header=True)

    self.checklist.hlist.header_create(0, itemtype=tix.TEXT, text='My Heading Text',
                                       relief='flat')

    self.checklist.hlist.add("CL1", text="checklist1")
    self.checklist.hlist.add("CL1.Item1", text="subitem1")
    self.checklist.setstatus("CL1", "on")
    self.checklist.setstatus("CL1.Item1", "off")

  def selectItem(self, item):
      print(item)

root = tix.Tk()
whatever(root)
root.mainloop()

追加情報:

ちなみに、私は主にこのサイトを使用して、どのメソッドが利用可能かを把握していますhlist- http://epydoc.sourceforge.net/stdlib/Tix.HList-class.html

この例も役に立ちました: https://svn.python.org/projects/stackless/trunk/Demo/tix/samples/SHList2.py

何を試した...

たくさんのことが何時間も続きます。これは次の場所にあるべきだと思います:

self.checklist.hlist.header_configure(0, background='white')

しかし、私は試しました: background, selectbackground, bg, color... など。それらはすべて同じ_tkinter.TclError: unknown option "-NAMEHERE"メッセージで終了します。

4

1 に答える 1

2

メソッドにheaderbackgroundパラメーターを追加するだけです。header_create()

...
self.checklist.hlist.header_create(0, itemtype=tix.TEXT, text='My Heading Text', 
headerbackground="red", relief='flat')
...
于 2016-09-12T07:43:15.237 に答える