Ok, I have a ScrolledWindow with inside a Viewport and a Fixed inside of that. I'm using the Builder so I'm not gonna post ALL the code if is not necessary.
I'm using a function that multiplies the given coordinates per 50, so i have a grid with 50 x 50 pixel's squares (the number of squares can variate in the config).
The real question is very simple, how I can put a background of a grid of 50 per 50 pixels? And that should be """infinite""". Preferly the lines should be of 1 px.
Note: I'm not using a grid because I need only to put Images or Icons
I used that. Mainport is the fixed element, and wres and hres are the number of squares
for i in range(self.wres):
image = gtk.Image.new_from_file("resources/Back.png")
self.mainport.put(image, i*50, 0)
for z in range(self.hres):
image2 = gtk.Image.new_from_file("resources/Back.png")
self.mainport.put(image2, i*50, z*50)
Related
I have a chart that has strings for its x axis (a list of names). It's linked to a dynamic array, I have a problem where the graph resizes itself and squeezes 14-15 strings from the array and makes the bar chart small and tiny.
How can I achieve chunky bars and a scroll bar to scroll down to see the rest of the data even when new values are being added to the x-axis at runtime.
Have spent an hour searching with no help! =[
Edit:
Setting the PixelPointWidth Property to 300 gave me the width of the bar the way I want to be, but it has bunched the bars so that all the bars of the 4 series are overlapping instead of being side by side. WHere to go from here?
Edit2:
Manipulating the charts height is definitely getting the desired results, the only thing is the bigger the height, the more white space at the top of the chart, whats the fix for that,. and a fix for the Series representations to be "frozen" on scroll.
You can set the width of the chart every time you add new data to it:
Dim barWidth = Double.Parse(Chart1.Series(0)("PixelPointWidth"))
Chart1.Width = CInt(nData * barWidth) + 100
where nData is how many points there are and the 100 is some amount to take into account the space needed for the Y-axis labels and the legend.
Place the chart control in a Panel as suggested by jmcilhinney with AutoScroll set to true, and you will get a scrollbar when the width of the chart exceeds the width of the panel.
If you want the chart to show the latest added data, you can set the horizontal scroll position after setting the width of the chart:
Panel1.HorizontalScroll.Value = Panel1.HorizontalScroll.Maximum
I have a userform. In multiple cases across several different controls, I have observed the objects with the same Width, Height, Font, and Font Size display different font sizes depending on where they are placed on my userform.
. . . .
Above is an example of this. The two textbox's are both 26H and 48W, with a Left of 90. Both have font Tahoma Regular size 18. The only difference between them is their Top property. And yet visually, the upper one has much wider text than the lower one. The picture on the right has added dots to prove this is not an optical illusion. The upper one can only fit one dot between the letter and the edge. The lower one can fit at least two dots between the letter and the edge.
Can anyone explain why this is happening? What is happening? Or how I could stop it from happening?
Why its happening?
A normal windows graphical application renders in 96dpi/ppi.
However, excel’s rendering system is in 72dpi/ppi,so, when you specify 26 as the height, excel will first convert 72 to 96 dpi.
26 x 96 / 72 = 34.6667
Which means your control height is 34.667 pixels.
This will create artefacts in the rendering of your control.
How can you stop it?
Make sure that the final position of your control and its height has a final pixel position in the form to be a whole number.
You can do this by multiplying by your screen dpi and divide by excel dpi(72)
In your case you can apply a height of 25.5 which will render it correctly.
I hope I solved your answer!!
As Krishna Soni says in this thread, you should use a height of 25.5 for all the reasons he present.
This is equivalent to using controls with a height that is a multiple of 3. Since the rounding of 25.5 is 30, we can take 3 as a multiple of the Top, Height, and Width properties and avoid the text resizing issues.
Seen on Weird change of font size when changing Top proprierty by 1
I'm trying to scale a panel to fit it's parent panel, which I have accomplished By doing this:
ValSize = New Size(basePanel.Width - 20, basePanel.Height - 20)
This works well, but now I want to add another panel (dragItem) to this one I just scaled down (basePanel), but I need to keep the scaling the same between the 2 panels so they are not the same size but scaled the same mount. I was trying to use this formula to find how much I scaled the first item and get a percentage and use that for the new panel.
Dim scaleWidth As Double = Math.Abs(basePanel.Width - dragItem.Width) / dragItem.Width
Whats the proper way to do this?
If you want to get the ratio you are only supposed to divide.
Ratio of a smaller panel compared to the original:
Dim scaleWidth As Double = otherPanel.Width / basePanel.Width
Returns values <= 1
Ratio of the original panel compared to a smaller:
Dim scaleWidth As Double = basePanel.Width / otherPanel.Width
Returns values >= 1
So if you have a panel that is 200px wide and a smaller one that is 150px wide, the ratio will be 0.75. To create a new panel from this based on the smaller panel you would do:
Dim newWidth As Integer = scaleWidth * otherPanel.Width
Since scaleWidth is 0.75 and otherPanel.Width is 150, you will get the following result: 0.75 * 150 = 113 (112,5 to be exact, but it's rounded since it's an integer).
Now your third panel will be 25% smaller than the second panel. The second panel in turn is 25% smaller than the original panel.
Although it's possible, you don't need to do this calculations by yourself. Instead, set each panel's dock property to Fill and set the padding of the container as you like. In this case it's seems to want equal padding for every container.
I searched and tried the troubleshooting faqs but can't see a reference to the problem I'm having.
I have the following presets in the resizer section my web.config:
name="kbp600w" defaults="w=600;h=600;mode=max;anchor=MiddleCenter;watermark=kbp600"
name="kbp600" defaults="w=600;h=600;anchor=MiddleCenter;bgcolor=FEF2E1;watermark=kbp600"
name="kbp300" defaults="w=300;h=300;anchor=MiddleCenter;bgcolor=FEF2E1;watermark=kbp300"
I generate my images with the following urls (I generate three different images using the same file):
picture.jpg?preset=kbp600w
picture.jpg?preset=kbp300
picture.jpg?preset=kbp600
So, here's the thing:
The first URL works fine and does everything defined in the preset.
The second URL also works fine and does everything defined in the preset.
The third URL works fine when the image width is larger than the height (landscape), but when the height is the largest dimension (portrait) it resizes the height correctly but the width dimension does not get padded to fill the 600px width but instead becomes whatever size is calculated to maintain the aspect ratio. I need it to always have dimensions of 600 x 600 with padding either on the top and bottom or sides with the appropriate background color for the padding.
Am I doing something wrong?
https://gist.github.com/anonymous/5672886
Use mode=pad and scale=canvas (or scale=both) to always get exactly the requested dimensions.
Without scale=both or scale=canvas, an image < 600x600 in either dimension won't be upscaled or padded.
P.S. Anchor=MiddleCenter is the default, so you don't need to specify that.
Problem:
Given a grid and elements with height 1 and width 2, 3 or 4, determine if a new element with given width (w) and position ((x1,y), (x2,y)) can be allocated so that the grid has (and will have) as less empty cells as possible between existing and future elements.
Constaints:
You can't move the elements, you can only determine if an element with given position and width can be allocated
An element with width j has k probability to be allocated in the future, width 2 (high), width 3 (medium), width 4 (low)
You can't have more than 3 elements with the same x1 or x2
Minimise the number of empty cells between elements along the x axis
Example of grid:
The tricky part is that I don't know what elements will be allocated, I can only predict how the grid will be filled based on the probability logic defined above.
I'm looking for an algorithm to solve this problem, any tips appreciated.
Thanks a lot!
Suppose Grid is a 2-dim-array, initialised with Empty-Values. A Solution in Python could be:
def fitsInGrid(x1,y,w):
return all([Grid[x1+x,y] is Empty for x in range(w)])