Yea
g
This commit is contained in:
parent
ee9e2c1de3
commit
37f33f49ca
190
customtk.py
Normal file
190
customtk.py
Normal file
@ -0,0 +1,190 @@
|
||||
from os.path import isfile, join, exists
|
||||
import customtkinter
|
||||
from CTkMessagebox import CTkMessagebox
|
||||
from subfiles import helpers, install, savetools, themes, comunic
|
||||
|
||||
import json
|
||||
|
||||
from subprocess import Popen, PIPE
|
||||
import threading
|
||||
|
||||
from pathlib import Path
|
||||
from sys import platform
|
||||
|
||||
|
||||
from hashlib import sha256
|
||||
|
||||
from os import listdir
|
||||
from os.path import isfile, join, exists
|
||||
|
||||
import shutil
|
||||
from websockets.sync.client import connect
|
||||
|
||||
|
||||
customtkinter.set_appearance_mode("System")
|
||||
customtkinter.set_window_scaling(1)
|
||||
customtkinter.set_widget_scaling(1)
|
||||
|
||||
def placeholder():
|
||||
print("placeholder called")
|
||||
pass
|
||||
|
||||
class menuTools:
|
||||
def sideButtons(self, buttonList, frame):
|
||||
for button in buttonList.keys():
|
||||
sideButton = customtkinter.CTkButton(frame, height=28, hover_color=self.theme["highlight_color"],
|
||||
border_color=self.theme["highlight_color"],
|
||||
border_width=(self.x * .001),
|
||||
fg_color="transparent",
|
||||
text=button,
|
||||
command=buttonList[button])
|
||||
sideButton.pack(pady=(self.y * .01), side="top", anchor="nw")
|
||||
|
||||
def labelDown(self, labelList, frame, column):
|
||||
newFrame=customtkinter.CTkFrame(frame, fg_color="transparent")
|
||||
newFrame.grid(row=0, column=3, sticky="nswe")
|
||||
|
||||
i=1
|
||||
l = []
|
||||
for labelText in labelList:
|
||||
label = customtkinter.CTkLabel(newFrame, textvariable=labelText, height=28, text_color="white")
|
||||
l.append(label)
|
||||
|
||||
for g in l:
|
||||
g.pack(anchor='nw')
|
||||
i+=1
|
||||
|
||||
|
||||
|
||||
class menus():
|
||||
|
||||
def serverMenu(self):
|
||||
helpers.removeChildren(self.mainFrame)
|
||||
|
||||
topFrame = customtkinter.CTkFrame(self.mainFrame, fg_color=self.theme["bg_deep"], corner_radius=10, height=(self.y * .80), width=(self.x * (.70)),
|
||||
|
||||
)
|
||||
topFrame.pack(pady=(self.y * .10))
|
||||
topFrame.grid_propagate(0)
|
||||
|
||||
|
||||
sideFrame = customtkinter.CTkFrame(topFrame, width=(self.x * .7 * .25), height=self.y*.8, fg_color=self.theme['bg_deep'])
|
||||
sideFrame.grid(row=0, column=0, sticky="ns")
|
||||
|
||||
borderFrame=customtkinter.CTkFrame(topFrame, width=(self.x * .7 * .01), height=(self.y*.8), fg_color=self.theme['bg_color'])
|
||||
borderFrame.grid(row=0, column=1, sticky="ns")
|
||||
sideFrame.grid_propagate(1)
|
||||
|
||||
buttonList = {
|
||||
"Start Server" : lambda: placeholder(),
|
||||
"Open Server Location": lambda: helpers.openLocation(self, comunic.getSnPath('sngconfig.json'))
|
||||
}
|
||||
menuTools.sideButtons(self, buttonList=buttonList, frame=sideFrame)
|
||||
|
||||
self.logArea = customtkinter.CTkTextbox(topFrame, width=(self.x * .7 * .74))
|
||||
self.logArea.grid(row=0, column=2, sticky="ns")
|
||||
|
||||
def updateMenu(self):
|
||||
helpers.removeChildren(self.mainFrame)
|
||||
|
||||
topFrame = customtkinter.CTkFrame(self.mainFrame, fg_color=self.theme["bg_deep"], corner_radius=10, height=(self.y * .80), width=(self.x * (.70)),
|
||||
|
||||
)
|
||||
topFrame.pack(pady=(self.y * .10))
|
||||
topFrame.grid_propagate(0)
|
||||
|
||||
|
||||
sideFrame = customtkinter.CTkFrame(topFrame, width=(self.x * .7 * .25), height=self.y*.8, fg_color=self.theme['bg_deep'])
|
||||
sideFrame.grid(row=0, column=0, sticky="ns")
|
||||
|
||||
borderFrame=customtkinter.CTkFrame(topFrame, width=(self.x * .7 * .01), height=(self.y*.8), fg_color=self.theme['bg_color'])
|
||||
borderFrame.grid(row=0, column=1, sticky="ns")
|
||||
sideFrame.grid_propagate(1)
|
||||
|
||||
self.versions = [
|
||||
customtkinter.StringVar(),
|
||||
customtkinter.StringVar()
|
||||
]
|
||||
|
||||
buttonList = {
|
||||
"Open Client Location" : lambda: placeholder(),
|
||||
"Open Server Location": lambda: helpers.openLocation(self, comunic.getSnPath(self.configFile)),
|
||||
"Update Client" : lambda: comunic.downloadLatestDll(self, comunic.getSnPath(self.configFile))
|
||||
}
|
||||
menuTools.sideButtons(self, buttonList=buttonList, frame=sideFrame)
|
||||
|
||||
|
||||
self.versions[0].set("Checking Server Version")
|
||||
self.versions[1].set("Checking Client Version")
|
||||
|
||||
helpers.bgThread(comunic.getLatestVersions, [self, 'tempFile.json', self.versions])
|
||||
|
||||
|
||||
menuTools.labelDown(self, labelList=self.versions, frame=topFrame, column=3)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class main():
|
||||
def __init__(self, configFile):
|
||||
self.configFile = configFile
|
||||
self.debug = False
|
||||
self.root = customtkinter.CTk()
|
||||
self.x=750
|
||||
self.y=500
|
||||
self.theme = themes.getThemes(self)["black_orange"]
|
||||
print()
|
||||
for lib in [helpers, install, savetools]:
|
||||
lib.check()
|
||||
self.rightFrame = customtkinter.CTkScrollableFrame(self.root,
|
||||
orientation="vertical",
|
||||
width=(self.x * .20),
|
||||
height=(self.y * 1),
|
||||
fg_color=self.theme["fg_color"],
|
||||
bg_color=self.theme["bg_color"],
|
||||
corner_radius=0
|
||||
)
|
||||
|
||||
|
||||
buttonList = {
|
||||
"Server" : lambda: menus.serverMenu(self),
|
||||
"Inventory Management": lambda: placeholder(),
|
||||
"Server Settings": lambda: placeholder(),
|
||||
"Client" : lambda: placeholder(),
|
||||
"Scripts" : lambda: placeholder(),
|
||||
"Script Store": lambda: placeholder(),
|
||||
"Inline Scripting" : lambda: placeholder(),
|
||||
"Metadata" : lambda: placeholder(),
|
||||
"Arsenal Management": lambda: placeholder(),
|
||||
"Weapon Upgrades" : lambda: placeholder(),
|
||||
"Client Settings": lambda: placeholder(),
|
||||
"Updates": lambda: menus.updateMenu(self),
|
||||
"GUI Settings" : lambda: placeholder()
|
||||
}
|
||||
|
||||
menuTools.sideButtons(self, buttonList, self.rightFrame)
|
||||
self.rightFrame.grid(row=0, column=0)
|
||||
|
||||
self.mainFrame = customtkinter.CTkScrollableFrame(self.root,
|
||||
width=(self.x * (1-.20)),
|
||||
height=(self.y * 1),
|
||||
fg_color=self.theme["bg_color"],
|
||||
bg_color=self.theme["bg_color"],
|
||||
corner_radius=0)
|
||||
|
||||
self.mainFrame.grid(row=0, column=1)
|
||||
|
||||
self.root.title("SpaceNinGui CustomTK 1.0.0")
|
||||
|
||||
self.root.geometry(f"{str(self.x)}x{str(self.y)}")
|
||||
self.root.resizable(width=False, height=False)
|
||||
self.root.mainloop()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
if isfile('sngconfig.json'):
|
||||
main('sngconfig.json')
|
||||
else:
|
||||
pass
|
Loading…
x
Reference in New Issue
Block a user