I'm writing a script to output things to a window comprising a Tkhtml widget and a text widget displayed above each other in a ttk::panedwindow. Both widgets are scrollable both vertically and horizontally. There's also a button allowing the user to clear the text widget.
I'm doing some of the development on a laptop running Ubuntu. The window manager allows for four desktop workspaces in a 2x2 array, and when the GUI is first displayed, the bottom fifth or so bleeds from the workspace I'm using into the one below. It's irritating to have to muck around resizing the window to make it short enough to fit onto the screen so I want to resize it.
(I think) I know approximately how to do this, i.e bind to an appropriate event so that I can run a script when the window is first displayed. (Reset the binding from within the script so that it only fires once.) I believed that the "appropriate event" was <Map>, but when the window was first mapped, the two widgets had zero height (as reported by [winfo height]). I tried binding to <Expose> and this seems to work, ([winfo height] returns sensible numbers,) so:
Question 1: Which event should I bind to?
When the binding fires, [wm geometry] reports the geometry as 815x1029+49+24, [winfo height] reports the two heights of the two widgets as 600 and 366, and [wm screenheight] returns a height of 800. I know there are various other bits and pieces in the GUI so I'm not surprised that there are 63 pixels unaccounted for in the initial layout. I assume that I need the same amount of space after resizing, so I should request a geometry of 815x737+49+24, but when I do, a sliver (approximately the lower horizontal scrollbar) still bleeds onto the next workspace.
By mucking around manually, I know that when everything fits nicely onto the screen the geometry should be 815x717+49+24, so I've added a fudge factor of 20 to the amount of space I allow for the "other bits and pieces of the GUI". This works fine but seems a little inelegant (massive British understatement :-) ), so:
Question 2: What have I missed, requiring use of a fudge factor?
I'm using Tk 8.6.1 on Ubuntu 12.04.5 LTS. I'm using version 0.9.7.12 of the Compiz window manager.
Update
It struck me that I ought to find the height of the various panes, rather than the Tkhtml and text widgets as that would account for the scrollbars and the "Clear" button. The pane heights are 615 and 409 initially, but this just means that I have to increase my fudge factor from 20 to 78 to get the request height to my desired value of 717. Is there any way to predict what height to request for the toplevel containing my paned window in order to get that toplevel to fill the screen?
I recommend binding to <Map>. I would wait for all of: the paned window, the main tkhtml window, the text window and the scrollbars to be mapped before trying to adjust heights.
For Linux, the [winfo screenheight .] does not know about any panels that are configured, so you have to subtract those. You can get the actual screenheight available by creating a window, doing a wm attributes . -zoomed 1, then getting the geometry of the window.
The title bar and borders of the window take up space. The space needed for these can be calculated by comparing the output from [winfo geometry .] and [wm geometry .].
There is also the panedwindow sash height and any margins and padding.
You can calculate the total of these by subtracting the panedwindow heights from [winfo height .].
Here is one method that would always work, however, it is not very attractive, as the user would see the windows flashing as they change size.
Maximize the window (wm attributes . -zoomed 1)
Get the window geometry and parse out the screenheight.
De-maximize the window (wm attributes . -zoomed 0)
Get the window geometry and replace the screenheight
with the maximized screenheight.
Set the window geometry.
Related
In the design view of SSRS Report Builder, the developer had set the custom attributes for the bar "PixelPointWidth" to 30.
The width of the bar in the bar-chart is appearing good while viewing the report in the browser. However, when trying to export it to pdf or to print the report, the width of the bar in the bar-cart becomes very thin and the text labels within becomes almost unreadable.
Same scenario happens with stacked-bar-chart as well. Tried changing the pixepointwidth and other related parameters but in-effect the issue remains as is.
I'm not sure why the PixelPointWidth would not be left as default, maybe the developer thought this was the way to adjust the width of the bars (which it does, but not directly).
What you should probably do is set the PixelPointWidth to 0 (default) and then adjust the PointWidth property instead, so that you get the desired width.
PixelPointWidth (I think) sets the datapoint width to an exact number of pixels, depending on how you render the report, that will result in different physical dimensions (150 pixels at 100dpi is roughly 38mm but at 150dpi it's approx 25.4mm)
Here's an exmaple where I set the top bar to PixelPointWidth=40 and the bottom bar to PointWidth=0.5 . In design view, on my monitor, it appears the top bar is slightly smaller than the bottom bar.
When previewed (screen rendering) they appear more or less identical heights.
When I render the report to a PDF they look totally different.
As I said earlier, if you set the PixelPointWidth to 0 (default) and then adjust the PointWidth as a percentage of the default gap between categories then you should get much more consistent results. If you set the PointWidth to 1 there will be no gap between each bar, if you set it to 0.8 (default) then the bar will consume 80% of the space and the gap will consume the remaining 20%
I have a ViewController that has content in the top third and then a UIContainerView in the bottom two thirds of the view. The UIContainerView allows the user to rotate between three childViewControllers. Using AutoLayout, I have constrained the UIContainerView to the sides of the screen (widthAnchor), the bottom of the screen (bottomAnchor) and two thirds of the way up the screen (topAnchor).
In laying out content in the first childViewController, which appears on the initial load of the parent ViewController, I ran into difficulty. It appears that on that initial load, the childViewController view is given a view.frame.height equal to the height of the device. I set up my constraints to deal with that and the first screen displays fine.
The issue I am running into now is that when I rotate through the childViewControllers, the view.frame.height is set to the height of the ContainerView (which I would have suspected to be the case from the start). This causes the constraints in the first childViewController to "break".
Look at this behavior below.
Image #1: Initial load of the ParentViewController.
https://roryent.box.com/s/xhil4wk0ga5qoddhko5jxj3a1r4103h3
Image #2: Switching the childViewController.
https://roryent.box.com/s/9f2jj0l1waui3ekyplq4eae51m6wrqn5
Image #3: Coming back to the initial childViewController. The constraints "work" but are reacting to a different view.frame.height.
https://roryent.box.com/s/cj9ffyy3m9oh8f523l2vsdezo1frk12x
NOTE: I am creating the constraints in the ChildViewController class and trying to use the frame of that childViewController frame to do so.
I have attempted to move the methods for constraining the items into willLayoutSubviews() in the childViewController with no change.
I suspect that there is something wrong with where I am loading the different items.
I would expect the self.view.frame.height used in the childViewController code reflect the height of the UIContainerView that is displaying it. In my case the height should be .67 * UIScreen.Main.Bounds.Height.
I believe the issue was due to my implementation of the ContainerView and its corresponding childViewControllers.
I have rebuilt the feature following this tutorial and have not had any problems. https://cocoacasts.com/managing-view-controllers-with-container-view-controllers/
The width of the bar chart throughout the series is automatically reduced to barely visible (for each value) to accommodate the rendering of a large report i.e. extremely long x-axis
Each bar in the report is 1-2 pixels in width and in some cases looks like they are rendered inside each other.
I'm looking to keep the original width of each bar and render a scroll bar instead or something that allows this to be readable. Any suggestions?
Yes. I'd make the width of your chart dynamic in that you increase its width based on a count of the columns produced.
I haven't tried this but everthing seems to have an expression ability in report builder.
I've noticed when using ruler tools from my browser extensions (I've tried multiple) that pixel specifications are typically short by 2 pixels. After noticing this on a site I'm working on, I tried a very simple html page with a div specified with a width and height of 200px and no border or padding. Measuring it out afterwards across multiple browsers and with various ruler tools, the actual rendered box both width and height is 2 pixels shy of my css.
So, curious why this is. What contributes to the "physical" size of the box, screen resolution perhaps? Not the end of the world if this is really how it is, seeing as how it seems to be a consistent thing.
EDIT
Per the comments and reply, my code, very simple:
<html>
<body>
<div style="width: 200px; height: 200px;background: red"></div>
</body>
</html>
And I'm measuring from outside-to-outside. Like here:
If the box you are drawing with your cursor starts inside the box you are measuring, it will be 2 pixels less than if the box you are using to measure starts outside the box you are measuring.
Here is a little graphic:
best is use reset css to ignore such issue
http://yuilibrary.com/yui/docs/cssreset/
I just measured the height of the box above with the (freeware) pixel ruler I wrote, A Ruler for Windows, and it measured just fine as 200 pixels.
I'm a little confused by your box inside the big red box, but the inside box measures a width of 50 if you count the burgundy boarder as part of what needs to be measured.
Of note, with A Ruler for Windows (when it is horizontal) the line on the left edge of the ruler counts as pixel one, and if the ruler is set to a length of (for example) 200, the line on the right edge of the ruler counts as pixel 200.
In other words if you are measuring something that is, for example 3 pixels wide, you would see the 1 pixel on the left to start the ruler, only one pixel in the middle, and finally one pixel on the right to end the ruler.
This is done in this way to allow the ruler to be moved to the two edges of your screen and to have those pixels on the edges counted.
Would it be possible that the two pixels you seem to be shy are the two 1 pixel widths on either end of the ruler?
ref: www.arulerforwindows.com
I'm chalking this up to browser weirdness. Taking screenshots of pages and comparing them in photoshop, they line up perfectly.
I am trying to replace the maximize button in my (swing) screen.
I want my frame to change it's size to my definition of max size and min size,
without the window moving its position.
I tried the following ( and encountered a problem in all )
1. Frame.setMaximumSize, Frame.setMinimumSize. did actually nothing.
2. tableFrame.addWindowStateListener(new WindowStateListener() {
public void windowStateChanged(WindowEvent e) {
then I resized the window
did actually pretty well job in managing the sizes - only that it jumped the screen to the top right corner every click .
(And all I need is to resize the window size when maximize )
3. obviously adding window listener on componentResized doesnt do the job because when I change the sizes to my wanted size - it enters an infinite loop.
thanks a lot
I think you're looking for Frame#setMaximizedBounds(): http://download.oracle.com/javase/6/docs/api/java/awt/Frame.html