XUI is a page management GUI framework for python that is based on the platform-independent GUI package tinker.
Project description
xenon-UI (XUI)
XUI is a Python page management GUI framework based on the platform-independent GUI package tinker.
Author: H Junxiang If you have any questions and suggestions Please contact: huangjunshan@mail.ynu.edu.cn
Latest version: 1.2.6 Date 13/11/2023
Preinstall
Before installing XUI, tkinter libraries have to be installed
For windows/MacOS:
pip3 install tk
For CentOS/Fedora:
sudo yum install python3-tkinter
For Debian/Ubuntu:
sudo apt install python3-tk
Install
Please enter the following code on the command line to install XUI
pip3 install XenonUI
Create a page
XUI is managed based on page. Page is the basic unit of XUI, here we will create a page "pageA" and put it into the pages folder.
Version >=1.1.4 does not require XUI library
The download link is https://github.com/wacmkxiaoyi/Xenon-UI
And each page has many menus, and all information will be concentrated in each menu.
#pageA
import os
from XenonUI.XUIlib.imgtool import add_image
from XenonUI.XUIlib.page import *
logo=os.path.join("XenonUI","XUIlib","image","A.png") #select a logo you like
from tkinter import *
class page(page):
img={
"logo":logo
}
def menu1(self):
self.menu1=self.add_menu("menu1") #set menu
#add a title, can be call repeatedly
self.add_title(self.menu1,"Title of Menu 1")
##other arguments of add_title:
#bg: color of title, default "blue"
#fontsize: size of title, default 18
#height: title height, default 50
#add a row object
row=self.add_row(self.menu1)
#other arguments of add_row:
#bx: boundary x, (like margin_left/right in HTML), default 50
#height: height of row
#dosomething like using the tinker, with father object row
#e.g. a label
Label(row,text="this is a label").pack(side="left")
#an input box
Entry(row).pack(side="left")
#a button
Button(row).pack(side="left")
#.....
def menu2(self):
menu2=self.add_menu("menu2") #set menu2
self.add_title(menu2,"Title of Menu 2")
#do something as your wish
def initial(self): # this function builds up this page
self.set_image(self.img["logo"])
self.menu1()
self.menu2()
def show(self): #Default page
#This function means that as soon as XUI is opened, the contents of this directory will be displayed.
#You must use the attributes of <class page> to define the default menu, such as self.menu1
self.tkobj.open_smb(None,self.fmbindex)
self.tkobj.open_ro(None,self.fmbindex,self.menu1)
Readable Page
XUI has two readable pages: Help and Exit. You can directly copy the following code and save it as Help.py and Exit.py
#Help.py
import os
from XenonUI.XUIlib.imgtool import add_image
from XenonUI.XUIlib.page import *
logo=os.path.join("XenonUI","XUIlib","image","H.png")
main_logo=os.path.join("XenonUI","XUIlib","image","XUI.png")
from tkinter import *
class page(page):
img={
"main_logo":main_logo,
"logo":logo
}
def page_default(self):
self.default_page_smbindex=self.add_menu("XUI v1.1")
self.default_page_roindex=self.add_item(self.default_page_smbindex,self.ro_height)
add_image(self.tkobj.ro_item[self.fmbindex][self.default_page_smbindex][self.default_page_roindex][1],self.img["main_logo"],width=self.ro_width,height=self.ro_height)
def page_Document(self):
intro=self.add_menu("Readme")
self.add_row(intro,50)
self.add_title(intro,"Document of XUI please see:",fg="red")
self.add_title(intro,"https://www.github/wacmkxiaoyi/Xenon-UI",fontsize=10)
def page_author_information(self):
aui=self.add_menu("Author information")
self.add_row(aui,50)
self.add_title(aui,"Junxiang H.",fg="black")
self.add_title(aui,"huangjunxiang@mail.ynu.edu.cn",fontsize=10)
def initial(self):
self.set_image(self.img["logo"])
self.page_default()
self.page_author_information()
self.page_Document()
def show(self):
self.tkobj.open_smb(None,self.fmbindex)
self.tkobj.open_ro(None,self.fmbindex,self.default_page_smbindex)
#Exit.py
import os
from XenonUI.XUIlib.imgtool import add_image
from XenonUI.XUIlib.page import *
logo=os.path.join("XenonUI","XUIlib","image","E.png")
from tkinter import messagebox
class page(page):
img={
"logo":logo,
}
def initial(self):
def fun(event):
stt=""
if "windows_title" in self.pageargs.keys():
stt=" "+self.pageargs["windows_title"]
if messagebox.askokcancel(title="Warnning",message="Exit"+stt+" ?"):
#stop siobj.thread
try:
self.pageargs["XUIOBJ"].systeminfo.run=False
self.tkobj.io_state=False
except:
pass
self.tkobj.window.quit()
add_image(self.tkobj.fmb_item[self.fmbindex][1],self.img["logo"],width=self.tkobj.fmb.height-self.tkobj.fmb.scrollwidth-self.tkobj.get_pars("fmb_bd"),height=self.tkobj.fmb.height-self.tkobj.fmb.scrollwidth-self.tkobj.get_pars("fmb_bd"),event="<Button-1>",fun=fun)
Show pages
You can use the code below (save as a new Python script) to call the XUI and display the page you created
#Example.py
import os
try:
from XUIConfig import Pages #those folders/packages path modified by yourself
except:
pass
from XenonUI import XUI
from XenonUI.XUIlib.SystemInfo import SystemInfo
config_file="XUIConfig.py"
pages_import="pages" #aa.bb.cc.pages
def CollectPages():
pages_dir=os.path.join(*pages_import.split("."))
import datetime
pages_except=("__init__","page_model")
def FileNamePreProcess(filename):
filedir,filename=os.path.split(filename)
fileindex,filetype=os.path.splitext(filename)
return (fileindex.split(".")[-1],filedir,filetype.split(".")[1])
def GetFiles(filedir=os.getcwd(),filetype=""):
result=()
for file in os.listdir(filedir):
if file.endswith(filetype):
result+=(os.path.join(filedir,file),)
return result
strc="#File type: extension <class page> set\n#By Junxiang H., 2023/07/9\n#wacmk.com/cn Tech. Supp.\n\n#This script updates automaticly! Do not Modify!\n#Update time:"+datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")+"\n\nPages={}\n"
vaild_pages=tuple(set([FileNamePreProcess(i)[0] for i in GetFiles(pages_dir,"py")])-set(pages_except))
for i in vaild_pages:
strc+="import "+pages_import+"."+i+" as "+i+"\n"+"Pages[\""+i+"\"]="+i+"\n"
if "Help" not in vaild_pages:
strc+="import XenonUI.XUIlib.pages.Help as Help\nPages[\"Help\"]=Help\n"
if "Exit" not in vaild_pages:
strc+="import XenonUI.XUIlib.pages.Exit as Exit\nPages[\"Exit\"]=Exit\n"
file=open(config_file,"w")
file.writelines(strc)
file.close()
def build(**args):
class XUIOBJ:
def __init__(self,**args):
args.update({"XUIOBJ":self})
self.guiobj=XUI()
self.guiobj.build(**args)
#systeminfo
self.systeminfo=SystemInfo(self.guiobj)
self.systeminfo.lunch(1)
self.Pages={}
for i in reversed(Pages.keys()):
if i not in ("Exit","Help"):
self.Pages[i]=Pages[i].page(self.guiobj,**args)
if "Help" in Pages.keys():
self.Pages["Help"]=Pages["Help"].page(self.guiobj,**args)
if "Exit" in Pages.keys():
self.Pages["Exit"]=Pages["Exit"].page(self.guiobj,**args)
self.iofun=self.guiobj.io_recv
return XUIOBJ(**args)
if __name__=="__main__":
show=os.path.exists(config_file)
CollectPages()
if show:
xui=build() #you can set some arguments in here as you need
xui.guiobj.show()
else:
print("XUI configurates completed, please rerun script again")
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file XenonUI-1.2.6.tar.gz
.
File metadata
- Download URL: XenonUI-1.2.6.tar.gz
- Upload date:
- Size: 655.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 503ca4a301ef8b658286b457a5c5b7beaf68718206724ee33d415dd7f915ce34 |
|
MD5 | f54942da9c7f7142eaf76f5beab5af90 |
|
BLAKE2b-256 | cf573567a820f1b70b1efc9a358a75e76daef8a6142425e68927f5f6f5aa51d2 |
File details
Details for the file XenonUI-1.2.6-py3-none-any.whl
.
File metadata
- Download URL: XenonUI-1.2.6-py3-none-any.whl
- Upload date:
- Size: 726.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 37520016e1146b44c83cf75fc2d6eef31a0e8de74e7d2e7706e12c8bebead5a1 |
|
MD5 | c80cac22223228946c1c1127a50513ba |
|
BLAKE2b-256 | 6a775045c0608c9f563105fbe6ed0272195ff9cf304a2e549d007a00b11b1370 |