Using tkinter we can use either widget.grid(row,col) or widget.pack() to place a widget.
Since row,col corresponds to the row/col-index in a given Frame/Window - how do we know how many columns the Frame/Window consists of? E.g if I want to place a widget in the midle or to the very right
Rows and columns are just concepts, not actual things. There is effectively an infinite number of rows and columns, all with a width or height of zero until they contain a widget or are configured to have a minimum width or height. From a practical standpoint, there are as many rows and columns as there are pixels in the window.
In reality, the number of rows and columns is entirely up to you. A widget can have a single row and column or it can have several. It all depends on what you add to the window.
A frame starts out with nothing in it, so there are no rows and columns, just empty space. When you add a widget to a row and column, it now has one row and one column plus maybe some empty space. Even if you place your first widget at row 50 and column 20, there is still just one row (50) and one column (20).
There are simple techniques to put something in the middle, or along the right size. For example, because you can define how many columns, you can configure the master to use three columns and the place your widget in the middle column. You can use columnconfigure to cause the last column to take up all extra space with the weight option. This will move any widgets in the last column to the right edge.
Related
I have a spreadsheet with 1000's points that I want to graph.
Y axis are dates, X axis is time, values are electricity consumption in Kwh.
As you can see updates are in 15min intervals but every other is 0.
a) I want to delete the 0 columns.
b) And graph the result > 255points
excel.jpg
To delete every other column without doing it manually, you can create a formula to help. First insert a row at the top of the sheet (you will delete this row when you are done with it.) Next, in your new helper row, add a MOD function to the first column with the Kwh values (probably column B.) This returns a remainder after we make a division, so we pass the column function to it as our number parameter. The other parameter is the divisor so we will use 2 for that.
=MOD(COLUMN(),2)
With the cell selected, click the bottom right square of the green highlight of that cell (when your cursor turns to a +) and drag it across all of your columns. Now we will have a 0 and 1 in every other column.
We want to convert that formula to values to make sure nothing happens to our data so now copy the highlighted cells and right click to paste special. Here you will change the Paste radio button to Values.
Now we have values in the helper row so we can select all of our columns except the date row, so do that and open the data column. Click the Sort icon and in the sort window now you will click options and choose from left to right. We will then choose to sort by row 1, and choose the order to be smallest to largest.
Now when you click to sort you will have all of your columns with 0 in them (if it was indeed every other column) on the right-hand side, and all of your data is in the left. Easily select all of the zero rows now and delete them manually with one click. Also delete the helper row you created and you have the sheet ready to graph.
Select all of your data including column A and Row 1, and then go to the insert tab. In charts you can see the different types of graphs. Check the recommended charts or experiment by clicking on the different types of graphs to see which one fits your needs the best. If you choose the 2 Line or Scatter for instance, it will graph out each day in different colors showing Kwh on the Y axis, and X will be the time. You can then format as you wish.
I have an excel form which displays a six generation family pedigree chart. Each box for a person's data is merged together from 3 columns and 7 rows. 4 lines of text fit into each box, the 1st line is name, the 2nd birth date and place, the 3rd marriage date and place and the 4th death date and place.
The rightmost two columns are the triple great grandparents of the root person and sometimes a 2nd chart is needed to show their ancestors. The 2nd chart tile is Chart mm-nn where mm is the chart number where the person appears as a GGG grandparent and nn is their number in that chart.
How can I put a number in the upper right corner of these boxes in my chart?
I thought of appending the number to the person's name and flush it right. If possible, it must be with some exotic format string. But each box has 4 text lines and the flush right formatting needs only apply to the 1st.
Perhaps make the numbers as little graphics and overlay them? Chop up the base cells even smaller and merge them into 4 separate lines with the 1st line shorter than the others with a small number box at the end of it?
Ideas?
Jim
The short answer to your question is: no, that's not possible. This is Excel not MS Word. Hence, you can set any given cell only to be left-justified or right-justified. You cannot have both for one cell.
Yet, maybe any of the following work-around might be of help in your case. Of course, I can't be sure since you haven't provided any screenshots of the desired out-come (like a mock-up). But here we go:
This is where you are coming from. A merged box of three columns by seven rows containing four lines of text.
(1) One solution might be to have three different merged areas. The following example consists of three merged areas. The first two rows and the first two columns make up the name. The last column on the first two rows is merged to contain the number and the rest is one merged box again containing the dates and the places.
Note, that you can only see the difference to the original since I selected in this example the top right merged area (consisting of the number only). Otherwise, there wouldn't be any (visually apparent) difference.
(2) Another solution could be to manually insert as many spaces after the name as necessary to make it seem as if it were right-justified. The problem here is (of course) that this changes with the font, the font-size, if the font is bold (or italic) or not, and also the current zoom-factor for the sheet. Hence, this solution would soon wear you out as you would have to manually adjust all the cells constantly. I just wanted to point out this solution for the sake of completeness.
(3) The following solution consists of a text box shape on top of the cell. So, basically I am leaving your original cell (consisting of three columns and seven rows) as is and simply put a shape on top of that cell. The following screenshot shows the result in the top part and the text box being selected in the bottom part (so you can see how this one comes together).
(4) The following work-around is probably the solution you've been looking for and you want to go with. This one is moving away from the cells on the sheet and relies only on text-boxes which are shown on top of the sheet (and thus on top of the cells). Here you can "merge" several text boxes into a group. The group will move and size as a whole. At the same time this group consists of several text boxes and as such may consist of left-justified text boxes and right-justified text boxes as you can see in the screencast below.
My problem seems trivial … but I have stacked in Excel.
I have a really big data sheet and to be able to work with it I applied 3 first rows as frozen (not all cells in this range are filled but sometimes it looks like:
C1: Shop1,
C2: year,
C3: cashier
....data1
....data2
). Then I add there a filter and when data is filtered, I can see only the first row – without row 2 and 3.
Is there any way how to make the frozen rows, frozen also for filtering? Like “untouchable” headers?
Thanks for any answer
You need to input the filter starting in row 3, in other words, select the entire row number 3 in your data table and click on filter. This way you maintain the top 3 rows when you filter your data.
A work around for this could be.
split the view for the top three rows and then create filter on the first row, considering each cell of the first row can be used as column header.
Then you can use the lower part of the split view to work and the top three rows will always be there.
This though not optimal but a quick solution for large sheets with more than 3-4000+ rows of data.
Hope this helps.
I have a car maintenance schedule arranged in vertical table that has two columns: Mileage and Maintenance Cost at the corresponding Mileage.
Then I have a separate horizontal table that has the car actual mileage traveled at the end of each month (60 columns for 60 months).
I need to find a way in excel to cross-check the actual miles traveled in the horizontal table with the maintenance schedule and get the corresponding maintenance cost whenever the actual miles traveled equals a particular mileage on the maintenance schedule +/-1000 miles.
I tried various combinations of Mod, Match, Index, Vlookup but I couldn't get anything to work. Beside using VBA, is there any way I can achieve that in excel?
Any ideas?
Update:
This is the vertical maintenance schedule:
And this is the where the corresponding maintenance cost should be selected:
You can see the same cost values repeating while they should appear only once.
Update: I replaced the screenshots with clearer ones.
First lets work out how to get a lookup in every column, regardless of whether or not the value in row a is a multiple of 10,000.
Add a row (Row3?) to your horizontal table that has the mileage rounded to the nearest 1000 miles. Add another row (row4). Now B4 = vlookup(b3, yourVerticalTable,2)
You say: "but now I need to adjust it to never repeat a previously used maintenance cost value." Perhaps your vertical table isn't filled out all the way, so when it runs out of values, it repeats the last one over and over?
If so, edit one of your formulas by adding a comma after the "2" in your formula:
=vlookup(b3, yourVerticalTable,2 , **[CURSORHERE]** )
With your editing cursor in the formula after the cursor, you should see a tooltip with the words [range lookup] in bold. You might need to change this to 0 (exact match)
UPDATE: With the screenshot, I can refine a little more. This will restrict reporting to only once per 10,000 miles.
First check whether the value in F10 equals the value in E10 (both rounded to the nearest 10,000) If the rounded values are equal, then the formula should return 0 (Or a blank "", or whatever else you want) Otherwise it should perform the vlookup described above
=if(mround(F10,10000) = mround(e10,10000),0,vlookup(.....
I'm tired of merged cells. They just don't work.
So I found a way to avoid merging cells horizontally, when I just need my text to be centered across multiple columns. That's: Range("A1:C1").HorizontalAlignment = xlCenterAcrossSelection.
It works like a charm. It's perfect. It's just what I needed.
I oh-so-naively thought you could do the same vertically, for centering text over multiple rows. Something like: Range("A1:A3").VerticalAlignment = xlCenterAcrossSelection.
But alas, that doesn't work.
Am I missing something here, or did Excel developers really think that, while centering across columns is a common deal, centering over rows is so much of a silly idea nobody would ever do that so why even bother?
You can try this:
Sub VerticalAlign()
ThisWorkbook.Sheets(1).Cells(Round((WorksheetFunction.CountA(Range("A1:A6")) + WorksheetFunction.CountBlank(Range("A1:A6"))) / 2, 0), "A") = "Your Value Here"
End Sub
You'll need to change the ranges being counted, and the column it's referring to, but that should just about do it. A little warning, though: VBA does NOT round the same way that Excel does. It should always be within one digit, though. You can read more about that here: http://support.microsoft.com/kb/194983
We use textbox shapes over cells to do this. If you hold Alt while drawing out the shape, the corners will snap to the Excel grid and move and size with the cells, so it doesn't take much more time than typing into the cells.
I found a happy accident that works around my issue on this if anyone cares to know.
For my situation I needed to track employee vacation time on a linear calendar that was sort-able by name and responsible area. The title section covered three rows that i wanted visible when the data below was filtered. Row 1 = years (merged across months), Row 2 = months (merged across days), Row 3 = days.
Cells A1:A3 was merged and labeled Names (employees), B1:B3 merged and labeled AREA (responsibilities) so we could track vacation time on a calendar spreadsheet to make sure each area had coverage (at least one employee responsible for it was available). The downside of this method caused the filter blocks to be associated with row 1, so row 2 and 3 were hidden when names were filtered on.
Then I tried the VBA code from previous post and it worked, but maxed out at font size that would fit, if too big it would be cut off. So Aesthetically, it looked bad.
Then I put the Names/Area titles in cells A3 and B3 without merge and set filters on row three. This filtered everything starting at row 4 effectively without hiding anything above it, but still looked bad.
Now I found the work around. If you have your titles in the top cell of where you want to merge, and some value in the bottom section. Set filters on the bottom section (need a value to set filters). Then merge the three cells, it works.
So now my A1:A3 Name, and B1:B3 Area is merged, but the filter boxes are on the bottom of the sections (aligned with row 3).
Hopefully that works for some people. I then locked those cells from edit (except auto filter settings) and now it cant be changed accidentally. only filtered.