Skip to content

[R-gui] ttkentry background doesnt work

4 messages · Thomas Tschager, j verzani, Peter Dalgaard +1 more

#
Hello,

I'm trying to change the background color of a ttkentry-object. With
tkentry-objects it works fine:

  library(tcltk)
  tt <- tktoplevel()
  test1 <- tkentry(tt)
  test2 <- ttkentry(tt)
  tkgrid(test1,test2)
  tkconfigure(test1, background="yellow") #working
  tkconfigure(test2, background="yellow") #not working

I used different styles and tried suggestions from other mailing lists
(http://coding.derkeiler.com/Archive/Tcl/comp.lang.tcl/2006-11/msg00528.html),
but nothing worked for me... (I'm using WinXP)

Thanks,
Thomas Tschager



----------------------------------------------------
This mail has been sent using Alpikom webmail system
http://www.alpikom.it
1 day later
#
Thomas Tschager <thomastschager <at> dnet.it> writes:
You can use styles. Here is an example:

w <- tktoplevel()
.Tcl(paste("ttk::style layout styled.entry {",
           "  Entry.field -sticky nswe -border 0 -children {",
           "    Entry.padding -sticky nswe -children {",
           "      Entry.textarea -sticky nswe",
           "      }",
           "   }",
           "}",
           sep="\n"))
tcl("ttk::style", "configure","styled.entry", background="#b2b2b2")

e <- ttkentry(w,  style="styled.entry")

tkpack(e)
#
On 08/24/2010 04:59 PM, jverzani wrote:
w <- tktoplevel()
.Tcl(paste("ttk::style layout styled.entry {",
           "  Entry.field -sticky nswe -border 0 -children {",
           "    Entry.padding -sticky nswe -children {",
           "      Entry.textarea -sticky nswe",
           "      }",
           "   }",
           "}",
           sep="\n"))
tcl("ttk::style", "configure","styled.entry", background="#b2b2b2")

e <- ttkentry(w,  style="styled.entry")

tkpack(e)

----


Thanks John,

The whole thing indicates some rather glaring gaps in the interface.
Pasting large stretches of Tcl code together like that _should_ be
unnecessary, but for now, that's probably what you have to do.

What is probably needed is coercion between R list-like structures and
Tcl lists. With that in place, I'd conjecture that we could write
something like


ttkstyle.layout("mystyle",
  list("Entry.field", sticky="nswe", border=0,
       children=list("Entry.padding", sticky="nswe",
           children=list("Entry.textarea", sticky="nswe))))

or maybe

ttkstyle.layout("mystyle", expression(
 Entry.field(sticky="nswe", children=
 Entry.padding(sticky="nswe", children=
 Entry.textarea(sticky="nswe"))))

...if you catch my drift. The exact design probably requires a bit more
thought.
#
On Tue, Aug 24, 2010 at 1:30 PM, Peter Dalgaard <pdalgd at gmail.com> wrote:
You can do this which does not use paste:

w <- tktoplevel()
.Tcl("ttk::style layout styled.entry {
   Entry.field -sticky nswe -border 0 -children {
      Entry.padding -sticky nswe -children {
         Entry.textarea -sticky nswe
      }
    }
  }",
 sep="\n")
tcl("ttk::style", "configure","styled.entry", background="#b2b2b2")

e <- ttkentry(w,  style="styled.entry")

tkpack(e)