Working on launcher IHM

This commit is contained in:
Adrien Bourmault 2019-07-03 23:34:56 +02:00
parent cac10bacc6
commit a9ea152e74
5 changed files with 181 additions and 9 deletions

View File

@ -23,12 +23,30 @@
********************************************************************************
"""
import logger
import sys
import os
## Launching the launcher
import logger # logger.py
import ihm # ihm.py
# Creating a log file
logfile = logger.NewLoggingSystem()
# Hello world
logfile.printdbg('*** CNIRLauncher LOGFILE. Hello World ! ***')
## Main function
def main():
# Creating a log file and removing the old
logfile = logger.NewLoggingSystem()
# Hello world
logfile.printdbg('*** CNIRLauncher LOGFILE. Hello World ! ***')
launcherWindow = ihm.LauncherWindow()
launcherWindow.mainloop()
## Bootstrap
main()
sys.exit(0)

View File

@ -26,4 +26,5 @@ import os
CNIRTesserHash = '5b58db27f7bc08c58a2cb33d01533b034b067cf8'
#CNIRFolder = os.getenv('APPDATA') + '/CNIRevelator/'
CNIRFolder = '.'
CNIRFolder = "."
CNIRLColor = "#003380"

127
src/launcher/ihm.py Normal file
View File

@ -0,0 +1,127 @@
"""
********************************************************************************
* CNIRevelator *
* *
* Desc: Application launcher graphical interface *
* *
* Copyright © 2018-2019 Adrien Bourmault (neox95) *
* *
* This file is part of CNIRevelator. *
* *
* CNIRevelator is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 3 of the License, or *
* any later version. *
* *
* CNIRevelator is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY*without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with CNIRevelator. If not, see <https:*www.gnu.org/licenses/>. *
********************************************************************************
"""
from tkinter import *
from tkinter.messagebox import *
from tkinter import filedialog
from tkinter import ttk
import globs # globs.py
class LoginDialog(Toplevel):
def __init__(self, parent):
super().__init__(parent)
self.title('Connexion')
Label(self, text='IPN : ').pack()
self.entry_login = Entry(self)
self.entry_login.insert(0, '')
self.entry_login.pack()
Label(self, text='Mot de passe : ').pack()
self.entry_pass = Entry(self, show='*')
self.entry_pass.insert(0, '')
self.entry_pass.pack()
Button(self, text='Connexion', command=(self.connecti)).pack()
self.resizable(width=False, height=False)
w = 150
h = 110
self.update()
ws = self.winfo_screenwidth()
hs = self.winfo_screenheight()
if getattr(sys, 'frozen', False):
self.iconbitmap(sys._MEIPASS + '\\id-card.ico\\id-card.ico')
else:
self.iconbitmap('id-card.ico')
upwin.update()
x = ws / 2 - w / 2
y = hs / 2 - h / 2
self.geometry('%dx%d+%d+%d' % (w, h, x, y))
def connecti(self):
global key
global login
login = self.entry_login.get().strip()
key = self.entry_pass.get().strip()
self.destroy()
class LauncherWindow(Tk):
def __init__(self):
# Initialize the tkinter main class
Tk.__init__(self)
self.configure(bg=globs.CNIRLColor)
self.resizable(width=False, height=False)
# Setting up the geometry
ws = self.winfo_screenwidth()
hs = self.winfo_screenheight()
wheight = ws /4
wwidth = hs /4
#self.update()
# Creating objects
self.mainCanvas = Canvas(self, width=wwidth, height=wheight, bg=globs.CNIRLColor, highlightthickness=0)
self.pBarZone = Canvas(self, width=wwidth, height=wheight/10, bg=globs.CNIRLColor)
self.progressBar = ttk.Progressbar(self.pBarZone, orient=HORIZONTAL, length=wwidth-10, mode='determinate')
self.update()
self.mainCanvas.create_text((wwidth / 2), (wheight / 3), text=("TEST"), font='Calibri 30 bold', fill='white')
self.msg = self.mainCanvas.create_text((wwidth / 2), (wheight / 1.15), text=' ', font='Calibri 9', fill='white')
self.update()
# Centering
x = ws / 2 - wwidth / 2
y = hs / 2 - wheight / 2
self.geometry('%dx%d+%d+%d' % (wwidth, wheight, x, y))
self.mainCanvas.grid()
self.pBarZone.grid()
self.progressBar.grid()
#self.after(2000, updating)
# if getattr(sys, 'frozen', False):
# self.iconbitmap(sys._MEIPASS + '\\id-card.ico\\id-card.ico')
# else:
# self.iconbitmap('id-card.ico')
# logger.info('Success !')
self.protocol('WM_DELETE_WINDOW', lambda : self.destroy())

View File

@ -26,6 +26,7 @@
import logging
import globs
import os
class NewLoggingSystem:
@ -34,7 +35,8 @@ class NewLoggingSystem:
# Deleting the error log
try:
os.remove(globs.CNIRFolder + '\\error.log') # The deletion does not working
except:
except Exception as e:
#print(str(e) + " : " + str(globs.CNIRFolder + '\\error.log'))
pass
# Create new logging handle

24
src/launcher/updater.py Normal file
View File

@ -0,0 +1,24 @@
"""
********************************************************************************
* CNIRevelator *
* *
* Desc: Application launcher updating system *
* *
* Copyright © 2018-2019 Adrien Bourmault (neox95) *
* *
* This file is part of CNIRevelator. *
* *
* CNIRevelator is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 3 of the License, or *
* any later version. *
* *
* CNIRevelator is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY*without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with CNIRevelator. If not, see <https:*www.gnu.org/licenses/>. *
********************************************************************************
"""