Compare commits
No commits in common. "master" and "courseTable" have entirely different histories.
master
...
courseTabl
@ -24,12 +24,12 @@ if moodle.status:
|
||||
space()
|
||||
|
||||
# ===== Test 取得課程在當週發布的物件 ( 文件、功課、BBB連結... 等)
|
||||
for work in moodle.getWeekWorkInCourse('47552'):
|
||||
for work in moodle.getWeekWorkInCourse('47562'):
|
||||
print(work)
|
||||
space()
|
||||
|
||||
# ===== TEST 取得該課程的最新公告
|
||||
for anno in moodle.getAnnoInCourse('47552'):
|
||||
for anno in moodle.getAnnoInCourse('47555'):
|
||||
print(anno)
|
||||
space()
|
||||
else:
|
||||
@ -37,6 +37,7 @@ else:
|
||||
|
||||
|
||||
|
||||
|
||||
# =================== Test 暨大官網 API ==========================
|
||||
|
||||
# ===== Test 取得暨大官網最新消息 =====
|
||||
|
||||
27
MainWin.py
Normal file
27
MainWin.py
Normal file
@ -0,0 +1,27 @@
|
||||
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()
|
||||
@ -13,10 +13,16 @@ def getIdAndName(course):
|
||||
return coursesId ,courseName
|
||||
|
||||
|
||||
def createMoodleWin():
|
||||
moodle = MoodleAPI(CONFIG['moodle']['username'], CONFIG['moodle']['password'])
|
||||
|
||||
def createMoodleWin(moodle):
|
||||
if moodle.status:
|
||||
# ===== 取得課程ID與名稱 =====
|
||||
c = moodle.getCourses("1092")
|
||||
coursesId,coursesName=getIdAndName(c)
|
||||
|
||||
#for e in moodle.getUpcomingEvents()
|
||||
|
||||
win=Tk()
|
||||
|
||||
rightFrame=Frame(win,bg="red")
|
||||
@ -31,14 +37,9 @@ def createMoodleWin(moodle):
|
||||
|
||||
leftFrame.pack(fill=BOTH,side=LEFT)
|
||||
rightFrame.pack(fill=BOTH)
|
||||
|
||||
#=====Leftframe 1.button ->show UpComingEvent 2.choose courses=======
|
||||
|
||||
def showUpComingEvent(): #叫出未來事件
|
||||
ht='''<h5>讀取中</h5>'''
|
||||
htmlLb.set_html(ht)
|
||||
win.update()
|
||||
|
||||
tmphtml=''''''
|
||||
for e in moodle.getUpcomingEvents():
|
||||
tmphtml+='''<br> {} <br>時間:{} <p>'''.format(e.get("name"),e.get("time") )
|
||||
@ -48,6 +49,7 @@ def createMoodleWin(moodle):
|
||||
upComingEventBtn=Button(leftFrame,text="未來事件",font="Helvetica 10",command= lambda:showUpComingEvent() )
|
||||
coursesListBox=Listbox(leftFrame)
|
||||
mylb=Label(leftFrame,text="我的課程",font="Helvetica 15")
|
||||
coursesListBox.insert(END,*coursesName)
|
||||
|
||||
mylb.pack(fill=X)
|
||||
coursesListBox.pack(fill=BOTH)
|
||||
@ -58,9 +60,6 @@ def createMoodleWin(moodle):
|
||||
obj = event.widget
|
||||
Index = obj.curselection()
|
||||
tmpId=coursesId[coursesName.index(str(obj.get(Index)))]
|
||||
ht='''<h5>讀取中</h5>'''
|
||||
htmlLb.set_html(ht)
|
||||
win.update()
|
||||
Html='''<h3>本周作業</h3><ol>'''
|
||||
for work in moodle.getWeekWorkInCourse(str(tmpId)):
|
||||
Html+='''<li> <a href={}> {}</a> </li>'''.format(work.get("link"),work.get("name") )
|
||||
@ -70,21 +69,11 @@ def createMoodleWin(moodle):
|
||||
Html+='''</ol>'''
|
||||
htmlLb.set_html(Html)
|
||||
|
||||
|
||||
|
||||
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()
|
||||
|
||||
|
||||
|
||||
|
||||
else:
|
||||
print("Moodle 登入失敗")
|
||||
|
||||
createMoodleWin()
|
||||
@ -4,8 +4,8 @@ from config import CONFIG
|
||||
from tkinter import messagebox
|
||||
from tkhtmlview import HTMLLabel
|
||||
|
||||
def createNcnuWin(ncnu):
|
||||
|
||||
def createNcnuWin():
|
||||
ncnu = NcnuAPI(CONFIG['NCNU']['username'], CONFIG['NCNU']['password'])
|
||||
if ncnu.status:
|
||||
def dlCurriculum(sem):
|
||||
if ncnu.getCourseTable(sem):
|
||||
@ -45,10 +45,6 @@ def createNcnuWin(ncnu):
|
||||
def itemSelected(event):
|
||||
obj = event.widget
|
||||
Index = obj.curselection()
|
||||
ht='''<h5>讀取中</h5>'''
|
||||
htmlLb.set_html(ht)
|
||||
win.update()
|
||||
|
||||
|
||||
Html=''''''
|
||||
if str( obj.get(Index) ) == options[0]:
|
||||
@ -100,3 +96,5 @@ def createNcnuWin(ncnu):
|
||||
|
||||
else:
|
||||
print("NCNU 教務系統登入失敗")
|
||||
|
||||
createNcnuWin()
|
||||
@ -6,31 +6,23 @@ def createNcnuMainWin():
|
||||
win=Tk()
|
||||
win.title("暨大官網最新資訊!")
|
||||
win.geometry("600x600")
|
||||
main = NcnuMainAPI()
|
||||
Link='''<span style="background-color:#ffcccc"><ul>'''
|
||||
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)
|
||||
htmlLable=HTMLLabel(win)
|
||||
htmlLable=HTMLLabel(win,html=Link)
|
||||
htmlLable.configure(yscrollcommand=sb.set)
|
||||
textLb.pack(fill="x")
|
||||
|
||||
sb.pack(side=RIGHT,fill="y")
|
||||
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()
|
||||
|
||||
createNcnuMainWin()
|
||||
@ -79,10 +79,9 @@ class CourseTable():
|
||||
'''
|
||||
移除課程
|
||||
'''
|
||||
for i in self.table:
|
||||
if self.table[i]:
|
||||
if self.table[i]['number'] == courseID:
|
||||
self.table[i] = None
|
||||
for key, value in self.table.items():
|
||||
if value['number'] == courseID:
|
||||
self.table[key] = None
|
||||
|
||||
def getDepartmentList(self):
|
||||
ans = set()
|
||||
@ -96,10 +95,7 @@ class CourseTable():
|
||||
return ans
|
||||
|
||||
def conflict(self, course):
|
||||
if course['time'] != None:
|
||||
timeList = getTime(course['time'])
|
||||
else:
|
||||
return False
|
||||
timeList = getTime(course['time'])
|
||||
status = True
|
||||
for time in timeList:
|
||||
if time in self.table:
|
||||
@ -111,10 +107,28 @@ class CourseTable():
|
||||
|
||||
return status
|
||||
|
||||
def courseFilter(self, department):
|
||||
def filter(self, department):
|
||||
ans = []
|
||||
for course in self.courseData:
|
||||
if course['department'] == department:
|
||||
if self.conflict(course):
|
||||
ans.append(course)
|
||||
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,21 +45,25 @@ class EventRegistry():
|
||||
url = "https://ccweb.ncnu.edu.tw/SLLL/z6D3B52D553CA5831540D8CC7659967E58A62list.asp"
|
||||
response = self.session.get(url)
|
||||
|
||||
events = find(response, 'table').findAll('tr')
|
||||
with open('test.html') as fp:
|
||||
response = fp.read()
|
||||
|
||||
root = BeautifulSoup(response, 'html.parser')
|
||||
events = root.find('table').findAll('tr')
|
||||
|
||||
return [{
|
||||
'id': getUrlParam(data[0].find('a').get('href').replace('&', '&'), 'RowID'),
|
||||
# 活動詳細:
|
||||
# https://ccweb.ncnu.edu.tw/SLLL/z6D3B52D553CA5831540D8CC7659967E58A62view.asp?showdetail=&RowID={}
|
||||
|
||||
'semester': data[1].text.replace('\n', '').replace('\r', ''),
|
||||
'status': data[2].text.replace('\n', '').replace('\r', ''), # 活動報名狀態
|
||||
'name': data[3].text.replace('\n', '').replace('\r', ''),
|
||||
'time': data[4].text.replace('\n', '').replace('\r', ''), # 活動開始時間
|
||||
'method': data[5].text.replace('\n', '').replace('\r', ''), # 報名方式
|
||||
'hour': data[6].text.replace('\n', '').replace('\r', ''), # 時數
|
||||
'speaker': data[7].text.replace('\n', '').replace('\r', ''), # 講師
|
||||
'teacherEvent': data[8].text.replace('\n', '').replace('\r', ''), # 申請為教師知能活動
|
||||
'semester': data[1].text.replace('\n', ''),
|
||||
'status': data[2].text.replace('\n', ''), # 活動報名狀態
|
||||
'name': data[3].text.replace('\n', ''),
|
||||
'time': data[4].text.replace('\n', ''), # 活動開始時間
|
||||
'method': data[5].text.replace('\n', ''), # 報名方式
|
||||
'hour': data[6].text.replace('\n', ''), # 時數
|
||||
'speaker': data[7].text.replace('\n', ''), # 講師
|
||||
'teacherEvent': data[8].text.replace('\n', ''), # 申請為教師知能活動
|
||||
} for data in (event.findAll('td') for event in events[1:])]
|
||||
|
||||
def signUpPrepare(self, eventID):
|
||||
|
||||
@ -2,4 +2,3 @@ import json
|
||||
|
||||
with open('config.json') as fp:
|
||||
CONFIG = json.load(fp)
|
||||
|
||||
60
firstpage.py
Normal file
60
firstpage.py
Normal file
@ -0,0 +1,60 @@
|
||||
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
40
main.py
@ -1,40 +0,0 @@
|
||||
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,12 +1,6 @@
|
||||
from api.courseTable.courseTable import CourseTable
|
||||
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(win,ncnu,moodle):
|
||||
def createMainWin():
|
||||
'''
|
||||
用綠色校園作為基底色
|
||||
以暨大的三大特色
|
||||
@ -15,30 +9,18 @@ def createMainWin(win,ncnu,moodle):
|
||||
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)
|
||||
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")
|
||||
createNcnuWin.pack(fill="x")
|
||||
createTable.pack(fill="x")
|
||||
createRigestryWin.pack(fill="x")
|
||||
createMoodleWin.pack(fill="x")
|
||||
|
||||
win.mainloop()
|
||||
|
||||
|
||||
createMainWin()
|
||||
|
||||
@ -1,137 +0,0 @@
|
||||
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()
|
||||
@ -1,109 +0,0 @@
|
||||
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()
|
||||
|
||||
|
||||
|
||||
|
||||
@ -1,103 +0,0 @@
|
||||
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