Compare commits
37 Commits
courseTabl
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| ef42710ef8 | |||
| 09d2cb56c1 | |||
|
|
535d2d6e0e | ||
|
|
6c1037ea93 | ||
| 0c9034d05e | |||
|
|
ecd84ccdfe | ||
|
|
40857f16bd | ||
|
|
e951898829 | ||
| a286f64410 | |||
| deb93f4f45 | |||
| f3d4f06d01 | |||
|
|
781eb55010 | ||
|
|
fd888a0473 | ||
|
|
0ca341ca3c | ||
|
|
dce60de855 | ||
|
|
750b660931 | ||
|
|
51e4baa63d | ||
|
|
aec6b56150 | ||
|
|
c9078eb7a3 | ||
|
|
3cc94b7e1d | ||
|
|
f7d53846a4 | ||
|
|
e605816d24 | ||
|
|
5ba7922c7c | ||
|
|
0e80fd18c4 | ||
|
|
96e8e83692 | ||
|
|
d653592943 | ||
|
|
ba5d330509 | ||
|
|
b0475a0415 | ||
|
|
522cd1b7ad | ||
|
|
19939f3066 | ||
|
|
5cd92e8dc2 | ||
|
|
f38a666c5e | ||
| 674ed1277f | |||
| f7d5fa801c | |||
| 689ac1eb95 | |||
|
|
89a74eac3a | ||
|
|
dadeefa058 |
@ -24,12 +24,12 @@ if moodle.status:
|
|||||||
space()
|
space()
|
||||||
|
|
||||||
# ===== Test 取得課程在當週發布的物件 ( 文件、功課、BBB連結... 等)
|
# ===== Test 取得課程在當週發布的物件 ( 文件、功課、BBB連結... 等)
|
||||||
for work in moodle.getWeekWorkInCourse('47562'):
|
for work in moodle.getWeekWorkInCourse('47552'):
|
||||||
print(work)
|
print(work)
|
||||||
space()
|
space()
|
||||||
|
|
||||||
# ===== TEST 取得該課程的最新公告
|
# ===== TEST 取得該課程的最新公告
|
||||||
for anno in moodle.getAnnoInCourse('47555'):
|
for anno in moodle.getAnnoInCourse('47552'):
|
||||||
print(anno)
|
print(anno)
|
||||||
space()
|
space()
|
||||||
else:
|
else:
|
||||||
@ -37,7 +37,6 @@ else:
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# =================== Test 暨大官網 API ==========================
|
# =================== Test 暨大官網 API ==========================
|
||||||
|
|
||||||
# ===== Test 取得暨大官網最新消息 =====
|
# ===== Test 取得暨大官網最新消息 =====
|
||||||
|
|||||||
27
MainWin.py
27
MainWin.py
@ -1,27 +0,0 @@
|
|||||||
from tkinter import *
|
|
||||||
|
|
||||||
def createMainWin():
|
|
||||||
'''
|
|
||||||
用綠色校園作為基底色
|
|
||||||
以暨大的三大特色
|
|
||||||
1.穿山甲-moodle
|
|
||||||
2.櫻花-暨大官網 #ffcccc
|
|
||||||
3.國際性-教務系統
|
|
||||||
去做三個網頁的底色
|
|
||||||
'''
|
|
||||||
win=Tk()
|
|
||||||
win.configure(bg="#b2ffa6")
|
|
||||||
|
|
||||||
|
|
||||||
createMoodleWin=Button(win,text="Moodle",font="Helvetica 30",bg="#888084",fg="white",relief=GROOVE)
|
|
||||||
createNcnuMainWin=Button(win,text="暨大官網",font="Helvetica 30",bg="#ffcccc",fg="white",relief=GROOVE)
|
|
||||||
createNcnuWin=Button(win,text="暨大教務系統",font="Helvetica 30",bg="#df99ff",fg="white",relief=GROOVE)
|
|
||||||
|
|
||||||
|
|
||||||
createMoodleWin.pack(fill="x")
|
|
||||||
createNcnuMainWin.pack(fill="x")
|
|
||||||
createNcnuWin.pack(fill="x")
|
|
||||||
|
|
||||||
win.mainloop()
|
|
||||||
|
|
||||||
createMainWin()
|
|
||||||
@ -79,9 +79,10 @@ class CourseTable():
|
|||||||
'''
|
'''
|
||||||
移除課程
|
移除課程
|
||||||
'''
|
'''
|
||||||
for key, value in self.table.items():
|
for i in self.table:
|
||||||
if value['number'] == courseID:
|
if self.table[i]:
|
||||||
self.table[key] = None
|
if self.table[i]['number'] == courseID:
|
||||||
|
self.table[i] = None
|
||||||
|
|
||||||
def getDepartmentList(self):
|
def getDepartmentList(self):
|
||||||
ans = set()
|
ans = set()
|
||||||
@ -95,7 +96,10 @@ class CourseTable():
|
|||||||
return ans
|
return ans
|
||||||
|
|
||||||
def conflict(self, course):
|
def conflict(self, course):
|
||||||
timeList = getTime(course['time'])
|
if course['time'] != None:
|
||||||
|
timeList = getTime(course['time'])
|
||||||
|
else:
|
||||||
|
return False
|
||||||
status = True
|
status = True
|
||||||
for time in timeList:
|
for time in timeList:
|
||||||
if time in self.table:
|
if time in self.table:
|
||||||
@ -107,28 +111,10 @@ class CourseTable():
|
|||||||
|
|
||||||
return status
|
return status
|
||||||
|
|
||||||
def filter(self, department):
|
def courseFilter(self, department):
|
||||||
ans = []
|
ans = []
|
||||||
for course in self.courseData:
|
for course in self.courseData:
|
||||||
if course['department'] == department:
|
if course['department'] == department:
|
||||||
if self.conflict(course):
|
if self.conflict(course):
|
||||||
ans.append(course)
|
ans.append(course)
|
||||||
return ans
|
return ans
|
||||||
|
|
||||||
table = CourseTable()
|
|
||||||
table.showTableStatus()
|
|
||||||
print( table.add('240034') )
|
|
||||||
table.showTableStatus()
|
|
||||||
print( table.add('240057') )
|
|
||||||
table.showTableStatus()
|
|
||||||
print( table.add('240034') )
|
|
||||||
table.showTableStatus()
|
|
||||||
print( table.add('902048') )
|
|
||||||
table.showTableStatus()
|
|
||||||
|
|
||||||
departments = table.getDepartmentList()
|
|
||||||
print(departments)
|
|
||||||
|
|
||||||
courses = table.filter('21, 資工系')
|
|
||||||
for course in courses:
|
|
||||||
print(course)
|
|
||||||
@ -45,25 +45,21 @@ class EventRegistry():
|
|||||||
url = "https://ccweb.ncnu.edu.tw/SLLL/z6D3B52D553CA5831540D8CC7659967E58A62list.asp"
|
url = "https://ccweb.ncnu.edu.tw/SLLL/z6D3B52D553CA5831540D8CC7659967E58A62list.asp"
|
||||||
response = self.session.get(url)
|
response = self.session.get(url)
|
||||||
|
|
||||||
with open('test.html') as fp:
|
events = find(response, 'table').findAll('tr')
|
||||||
response = fp.read()
|
|
||||||
|
|
||||||
root = BeautifulSoup(response, 'html.parser')
|
|
||||||
events = root.find('table').findAll('tr')
|
|
||||||
|
|
||||||
return [{
|
return [{
|
||||||
'id': getUrlParam(data[0].find('a').get('href').replace('&', '&'), 'RowID'),
|
'id': getUrlParam(data[0].find('a').get('href').replace('&', '&'), 'RowID'),
|
||||||
# 活動詳細:
|
# 活動詳細:
|
||||||
# https://ccweb.ncnu.edu.tw/SLLL/z6D3B52D553CA5831540D8CC7659967E58A62view.asp?showdetail=&RowID={}
|
# https://ccweb.ncnu.edu.tw/SLLL/z6D3B52D553CA5831540D8CC7659967E58A62view.asp?showdetail=&RowID={}
|
||||||
|
|
||||||
'semester': data[1].text.replace('\n', ''),
|
'semester': data[1].text.replace('\n', '').replace('\r', ''),
|
||||||
'status': data[2].text.replace('\n', ''), # 活動報名狀態
|
'status': data[2].text.replace('\n', '').replace('\r', ''), # 活動報名狀態
|
||||||
'name': data[3].text.replace('\n', ''),
|
'name': data[3].text.replace('\n', '').replace('\r', ''),
|
||||||
'time': data[4].text.replace('\n', ''), # 活動開始時間
|
'time': data[4].text.replace('\n', '').replace('\r', ''), # 活動開始時間
|
||||||
'method': data[5].text.replace('\n', ''), # 報名方式
|
'method': data[5].text.replace('\n', '').replace('\r', ''), # 報名方式
|
||||||
'hour': data[6].text.replace('\n', ''), # 時數
|
'hour': data[6].text.replace('\n', '').replace('\r', ''), # 時數
|
||||||
'speaker': data[7].text.replace('\n', ''), # 講師
|
'speaker': data[7].text.replace('\n', '').replace('\r', ''), # 講師
|
||||||
'teacherEvent': data[8].text.replace('\n', ''), # 申請為教師知能活動
|
'teacherEvent': data[8].text.replace('\n', '').replace('\r', ''), # 申請為教師知能活動
|
||||||
} for data in (event.findAll('td') for event in events[1:])]
|
} for data in (event.findAll('td') for event in events[1:])]
|
||||||
|
|
||||||
def signUpPrepare(self, eventID):
|
def signUpPrepare(self, eventID):
|
||||||
|
|||||||
@ -2,3 +2,4 @@ import json
|
|||||||
|
|
||||||
with open('config.json') as fp:
|
with open('config.json') as fp:
|
||||||
CONFIG = json.load(fp)
|
CONFIG = json.load(fp)
|
||||||
|
|
||||||
60
firstpage.py
60
firstpage.py
@ -1,60 +0,0 @@
|
|||||||
from tkinter import *
|
|
||||||
from tkinter import ttk
|
|
||||||
|
|
||||||
def firstWin():
|
|
||||||
first=Tk()
|
|
||||||
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()] )
|
|
||||||
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")
|
|
||||||
|
|
||||||
frame.pack(expand=1)
|
|
||||||
imgLabel.pack()
|
|
||||||
text_lb.pack(padx=100)
|
|
||||||
go_to_loginwin_btn.pack(pady=50)
|
|
||||||
|
|
||||||
first.mainloop()
|
|
||||||
|
|
||||||
def loginwin():
|
|
||||||
login=Tk()
|
|
||||||
login.geometry("300x200")
|
|
||||||
login.configure(bg="lightgreen")
|
|
||||||
login.resizable(width=0,height=0)
|
|
||||||
|
|
||||||
frame=Frame(login,width=100,height=100,bg="lightgreen")
|
|
||||||
frame1=Frame(login,width=300,height=100,bg="lightgreen")
|
|
||||||
frame2=Frame(login,width=300,height=100,bg="lightgreen")
|
|
||||||
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"))
|
|
||||||
enter_name=Entry(frame1,bd=3)
|
|
||||||
enter_password=Entry(frame2,show="*",bd=3)
|
|
||||||
name_lb=Label(frame1,text="學號",font="Helvetica 12",bg="lightgreen")
|
|
||||||
pw_lb=Label(frame2,text="密碼",font="Helvetica 12",bg="lightgreen")
|
|
||||||
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="*") )
|
|
||||||
|
|
||||||
frame.pack()
|
|
||||||
frame1.pack()
|
|
||||||
frame2.pack()
|
|
||||||
frame3.pack()
|
|
||||||
prompt_lb.pack(pady=10,side="top")
|
|
||||||
name_lb.pack(side="left")
|
|
||||||
enter_name.pack(side="left")
|
|
||||||
pw_lb.pack(side="left")
|
|
||||||
enter_password.pack(side="left")
|
|
||||||
show_password.pack(side="left",pady=10,padx=10)
|
|
||||||
login_btn.pack(side="left",pady=10)
|
|
||||||
|
|
||||||
login.mainloop()
|
|
||||||
|
|
||||||
firstWin()
|
|
||||||
|
|
||||||
40
main.py
Normal file
40
main.py
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
from tkinter import *
|
||||||
|
from wins.firstpage import *
|
||||||
|
from wins.MainWin import *
|
||||||
|
from config import CONFIG
|
||||||
|
from wins.Ncnu import *
|
||||||
|
from wins.Moodle import *
|
||||||
|
from wins.NcnuMainWin import *
|
||||||
|
from api.moodle import MoodleAPI
|
||||||
|
from api.ncnu import NcnuAPI
|
||||||
|
import threading
|
||||||
|
|
||||||
|
moodle = None
|
||||||
|
ncnu = None
|
||||||
|
|
||||||
|
win=Tk()
|
||||||
|
firstWin(win)
|
||||||
|
def checkJson():
|
||||||
|
def login():
|
||||||
|
global moodle, ncnu
|
||||||
|
moodle = MoodleAPI(CONFIG['moodle']['username'], CONFIG['moodle']['password'])
|
||||||
|
ncnu = NcnuAPI(CONFIG['NCNU']['username'], CONFIG['NCNU']['password'])
|
||||||
|
tempWin.destroy()
|
||||||
|
|
||||||
|
tempWin = Tk()
|
||||||
|
Label(tempWin, text="登入中...", font="50").pack()
|
||||||
|
t = threading.Thread(target=login)
|
||||||
|
t.start()
|
||||||
|
|
||||||
|
tempWin.mainloop()
|
||||||
|
|
||||||
|
if moodle.status and ncnu.status:
|
||||||
|
mainWin=Tk()
|
||||||
|
createMainWin(mainWin,ncnu,moodle)
|
||||||
|
else:
|
||||||
|
mainWin=Tk()
|
||||||
|
loginwin(mainWin)
|
||||||
|
|
||||||
|
win.protocol("WM_DELETE_WINDOW",checkJson())
|
||||||
|
|
||||||
|
|
||||||
@ -1,6 +1,12 @@
|
|||||||
|
from api.courseTable.courseTable import CourseTable
|
||||||
from tkinter import *
|
from tkinter import *
|
||||||
|
from wins.Moodle import createMoodleWin as moodleWin
|
||||||
|
from wins.Ncnu import createNcnuWin as ncnuWin
|
||||||
|
from wins.NcnuMainWin import createNcnuMainWin as ncnuMainWin
|
||||||
|
from wins.courseTable import callTable
|
||||||
|
from wins.rigestryWin import createRigestryWin as rigestryWin
|
||||||
|
|
||||||
def createMainWin():
|
def createMainWin(win,ncnu,moodle):
|
||||||
'''
|
'''
|
||||||
用綠色校園作為基底色
|
用綠色校園作為基底色
|
||||||
以暨大的三大特色
|
以暨大的三大特色
|
||||||
@ -9,18 +15,30 @@ def createMainWin():
|
|||||||
3.國際性-教務系統
|
3.國際性-教務系統
|
||||||
去做三個網頁的底色
|
去做三個網頁的底色
|
||||||
'''
|
'''
|
||||||
win=Tk()
|
|
||||||
|
|
||||||
|
|
||||||
win.configure(bg="#b2ffa6")
|
win.configure(bg="#b2ffa6")
|
||||||
|
|
||||||
|
|
||||||
createMoodleWin=Button(win,text="Moodle",font="Helvetica 30",bg="#888084",fg="white",relief=GROOVE)
|
createMoodleWin=Button(win,text="Moodle",font="Helvetica 30",bg="#888084",fg="white",relief=GROOVE)
|
||||||
createNcnuMainWin=Button(win,text="暨大官網",font="Helvetica 30",bg="#ffcccc",fg="white",relief=GROOVE)
|
createNcnuMainWin=Button(win,text="暨大官網",font="Helvetica 30",bg="#ffcccc",fg="white",relief=GROOVE)
|
||||||
createNcnuWin=Button(win,text="暨大教務系統",font="Helvetica 30",bg="#df99ff",fg="white",relief=GROOVE)
|
createNcnuWin=Button(win,text="暨大教務系統",font="Helvetica 30",bg="#df99ff",fg="white",relief=GROOVE)
|
||||||
|
createTable=Button(win,text="自己課表自己排",font="Helvetica 30",bg="blue",fg="white",relief=GROOVE,command=lambda:callTable())
|
||||||
|
createRigestryWin=Button(win,text="查詢活動報名資料",font="Helvetica 30",bg="black",fg="white",relief=GROOVE)
|
||||||
|
|
||||||
|
createMoodleWin.config(command=lambda:moodleWin(moodle) )
|
||||||
|
createNcnuMainWin.config(command=lambda:ncnuMainWin() )
|
||||||
|
createNcnuWin.config(command=lambda:ncnuWin(ncnu) )
|
||||||
|
createRigestryWin.config(command=lambda:rigestryWin())
|
||||||
|
|
||||||
|
|
||||||
|
createMoodleWin.pack(fill="x")
|
||||||
createNcnuMainWin.pack(fill="x")
|
createNcnuMainWin.pack(fill="x")
|
||||||
createNcnuWin.pack(fill="x")
|
createNcnuWin.pack(fill="x")
|
||||||
createMoodleWin.pack(fill="x")
|
createTable.pack(fill="x")
|
||||||
|
createRigestryWin.pack(fill="x")
|
||||||
|
|
||||||
win.mainloop()
|
win.mainloop()
|
||||||
|
|
||||||
createMainWin()
|
|
||||||
|
|||||||
@ -13,16 +13,10 @@ def getIdAndName(course):
|
|||||||
return coursesId ,courseName
|
return coursesId ,courseName
|
||||||
|
|
||||||
|
|
||||||
def createMoodleWin():
|
|
||||||
moodle = MoodleAPI(CONFIG['moodle']['username'], CONFIG['moodle']['password'])
|
|
||||||
|
|
||||||
|
def createMoodleWin(moodle):
|
||||||
if moodle.status:
|
if moodle.status:
|
||||||
# ===== 取得課程ID與名稱 =====
|
# ===== 取得課程ID與名稱 =====
|
||||||
c = moodle.getCourses("1092")
|
|
||||||
coursesId,coursesName=getIdAndName(c)
|
|
||||||
|
|
||||||
#for e in moodle.getUpcomingEvents()
|
|
||||||
|
|
||||||
win=Tk()
|
win=Tk()
|
||||||
|
|
||||||
rightFrame=Frame(win,bg="red")
|
rightFrame=Frame(win,bg="red")
|
||||||
@ -37,9 +31,14 @@ def createMoodleWin():
|
|||||||
|
|
||||||
leftFrame.pack(fill=BOTH,side=LEFT)
|
leftFrame.pack(fill=BOTH,side=LEFT)
|
||||||
rightFrame.pack(fill=BOTH)
|
rightFrame.pack(fill=BOTH)
|
||||||
|
|
||||||
#=====Leftframe 1.button ->show UpComingEvent 2.choose courses=======
|
#=====Leftframe 1.button ->show UpComingEvent 2.choose courses=======
|
||||||
|
|
||||||
def showUpComingEvent(): #叫出未來事件
|
def showUpComingEvent(): #叫出未來事件
|
||||||
|
ht='''<h5>讀取中</h5>'''
|
||||||
|
htmlLb.set_html(ht)
|
||||||
|
win.update()
|
||||||
|
|
||||||
tmphtml=''''''
|
tmphtml=''''''
|
||||||
for e in moodle.getUpcomingEvents():
|
for e in moodle.getUpcomingEvents():
|
||||||
tmphtml+='''<br> {} <br>時間:{} <p>'''.format(e.get("name"),e.get("time") )
|
tmphtml+='''<br> {} <br>時間:{} <p>'''.format(e.get("name"),e.get("time") )
|
||||||
@ -49,7 +48,6 @@ def createMoodleWin():
|
|||||||
upComingEventBtn=Button(leftFrame,text="未來事件",font="Helvetica 10",command= lambda:showUpComingEvent() )
|
upComingEventBtn=Button(leftFrame,text="未來事件",font="Helvetica 10",command= lambda:showUpComingEvent() )
|
||||||
coursesListBox=Listbox(leftFrame)
|
coursesListBox=Listbox(leftFrame)
|
||||||
mylb=Label(leftFrame,text="我的課程",font="Helvetica 15")
|
mylb=Label(leftFrame,text="我的課程",font="Helvetica 15")
|
||||||
coursesListBox.insert(END,*coursesName)
|
|
||||||
|
|
||||||
mylb.pack(fill=X)
|
mylb.pack(fill=X)
|
||||||
coursesListBox.pack(fill=BOTH)
|
coursesListBox.pack(fill=BOTH)
|
||||||
@ -60,6 +58,9 @@ def createMoodleWin():
|
|||||||
obj = event.widget
|
obj = event.widget
|
||||||
Index = obj.curselection()
|
Index = obj.curselection()
|
||||||
tmpId=coursesId[coursesName.index(str(obj.get(Index)))]
|
tmpId=coursesId[coursesName.index(str(obj.get(Index)))]
|
||||||
|
ht='''<h5>讀取中</h5>'''
|
||||||
|
htmlLb.set_html(ht)
|
||||||
|
win.update()
|
||||||
Html='''<h3>本周作業</h3><ol>'''
|
Html='''<h3>本周作業</h3><ol>'''
|
||||||
for work in moodle.getWeekWorkInCourse(str(tmpId)):
|
for work in moodle.getWeekWorkInCourse(str(tmpId)):
|
||||||
Html+='''<li> <a href={}> {}</a> </li>'''.format(work.get("link"),work.get("name") )
|
Html+='''<li> <a href={}> {}</a> </li>'''.format(work.get("link"),work.get("name") )
|
||||||
@ -69,11 +70,21 @@ def createMoodleWin():
|
|||||||
Html+='''</ol>'''
|
Html+='''</ol>'''
|
||||||
htmlLb.set_html(Html)
|
htmlLb.set_html(Html)
|
||||||
|
|
||||||
coursesListBox.bind("<<ListboxSelect>>", itemSelected)
|
|
||||||
|
|
||||||
|
|
||||||
|
coursesName=[]
|
||||||
|
coursesListBox.insert(END,*coursesName)
|
||||||
|
|
||||||
|
win.update()
|
||||||
|
|
||||||
|
coursesId,coursesName=getIdAndName(moodle.getCourses("1092"))
|
||||||
|
coursesListBox.insert(END,*coursesName)
|
||||||
|
print(coursesName)
|
||||||
|
coursesListBox.bind("<<ListboxSelect>>", itemSelected)
|
||||||
win.mainloop()
|
win.mainloop()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
else:
|
else:
|
||||||
print("Moodle 登入失敗")
|
print("Moodle 登入失敗")
|
||||||
|
|
||||||
createMoodleWin()
|
|
||||||
@ -4,8 +4,8 @@ from config import CONFIG
|
|||||||
from tkinter import messagebox
|
from tkinter import messagebox
|
||||||
from tkhtmlview import HTMLLabel
|
from tkhtmlview import HTMLLabel
|
||||||
|
|
||||||
def createNcnuWin():
|
def createNcnuWin(ncnu):
|
||||||
ncnu = NcnuAPI(CONFIG['NCNU']['username'], CONFIG['NCNU']['password'])
|
|
||||||
if ncnu.status:
|
if ncnu.status:
|
||||||
def dlCurriculum(sem):
|
def dlCurriculum(sem):
|
||||||
if ncnu.getCourseTable(sem):
|
if ncnu.getCourseTable(sem):
|
||||||
@ -45,6 +45,10 @@ def createNcnuWin():
|
|||||||
def itemSelected(event):
|
def itemSelected(event):
|
||||||
obj = event.widget
|
obj = event.widget
|
||||||
Index = obj.curselection()
|
Index = obj.curselection()
|
||||||
|
ht='''<h5>讀取中</h5>'''
|
||||||
|
htmlLb.set_html(ht)
|
||||||
|
win.update()
|
||||||
|
|
||||||
|
|
||||||
Html=''''''
|
Html=''''''
|
||||||
if str( obj.get(Index) ) == options[0]:
|
if str( obj.get(Index) ) == options[0]:
|
||||||
@ -96,5 +100,3 @@ def createNcnuWin():
|
|||||||
|
|
||||||
else:
|
else:
|
||||||
print("NCNU 教務系統登入失敗")
|
print("NCNU 教務系統登入失敗")
|
||||||
|
|
||||||
createNcnuWin()
|
|
||||||
@ -6,23 +6,31 @@ def createNcnuMainWin():
|
|||||||
win=Tk()
|
win=Tk()
|
||||||
win.title("暨大官網最新資訊!")
|
win.title("暨大官網最新資訊!")
|
||||||
win.geometry("600x600")
|
win.geometry("600x600")
|
||||||
main = NcnuMainAPI()
|
|
||||||
Link='''<span style="background-color:#ffcccc"><ul>'''
|
|
||||||
textLb=Label(win,text="暨大校園最新資訊",font="Helvetica 20",bg="#ffcccc")
|
textLb=Label(win,text="暨大校園最新資訊",font="Helvetica 20",bg="#ffcccc")
|
||||||
|
|
||||||
for anno in main.getAnno():
|
|
||||||
Link+='''<li> <a href={}> {}</a> </li>'''.format(anno.get("link"),anno.get("title") )
|
|
||||||
|
|
||||||
Link=Link+'''</ul></span>'''
|
|
||||||
|
|
||||||
sb=Scrollbar(win)
|
sb=Scrollbar(win)
|
||||||
htmlLable=HTMLLabel(win,html=Link)
|
htmlLable=HTMLLabel(win)
|
||||||
htmlLable.configure(yscrollcommand=sb.set)
|
htmlLable.configure(yscrollcommand=sb.set)
|
||||||
textLb.pack(fill="x")
|
textLb.pack(fill="x")
|
||||||
|
|
||||||
sb.pack(side=RIGHT,fill="y")
|
sb.pack(side=RIGHT,fill="y")
|
||||||
htmlLable.pack(fill="both",expand=True)
|
htmlLable.pack(fill="both",expand=True)
|
||||||
|
win.update()
|
||||||
|
#=====爬=====
|
||||||
|
ht='''<span style="background-color:#ffcccc"><h5>讀取中</h5></span>'''
|
||||||
|
htmlLable.set_html(ht)
|
||||||
|
win.update()
|
||||||
|
|
||||||
|
main = NcnuMainAPI()
|
||||||
|
Link='''<span style="background-color:#ffcccc"><ul>'''
|
||||||
|
for anno in main.getAnno():
|
||||||
|
Link+='''<li> <a href={}> {}</a> </li>'''.format(anno.get("link"),anno.get("title") )
|
||||||
|
Link=Link+'''</ul></span>'''
|
||||||
|
htmlLable.set_html(Link)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
win.mainloop()
|
win.mainloop()
|
||||||
|
|
||||||
createNcnuMainWin()
|
|
||||||
137
wins/courseTable.py
Normal file
137
wins/courseTable.py
Normal file
@ -0,0 +1,137 @@
|
|||||||
|
import requests
|
||||||
|
import json
|
||||||
|
from tkinter import *
|
||||||
|
from api.courseTable.courseTable import *
|
||||||
|
def callTable():
|
||||||
|
url = 'https://raw.githubusercontent.com/snsd0805/NCNU_Course/master/%E6%AD%B7%E5%B9%B4%E8%AA%B2%E7%A8%8B%E8%B3%87%E6%96%99/1092_output.json'
|
||||||
|
response = requests.get(url)
|
||||||
|
|
||||||
|
data = json.loads(response.text)
|
||||||
|
|
||||||
|
class Choose():
|
||||||
|
def __init__(self,root,name,typeS):
|
||||||
|
self.frame=Frame(root)
|
||||||
|
self.classname = Label(self.frame, font="10", width="10", text=name)
|
||||||
|
self.listbox = Listbox(self.frame)
|
||||||
|
self.scrollbar=Scrollbar(self.frame)
|
||||||
|
self.checkBtn = Button(self.frame, text="選取")
|
||||||
|
self.checkBtn.config(
|
||||||
|
command=lambda: self.setDepartment() if self.type=="department" else self.setCourse()
|
||||||
|
)
|
||||||
|
self.type = typeS
|
||||||
|
|
||||||
|
def setDepartment(self):
|
||||||
|
# print("set department")
|
||||||
|
# print(self.listbox.get(ACTIVE))
|
||||||
|
self.update()
|
||||||
|
|
||||||
|
def setCourse(self):
|
||||||
|
# print("set course")
|
||||||
|
# print(self.listbox.get(ACTIVE).split(' ')[0])
|
||||||
|
courseTable.add(
|
||||||
|
self.listbox.get(ACTIVE).split(' ')[0]
|
||||||
|
)
|
||||||
|
self.update()
|
||||||
|
|
||||||
|
def update(self):
|
||||||
|
courses = courseTable.courseFilter(box[0].listbox.get(ACTIVE))
|
||||||
|
courses = ["{} {}({})".format(course['number'], course['name'], course['time']) for course in courses]
|
||||||
|
box[1].listbox.delete(0, END)
|
||||||
|
box[1].insert(courses)
|
||||||
|
|
||||||
|
# update table draw
|
||||||
|
for j in range(5):
|
||||||
|
for i in range(13):
|
||||||
|
if courseTable.table[str(j+1) + tmp[i]] != None:
|
||||||
|
table[18 + (13*j+i)].classname.config(text=
|
||||||
|
courseTable.table[str(j+1) + tmp[i]]['name']
|
||||||
|
)
|
||||||
|
table[18 + (13*j+i)].removeBtn.grid()
|
||||||
|
table[18 + (13*j+i)].id = courseTable.table[str(j+1) + tmp[i]]['number']
|
||||||
|
else:
|
||||||
|
table[18 + (13*j+i)].classname.config(text="")
|
||||||
|
table[18 + (13*j+i)].removeBtn.grid_forget()
|
||||||
|
table[18 + (13*j+i)].id = None
|
||||||
|
|
||||||
|
def insert(self,LIST):
|
||||||
|
self.listbox.insert(END,*LIST)
|
||||||
|
|
||||||
|
def grid(self,Row,Column,span):
|
||||||
|
self.listbox.selection_set(15)
|
||||||
|
self.frame.grid(row=Row,column=Column,rowspan=span,padx=10,sticky="n"+"s")
|
||||||
|
self.classname.pack()
|
||||||
|
self.scrollbar.pack(fill=Y,side=RIGHT)
|
||||||
|
self.listbox.pack()
|
||||||
|
self.listbox.config(yscrollcommand=self.scrollbar.set)
|
||||||
|
self.checkBtn.pack()
|
||||||
|
|
||||||
|
class Space():
|
||||||
|
def __init__(self, root, name=None):
|
||||||
|
self.frame = Frame(root,relief=RIDGE,bd=1)
|
||||||
|
self.classname = Label(self.frame, font=("Curier New",10),padx=10, text=name,justify="right")
|
||||||
|
self.removeBtn = Button(self.frame, font=("Curier New",10), text="刪", command=self.removeCourse)
|
||||||
|
#self.frame.config(relief=RIDGE)
|
||||||
|
self.id = None
|
||||||
|
|
||||||
|
def grid(self,Row,Column):
|
||||||
|
if Row==5:
|
||||||
|
self.frame.config(bg="green")
|
||||||
|
self.classname.config(bg="green")
|
||||||
|
self.frame.grid(row=Row,column=Column,padx=20,sticky="w"+"e")
|
||||||
|
self.classname.grid(row=0,column=0)
|
||||||
|
self.removeBtn.grid(row=0,column=1)
|
||||||
|
self.removeBtn.grid_forget()
|
||||||
|
|
||||||
|
def removeCourse(self):
|
||||||
|
# print(self.id)
|
||||||
|
courseTable.remove(self.id)
|
||||||
|
box[0].update()
|
||||||
|
# courseTable.showTableStatus()
|
||||||
|
|
||||||
|
root = Tk()
|
||||||
|
root.geometry('800x600')
|
||||||
|
|
||||||
|
courseTable = CourseTable()
|
||||||
|
|
||||||
|
box=[]
|
||||||
|
box.append(Choose(root,name="科系",typeS='department'))
|
||||||
|
departments = courseTable.getDepartmentList()
|
||||||
|
box[0].insert(departments)
|
||||||
|
box[0].listbox.select_set(0)
|
||||||
|
box[0].grid(0,0,7)
|
||||||
|
|
||||||
|
box.append(Choose(root,name="課程",typeS='courses'))
|
||||||
|
courses = courseTable.courseFilter("21, 資工系")
|
||||||
|
|
||||||
|
box[1].insert(["{} {}({})".format(course['number'], course['name'], course['time']) for course in courses])
|
||||||
|
box[1].grid(7,0,6)
|
||||||
|
|
||||||
|
|
||||||
|
table = []
|
||||||
|
k=0
|
||||||
|
|
||||||
|
tmp=list("abcdzefghijklm")
|
||||||
|
|
||||||
|
for j in range(5):
|
||||||
|
table.append(Label(root,text=j+1,font=("Curier New",20)))
|
||||||
|
table[k].grid(row=0,column=j+3)
|
||||||
|
k+=1
|
||||||
|
|
||||||
|
for i in range(13):
|
||||||
|
table.append(Label(root,text=tmp[i]))
|
||||||
|
table[k].grid(row=i+1,column=1)
|
||||||
|
|
||||||
|
k+=1
|
||||||
|
|
||||||
|
table[9].config(bg="green")
|
||||||
|
|
||||||
|
# 18~
|
||||||
|
for j in range(5):
|
||||||
|
for i in range(13):
|
||||||
|
table.append(Space(root))
|
||||||
|
table[k].grid(i+1,j+3)
|
||||||
|
k+=1
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
root.mainloop()
|
||||||
109
wins/firstpage.py
Normal file
109
wins/firstpage.py
Normal file
@ -0,0 +1,109 @@
|
|||||||
|
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 wins.MainWin import *
|
||||||
|
|
||||||
|
|
||||||
|
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()] )
|
||||||
|
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")
|
||||||
|
|
||||||
|
frame.pack(expand=1)
|
||||||
|
imgLabel.pack()
|
||||||
|
text_lb.pack(padx=100)
|
||||||
|
go_to_loginwin_btn.pack(pady=50)
|
||||||
|
|
||||||
|
first.mainloop()
|
||||||
|
|
||||||
|
def loginwin(login):
|
||||||
|
#login=Tk()
|
||||||
|
login.geometry("300x200")
|
||||||
|
login.configure(bg="lightgreen")
|
||||||
|
login.resizable(width=0,height=0)
|
||||||
|
|
||||||
|
frame=Frame(login,width=100,height=100,bg="lightgreen")
|
||||||
|
frame1=Frame(login,width=300,height=100,bg="lightgreen")
|
||||||
|
frame2=Frame(login,width=300,height=100,bg="lightgreen")
|
||||||
|
frame3=Frame(login,width=300,height=100,bg="lightgreen")
|
||||||
|
frame4=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:Login() )
|
||||||
|
|
||||||
|
enter_name=Entry(frame1,bd=3)
|
||||||
|
enter_password=Entry(frame2,show="*",bd=3)
|
||||||
|
enter_ncnupw=Entry(frame4,show="*",bd=3)
|
||||||
|
|
||||||
|
name_lb=Label(frame1,text="學號",font="Helvetica 12",bg="lightgreen")
|
||||||
|
|
||||||
|
pw_lb=Label(frame2,text="Moodle密碼",font="Helvetica 12",bg="lightgreen")
|
||||||
|
ncnupw_lb=Label(frame4,text="教務系統密碼",font="Helvetica 12",bg="lightgreen")
|
||||||
|
|
||||||
|
show_password=Button( frame3,text="透視moodle密碼")
|
||||||
|
show_ncnupw=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="*") )
|
||||||
|
|
||||||
|
show_ncnupw.bind( '<Button-1>',lambda event:enter_ncnupw.config(show=""))
|
||||||
|
show_ncnupw.bind( '<ButtonRelease-1>',lambda event : enter_ncnupw.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_ncnupw.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()
|
||||||
|
frame4.pack()
|
||||||
|
frame3.pack()
|
||||||
|
prompt_lb.pack(pady=10,side="top")
|
||||||
|
name_lb.pack(side="left")
|
||||||
|
enter_name.pack(side="left")
|
||||||
|
pw_lb.pack(side="left")
|
||||||
|
enter_password.pack(side="left")
|
||||||
|
ncnupw_lb.pack(side="left")
|
||||||
|
enter_ncnupw.pack()
|
||||||
|
|
||||||
|
show_password.pack(side="left",pady=10,padx=10)
|
||||||
|
show_ncnupw.pack(side="left",pady=10,padx=10)
|
||||||
|
login_btn.pack(side="left",pady=10)
|
||||||
|
|
||||||
|
login.mainloop()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
103
wins/rigestryWin.py
Normal file
103
wins/rigestryWin.py
Normal file
@ -0,0 +1,103 @@
|
|||||||
|
from api.eventRigestry import EventRegistry
|
||||||
|
from config import CONFIG
|
||||||
|
from tkinter import *
|
||||||
|
from tkhtmlview import HTMLLabel
|
||||||
|
|
||||||
|
class textBox():
|
||||||
|
def __init__(self, root, key, value, Stype):
|
||||||
|
self.key = key
|
||||||
|
self.value = value
|
||||||
|
self.type = Stype
|
||||||
|
self.frame = Frame(root)
|
||||||
|
self.label = Label(self.frame, text=key)
|
||||||
|
self.entry = Entry(self.frame)
|
||||||
|
self.entry.insert(0, value)
|
||||||
|
|
||||||
|
if Stype==False:
|
||||||
|
self.entry.config(state='disabled')
|
||||||
|
|
||||||
|
def pack(self):
|
||||||
|
self.label.pack(side=LEFT)
|
||||||
|
self.entry.pack(side=RIGHT)
|
||||||
|
self.frame.pack()
|
||||||
|
|
||||||
|
|
||||||
|
def createRigestryWin():
|
||||||
|
|
||||||
|
root=Tk()
|
||||||
|
frame1=Frame(root)
|
||||||
|
frame2=Frame(root)
|
||||||
|
frame1.pack(side=LEFT)
|
||||||
|
frame2.pack()
|
||||||
|
winScrollBar=Scrollbar(frame1)
|
||||||
|
htmlLb=HTMLLabel(frame1,html="")
|
||||||
|
|
||||||
|
|
||||||
|
winScrollBar.pack(side=RIGHT,fill="y")
|
||||||
|
htmlLb.pack(fill=BOTH)
|
||||||
|
htmlLb.configure(yscrollcommand=winScrollBar.set)
|
||||||
|
|
||||||
|
ht='''<span style="background-color:#ffcccc"><h5>讀取中</h5></span>'''
|
||||||
|
htmlLb.set_html(ht)
|
||||||
|
root.update()
|
||||||
|
html=''''''
|
||||||
|
|
||||||
|
root.update()
|
||||||
|
|
||||||
|
|
||||||
|
rigestry=EventRegistry(CONFIG['moodle']['username'], CONFIG['moodle']['password'])
|
||||||
|
tmpid=[]
|
||||||
|
tmpname=[]
|
||||||
|
events = rigestry.getEventsList()
|
||||||
|
if rigestry.status:
|
||||||
|
for i in events:
|
||||||
|
html+='''<tr> <td>活動ID:{}</td> <td>學期{}</td> <br> <td>活動報名狀態:{}</td> <br> <td>活動名稱:{}</td> <br> <td>活動開始時間: {}</td> <br> <td>報名方式:{}</td> <br> <td>時數: {}</td> <br><td>講師: {}</td> <br> <td>申請為教師之能活動: {}</td> </tr><p> '''.format(
|
||||||
|
i.get("id"),i.get("semester"),i.get("status"),i.get("name"),i.get("time"),i.get("method"),i.get("hour"),i.get("speaker"),i.get("teacherEvevt") )
|
||||||
|
tmpid.append(i.get("id"))
|
||||||
|
tmpname.append(i.get("name"))
|
||||||
|
htmlLb.set_html(html)
|
||||||
|
else:
|
||||||
|
print("NO")
|
||||||
|
|
||||||
|
def signUpWin(event):
|
||||||
|
win=Tk()
|
||||||
|
data = rigestry.signUpPrepare(event.get('id'))
|
||||||
|
|
||||||
|
idBox = textBox(win, "學號:", data['x_applicantID'], False)
|
||||||
|
idBox.pack()
|
||||||
|
|
||||||
|
nameBox = textBox(win, "姓名:", data['x_applicantName'], False)
|
||||||
|
nameBox.pack()
|
||||||
|
|
||||||
|
departmentBox = textBox(win, "科系:", data['x_applicantUabbrname'], False)
|
||||||
|
departmentBox.pack()
|
||||||
|
|
||||||
|
authBox = textBox(win, "身份:", data['x_applicantTitle'], False)
|
||||||
|
authBox.pack()
|
||||||
|
|
||||||
|
iphoneBox = textBox(win, "分機:", data['x_iphone'], True)
|
||||||
|
iphoneBox.pack()
|
||||||
|
|
||||||
|
phoneBox = textBox(win, "電話:", data['x_phone'], True)
|
||||||
|
phoneBox.pack()
|
||||||
|
|
||||||
|
mailBox = textBox(win, "mail:", data['x_zemail'], True)
|
||||||
|
mailBox.pack()
|
||||||
|
|
||||||
|
markBox = textBox(win, "備註:", data['x_remark'], True)
|
||||||
|
markBox.pack()
|
||||||
|
|
||||||
|
submit = Button(win, text="報名")
|
||||||
|
submit.pack()
|
||||||
|
|
||||||
|
win.mainloop()
|
||||||
|
|
||||||
|
|
||||||
|
for i in events:
|
||||||
|
if i.get('status') == "B, 開放公告":
|
||||||
|
Button(frame2,text="我要報名 {}".format(i.get('name')),command=lambda:signUpWin(i) ).pack(anchor="w")
|
||||||
|
|
||||||
|
root.update()
|
||||||
|
|
||||||
|
root.mainloop()
|
||||||
|
|
||||||
Loading…
Reference in New Issue
Block a user