How to Center the Main Window on the Screen in Tkinter with Python 3

Python 3, Tkinter 8.6. GUI examples in Windows 10

When your first window loads in Tkinter it will generally appear slightly offset from the top left-hand corner of the screen. This is a fairly counter-intuitive location and most of the GUI driven programs that I run usually open at the centre of the page or a little higher than the center.

If you want a primer of window positioning, check out the following tutorial:

How Do I Change the Size and Position of the Main Window in Tkinter and Python 3

In Python 3, to put the main window in the center of the screen I use the following code:

Window Centered on the Screen in Tkinter with Python 3
Output in Windows 10

Continue reading “How to Center the Main Window on the Screen in Tkinter with Python 3”

How Do I Change the Size and Position of the Main Window in Tkinter and Python 3

Python 3, Tkinter 8.6. GUI examples in Windows 10

When you create your first window in Tkinter, you can set it’s starting size and position on the screen by using the geometry method.

When using this method, note that it only provides the window with the size and position when it is initialized. This means that the user can then change the size of the window and move it once it has first been put on the screen.

Initial Window Size

Continue reading “How Do I Change the Size and Position of the Main Window in Tkinter and Python 3”

Copy and paste ranges in excel with OpenPyXl and Python 3

OpenPyXl is a Python open library that allows you to read and write Microsoft Excel files. Specifically, the ‘*.xlsx’ file extension. It helps you to create programs to create and modify files and automate your processes in excel.

Python Logo

NOTE: This post requires that you have some knowledge of Python and the OpenPyXl library. The library also needs to be installed for you to use. 

Quite often, I find that I have to work with ranges of data that I need to either copy and paste into a new file or files, or copy > modify > paste into files.

The OpenPyXl library allows you to look at every cell of a file and either copy it or modify it by using the openpyxl.worksheet.Worksheet.cell() method. This method allows you to access each cell by the row and column as a numerical value. 

Note! Unlike everything else in coding, rows and columns start with one(1) and not zero(0).

To select whole ranges of our data we need to iterate through it by both row and column and then store that data in a list to be pasted to the new file, spreadsheet or location that we desire.

The following example will take you through the process. For your own data you will need to modify the file, sheet and range locations. Everything else should be good to go.

You can find the whole code at the end of the post.

Why does your MS Excel look weird?

To be honest my screenshots of the ‘.xlsx files will be in Libreoffice. But this simple example will be able to load without issue in MS Excel.

The Example

Continue reading “Copy and paste ranges in excel with OpenPyXl and Python 3”