Python Forum
need hep with entry
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
need hep with entry
#1
why the option Retrieve Report in this code does not record a number in the variable WO-rep after enter it.? like WO entry does.



#!/usr/bin/python
#imports ===========================================================================================
from tkinter import *
from tkinter import ttk
import tkinter as tk
import tkinter.messagebox
from tkinter.messagebox import showinfo
from Test_1 import *
from Test_2 import *
from Test_3 import *
from Test_4 import *
from Test_5 import *
from Test_6 import *
from view_report import *
from save_USB import *
from print_report import *
from help_window import *
from about_window import *
from fail_database import *
from FAQ_window import *
from Exit_ATP import *
from ending_session import *
import os, time


# Create instance
CDU = tk.Tk()

def window(CDU):
   CDU.title('ATA: 34-61-14,   Liquid Crystal Display Control Display Unit')
   CDU.wm_attributes('-type', 'splash')
   CDU.resizable(False,False)       # prevent the GUI from being resizable, the same for (0,0)
   f = open("report.rep",'a+')
   
def donothing():
   print("ok, ok I won't")     

def about():
   showinfo(title='About', message='Application developed in Python with Tkinter by AQS\nAny problem or suggestion, please contact (941) 726-6632')   

def start_progressbar():
   progress_bar.start()

def stop_progressbar():
   progress_bar.stop()

def ending_session():

#   print("Work Order: %s\n" % (UUT_wo.get()))   
   os.rename('report.rep','%s.rep' % (UUT_wo.get()))
   CDU.destroy()       
   sys.exit()
#   os.execv('//media/pi/ROOT/GUI_CDU_2__1_2_2019.py', [''])

def run_progressbar():
   progress_bar["maximum"] = 100
   for i in range [101]:
         sleep(0.05)
         progress_bar["value"] = i          #increment progressbar
         progress_bar.update()              #have to call update() in loop
   progress_bar["value"] = 0                #reset / clear progressbar  

 
def retrieve_report():
   Label(CDU, text="WO Report:",font = ('Arial', 13, "bold"), fg = 'darkblue').grid(row=12, column=3, sticky='e')
   WO_rep = tk.Entry(CDU, width=30)
   WO_rep.grid(row=12, column=4, sticky='w')
   print("WO: %s\n" % (UUT_wo.get()))
   print("WO Retrieve: %s\n" % (WO_rep.get()))


def test_procedure():
   atp = tk.Tk()
   atp.geometry('800x480+0+0')
   atp.overrideredirect(1)
   
   menubar = Menu(atp)
   atp.config(menu=menubar)
   menubar.config(font=('Arial',16,"bold"))
 
   
   def exit_ATP():
       f = open('report.rep','a')
       f.write("===========================================================\n")
       f.write("Closing session\n")
       d = datetime.now()
       f.write("{:%H:%M:%S}\n".format(d))
       f.write("\n")
       f.write("                      ...Bye\n")
       f.close()
       atp.destroy()
       
       
   def complete_test():
      print ("Complete Test!")
      f = open("report.rep",'a')
      f.write("Developing All Tests\n")
        

   # create a pulldown menu, and add it to the menu bar
   atpmenu = Menu(menubar, tearoff=0)
   atpmenu.configure(font=('Arial',16,"bold"))
   atpmenu.add_command(label="Complete test", command=complete_test)

   stepsmenu = Menu(atpmenu, tearoff=0)
   stepsmenu.configure(font=('Arial',16,"bold"))
   stepsmenu.add_command(label="Test No1", command=Test_1)
   stepsmenu.add_command(label="Test No2", command=Test_2)
   stepsmenu.add_command(label="Test No3", command=Test_3)
   stepsmenu.add_command(label="Test No4", command=Test_4)
   stepsmenu.add_command(label="Test No5", command=Test_5)
   stepsmenu.add_command(label="Test No6", command=Test_6)
   
   atpmenu.add_cascade(label="Step by step", menu=stepsmenu) 
   
   atpmenu.add_separator()
   atpmenu.add_command(label="Exit", command=exit_ATP)   
   menubar.add_cascade(label="Test Procedure", menu=atpmenu)

   reportmenu = Menu(menubar, tearoff=0)
   reportmenu.configure(font=('Arial',16,"bold"))
   reportmenu.add_command(label="View (display)", command=view_report)
   reportmenu.add_separator()
   reportmenu.add_command(label="Save to USB", command=save_USB)   
   reportmenu.add_command(label="Print...", command=print_report)   
   menubar.add_cascade(label="Reports", menu=reportmenu)

   helpmenu = Menu(menubar, tearoff=0)
   helpmenu.configure(font=('Arial',16,"bold"))
   helpmenu.add_command(label="Help...", command=help_window) 
   helpmenu.add_command(label="FAQ", command=FAQ_window) 
   helpmenu.add_command(label="Failures database", command=fail_database)
   helpmenu.add_separator()
   helpmenu.add_command(label="About...", command=about_window)   
   menubar.add_cascade(label="Help", menu=helpmenu)
   
   # display the menu
   atp.config(menu=menubar)
   print("===========================================================")
   print("Work Order: %s\nUUT_PN: %s\nUUT SN:%s\nTechnician:%s" % (UUT_wo.get(), UUT_pn.get(), UUT_sn.get(), WO_tech.get()))
   if radVar.get() == 1: print ("Work Requested: Bench Check")
   elif radVar.get() == 2: print ("Work Requested: Repair")
   elif radVar.get() == 3: print ("Work Requested: Overhaul")
   print("===========================================================")
   print("Acceptance Test Procedure")
   print("Liquid Crystal Display Control Display Unit")
   print("174101  Model 2584")
   print("ATA 34-61-14, ATLAS Test Specification 552353-10-01")
   print("===========================================================")
   from datetime import datetime
   d = datetime.now()
   print("{:%Y-%m-%d %H:%M:%S}".format(d))

   f = open("report.rep",'a')
   f.write("Acceptance Test Procedure\n")
   f.write("Liquid Crystal Display Control Display Unit\n")
   f.write("174101  Model 2584\n")
   f.write("ATA 34-61-14, ATLAS Test Specification 552353-10-01\n")
   f.write("Date:")
   f.write("{:%m-%d-%Y %H:%M:%S}\n".format(d))
   f.write("===========================================================\n")   
   f.write('WO:'+ UUT_wo.get())
   f.write("\nUUT_PN: %s\nUUT SN:%s\nTechnician:%s" % (UUT_pn.get(), UUT_sn.get(), WO_tech.get()))
   f.write("\n===========================================================\n")
   f = open("report.rep",'a')
    

#==========================================================================================
#window(CDU)===========================================================================================
 
# Add a title, size and disabling resize
CDU.attributes('-type', 'dock')
CDU.geometry('800x480+0+0')
CDU.title('ATA: 34-61-14,   Liquid Crystal Display Control Display Unit')

# Adding Labels and Entries widgets =======================================================================
Label(CDU, text="UUT PN:",font = ('Arial', 16,"bold"), fg = 'darkblue').grid(row=1, column=3, sticky='e')
Label(CDU, text="Work Order:",font = ('Arial', 16, "bold"), fg = 'darkblue').grid(row=2, column=3, sticky='e')
Label(CDU, text="UUT SN:",font = ('Arial', 16, "bold"), fg = 'darkblue').grid(row=3, column=3, sticky='e')
Label(CDU, text="Technician:",font = ('Arial', 16, "bold"), fg = 'darkblue').grid(row=5, column=3, sticky='e')

UUT_pn = tk.Entry(CDU, width=30)
UUT_wo = tk.Entry(CDU, width=30)
UUT_sn = tk.Entry(CDU, width=30)
WO_tech = tk.Entry(CDU, width=18)
#WO_retrieve = tk.Entry(CDU, width=30)

UUT_pn.grid(row=1, column=4, sticky='e')
UUT_wo.grid(row=2, column=4, sticky='e')
UUT_sn.grid(row=3, column=4, sticky='e')
WO_tech.grid(row=5, column=4, sticky='w')

CDU.focus_force()

# Radiobuttons ===========================================================================================
# Radiobuttons Callback
def radCall():
    radSel=radVar.get()
    if radSel == 1: CDU.configure()
    elif radSel == 2: CDU.configure()
    elif radSel == 3: CDU.configure()
    
# Create three Radiobuttons using one variable
radVar = IntVar() 
 
Label(CDU, text="Work Requested:",font = ('Arial', 16, "bold"), fg = 'darkblue'). grid(row=7, column=3, sticky='w')
benchtest = Radiobutton(CDU, text="Bench Test", font = ('Arial', 16, "bold"),variable=radVar, value=1, command=radCall)
benchtest.grid(row=7, column=4, columnspan=2, sticky='w')
repair = Radiobutton(CDU, text="Repair", font = ('Arial', 16, "bold"), variable=radVar, value=2, command=radCall)
repair.grid(row=8, column=4, columnspan=2, sticky='w')
overhaul = Radiobutton(CDU, text="Overhaul", font = ('Arial', 16, "bold"), variable=radVar, value=3, command=radCall)
overhaul.grid(row=9, column=4, columnspan=4, sticky='w')

# Canvas =================================================================================================
canvas_width = 291
canvas_height =387 
canvas = Canvas(CDU,
                width=canvas_width,
                height=canvas_height)
canvas.grid(row=1, column=0, rowspan=11, columnspan=2, sticky='n')
img = PhotoImage(file="174101_2.gif")
canvas.create_image(20,20, anchor=NW, image=img)

Label(CDU, text="").grid(row=12, column=18, sticky='e')

# Functions ===============================================================================================
Button(CDU, text="   Test Procedure    ",font = ('Arial', 16, "bold"), command = test_procedure).grid(row=10, column=4, sticky='e', padx=2)
Button(CDU, text=" Retrieve Report ",font = ('Arial', 16, "bold"), command = retrieve_report).grid(row=12, column=1, sticky='e')
Button(CDU, text=" About...",font = ('Arial', 16, "bold"), command = about).grid(row=15, column=1, sticky='e', padx=2)
Button(CDU, text=" Close Session ",font = ('Arial', 16, "bold"), command = ending_session).grid(row=15, column=4, sticky='e', padx=2)

window(CDU)

#==========================================================================================
#Start GUI
CDU.mainloop( ) 
Reply
#2
Where's the WO entry, so I can see your code that you say is working? Or could you maybe simplify the code to just 10ish lines demonstrating the issue? I don't want to have to try to pour through 235 lines of poorly written code to try to figure out where the problem might be.
Reply
#3
There are other errors. Like progress_bar has not been declared that I can see, you import tkinter more than once, and you have more than one Tk() instance. And does Test_1.py contain a function or class also named Test_1? If not, you will have problems there as well. Looks like some testing and organization are in order.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Transfer Toplevel window entry to root window entry with TKinter HBH 0 4,422 Jan-23-2020, 09:00 PM
Last Post: HBH
  [Tkinter] how to get the entry information using Entry.get() ? SamyPyth 2 3,455 Mar-18-2019, 05:36 PM
Last Post: woooee

Forum Jump:

User Panel Messages

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