Tkinter - Columns of equal weight are NOT equal width - python-2.7

I have a Tkinter Toplevel window with three columns. All three columns are configured to have equal weight. Inside column 0 and 2 are sub-frames, inside which are Listbox widgets. Inside column 1 is a set of buttons. For some reason, despite the fact that my 3 columns have equal weight, these Listboxes 'force' their columns to occupy more space.
I've written,
window.columnconfigure(0,weight=1)
window.columnconfigure(1,weight=1)
window.columnconfigure(2,weight=1)
But I get:
I've also given column 1 weights of 3 and 5, but it still remains small. However, having done this, it seems that columns 0 and 2 have some minimum size, then after subtracting that from the real width, the leftover width is used and divided by weight.
Is this a bug? Is there something I need to do to my lists? Might I be forgetting something?

It is not a bug. weight determines how extra space is allocated. It doesn't make any guarantees about the size of a row or column.
If you want columns to have a uniform width, use the uniform option and make them all be part of the same uniform group.
window.columnconfigure(0,weight=1, uniform='third')
window.columnconfigure(1,weight=1, uniform='third')
window.columnconfigure(2,weight=1, uniform='third')
Note: there is nothing special about 'third' -- it can be any string as long as it's the same string for all three columns.

Related

How to Format Power BI Table / Matrix Regardless Of Values

I am very new to Power BI and I have this requirement to format the table which is not conditional formatting but kind a hard coding formatting.
First Row Column 1 is Yellow, Columns 2, 3 and 4 are Red
Second Row Column 1 is Green, Column 2 and 3 are Yellow, Column 4 is Red
Third Row Column 1, 2, 3 and 4 are Green
Fourth Row No Colour
I have also attached the pic below
I guess this is not possible. The reason is, all columns are generated dynamically based on your data in the table. That's why you need to apply conditions to color cells as you want.
Now, as you showed in the sample presentation, if you have that fixed amount of rows and columns with known fixed values in different cells, you can use CARD visual for each individual value to show and then use your expected background.Not a good approach, but the end user will see the expected output :)

Number of ways to color exactly K cells in a 3xN matrix such that no two colored cell are adjacent(do not share edges)?

I tried to solve this problem using Dynamic Programming but it seems I am missing some cases that I am unable to find.
Here is the equation that I used for getting values from sub-problem
dp[i][j] = dp[i][j-1] + 3*(dp[i-1][j-1] - dp[i-2][j-2]) + dp[i-3][j-2]
(i = k = no of cells to be colored and j = n = number of columns, note the row is fixed i.e 3)
The terms are as defined below:
dp[i][j-1] : case when I don't color any cell in the nth column.
dp[i-1][j-1] - dp[i-2][j-2] : case when I color one cell in the last column and then have to subtract the case where I color the adjacent cell in the n-1th column and since this can be done for each of the 3 cells in the nth column I multiplied it with 3.
dp[i-3][j-2] : case when I color two cells(top and bottom ones) in the nth column and thus have only one choice for the n-1th column, that is the middle one, hence subtracting 3 from i and since we have already considered the last two columns I reduce 2 from j.
I couldn't find any mistake in the above approach, If you see any mistake please help.
Below is the actual question where an extra condition of P consecutive column not be empty is also mentioned and should be taken care of.
My approach is to first find all the possible ways to color k cells in 3xN matrix such that they are not adjacent and then finding the number of ways where P consecutive columns exist such that there are no cells colored in them and subtracting it with the total count, but in this approach, I'm missing the correct answer by a small margin for smaller inputs and a large margin for larger inputs. I must be missing something here.

WatchKit: Create ring graph (One ring)

I want to create circle graph on first page of Page Controller and bar graphic on second page of Page Controller. I have use WKInterfaceActivityRing, but it represent only 3 rings together.
I have 2 questions about WatchKit:
How to create standard ring graph (one ring)?
How to create standard bar graph?
What i mean:
p.s. Sorry for my English
I have created a bar graph similar to the one listed by simply adding groups side by side within a containing group and setting all of their widths to say 5 pixels, and the height to zero. Set the height of the container group to say 100 pixels. Then create an outlet for each "element" group within the container and assign the height of the group to be equal to whatever value you want to display. If your scale is only 1 - 10 then calculate what percentage of 10 your value is and multiply that by 100 to tell the element group how large to be.
for example
scale is 1 - 10, value is 5 which is 50%, or .5 of 10, 100 * .5 is 50 so set your element groups height to be 50
Hope that makes sense

Caffe: Multi-Label Images with Varying Number of Labels

I have a dataset where the images have VARYING number of labels. The number of labels is between 1 and 5. There are 100 classes.
After googling, it seems like HDF5 db with slice layer can deal with multiple labels, as in the following URL.
The only problem is that it supposes a fixed number of labels. Following this, I would have to create a 1x100 matrix, where entry value is 1 for the labeled classes, and 0 for non-label classes, as in the following definition:
layers {
name: "slice0"
type: SLICE
bottom: "label"
top: "label_matrix"
slice_param {
slice_dim: 1
slice_point: 100
}
}
where each image contains a a label looking like (1,0,0,...1,...0,....,0,1) where the vector size is 100 dimension.
Now, I apologize that my question becomes somehow vague, but is this a feasible idea? I.e., is there a better approach to this problem?
I get that you have 5 types of labels that are not always present for each data point. 1 of the 5 labels is for 100-way classification. Correct so far?
I would suggest always writing all 5 labels into your HDF5 and use a special value for when the label is missing. You can then use the missing_value option to skip computing the loss for that layer for that iteration. Using it requires add loss_param{ ignore_label = Y } to the loss layer in your network prototxt definition where Y is a scalar.
The backpropagated error will only be a function of labels that are present. If input X does not have a valid value for a label, the network will still produce an estimate for that label. But it will not be penalized for it. The output is produced without any effect on how the weights are updated in that iteration. Only outputs for non-missing labels contribute to the error signal and the weight gradients.
It seems that only the Accuracy and SoftmaxWithLossLayer layers support missing_values.
Each label is a 1x5 matrix. The first entry can be for the 100-way classification (e.g. [0-99]) and entries 2:5 have scalars that reflect the values that the other labels can take. The order of the columns is the same for all entries in your dataset. A missing label is marked by a special value of your choosing. This special value has to lie outside the set of valid label values. This will depend on what those labels represent. If a label value of -1 never occurs you can use this to flag a missing label.

Calculate scrollbar height in grid with varied row height

I've grid with a lot of rows (e.g. 1 000 000). Height of each row may be unique. But most of rows has same height. So it's not possible to determine height of each row and get total grid height.
I need implement smooth vertical scrolling over this grid, not only jump over row, because row can be higher than visible area.
My solution is:
get number of rows
each row is divided into 10 parts
=> scroll bar max value is (number of rows)*10
from scroll position I get :
first visible row = (scroll position) / 10
first visible row shift = (scroll position) % 10
This work fine, if all rows has +- same height. If there is one row with height 500 px and other has 25 px scroll looks awful.
Has anybody suggestion how to better solve this problem?
Grid is here :
http://img560.imageshack.us/img560/7775/scroll.png
Let the scroll be in pixel units:
Sum the total height of all the rows and set the scrollbar max value to that value.
Cache the first visible row index in a variable.
When the user scrolls up or down, you can scan sequentially from the current first visible row to find the new one. This gives amortized constant-time work per update for sequential read.
You won't do random access (e.g. scroll to row number N) frequently so doing a linear search when you do is fine. If you need something faster (I doubt that) then you can pre compute the partial sums of row heights and do binary search.