-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path04_string.py
More file actions
34 lines (25 loc) · 920 Bytes
/
Copy path04_string.py
File metadata and controls
34 lines (25 loc) · 920 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
from tkinter import *
from tkinter import ttk
root = Tk()
root.title("03 - String")
root.iconbitmap("name.ico")
frm = ttk.Frame(root, padding=10)
frm.grid()
# String
my_name = "Cristian"
last_name = "Ricardo"
#concatenación de strings
complete_name = my_name + " " + last_name
# format opción 1
template1 = "Hola, mi nombre es " + my_name + "y mi apellido es " + last_name
# format opción 2
template2 = "Hola, mi nombre es {} y mi apellido es {}".format(my_name, last_name)
# format opción 3
template3 = f"Hola, mi nombre es {my_name} y mi apellido es {last_name}"
ttk.Label(frm, text=complete_name).grid(column=0, row=0)
ttk.Label(frm, text=template1).grid(column=0, row=1)
ttk.Label(frm, text=template2).grid(column=0, row=2)
ttk.Label(frm, text=template2).grid(column=0, row=3)
# ttk.Button(frm, text="Salir", command=root.destroy).grid(column=0, row=3)
# El metodo loop siempre al final
root.mainloop()