Python 3 - PySide2 - Setting up and using Qt Designer

PySide2 is a Python API for the Qt framework. This API is made with Shiboken2, the Python binding generator. It means that you can write your code in Python and use the Qt framework as you’d do with C++. Even building a GUI with the Qt Designer is possible. So what do we wait to start using it? First of all We need to install Python 3on your computer. So in order to have the exact same software and libraries installed in the exact same locations, I suggest to follow the following tutorial: ...

November 27, 2019

Python 3 - Installing - On Windows 10

Python 3 has become an important language nowadays. So if you haven’t installed it yet on your Windows 10 operating system, it’s time (it should work as well on Windows 11). We are going to setup a complete installation in order to be ready using it later. Let’s see that in this Python 3 setting up tutorial. First of all We are going to set up our computer in order to use the following software: ...

November 10, 2019

Python 3 - Generating get and set for C++

Creating get and set can be a tough task. Indeed if you have like dozen of new properties to add to new classes, it could take hours. So what about generating them in few minutes with a script? Let’s see that in this Python scripting tutorial for the C++ language. First of all Fell free to adapt the code for your own language such as Java, PHP or C# for example. ...

February 9, 2019

Python 3 - Data types - Using a dictionary

A dictionary is useful when you want to associate a key with a value. A key is for example the first name of a person and the value his last name. But this is the same for a car and its color. Of course, it is possible to have a dictionary of dictionaries of dictionaries of dictionaries. This is a bit more complex for your brain although it works as well. In this context, a dictionary is like a database that contains all data necessary. ...

June 2, 2012

Python 3 - Data types - Using a set

A set is a container that enables a way to retrieve unique data inside this container. It means that if you want to be sure that only one occurrence is present in a container, you have to choose the set one. For the form, we have to use the curly brackets to declare a set. Let’s see examples in detail with this tutorial of the Python 3 set data type. ...

May 27, 2012

Python 3 - Data types - Using a tuple

A tuple is like a list but without possibility to modify it. We can see a tuple like something declared once to be sure data inside won’t be modified in the future. A bit like a #define or const in C/C++ or the final keyword in Java. So there are only two methods for the tuple data type. Let’s see this in this Python 3 data type tuple tutorial. In the form, there is also a difference with a list or a set, we declare it with parentheses: ...

May 27, 2012

Python 3 - Data types - Using a list

The list data type is like a container. So we can manage it like an array in other programming languages. In this tutorial of the Python 3 data type list, we are going to play with all methods of the list. You can find the count() and index() methods in the listManager() function that I created below. Code ''' Display what there is into myList ''' def listManager(myType, myList): i = 0 name = 50 listSize = myList.\_\_len\_\_() print("\n--> " + myType) print("Number of items = " + str(listSize)) print("Number of \"" + str(name) + "\" value = " + str(theList.count(name)) + ".") try: occurrence = theList.index(name) except ValueError as myError: print("Error:", myError) print("The first occurrence of " + str(name) + " is at index: " + str(occurrence) + ".") for i in myList: print(i) ''' End of listManager ''' theList = ["Hello", "World", 50] listManager("classic", theList) theList.append("Hello") listManager("append", theList) theList[0] = 21 listManager("adding by index", theList) theList.insert(1, "John") listManager("insert", theList) secondList = [34, 12, 57, "Gorgeous"] theList.extend(secondList) listManager("extend", theList) theList.pop() listManager("pop", theList) theList.remove("World") theList.remove("John") theList.remove("Hello") listManager("remove", theList) theList.sort(key=None, reverse=False) listManager("sort", theList) theList.reverse() listManager("reverse", theList) Result --> classic Number of items = 3 Number of "50" value = 1. The first occurrence of 50 is at index: 2. Hello World 50 --> append Number of items = 4 Number of "50" value = 1. The first occurrence of 50 is at index: 2. Hello World 50 Hello --> adding by index Number of items = 4 Number of "50" value = 1. The first occurrence of 50 is at index: 2. 21 World 50 Hello --> insert Number of items = 5 Number of "50" value = 1. The first occurrence of 50 is at index: 3. 21 John World 50 Hello --> extend Number of items = 9 Number of "50" value = 1. The first occurrence of 50 is at index: 3. 21 John World 50 Hello 34 12 57 Gorgeous --> pop Number of items = 8 Number of "50" value = 1. The first occurrence of 50 is at index: 3. 21 John World 50 Hello 34 12 57 --> remove Number of items = 5 Number of "50" value = 1. The first occurrence of 50 is at index: 1. 21 50 34 12 57 --> sort Number of items = 5 Number of "50" value = 1. The first occurrence of 50 is at index: 3. 12 21 34 50 57 --> reverse Number of items = 5 Number of "50" value = 1. The first occurrence of 50 is at index: 1. 57 50 34 21 12 A great data type, isn’t it?

May 26, 2012

Python 3 - General programming - Statements

In Python 3 we cannot increment a variable directly with "++" before or after this variable. We have to add + 1 on the variable to increment it. That’s a bit annoying but life is life. In this tutorial we are going to see examples of the Python 3 statements. While statement We use the while statement to iterate through a number. An int for example. Code i = 0 end = 10 while i < end: print(i) i = i + 1 Result 0 1 2 3 4 5 6 7 8 9 For statement We use the for statement to iterate through something that have data such a string (has characters), an or a list (have items) for example. ...

May 26, 2012

Python 3 - Function - Declaration

The following code is an example of how declaring a function with Python 3: def myFunction(name): print("Hello " + name + "!") Then to use it: myFunction("YOU") It will display: Hello YOU! We can note that there is neither semicolon at the end of a code line nor curly brackets. Only indentation! 😱

September 6, 2011

Python 3 - Installing - On Windows 7

First of all, let’s download the last version of Python 3 on the official website of Python : http://www.python.org/download/releases/ I suggest you to select the last one. And of course to choose the right version of your Operating System (OS). For this Python tutorial on Windows 7, we will take, of course, the Windows X86-64 MSI Installer because the installation is under Windows 7 - 64 bits. If you do not know if your Windows 7 is 64 bits or not, choose the Windows x86 MSI Installer. This version will work on both 32 and 64 bits, so do not hesitate to take it in any doubt. ...

September 1, 2011