0% found this document useful (0 votes)
3 views6 pages

Solver Tkinter

The document contains a series of exercises and practices focused on creating graphical user interfaces (GUIs) using Python's Tkinter library. It includes examples such as a simple GUI window, a button click counter, a calculator, a temperature converter, a student grade manager, and a multi-window application. Each section provides code snippets and descriptions for implementing these GUI applications.

Uploaded by

Leotrap 2008
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views6 pages

Solver Tkinter

The document contains a series of exercises and practices focused on creating graphical user interfaces (GUIs) using Python's Tkinter library. It includes examples such as a simple GUI window, a button click counter, a calculator, a temperature converter, a student grade manager, and a multi-window application. Each section provides code snippets and descriptions for implementing these GUI applications.

Uploaded by

Leotrap 2008
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

NSTITUTO TECNOLÓGICO Y DE ESTUDIOS SUPERIORES DE MONTERREY

CAMPUS CIUDAD DE MÉXICO


Eduardo Álvarez del Castillo Zatarain
Computer Science
Solver

Contents
Exercise 1. Hello GUI Window ........................................................................................... 2
Excersice 2. Button Click Counter ...................................................................................... 2
Practice 03. Simple Calculator GUI .................................................................................... 3
Practice 04 — Temperature Converter .............................................................................. 4
Practice 05 — Student Grade Manager ............................................................................. 5
Practice 06 — Multi-Window Application ......................................................................... 6
Exercise 1. Hello GUI Window
import tkinter as tk

root = [Link]()

[Link]("My First GUI")

[Link]("300x150")

label = [Link](root, text="Hello, welcome to Python GUI programming!")

[Link](expand=True)

[Link]()

Excersice 2. Button Click Counter

import tkinter as tk

count = 0

def click():
global count

count += 1

[Link](text=f"Clicks: {count}")

root = [Link]()

[Link]("Click Counter")

label = [Link](root, text="Clicks: 0")

[Link](pady=10)

btn = [Link](root, text="Click me", command=click)

[Link]()

[Link]()
Practice 03. Simple Calculator GUI
import tkinter as tk

root = [Link]()
[Link]("Calculator")
entry1 = [Link](root)
entry2 = [Link](root)

[Link](row=0, column=0)
[Link](row=0, column=1)

result = [Link](root, text="Result:")


[Link](row=1, column=0, columnspan=2)

def add():
a = float([Link]())
b = float([Link]())
[Link](text=f"Result: {a + b}")

btn = [Link](root, text="Add", command=add)


[Link](row=2, column=0, columnspan=2)

[Link]()
Practice 04 — Temperature Converter

import tkinter as tk

root = [Link]()
[Link]("Temperature Converter")

value = [Link](root)
[Link]()

option = [Link](value="C to F")

menu = [Link](root, option, "C to F", "F to C")


[Link]()

result = [Link](root, text="Result:")


[Link]()

def convert():
temp = float([Link]())

if [Link]() == "C to F":


res = temp * 9 / 5 + 32

else:
res = (temp - 32) * 5 / 9

[Link](text=f"Result: {res:.2f}")

btn = [Link](root, text="Convert", command=convert)


[Link]()

[Link]()
Practice 05 — Student Grade Manager
import tkinter as tk

students = []

def add_student():
name = [Link]()
grade = float(grade_entry.get())
[Link]((name, grade))
[Link]([Link], f"{name}: {grade}")

root = [Link]()
[Link]("Grade Manager")

entry = [Link](root)
[Link]()

grade_entry = [Link](root)
grade_entry.pack()

btn = [Link](root, text="Add Student", command=add_student)


[Link]()

listbox = [Link](root)
[Link]()

[Link]()
Practice 06 — Multi-Window Application
import tkinter as tk

def open_main():
user = [Link]()

if user:
[Link]()
main = [Link]()
[Link]("Main Menu")
[Link](main, text=f"Welcome, {user}!").pack(pady=10)
[Link](main, text="Logout", command=lambda: ([Link](),
[Link]())).pack()

login = [Link]()
[Link]("Login")

username = [Link](login)
[Link](pady=5)

password = [Link](login, show="*")


[Link](pady=5)

btn = [Link](login, text="Login", command=open_main)


[Link](pady=10)

[Link]()

You might also like