473,396 Members | 2,014 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Having problem using tkinter to collect data and send to AddEmployeeManually class

Expand|Select|Wrap|Line Numbers
  1. import tkinter
  2. from tkinter import ttk
  3.  
  4. window = tkinter.Tk()
  5. window.title("Employees Management Form")
  6. window.geometry('600x600')
  7. window.configure(background="white");
  8.  
  9. class EmployeeForm():
  10.  
  11.     def __init__(self):
  12.         #labels for the Entries
  13.         lblName = ttk.Label(window, text="Name").grid(row=0, column=0)
  14.         lblId = ttk.Label(window, text="Id").grid(row=1, column=0)
  15.         lblPhone = ttk.Label(window, text="Phone Number").grid(row=2, column=0)
  16.         lblAge = ttk.Label(window, text="Age").grid(row=3, column=0)
  17.         #Entries
  18.         self.name = ttk.Entry(window).grid(row=0, column=1)
  19.         self.id = ttk.Entry(window).grid(row=1, column=1)
  20.         self.phone = ttk.Entry(window).grid(row=2, column=1)
  21.         self.age = ttk.Entry(window).grid(row=3, column=1)
  22.         #Submit Button
  23.         self.button = ttk.Button(window, text="Submit", command=self.on_button()).grid(row=4, column=1)
  24.  
  25.     #when Submit is press the data is sent to Add Empl manually class
  26.     def on_button(self):
  27.         employee = AddEmployeeManually(self.name, self.id, self.phone, self.phone)
  28.         employee.setData()
  29.         window.mainloop()
  30.  
  31. class AddEmployeeManually():
  32.     def __init__(self, name, id, age, phone):
  33.         self.name = name
  34.         self.phone = phone
  35.         self.age = age
  36.         self.id = id
  37.  
  38.     def setData(self):
  39.         employees = open('Employees.txt', 'a')
  40.         try:
  41.             employees.write(self.id)
  42.             employees.write(self.name)
  43.             employees.write(self.phone)
  44.             employees.write(self.age)
  45.             employees.write('\n')
  46.         except:
  47.             print('Error!')
  48.  
  49. def main():
  50.     choice = int(input("Please type: 1 to Add Employee Manually, 2 to Add from file and 3 to Delete Employee: \n"))
  51.     if choice == 1:
  52.         chosen = EmployeeForm()
  53.     elif choice == 2:
  54.         print("File import needs to be build!")
  55.     elif choice == 3:
  56.         print("Delete class needs to be build!")
  57.     else:
  58.         print ("Not correct choice!")
  59. if __name__ == "__main__":
  60.     main()
Sep 22 '19 #1
1 1055
dwblas
626 Expert 512MB
First, you must format you code in code tages so it can be read. Edit your post and format the code to get any help. Second do you have a specific problem? "Having problem using tkinter" is too vague to respond to. I did happen to notice
Expand|Select|Wrap|Line Numbers
  1. self.name = ttk.Entry(window).grid(row=0, column=1)
grid() returns None to self.name will always be None. Print it to see for yourself. Am not willing to guess further about what other problems you are having or how your code is formatted.
Sep 23 '19 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: nick_faye | last post by:
Hi, I hope somebody can help me. I am collecting data from different external ms access database on my VB programming. I am using the SQL command as shown below: While strPaths(iCtr) <> ""...
1
by: Zurab | last post by:
Hi, I have problem to collect data received with callback from .NET dll to my managed class. I can't use map, queue or something else in managed class and can't place event delegate to my other...
1
by: olersquared | last post by:
Hello ! Please i need a php script that can collect and send data to a specified email address using textfield and radio button and anyother form field. thank you
6
by: Senthil | last post by:
Hi All We are having a VB application on SQL. But we need to collect information from persons who will be offline to verify data and insert new data. Generally they will be entering the data in...
3
by: Mikegtr | last post by:
I need to collect and send data from a rs232 device- it is a simple temperature controller. I need to be able to collect actual temperature ,store the result in database (mysql) and show it in...
1
by: Ankit | last post by:
Hi guys i need to make a table to store a certain data using Tkinter..I have searched on the group but i have not been able to find a solution that would work for me..The thing is that i want my...
1
by: viv1tyagi | last post by:
Hi everyone ! ! ! I'm just a month old in the world of Python and trying to develop an application using Tkinter in which a new window pops out on a particular button press.The code for this new...
3
by: J-Burns | last post by:
Hello. Im a bit new to using Tkinter and im not a real pro in programming itself... :P. Need some help here. Problem 1: How do I make something appear on 2 separate windows using Tkinter? By...
6
by: mulamootil | last post by:
Hi, I have few tables and i am populating them using respective forms. However on one of the tables, there are 10 fields out of which 2 fields, I would like some other user to fill it. Is there a way...
5
by: woodsmith1007 | last post by:
I am using Access to collect data via email. I have a problem that could be solved in one of two ways. I need to collect the unique employeeID of the individual sending the email back. I can...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.