How to do it...

We will create a DoubleVar of tkinter variable and add a float number literal to it using the + operator. After that, we will look at the resulting Python type.

Here are the steps to see the different tkinter data types:

  1. Create a new Python module and name it GUI_PyDoubleVar_to_Float_Get.py.
  2. At the top of the GUI_PyDoubleVar_to_Float_Get.py module, import tkinter:
import tkinter as tk
  1. Create an instance of the tkinter class:
win = tk.Tk()
  1. Create a DoubleVar and give it a value:
doubleData = tk.DoubleVar()print(doubleData.get())doubleData.set(2.4)print(type(doubleData))add_doubles = 1.222222222222222222222222 + doubleData.get()print(add_doubles)print(type(add_doubles))
  1. The following screenshot shows the final GUI_PyDoubleVar_to_Float_Get.py ...

Get Python GUI Programming Cookbook - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.