Applet implementation + oxiver
This commit is contained in:
parent
0e6421ef58
commit
6adf3653bb
|
@ -0,0 +1,10 @@
|
||||||
|
global oxiAppletLock
|
||||||
|
oxiAppletLock = threading.Lock()
|
||||||
|
|
||||||
|
global oxiApplets
|
||||||
|
oxiApplets = []
|
||||||
|
|
||||||
|
global oxiApplet
|
||||||
|
class oxiApplet(object):
|
||||||
|
def __init__(self):
|
||||||
|
pass
|
|
@ -0,0 +1,11 @@
|
||||||
|
global oxiAppletCollectionLock
|
||||||
|
oxiAppletCollectionLock = threading.Lock()
|
||||||
|
|
||||||
|
global oxiAppletCollection
|
||||||
|
oxiAppletCollection = {}
|
||||||
|
|
||||||
|
global oxiAppletCollectionRun
|
||||||
|
def oxiAppletCollectionRun(appletName):
|
||||||
|
with oxiAppletCollectionLock:
|
||||||
|
appletDefinition = oxiAppletCollection[appletName].copy()
|
||||||
|
appletDefinition[0](*appletDefinition[1],**appletDefinition[2])
|
|
@ -1 +1,5 @@
|
||||||
helloworld.py # show a hello world message in terminal, as the simplest check
|
helloworld.py # show a hello world message in terminal, as the simplest check
|
||||||
|
applet.py
|
||||||
|
appletCollection.py
|
||||||
|
qt.py
|
||||||
|
oxiver.py
|
|
@ -0,0 +1,14 @@
|
||||||
|
global platform
|
||||||
|
import platform
|
||||||
|
global QMainWindow
|
||||||
|
from qtpy.QtWidgets import QMainWindow
|
||||||
|
global QPixmap
|
||||||
|
from qtpy.QtGui import QPixmap
|
||||||
|
global QLabel
|
||||||
|
from qtpy.QtWidgets import QLabel
|
||||||
|
global QPushButton
|
||||||
|
from qtpy.QtWidgets import QPushButton
|
||||||
|
with oxiAppletCollectionLock:
|
||||||
|
oxiAppletCollection["oxiver"] = [oxiQtQueue.put,[[oxiRunScript,[oxiGetConfig("oxiver.qt.py")],{}]],{}]
|
||||||
|
|
||||||
|
#oxiAppletCollectionRun("oxiver")
|
|
@ -0,0 +1,45 @@
|
||||||
|
class splashWindow(QMainWindow):
|
||||||
|
def __init__(self,applet,*args,**kwargs):
|
||||||
|
super().__init__(*args,**kwargs)
|
||||||
|
|
||||||
|
with oxiAppletLock:
|
||||||
|
self.applet = applet
|
||||||
|
oxiApplets.append(self.applet)
|
||||||
|
self.applet.windows = [self]
|
||||||
|
|
||||||
|
self.cTitle = "About " +oxiDistro
|
||||||
|
self.setWindowTitle(self.cTitle)
|
||||||
|
|
||||||
|
self.cWidth = 414
|
||||||
|
self.cHeight = 304
|
||||||
|
self.resize(self.cWidth,self.cHeight)
|
||||||
|
|
||||||
|
self.cCreateElements()
|
||||||
|
|
||||||
|
def cCreateElements(self):
|
||||||
|
self.cImageLabel = QLabel(self)
|
||||||
|
self.cImageLabel.setPixmap(QPixmap(oxiGetConfig("splash.bmp")))
|
||||||
|
self.cImageLabel.move(0,0)
|
||||||
|
self.cImageLabel.resize(414,78)
|
||||||
|
self.cText = QLabel(self)
|
||||||
|
|
||||||
|
applets = 0
|
||||||
|
with oxiAppletLock: applets = len(oxiApplets)
|
||||||
|
|
||||||
|
self.cText.setText(oxiDistro + "\n" + "Version 0.0 (Build 0000)" + "\nLicensed under MIT, Copyright (C) 2022\n\n\noxi-applets running: " +str(applets)+ "\nOS: " +platform.system()+ " " +platform.release()+ "\nQt: " +str(QtCore.qVersion()))
|
||||||
|
self.cText.move(105,78 + 15)
|
||||||
|
self.cText.resize(414 - 105,304 - (78 + 15) - 31 - 15)
|
||||||
|
self.cText.setAlignment(QtCore.Qt.AlignLeft)
|
||||||
|
|
||||||
|
self.cQuitButton = QPushButton("OK",self)
|
||||||
|
self.cQuitButton.clicked.connect(self.close)
|
||||||
|
self.cQuitButton.move(414 - 83,304 - 31)
|
||||||
|
self.cQuitButton.resize(75,23)
|
||||||
|
self.show()
|
||||||
|
|
||||||
|
def closeEvent(self,event):
|
||||||
|
with oxiAppletLock:
|
||||||
|
oxiApplets.remove(self.applet)
|
||||||
|
|
||||||
|
applet = oxiApplet()
|
||||||
|
splashWindow(applet)
|
|
@ -0,0 +1,63 @@
|
||||||
|
def main():
|
||||||
|
global threading
|
||||||
|
import threading
|
||||||
|
global queue
|
||||||
|
import queue
|
||||||
|
global qtpy
|
||||||
|
import qtpy
|
||||||
|
|
||||||
|
global QApplication
|
||||||
|
from qtpy.QtWidgets import QApplication
|
||||||
|
global QtCore
|
||||||
|
import qtpy.QtCore as QtCore
|
||||||
|
global QThread
|
||||||
|
from qtpy.QtCore import QThread
|
||||||
|
global QObject
|
||||||
|
from qtpy.QtCore import QObject
|
||||||
|
|
||||||
|
global oxiQtQueue
|
||||||
|
oxiQtQueue = queue.Queue()
|
||||||
|
|
||||||
|
class qtThread(QThread):
|
||||||
|
#qt5:
|
||||||
|
cmd = QtCore.Signal(list)
|
||||||
|
|
||||||
|
def __init__(self,*args,**kwargs):
|
||||||
|
super().__init__(*args,**kwargs)
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
while True:
|
||||||
|
cmd = oxiQtQueue.get()
|
||||||
|
#qt4:
|
||||||
|
#self.emit(QtCore.SIGNAL("cmd"),cmd)
|
||||||
|
|
||||||
|
#qt5:
|
||||||
|
self.cmd.emit(cmd)
|
||||||
|
|
||||||
|
class qtApp(QApplication):
|
||||||
|
def __init__(self,readyQueue,*args,**kwargs):
|
||||||
|
super().__init__(*args,**kwargs)
|
||||||
|
self.queueThread = qtThread()
|
||||||
|
#qt4:
|
||||||
|
#self.queueThread.connect(self.queueThread,QtCore.SIGNAL("cmd"),self.queueCallback)
|
||||||
|
|
||||||
|
#qt5:
|
||||||
|
self.queueThread.cmd.connect(self.queueCallback)
|
||||||
|
|
||||||
|
self.queueThread.start()
|
||||||
|
readyQueue.put(True)
|
||||||
|
|
||||||
|
def queueCallback(self,cmd):
|
||||||
|
cmd[0](*cmd[1],**cmd[2])
|
||||||
|
|
||||||
|
def close(self):
|
||||||
|
self.quit()
|
||||||
|
|
||||||
|
readyQueue = queue.Queue()
|
||||||
|
global oxiQtApp
|
||||||
|
oxiQtApp = qtApp(readyQueue,sys.argv)
|
||||||
|
global oxiMainThreadQueue
|
||||||
|
oxiMainThreadQueue.put([oxiQtApp.exec_,[],{}])
|
||||||
|
readyQueue.get()
|
||||||
|
print("Qt app running")
|
||||||
|
main()
|
Binary file not shown.
After Width: | Height: | Size: 126 KiB |
55
main.py
55
main.py
|
@ -1,22 +1,37 @@
|
||||||
global oxiDistro
|
def main():
|
||||||
oxiDistro = "oxiDE"
|
global oxiDistro
|
||||||
|
oxiDistro = "oxiDE"
|
||||||
|
|
||||||
global oxiMakeConfigPaths
|
global oxiMakeConfigPaths
|
||||||
def oxiMakeConfigPaths():
|
def oxiMakeConfigPaths():
|
||||||
global oxiConfigPaths
|
global oxiConfigPaths
|
||||||
oxiConfigPaths = []
|
oxiConfigPaths = []
|
||||||
if os.name == "nt":
|
if os.name == "nt":
|
||||||
oxiConfigPaths.append(p(os.environ["APPDATA"],oxiDistro))
|
oxiConfigPaths.append(p(os.environ["APPDATA"],oxiDistro))
|
||||||
else:
|
else:
|
||||||
oxiConfigPaths.append(p(os.environ["HOME"],".config",oxiDistro))
|
oxiConfigPaths.append(p(os.environ["HOME"],".config",oxiDistro))
|
||||||
oxiConfigPaths.append(p(sp,"config"))
|
oxiConfigPaths.append(p(sp,"config"))
|
||||||
|
|
||||||
global oxiGetConfig
|
global oxiGetConfig
|
||||||
def oxiGetConfig(file):
|
def oxiGetConfig(file):
|
||||||
for cpath in oxiConfigPaths:
|
for cpath in oxiConfigPaths:
|
||||||
ffile = p(cpath,file)
|
ffile = p(cpath,file)
|
||||||
if os.path.isfile(ffile): return ffile
|
if os.path.isfile(ffile): return ffile
|
||||||
return False
|
return False
|
||||||
|
|
||||||
oxiMakeConfigPaths()
|
global threading
|
||||||
oxiRunScript(oxiGetConfig("userMain.py"))
|
import threading
|
||||||
|
global queue
|
||||||
|
import queue
|
||||||
|
|
||||||
|
global oxiMainThreadQueue
|
||||||
|
oxiMainThreadQueue = queue.Queue()
|
||||||
|
|
||||||
|
oxiMakeConfigPaths()
|
||||||
|
|
||||||
|
threading.Thread(target=oxiRunScript,args=(oxiGetConfig("userMain.py"),)).run()
|
||||||
|
|
||||||
|
while True:
|
||||||
|
cmd = oxiMainThreadQueue.get()
|
||||||
|
cmd[0](*cmd[1],**cmd[2])
|
||||||
|
main()
|
2
oxiDE.py
2
oxiDE.py
|
@ -4,7 +4,7 @@ import sys
|
||||||
oldexcepthook = sys.excepthook
|
oldexcepthook = sys.excepthook
|
||||||
def newexcepthook(type,value,traceback):
|
def newexcepthook(type,value,traceback):
|
||||||
oldexcepthook(type,value,traceback)
|
oldexcepthook(type,value,traceback)
|
||||||
input("Press ENTER to quit.")
|
#input("Press ENTER to quit.")
|
||||||
sys.excepthook = newexcepthook
|
sys.excepthook = newexcepthook
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
|
Loading…
Reference in New Issue