I am trying to write a simple GUI for editing key-value pairs in TCL+Tk. It is based on a vertical ttk::panedwindow widget containing an arbitrary number of horizontal ttk::panedwindow widgets, each with a ttk::entry on the left side and a text widget on the right side. Below the main ttk::panedwindow is a frame containing buttons to do things like saving and loading files and adding new rows. This works fine, with all widgets scaling as I expect them to, but when more rows are added they get squeezed together or stretch the window.
Trying to make the window vertically scrollable didn't work properly. Tk is unfortunately very picky about what it will let me attatch scrollbars to, so I couldn't just put one on the main ttk::panedwindow. I tried various hacks listed on wiki.tcl.tk, but most of them use a canvas widget and scroll in both directions. If I remove the horizontal scrollbar, it won't be there anymore but the widgets will still extend beyond the edge of the window or stop before the edge of the window.
I also tried BWidget, but I didn't understand the relationship between the ScrolledWindow and ScrollableFrame widgets that I was told to use together. When I followed the examples they had the same problem as the canvas version. I suspect that they actually use a canvas internally rather than implementing a true scrollable frame.
How can I make the main interface scale to the dimensions of the window while also allowing vertical scrolling? I'm using Linux, if that helps.
I made a GIF to show what I want:
dissapearing scrollbar is optional, it just happened like that. The changing scribbles represent the lines of text adjusting to the available space.
So… you want the content to be “natural” in the vertical direction, yet stretched in the horizontal direction? Tricksy.
Your basic approach is going to be to put a frame (or ttk::frame) inside a canvas, put your “interesting” content inside the frame and add a scrollbar to the canvas. However, that's not the tricky bit. The tricky part is that you need to notice changes to the dimensions of the canvas and to the dimensions of the frame; a change to the frame should cause the adjustment of the canvas's bounding box, and a change to the canvas should cause adjustment to the requested width of the frame.
To notice a change to the size of any widget, you bind to the <Configure> event sent to that widget and use the %w and %h to get the width and height that the widget is being set to. (Indeed, geometry managers like grid and pack work exactly like that internally, except they use C-level bindings and not script-level ones.)
bind $canvas <Configure> {adjustCanvasDimensions %W %w %h}
bind $frame <Configure {adjustFrameDimensions %W %w %h}
proc adjustCanvasDimensions {theCanvas width height} {
set theFrame $theCanvas.frame
set oldwidth [$theFrame cget -width]
if {$width != $oldwidth} {
$theFrame configure -width $width
}
# Consider adjusting the frame height if canvas height greater
}
proc adjustFrameDimensions {theFrame width height} {
set theCanvas [winfo parent $theFrame]
$theCanvas configure -bbox [list 0 0 $width $height]
}
Or something like that. This is untested code (and assumes you put the frame in the canvas, etc.) but ought to show you the way forward.
Related
i need to create a footer that can stay at the bottom of every pages of the report, but i can't use the standard function because i need to hide some element before it self.
I hope that i've explained correctly!
Somebody can help me?
If I've understood you correctly, you should be able to do this by creating rectangles to hold your report content.
If you need a header, body and footer then you would need 3 rectangles, if you only need the main body and a footer then 2 rectangles.
For simplicity, let's say you page is 29cm high and the bottom 6cm will contain the footer.
You create a rectangle that is 23cm high and wide enough to hold the elements you need in it. Then your seconds rectangle immediately below will be 6cm.
Within each rectangle, place you report elements (text boxes, tables etc).
Note: If you already have the report elements in your report, do not drag them over the rectangle as this will literally overlay them, instead, select everything you ned, then cut them. Then click in the rectangle to make it active and paste them, this way the rectangle will be the container. If you are creating the elements from new then you can add them within the rectangle as normal.
Once all your body and footer elements are in position, change the 'ConsumeContainerWhiteSpace' property of Report to true. This property will prevent the rectangle from expanding as the number of rows in a table gets larger, as it will use the space in the container first.
I saw the Google Material Design website and was amazed by the change of color of the left, sticky "speech bubble"-image when you scroll down.
I am trying to understand the concept but Google's code is huge and somewhat confusing...
I think there are actually two images, but I cant recreate it just with different z-index values alone (I can let the first image disappear and the first appear but in combination it doesn't work).
Do I need a JS-library for that? Waypoints/scrollreveal etc., is this some kind of SVG magic or am I overlooking a simple solution?
on simple usage try onScroll() method using js for applying basic css colors on your element.
I believe those are animated objects, and the sections (their containers) have overflow:hidden, so those objects stay within their sections.
Also they probably have position:fixed and positioned using'top' and 'left' properties to stay on place all the time (or probably some JavaScript magic).
And ther animation is launched using JavaScript function scrollTop(), when visitor is on a certain distance from a page top.
I'm not sure what is used in this exactly page, but you can change and adjust scale, size, color and transparency depending on position from page top using JavaScrip - 100%.
TK GUI having scrolling canvasCan we create a window in canvas, with relative positioning?
Or is there any way to place the object in canvas that could be binded with canvas for scrolling.
You can put windows into canvases such that they can be scrolled. To do this, you should create a window item:
canvas .c -borderwidth 0 -highlightthickness 0
button .c.btn
# Arbitrary coordinates
.c create window 20 20 -window .c.btn
If you're doing this, be aware that it's really advised to make the window being scrolled be a child of the canvas, and to disable (well, make zero width) any border or highlight ring of the canvas. Otherwise you'll get “interesting” graphical artefacts when the window goes over the edge or even out of the canvas entirely. Windows are only ever clipped by their parent widgets (up to the nearest toplevel).
I'm using the WinRT XAML Toolkit v1.6.1.3. I have a very small graph that fits on a GridView tile and the legend takes up room that I'd rather give to the graph:
Setting the LegendStyle's Visibility to Collapsed doesn't do anything.
I have read that people have had success with just setting the LegendStyle's Width to 0. However, when I do that, I get weird clipping issues with the right and bottom axes:
Does anyone know how of a way to hide the legend without clipping the axes?
Never mind, it seems that the clipping is due to the weird axis setup I have (I'd like to have one Y axis on the left for the first two series and a second Y axis on the right for the third series), not hiding the legend. Adding a LegendStyle with Width set to 0 works great for hiding the legend. I'll post another question for the axes.
I have a background that is a set of fairly complex gradients (done with CSS, not images). In the middle of the page is a fixed frame, and the content sits inside this frame. I can set overflow-y: auto on this frame to scroll the content, but I would like to be able to use the window to scroll instead.
Here is what the page looks like now:
I would like the scroll bar to be on the window instead. I can take the content outside of the frame and add margins as necessary, but the problem is that then the content will appear outside the frame. I could then cover it up on the top and bottom, but this is difficult/impossible because the background is not an image and is not solid.
Is there any way to have a transparent element at the top/bottom block text that scrolls under it? Can you somehow apply styles to content that overlaps?
Even the fanciest single-browser only solution that requires JavaScript is perfectly acceptable.
if all you're aiming at is hiding the scrollbar (and assuming you're ok with jQuery), i'd suggest to use something like slimScroll.
what's going on under the hood is simple: the designated container is assigned with overflow: hidden;, and attached with a hover handler - with the sole purpose of simulating a custom scrollbar in response to mouse-over events.
Try to explore jScrollPane features.
It's powerfull flexible JQuery plugin for working with scrollbars, possibly you will find solution with it.