[Python] How can I make a in interactive list in Python's Tkinter complete with buttons that...

Discussão em 'Python' iniciado por Stack, Março 26, 2025.

  1. Stack

    Stack Membro Participativo

    Basically I want there to be a list, which displays files I have stored in a certain folder, and beside the list there are buttons which open up separate windows which can edit or add a new item to that list.

    I want addchar to open up an new window with spaces for different fields, then when you press a "create" button in that window it closes, creates a file on the info you just entered (that's why i've imported os) as well as creating a new item on the main interface's listbox as the name of the character (which is one of the fields). The removechar function would remove that entry and delete the file, and editchar would open up a window similar to addchar, but with the info of the selected item on the list.

    EDIT: Here's the code so far

    from tkinter import *
    import os
    import easygui as eg

    class App:

    def __init__(self, master):
    frame = Frame(master)
    frame.pack()

    # character box
    Label(frame, text = "Characters Editor").grid(row = 0, column = 0, rowspan = 1, columnspan = 2)
    charbox = Listbox(frame)
    for chars in []:
    charbox.insert(END, chars)
    charbox.grid(row = 1, column = 0, rowspan = 5)
    charadd = Button(frame, text = " Add ", command = self.addchar).grid(row = 1, column = 1)
    charremove = Button(frame, text = "Remove", command = self.removechar).grid(row = 2, column = 1)
    charedit = Button(frame, text = " Edit ", command = self.editchar).grid(row = 3, column = 1)

    def addchar(self):
    print("not implemented yet")
    def removechar(self):
    print("not implemented yet")
    def editchar(self):
    print("not implemented yet")


    root = Tk()
    root.wm_title("IA Development Kit")
    app = App(root)
    root.mainloop()

    Continue reading...

Compartilhe esta Página