started GUI development
57
GUIwrap.py
Normal file
|
@ -0,0 +1,57 @@
|
||||||
|
# handles GUI
|
||||||
|
from langsys import langhandler
|
||||||
|
import mtTkinter as tk
|
||||||
|
from tkinter import ttk as tkk
|
||||||
|
import multiprocessing
|
||||||
|
import os
|
||||||
|
|
||||||
|
global LH
|
||||||
|
LH = langhandler()
|
||||||
|
LH.setlang("en_EN")
|
||||||
|
|
||||||
|
# define functions
|
||||||
|
def do_popup(event):
|
||||||
|
try:
|
||||||
|
rm.tk_popup(event.x_root, event.y_root)
|
||||||
|
finally:
|
||||||
|
rm.grab_release()
|
||||||
|
|
||||||
|
def delobj():
|
||||||
|
raise NotImplementedError()
|
||||||
|
|
||||||
|
container = tk.Tk()
|
||||||
|
|
||||||
|
# init icons
|
||||||
|
global icons
|
||||||
|
icons = {}
|
||||||
|
|
||||||
|
for i in os.listdir("icons"):
|
||||||
|
icons[i.split(".")[0]] = tk.PhotoImage(file=f"icons/{i}")
|
||||||
|
|
||||||
|
global canvas
|
||||||
|
canvas = tk.Canvas(container)
|
||||||
|
canvas.grid(row=0, column=0)
|
||||||
|
|
||||||
|
global objtree
|
||||||
|
objtree = tkk.Treeview(container, columns=("-"))
|
||||||
|
objtree.heading("#0", text=LH.string("game"))
|
||||||
|
objtree.grid(row=1, column=0)
|
||||||
|
objectsid = objtree.insert("", "end", text=LH.string("objs"), image=icons["game"])
|
||||||
|
scriptssid = objtree.insert("", "end", text=LH.string("scriptserv"), image=icons["scriptserv"])
|
||||||
|
soundssid = objtree.insert("", "end", text=LH.string("soundserv"), image=icons["soundserv"])
|
||||||
|
|
||||||
|
global rm
|
||||||
|
rm = tk.Menu(container, tearoff=0)
|
||||||
|
rm.add_command(label=LH.string("del"), command=delobj)
|
||||||
|
container.bind("<Button-3>", do_popup)
|
||||||
|
|
||||||
|
global menu
|
||||||
|
menu = tk.Menu(container)
|
||||||
|
container.config(menu=menu)
|
||||||
|
|
||||||
|
global filemenu
|
||||||
|
filemenu = tk.Menu(container)
|
||||||
|
filemenu.add_command(label=LH.string("exit"), command=container.quit)
|
||||||
|
menu.add_cascade(menu=filemenu, label=LH.string("file"))
|
||||||
|
|
||||||
|
container.mainloop()
|
2
autoexec
|
@ -0,0 +1,2 @@
|
||||||
|
import threading
|
||||||
|
threading.Thread(target=lambda: loadfile("GUIwrap.py")).start()
|
|
@ -41,6 +41,21 @@ class obj:
|
||||||
self._parent = value
|
self._parent = value
|
||||||
self._parent.children.append(self)
|
self._parent.children.append(self)
|
||||||
|
|
||||||
|
class folder:
|
||||||
|
def __init__(self):
|
||||||
|
self._parent = NULL()
|
||||||
|
self.children = []
|
||||||
|
|
||||||
|
@property
|
||||||
|
def parent(self):
|
||||||
|
return self._parent
|
||||||
|
|
||||||
|
@parent.setter
|
||||||
|
def parent(self, value):
|
||||||
|
self._parent.children.remove(self)
|
||||||
|
self._parent = value
|
||||||
|
self._parent.children.append(self)
|
||||||
|
|
||||||
class game:
|
class game:
|
||||||
def __init__(self, canvas: tk.Canvas, pixelsize=3):
|
def __init__(self, canvas: tk.Canvas, pixelsize=3):
|
||||||
self._canvas = canvas
|
self._canvas = canvas
|
||||||
|
|
BIN
icons/ar-down.png
Normal file
After Width: | Height: | Size: 194 B |
BIN
icons/ar-left.png
Normal file
After Width: | Height: | Size: 185 B |
BIN
icons/ar-right.png
Normal file
After Width: | Height: | Size: 186 B |
BIN
icons/ar-up.png
Normal file
After Width: | Height: | Size: 177 B |
BIN
icons/build.png
Normal file
After Width: | Height: | Size: 180 B |
BIN
icons/game.png
Normal file
After Width: | Height: | Size: 279 B |
BIN
icons/obj.png
Normal file
After Width: | Height: | Size: 216 B |
BIN
icons/script.png
Normal file
After Width: | Height: | Size: 248 B |
BIN
icons/scriptserv.png
Normal file
After Width: | Height: | Size: 242 B |
BIN
icons/sound.png
Normal file
After Width: | Height: | Size: 209 B |
BIN
icons/soundserv.png
Normal file
After Width: | Height: | Size: 207 B |
BIN
icons/stop-test.png
Normal file
After Width: | Height: | Size: 200 B |
BIN
icons/test.png
Normal file
After Width: | Height: | Size: 212 B |
30
langsys/__init__.py
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
import os
|
||||||
|
import ast
|
||||||
|
class langhandler:
|
||||||
|
def __init__(self, LANGNOTFOUND="LANGNULL", TEXTNOTFOUND="NULL"):
|
||||||
|
self._langnf = LANGNOTFOUND
|
||||||
|
self._textnf = TEXTNOTFOUND
|
||||||
|
self._langs = {}
|
||||||
|
for i in os.listdir(os.path.dirname(__file__)+"/lang"):
|
||||||
|
if i.split(".")[1] == "LAN":
|
||||||
|
file = open(os.path.dirname(__file__)+"/lang/"+i, 'r')
|
||||||
|
file = file.read()
|
||||||
|
file = ast.literal_eval(file)
|
||||||
|
self._langs[i.split(".")[0]] = file
|
||||||
|
if len(self._langs) <= 0:
|
||||||
|
print("NO languages found!")
|
||||||
|
self._langs["NULL"] = {
|
||||||
|
"NULL": "NULL",
|
||||||
|
}
|
||||||
|
self._lang = list(self._langs.keys())[0]
|
||||||
|
|
||||||
|
def setlang(self, new):
|
||||||
|
self._lang = new
|
||||||
|
|
||||||
|
def string(self, x):
|
||||||
|
if not self._lang in self._langs: return self._langnf
|
||||||
|
if not x in self._langs[self._lang]: return x
|
||||||
|
return self._langs[self._lang][x]
|
||||||
|
|
||||||
|
def getlangs(self):
|
||||||
|
return list(self._langs.keys())
|
1
langsys/lang/NULL.LAN
Normal file
|
@ -0,0 +1 @@
|
||||||
|
{}
|
13
langsys/lang/en_EN.LAN
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
{
|
||||||
|
"game": "Game",
|
||||||
|
"objs": "Objects",
|
||||||
|
"scriptserv": "Scripts",
|
||||||
|
"soundserv": "Sounds",
|
||||||
|
"folder": "Folder",
|
||||||
|
"object": "Object",
|
||||||
|
"script": "Script",
|
||||||
|
"sound": "Sound",
|
||||||
|
"del": "Delete",
|
||||||
|
"file": "File",
|
||||||
|
"exit": "Exit",
|
||||||
|
}
|