Relative Content

Tag Archive for python-3.xtkinter

Me ask is How to draw a windows for customtkinter in python Treeview

import customtkinter as ctk import pandas as pd from tkinter import filedialog, messagebox import threading # Função para carregar e exibir o arquivo Excel def load_excel(): file_path = filedialog.askopenfilename(filetypes=[(“Excel files”, “*.xlsx”)]) if file_path: global df df = pd.read_excel(file_path) if ‘Matrículas’ in df.columns: display_table(df) else: messagebox.showerror(“Erro”, “O arquivo selecionado não segue o padrão esperado.”) # Função para exibir os dados na Treeview def display_table(df): for i, row in df.iterrows(): tree.insert(“”, “end”, values=list(row)) # Função para validar e destacar matrículas inválidas def validate_data(): for i, item in enumerate(tree.get_children()): matricula = tree.item(item)[‘values’][0] if len(str(matricula)) != 5 or not str(matricula).isdigit(): tree.item(item, tags=(“invalid”,)) else: tree.item(item, tags=(“valid”,)) tree.tag_configure(‘invalid’, background=’red’) tree.tag_configure(‘valid’, background=’white’) # Função para atualizar o DataFrame e salvar o arquivo corrigido def update_and_save(): for i, item in enumerate(tree.get_children()): df.iloc[i, 0] = tree.item(item)[‘values’][0] # Assumindo que a coluna de matrículas é a primeira df.to_excel(“corrected_file.xlsx”, index=False) messagebox.showinfo(“Sucesso”, “Arquivo salvo com sucesso!”) # Configuração da interface CustomTkinter app = ctk.CTk() app.geometry(“800×600″) load_button = ctk.CTkButton(app, text=”Carregar Arquivo”, command=load_excel) load_button.pack(pady=20) tree = ctk.CTkTreeview(app, columns=(“Matrícula”,)) tree.heading(“#0″, text=””) tree.heading(“Matrícula”, text=”Matrícula”) tree.pack(pady=20) validate_button = ctk.CTkButton(app, text=”Validar Matrículas”, command=validate_data) validate_button.pack(pady=20) save_button = ctk.CTkButton(app, text=”Salvar Correções”, command=update_and_save) save_button.pack(pady=20) app.mainloop()

Listbox not showing or 2 forms tkinter

I call another form with this one, and the listboxes of the second form are either not displayed when I add the self.destroy(), in the function where it is displayed in two forms when I remove the line. Do you have any clues? I have been looking for days but have found nothing.

tkinter not running on ubuntu

When I try to import tkinter I get the error message: Python 3.12.3 (main, May 25 2024, 22:44:21) [GCC 13.2.0] on linux
Type “help”, “copyright”, “credits” or “license” for more information.

Use dotenv LD_LIBRARY_PATH in python-tkinter

I am new to python-tkinter. I am trying to load a library in tkinter tcl interpreter. However, I am not able to use environment variable LD_LIBRARY_PATH which I am setting using dotenv.