leecokime / Lib

0 stars 0 forks source link

Menu_HiL_1 #6

Open leecokime opened 7 years ago

leecokime commented 7 years ago

from tkinter import * import pyodbc from Input_DB import DB_Path

class App_Menu:

def __init__(self):
    # Window for Data choice for data show
    self.root = Tk()
    self.check_DB_Path_Flag = 0
    # Init
    # Daten Bank import and temp List ready
    self.Hils = ['Motor', 'Getriebe', 'Fahrwerk']
    self.temp_Hil = ''
    self.temp_Step = 101

    # Frm Setup: title and size
    self.root.title('KLi Automation System')
    self.root.geometry('600x300+620+290')

    # a summary form
    self.Frm_all = Frame(self.root)

    # TOP form
    self.Frm_TOP = Frame(self.Frm_all)
    # Logo
    Label(self.Frm_TOP, text='Porsche\n\n',font=('Porsche Design Font', 14)).pack(pady=50)
    # a temp list for input data into data
    self.Frm_TOP.pack(side=TOP)

    # Mid From
    # check if the input checked is and right is
    self.Frm_BOTTOM = Frame(self.Frm_all)
    # jump check to Input
    Button(self.Frm_BOTTOM, text='Getriebe', command=self.Getriebe_Input).pack(side=LEFT, padx=60, pady=0)
    # jump input to Inpu
    Button(self.Frm_BOTTOM, text='Motor', command=self.Motor_Input).pack(side=LEFT, padx=30, pady=0)
    # jump input to Input
    Button(self.Frm_BOTTOM, text='Fahrwerk', command=self.Fahrwerk_Input).pack(side=LEFT, padx=60, pady=0)
    self.Frm_BOTTOM.pack(side=BOTTOM)

    self.Frm_all.pack()

def Getriebe_Input(self):
    self.temp_Hil = 'Getriebe'
    self.root.destroy()
    self.Check_DB_Path()
    if self.check_DB_Path_Flag == 0:
        self.temp_Step = 2
    else:
        self.temp_Step = 1
    return self.temp_Hil, self.temp_Step

def Motor_Input(self):
    self.temp_Hil = 'Motor'
    self.root.destroy()
    self.temp_Step = 2
    return self.temp_Hil, self.temp_Step

def Fahrwerk_Input(self):
    self.temp_Hil = 'Fahrwerk'
    self.root.destroy()
    self.temp_Step = 2
    return self.temp_Hil, self.temp_Step

def Check_DB_Path(self):
    filename = DB_Path
    try:
        self.conn = pyodbc.connect('DRIVER={Microsoft Access Driver (*.mdb, *.accdb)};DBQ='+filename)
        self.conn.close()
        return
    except pyodbc.Error:
        root = Tk()
        root.geometry('+550+350')
        Label(root, text='Database doesn\'t exist.Please put Database at the following Path:\nC:\Users\p357391\Downloads\Access', font=('Arial', 10)).pack()
        Button(root, text='OK', command=root.destroy).pack()
        self.check_DB_Path_Flag = 1
        return

def Menu_main(anyOutput=None): App = App_Menu() mainloop()

print App.temp_Step

return App.temp_Hil, App.temp_Step

if name == 'main':

HiL = Menu_main()