Je voudrais avoir une interface graphique de base avec deux entrées de zone de texte: une pour chacun des arguments dans ma fonction, convert_databases, mais je ne suis pas sûr de savoir comment passer ces arguments (I J'ai vu quelques exemples en utilisant lambda, mais je n'ai pas pu les implémenter correctement.Débutant Tkinter en Python: Fonctions avec des entrées
Voici ma tentative à ce jour, laquelle a été principalement tutoriel natif de Tkinter:
from tkinter import *
from tkinter import ttk
def convert_databases(input_file, output_format):
#Function deleted for simplicity
root = Tk()
root.title("Title")
#Formatting
mainframe = ttk.Frame(root, padding="3 3 12 12")
mainframe.grid(column=0, row=0, sticky=(N, W, E, S))
mainframe.columnconfigure(0, weight=1)
mainframe.rowconfigure(0, weight=1)
#Setting Variables
file = StringVar()
conversion = StringVar()
# Places to enter variables
file_entry = ttk.Entry(mainframe, width=50, textvariable=file)
file_entry.grid(column=2, row=2, sticky=(W, E))
type_entry = ttk.Entry(mainframe, width=50, textvariable=conversion)
type_entry.grid(column=2,row=3, sticky=(W,E))
# Convert Button
ttk.Button(mainframe, text="Convert", command= # Here is where I'm having trouble#)
#Label for the variable 1 input
ttk.Label(mainframe, text="Input file name: ").grid(column=1, row=2, sticky=W)
#Label for the variable 2 input
ttk.Label(mainframe, text="Input file type conversion: ").grid(column=1, row=3, sticky=W)
# This sets the window, I think?
for child in mainframe.winfo_children(): child.grid_configure(padx=5, pady=5)
# Puts the cursor automatically in the text box
file_entry.focus()
# Runs the thing
root.mainloop()
Merci!
a fait cela a fonctionné ?? –
je vais vous donner un lien de mes projets tkinter j'espère qu'ils vont vous aider https://github.com/Burhanasif59/Python-modules télécharger les projets tkinter zip.Ils sont en python 2.7 mais ce ne sera pas un problème –
Il a travaillé magnifiquement, il m'a juste fallu quelques minutes pour le faire fonctionner sur ma fin! Merci beaucoup!! – CalendarJ