KernelChan/main.py

125 lines
3.7 KiB
Python
Raw Normal View History

2021-04-30 02:47:06 +02:00
from PySide2.QtWidgets import *
from PySide2.QtGui import *
from PySide2.QtCore import *
2021-05-01 21:02:46 +02:00
from getKernelInfo import KernelVerList, KernelURL
2021-04-30 02:47:06 +02:00
import sys,os
2021-05-01 00:41:15 +02:00
# TODO: Fix the install Process function.
2021-05-01 21:02:46 +02:00
# TODO: Implement when ListItem selected and install pressed, to parse the array and download the right Kernel with wget or curl from the Archive
2021-05-01 00:41:15 +02:00
# TODO: Implement resizible Windows
2021-05-01 14:43:58 +02:00
# TODO: Clean the code.
2021-05-01 14:52:55 +02:00
# TODO: Import from PySide only the needed functions
2021-05-01 00:41:15 +02:00
2021-04-30 04:14:55 +02:00
## Creating the MainWindow
2021-04-30 02:47:06 +02:00
class Window(QWidget):
def __init__(self):
super().__init__()
self.setWindowTitle("KernelChan")
self.setFixedSize(600,600)
self.center()
self.setIcon()
List.setList(self,25,20)
Button.setButton(self,"Install",400,540,self.installKernel)
Button.setButton(self,"Exit",490,540,self.exitApp)
def center(self):
qRect = self.frameGeometry()
2021-05-01 22:24:33 +02:00
centerPoint = QGuiApplication.primaryScreen().availableGeometry().center()
2021-04-30 02:47:06 +02:00
qRect.moveCenter(centerPoint)
self.move(qRect.topLeft())
def setIcon(self):
appIcon = QIcon('icon.png')
self.setWindowIcon(appIcon)
def installKernel(self):
self.install = InstallProcess()
self.install.show()
2021-05-01 00:41:15 +02:00
2021-04-30 04:14:55 +02:00
## Application Quit Popup
2021-04-30 02:47:06 +02:00
def exitApp(self):
askUser = QMessageBox.question(self, "Quit", "Are you Sure?", QMessageBox.Yes | QMessageBox.No)
if askUser == QMessageBox.Yes:
App.quit()
elif askUser == QMessageBox.No:
pass
2021-05-01 22:02:52 +02:00
## Making an Button
class Button(QPushButton):
def setButton(self, name, x, y,function):
button = QPushButton(name,self)
button.move(x,y)
button.clicked.connect(function)
## Making a List
class List(QListWidget):
def setList(self,x,y):
global aList
self.aList = QListWidget(self)
self.aList.resize(550,500)
self.aList.move(x,y)
aList = self.aList
## Taking the output from getKernelInfo and put it in the List
def addItem(self):
for i in KernelVerList:
self.item = QListWidgetItem(i, aList)
font = QFont()
font.setPixelSize(16)
self.item.setFont(font)
2021-04-30 02:47:06 +02:00
class InstallProcess(QWidget):
2021-04-30 04:14:55 +02:00
def __init__(self, *args):
QWidget.__init__(self, *args)
2021-04-30 02:47:06 +02:00
self.setWindowTitle("Kernel Installation")
self.setFixedSize(400,300)
self.center()
2021-04-30 04:14:55 +02:00
2021-05-01 22:02:52 +02:00
def Installation():
DeList = List()
print(DeList.item)
2021-05-01 00:41:15 +02:00
#!!! WARNING this function is wrong it waits for the Terminal to finish then it display the output.
2021-05-01 14:52:55 +02:00
#!!! If you put yes in it, the Program will freeze, there needs to be a better way to implement this.
2021-05-01 00:41:15 +02:00
# Output into InstallProcess Windows -> QTextBrowser
def letsgo():
2021-05-01 14:52:55 +02:00
output = os.popen("echo 'The Place where all the Terminal work is gonna be done.'").read()
2021-05-01 00:41:15 +02:00
return output
Stream = letsgo()
2021-04-30 04:14:55 +02:00
# create objects
self.te = QTextBrowser()
2021-05-01 00:41:15 +02:00
# puts the Terminal output into InstallWindow
self.te.setHtml(Stream)
2021-04-30 04:14:55 +02:00
# layout
layout = QVBoxLayout(self)
layout.addWidget(self.te)
self.setLayout(layout)
2021-04-30 02:47:06 +02:00
def center(self):
qRect = self.frameGeometry()
2021-05-01 22:24:33 +02:00
centerPoint = QGuiApplication.primaryScreen().availableGeometry().center()
2021-04-30 02:47:06 +02:00
qRect.moveCenter(centerPoint)
self.move(qRect.topLeft())
2021-05-01 14:52:55 +02:00
def main():
2021-05-01 22:02:52 +02:00
global App,window,DeList
2021-05-01 14:52:55 +02:00
App = QApplication(sys.argv)
window = Window()
2021-05-01 22:02:52 +02:00
DeList = List()
2021-05-01 14:52:55 +02:00
window.show()
2021-05-01 22:02:52 +02:00
DeList.addItem()
2021-04-30 04:14:55 +02:00
2021-05-01 14:52:55 +02:00
App.exec_()
sys.exit(0)
2021-04-30 02:47:06 +02:00
2021-05-01 14:52:55 +02:00
main()