Python Forum
.get() from generated Entry widgets in tkinter
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
.get() from generated Entry widgets in tkinter
#3
Thank you for replying.

It seems difficult for me! but would that mean in my request_details method I would also need to to start building a dictionary... the key being the detail_name that I send from the customer_tab function and the value being from a .get()?

Right now, I think I need to start again.

Is using a class the best way to go about this? So far, I don't quite see the point in using classes. It feels like it's a good way to build a tab but I'm struggling to do much with it once it's set out.

To make it easier for me to read I've removed the sql stuff.

from tkinter import *
from tkinter.ttk import *
import sqlite3

### Create tkinter window ###
root = Tk()
root.title("Bookkeeping")
root.geometry("800x600") 

### Add a Notebook to window ###
home_screen = Notebook(root)
home_screen.pack(fill="both", expand=1, pady=15)

### Class to add tabs to Notebook with a method to add entry boxes and a save button ###
class Create_tab:
    def __init__(self, tab):
        tab_name = str(tab)
        self.tab = tab
        self.tab = Frame(home_screen)
        self.tab.pack(fill="both", expand=1)
        home_screen.add(self.tab, text=tab_name)
        
    def request_details(self, detail_name):
        entry_box = Entry(self.tab)
        entry_box.grid(column=1)
        entry_box.insert(0, detail_name)   

    def save_button(self):
        save_button = Button(self.tab, text="Save")
        save_button.grid(column=1)       

### Create Customers tab ###
def customer_tab():
    customer_tab = Create_tab("Customers")
    entry_boxes = ["Customer ID","Name","Address 1","Address 2","Address 3","Address 4", "Email Address", "Phone 1", "Phone 2"]
    for detail_name in entry_boxes:
        customer_details = customer_tab.request_details(detail_name)  
    save_button = customer_tab.save_button()     

### Create Vendors tab ###
def vendor_tab():
    vendor_tab = Create_tab("Vendors")

    for detail_name in ["Name","Address 1","Address 2","Address 3","Address 4", "Email Address", "Phone 1", "Phone 2"]:
        vendor_details = vendor_tab.request_details(detail_name)

#Main
customer_tab()
vendor_tab()
root.mainloop()
Reply


Messages In This Thread
RE: .get() from generated Entry widgets in tkinter - by snakes - May-02-2021, 10:51 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  make widgets disappear from tkinter jacksfrustration 12 1,313 Feb-06-2024, 03:58 PM
Last Post: deanhystad
  [Tkinter] Making entry global in tkinter with multiprocessing luckyingermany 2 2,368 Jan-21-2022, 03:46 PM
Last Post: deanhystad
  Tkinter Exit Code based on Entry Widget Nu2Python 6 3,079 Oct-21-2021, 03:01 PM
Last Post: Nu2Python
  [Tkinter] Update variable using tkinter entry methon drSlump 6 5,299 Oct-15-2021, 08:01 AM
Last Post: drSlump
  Tkinter | entry output. Sap2ch 1 2,039 Sep-25-2021, 12:38 AM
Last Post: Yoriz
  Entry Validation in tkinter shahulvk 4 16,601 Oct-28-2020, 10:12 PM
Last Post: joe_momma
  [Tkinter] Getting Input from Tkinter Entry juliabrushett 6 21,536 May-30-2020, 03:29 PM
Last Post: Larz60+
  Converting Entry field value to integer in tkinter scratchmyhead 2 5,023 May-11-2020, 03:41 PM
Last Post: scratchmyhead
  [Tkinter] Tkinter adding entry values scratchmyhead 1 2,239 May-04-2020, 05:21 AM
Last Post: Yoriz
  [Tkinter] Connect Toplevel Radiobuttons to root Label/Entry widgets iconit 2 2,506 Apr-28-2020, 06:50 AM
Last Post: iconit

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020