Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
GUI and PDf
#3
I think kevin wants to get the entries and save to pdf.(my interpretation),,
A couple of observations: Keep your code simple. it's easier to read and
modify later on. Start on a small scale.
You could do this with one class- this will make it easier
to pass attributes and objects. The use of the prefix self makes objects
global. Make a list of fields and use a for loop to create all you labels and entries.
Lastly I don't have the fpdf module but I hope this points you in the right direction.
Great you made a class let's deal with what you have.
you made this entry widget:
def __init__(self, parent, controller):
    #omitting the rest....
    manufacturer = tk.StringVar()
    manufacturer_entry = tk.Entry(self, textvariable = manufacturer, width =  "30")
    button2 = ttk.Button(self, text="Submit", 
                            command=lambda: controller.show_frame(sub))
    button2.place(x = 700, y =730)
modified to:
def __init__(self, parent, controller):
    #omitting the rest....
    self.manufacturer = tk.StringVar()
    manufacturer_entry = tk.Entry(self, textvariable = self.manufacturer, width =  "30")
    button2 = ttk.Button(self, text="Submit", 
                            command= self.get_info)
    button2.place(x = 700, y =730)
def get_info(self):
     manu= self.manufacturer.get()
     print(manu)
know this also can be done without the textvariable I don't see the point in using
in this application. here's a way to pull the string from the entry widget:
def __init__(self, parent, controller):
    #omitting the rest....
    
    self.manufacturer_entry = tk.Entry(self, width =  "30")
    button2 = ttk.Button(self, text="Submit", 
                            command= self.get_info)
    button2.place(x = 700, y =730)
def get_info(self):
     manu= self.manufacturer_entry.get()
     print(manu)
Reply


Messages In This Thread
GUI and PDf - by kevinlau2220 - Sep-05-2019, 04:19 AM
RE: GUI and PDf - by buran - Sep-05-2019, 05:13 AM
RE: GUI and PDf - by joe_momma - Sep-05-2019, 03:10 PM

Forum Jump:

User Panel Messages

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