I've been able to figure out on my own how to do what I need in the 
largely undocumented tcltk package, but I've finally hit a wall. I can't 
even think of any sufficiently specific search terms to use for this.

I'm trying to make the widgets in my tk window resize when the window is 
resized by clicking and dragging on its corners or edges. Instead they 
stay exactly where they are, and parts of them get cut off when the 
window is made smaller and reveal large empty spaces when the windows is 
made bigger. Looks terrible.

I've tried doing tkconfig(mywidget,sticky='news') and all that does is 
stretch the widget out to the original window dimensions, but this 
doesn't help at all when the window is resized. From reading the TclTK 
documentation, it seems like the 'rowconfigure' and 'columnconfigure' 
methods of the grid are supposed to solve this problem by setting the 
'weight' grid option. There exists a tkgrid.rowconfigure() command and 
the following invocation did not produce any errors...

tkgrid.rowconfigure(mywidget,0,weight=1)

...but it didn't make the widget dynamically resize with the parent 
window either. Either I'm invoking it incorrectly, or it doesn't 
actually do what I think it does. Rather than posting my lengthy and 
complicated code, I'll post this example instead from 
bioinf.wehi.edu.au/~wettenhall/RTclTkExamples/ (a very helpful site 
without which I would never have been able to use the tcltk package at all).

require(tcltk)
tt<- tktoplevel()
xscr<- tkscrollbar(tt, repeatinterval=5,orient="horizontal",
                        command=function(...)tkxview(txt,...))
yscr<- tkscrollbar(tt, repeatinterval=5,
                        command=function(...)tkyview(txt,...))
txt<- tktext(tt,bg="white",font="courier",
     
xscrollcommand=function(...)tkset(xscr,...),yscrollcommand=function(...)tkset(yscr,...),
     wrap="none")
tkgrid(txt,yscr)
tkgrid(xscr)
tkgrid.configure(yscr,sticky="ns")
tkgrid.configure(xscr,sticky="ew")
for (i in (1:100)) tkinsert(txt,"end",paste(i,"^ 2 =",i*i,", "))
tkconfigure(txt, state="disabled")
tkfocus(txt)

This creates a scrollable text window, and it suffers from exactly the 
problem I described above. My question is: what needs to be changed in 
order to make the tktext widget and its scrollbars automatically resize 
with the parent window?

Thank you.

        [[alternative HTML version deleted]]

______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

Reply via email to