主要檔案
This commit is contained in:
parent
f38a666c5e
commit
5cd92e8dc2
26
MainTkinter.py
Normal file
26
MainTkinter.py
Normal file
@ -0,0 +1,26 @@
|
||||
from tkinter import *
|
||||
from firstpage import *
|
||||
from MainWin import *
|
||||
from config import CONFIG
|
||||
from Ncnu import *
|
||||
from Moodle import *
|
||||
from NcnuMainWin import *
|
||||
from api.moodle import MoodleAPI
|
||||
from api.ncnu import NcnuAPI
|
||||
|
||||
def main():
|
||||
win=Tk()
|
||||
firstWin(win)
|
||||
moodle = MoodleAPI(CONFIG['moodle']['username'], CONFIG['moodle']['password'])
|
||||
ncnu = NcnuAPI(CONFIG['NCNU']['username'], CONFIG['NCNU']['password'])
|
||||
if moodle.status and ncnu.status:
|
||||
mainWin=Tk()
|
||||
createMainWin(mainWin,ncnu,moodle)
|
||||
else:
|
||||
loginWin=Tk()
|
||||
loginwin(loginWin)
|
||||
|
||||
|
||||
|
||||
|
||||
main()
|
||||
51
firstpage.py
51
firstpage.py
@ -1,15 +1,23 @@
|
||||
from tkinter import *
|
||||
from tkinter import *
|
||||
from tkinter import ttk
|
||||
from config import CONFIG
|
||||
import json
|
||||
from api.moodle import MoodleAPI
|
||||
from tkinter import messagebox
|
||||
from api.ncnu import NcnuAPI
|
||||
from MainWin import *
|
||||
|
||||
def firstWin():
|
||||
first=Tk()
|
||||
|
||||
def firstWin(first):
|
||||
#first=Tk()
|
||||
#login.withdraw()
|
||||
first.geometry("600x400")
|
||||
first.minsize(400,400)
|
||||
first.maxsize(600,600)
|
||||
first.configure(background="skyblue")
|
||||
|
||||
frame=Frame(first,bg="skyblue")
|
||||
go_to_loginwin_btn=Button(first,text="進入登入畫面",font="Helvetica 20",bg="yellow",command=lambda: [first.destroy(),loginwin()] )
|
||||
go_to_loginwin_btn=Button(first,text="開始進入暨管家",font="Helvetica 20",bg="yellow",command=lambda: [first.destroy()] )
|
||||
text_lb=Label(frame,text="歡迎來到暨管家",font=("Courier New Greek",40),bg="skyblue")
|
||||
photo = PhotoImage(file="100_100.gif")
|
||||
imgLabel =Label(frame,image=photo,bg="skyblue")
|
||||
@ -21,8 +29,8 @@ def firstWin():
|
||||
|
||||
first.mainloop()
|
||||
|
||||
def loginwin():
|
||||
login=Tk()
|
||||
def loginwin(login):
|
||||
#login=Tk()
|
||||
login.geometry("300x200")
|
||||
login.configure(bg="lightgreen")
|
||||
login.resizable(width=0,height=0)
|
||||
@ -33,7 +41,7 @@ def loginwin():
|
||||
frame3=Frame(login,width=300,height=100,bg="lightgreen")
|
||||
|
||||
prompt_lb=Label(frame,text="請輸入你的學號與密碼",font="Helvetica 20",bg="lightgreen")
|
||||
login_btn=Button(frame3,text="登入",command=lambda:print("1"))
|
||||
login_btn=Button(frame3,text="登入",command=lambda:Login() )
|
||||
enter_name=Entry(frame1,bd=3)
|
||||
enter_password=Entry(frame2,show="*",bd=3)
|
||||
name_lb=Label(frame1,text="學號",font="Helvetica 12",bg="lightgreen")
|
||||
@ -41,7 +49,31 @@ def loginwin():
|
||||
show_password=Button( frame3,text="透視密碼")
|
||||
show_password.bind( '<Button-1>',lambda event:enter_password.config(show=""))
|
||||
show_password.bind( '<ButtonRelease-1>',lambda event : enter_password.config(show="*") )
|
||||
|
||||
|
||||
|
||||
#===== 輸入帳密=====
|
||||
def Login():
|
||||
with open('config.json') as fp:
|
||||
CON = json.load(fp)
|
||||
CON["semester"]="1092"
|
||||
CON["moodle"]["username"]=str(enter_name.get() )
|
||||
CON["moodle"]["password"]=str(enter_password.get())
|
||||
CON["NCNU"]["username"]=str(enter_name.get())
|
||||
CON["NCNU"]["password"]=str(enter_password.get())
|
||||
|
||||
json.dump(CON, open("config.json", "w"))
|
||||
try:
|
||||
moodle = MoodleAPI(CONFIG['moodle']['username'], CONFIG['moodle']['password'])
|
||||
ncnu = NcnuAPI(CONFIG['NCNU']['username'], CONFIG['NCNU']['password'])
|
||||
moodle.status
|
||||
ncnu.status
|
||||
except:
|
||||
messagebox.showinfo(message="Error")
|
||||
else:
|
||||
login.destroy
|
||||
mainWin=Tk()
|
||||
createMainWin(mainWin,ncnu,moodle)
|
||||
|
||||
frame.pack()
|
||||
frame1.pack()
|
||||
frame2.pack()
|
||||
@ -56,5 +88,6 @@ def loginwin():
|
||||
|
||||
login.mainloop()
|
||||
|
||||
firstWin()
|
||||
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user