Added Image Viewer
This commit is contained in:
parent
e8d258876f
commit
afccf17ecb
7 changed files with 146 additions and 44 deletions
|
@ -7,6 +7,8 @@ from tkinter import *
|
||||||
from JDE.Interfaces import start
|
from JDE.Interfaces import start
|
||||||
from Programs import jpad
|
from Programs import jpad
|
||||||
from Programs import info
|
from Programs import info
|
||||||
|
from Programs import imageViewer
|
||||||
|
from Programs import minesweeper
|
||||||
|
|
||||||
desktopLog = logging.getLogger("desktop.py")
|
desktopLog = logging.getLogger("desktop.py")
|
||||||
|
|
||||||
|
@ -113,6 +115,7 @@ class desktop:
|
||||||
try:
|
try:
|
||||||
# start.start(self.menuColour, event.x_root, event.y_root)
|
# start.start(self.menuColour, event.x_root, event.y_root)
|
||||||
self.contextMenu.post(event.x_root, event.y_root)
|
self.contextMenu.post(event.x_root, event.y_root)
|
||||||
|
self.contextMenu.focus()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
desktopLog.error(str(e))
|
desktopLog.error(str(e))
|
||||||
|
|
||||||
|
@ -125,16 +128,34 @@ class desktop:
|
||||||
def createContextMenu(self):
|
def createContextMenu(self):
|
||||||
desktopLog.debug("Running createContextMenu")
|
desktopLog.debug("Running createContextMenu")
|
||||||
try:
|
try:
|
||||||
self.contextMenu = Menu(self.window, tearoff=0)
|
self.contextMenu = Menu(self.window, tearoff=0, bg=self.contextMenuColour)
|
||||||
|
|
||||||
|
self.games = Menu(self.contextMenu, bg=self.contextMenuColour)
|
||||||
|
self.applications = Menu(self.contextMenu, bg=self.contextMenuColour)
|
||||||
|
|
||||||
|
def minesweeperRun():
|
||||||
|
minesweeper.mine_sweeper(self.window, self.menuColour)
|
||||||
|
|
||||||
|
def jpadEdit():
|
||||||
|
jpad.jpadEditor(self.window)
|
||||||
|
|
||||||
|
def viewImage():
|
||||||
|
imageViewer.imageViewer(self.window)
|
||||||
|
|
||||||
self.contextMenu.add_command(label="Refresh", command=self.desktopRefresh)
|
self.contextMenu.add_command(label="Refresh", command=self.desktopRefresh)
|
||||||
self.contextMenu.add_command(label="Jpad", command=jpad.jpadEditor)
|
|
||||||
self.contextMenu.add_command(label="File Explorer", state=DISABLED)
|
self.contextMenu.add_cascade(label="Games", menu=self.games)
|
||||||
self.contextMenu.add_command(label="Hardware Monitor", state=DISABLED)
|
self.contextMenu.add_cascade(label="Applications", menu=self.applications)
|
||||||
self.contextMenu.add_command(label="Music Player", state=DISABLED)
|
|
||||||
self.contextMenu.add_command(label="Info", command=info.info)
|
self.applications.add_command(label="Jpad", command=jpadEdit)
|
||||||
self.contextMenu.add_command(label="Terminal", state=DISABLED)
|
self.applications.add_command(label="View Images", command=viewImage)
|
||||||
self.contextMenu.add_command(label="Settings", state=DISABLED)
|
self.games.add_command(label="Minesweeper", command=minesweeperRun)
|
||||||
|
self.applications.add_command(label="File Explorer", state=DISABLED)
|
||||||
|
self.applications.add_command(label="Hardware Monitor", state=DISABLED)
|
||||||
|
self.applications.add_command(label="Music Player", state=DISABLED)
|
||||||
|
self.applications.add_command(label="Info", command=info.info)
|
||||||
|
self.applications.add_command(label="Terminal", state=DISABLED)
|
||||||
|
self.applications.add_command(label="Settings", state=DISABLED)
|
||||||
self.contextMenu.add_command(label="Restart", state=DISABLED)
|
self.contextMenu.add_command(label="Restart", state=DISABLED)
|
||||||
self.contextMenu.add_command(label="Shutdown", command=sys.exit)
|
self.contextMenu.add_command(label="Shutdown", command=sys.exit)
|
||||||
|
|
||||||
|
@ -155,12 +176,12 @@ class desktop:
|
||||||
prefix = self.user_dir
|
prefix = self.user_dir
|
||||||
|
|
||||||
# prefix = os.path.expanduser("~")
|
# prefix = os.path.expanduser("~")
|
||||||
def openFile(self):
|
def openFile(event):
|
||||||
# print(fName)
|
# print(fName)
|
||||||
self.fileURL = prefix + "/Desktop/" + str(fName[files])
|
self.fileURL = prefix + "/Desktop/" + str(fName[files])
|
||||||
# print(fileURL)
|
# print(fileURL)
|
||||||
self.a = jpad
|
self.a = jpad
|
||||||
self.a.jpadEditor(str(self.fileURL))
|
self.a.jpadEditor(self.window, str(self.fileURL))
|
||||||
|
|
||||||
def openFolder(self):
|
def openFolder(self):
|
||||||
self.folderURL = prefix + "/Desktop/" + str(fName[files])
|
self.folderURL = prefix + "/Desktop/" + str(fName[files])
|
||||||
|
@ -193,8 +214,8 @@ class desktop:
|
||||||
else:
|
else:
|
||||||
pass
|
pass
|
||||||
self.l[files].place(x=int(100), y=int(70) + self.space, anchor=CENTER)
|
self.l[files].place(x=int(100), y=int(70) + self.space, anchor=CENTER)
|
||||||
except:
|
except Exception as e:
|
||||||
pass
|
desktopLog.error(str(e))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
desktopLog.error(str(e))
|
desktopLog.error(str(e))
|
||||||
|
|
||||||
|
@ -211,7 +232,6 @@ class desktop:
|
||||||
start.start(self.menuColour, int(0), int(self.window.winfo_height()))
|
start.start(self.menuColour, int(0), int(self.window.winfo_height()))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
desktopLog.error(str(e))
|
desktopLog.error(str(e))
|
||||||
pass
|
|
||||||
|
|
||||||
def createBackground(self):
|
def createBackground(self):
|
||||||
try:
|
try:
|
||||||
|
@ -280,6 +300,7 @@ class desktop:
|
||||||
self.cTime = time.strftime("%H:%M")
|
self.cTime = time.strftime("%H:%M")
|
||||||
self.time1 = ""
|
self.time1 = ""
|
||||||
self.menuColour = config["colour"].replace("\n", "")
|
self.menuColour = config["colour"].replace("\n", "")
|
||||||
|
self.contextMenuColour = config["contextMenuColour"].replace("\n", "")
|
||||||
self.startMenuPic = config["startPic"].replace("\n", "")
|
self.startMenuPic = config["startPic"].replace("\n", "")
|
||||||
self.background = config["background"]
|
self.background = config["background"]
|
||||||
self.user_dir = config["userDirs"] + username + "/"
|
self.user_dir = config["userDirs"] + username + "/"
|
||||||
|
|
11
JDE/Recent
11
JDE/Recent
|
@ -26,4 +26,15 @@ jpad
|
||||||
jpad
|
jpad
|
||||||
jpad
|
jpad
|
||||||
jpad
|
jpad
|
||||||
|
jpad
|
||||||
|
jpad
|
||||||
|
jpad
|
||||||
|
jpad
|
||||||
|
jpad
|
||||||
|
jpad
|
||||||
|
jpad
|
||||||
|
jpad
|
||||||
|
jpad
|
||||||
|
jpad
|
||||||
|
jpad
|
||||||
jpad
|
jpad
|
|
@ -5,4 +5,6 @@ background = "JDE/Images/background.png"
|
||||||
colour = "#a0fd44"
|
colour = "#a0fd44"
|
||||||
startPic = "JDE/Images/start.png"
|
startPic = "JDE/Images/start.png"
|
||||||
fullStart = "0"
|
fullStart = "0"
|
||||||
version = "1.1.0 ALPHA"
|
contextMenuColour = "#a0fd44"
|
||||||
|
|
||||||
|
version = "1.2.0 ALPHA"
|
68
Programs/imageViewer.py
Normal file
68
Programs/imageViewer.py
Normal file
|
@ -0,0 +1,68 @@
|
||||||
|
from tkinter import *
|
||||||
|
from tkinter.filedialog import askopenfilename
|
||||||
|
from PIL import Image
|
||||||
|
import gc
|
||||||
|
|
||||||
|
Canvas.image = None
|
||||||
|
|
||||||
|
|
||||||
|
class imageViewer:
|
||||||
|
def fullScreen(self):
|
||||||
|
try:
|
||||||
|
if self.max == 0:
|
||||||
|
self.window.attributes('-fullscreen', True)
|
||||||
|
self.max = 1
|
||||||
|
else:
|
||||||
|
self.window.attributes('-fullscreen', False)
|
||||||
|
self.max = 0
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
|
def openimage(self):
|
||||||
|
self.picfile = askopenfilename()
|
||||||
|
if self.picfile:
|
||||||
|
Canvas.image = PhotoImage(file=self.picfile)
|
||||||
|
self.canvas.create_image(0, 0, anchor=NW, image=Canvas.image)
|
||||||
|
self.canvas.configure(self.canvas, scrollregion=(0, 0, Canvas.image.width(), Canvas.image.height()))
|
||||||
|
|
||||||
|
def createWidgets(self):
|
||||||
|
self.menu = Menu(self.window)
|
||||||
|
self.window.config(menu=self.menu)
|
||||||
|
self.filemenu = Menu(self.menu)
|
||||||
|
self.menu.add_cascade(label="File", menu=self.filemenu)
|
||||||
|
self.filemenu.add_command(label="Open Image", command=self.openimage)
|
||||||
|
self.filemenu.add_command(label="Fullscreen", command=self.fullScreen)
|
||||||
|
self.filemenu.add_separator()
|
||||||
|
self.filemenu.add_command(label="Exit", command=self.window.destroy)
|
||||||
|
|
||||||
|
self.yscrollbar = Scrollbar(self.window)
|
||||||
|
self.yscrollbar.pack(side=RIGHT, fill=Y)
|
||||||
|
|
||||||
|
self.xscrollbar = Scrollbar(self.window, orient=HORIZONTAL)
|
||||||
|
self.xscrollbar.pack(side=BOTTOM, fill=X)
|
||||||
|
|
||||||
|
self.canvas = Canvas(self.window, width=self.canvas_width, height=self.canvas_height,
|
||||||
|
yscrollcommand=self.yscrollbar.set,
|
||||||
|
xscrollcommand=self.xscrollbar.set)
|
||||||
|
# button = Button(root,text="Open",command=openimage)
|
||||||
|
# button.pack(side=BOTTOM)
|
||||||
|
self.canvas.pack(side=TOP, expand=YES, fill=BOTH)
|
||||||
|
self.yscrollbar.config(command=self.canvas.yview)
|
||||||
|
self.xscrollbar.config(command=self.canvas.xview)
|
||||||
|
|
||||||
|
def createWindow(self):
|
||||||
|
self.window = Toplevel(self.master)
|
||||||
|
self.window.title("Image Viewer")
|
||||||
|
# self.window.config(bg="white")
|
||||||
|
self.createWidgets()
|
||||||
|
|
||||||
|
self.window.attributes('-fullscreen', False)
|
||||||
|
self.max = 0
|
||||||
|
|
||||||
|
self.window.mainloop()
|
||||||
|
|
||||||
|
def __init__(self, master):
|
||||||
|
self.master = master
|
||||||
|
self.canvas_width = 800
|
||||||
|
self.canvas_height = 600
|
||||||
|
self.createWindow()
|
|
@ -88,7 +88,7 @@ class jpadEditor:
|
||||||
self.jpadFile = open(str(self.jpadFile), "w")
|
self.jpadFile = open(str(self.jpadFile), "w")
|
||||||
if self.jpadFile != None:
|
if self.jpadFile != None:
|
||||||
# slice off the last character from get, as an extra return is added
|
# slice off the last character from get, as an extra return is added
|
||||||
self.data = self.textPad.get(0.0, END)
|
self.data = str(self.textPad.get(0.0, END)).replace("\n", "")
|
||||||
self.jpadFile.write(self.data)
|
self.jpadFile.write(self.data)
|
||||||
self.jpadFile.close()
|
self.jpadFile.close()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
@ -100,9 +100,11 @@ class jpadEditor:
|
||||||
self.jpadFile = open(str(self.jpadFile), "w")
|
self.jpadFile = open(str(self.jpadFile), "w")
|
||||||
if self.jpadFile != None:
|
if self.jpadFile != None:
|
||||||
# slice off the last character from get, as an extra return is added
|
# slice off the last character from get, as an extra return is added
|
||||||
self.data = self.textPad.get(0.0, END)
|
self.data = str(self.textPad.get(0.0, END)).replace("\n", "")
|
||||||
self.jpadFile.write(self.data)
|
self.jpadFile.write(self.data)
|
||||||
self.jpadFile.close()
|
self.jpadFile.close()
|
||||||
|
else:
|
||||||
|
self.saveAs_command()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
jpadLog.error(str(e))
|
jpadLog.error(str(e))
|
||||||
|
|
||||||
|
@ -125,7 +127,7 @@ class jpadEditor:
|
||||||
jpadLog.error(str(e))
|
jpadLog.error(str(e))
|
||||||
|
|
||||||
def chfont(self):
|
def chfont(self):
|
||||||
def apply(self):
|
def apply():
|
||||||
try:
|
try:
|
||||||
self.textPad.configure(font=(self.font1.get(), int(self.font2.get()), self.font3.get()))
|
self.textPad.configure(font=(self.font1.get(), int(self.font2.get()), self.font3.get()))
|
||||||
self.font[0] = self.font1.get()
|
self.font[0] = self.font1.get()
|
||||||
|
@ -165,18 +167,21 @@ class jpadEditor:
|
||||||
self.textPad.configure(font=(self.font[0], int(self.font[1]), self.font[2]))
|
self.textPad.configure(font=(self.font[0], int(self.font[1]), self.font[2]))
|
||||||
self.textPad.focus()
|
self.textPad.focus()
|
||||||
|
|
||||||
if self.jpadFile != None:
|
try:
|
||||||
self.window.title("Jpad Text Editor" + " File: " + str(self.jpadFile))
|
if self.jpadFile != None:
|
||||||
self.jpadFile = open(str(self.jpadFile), "r")
|
self.window.title("Jpad Text Editor" + " File: " + str(self.jpadFile))
|
||||||
self.contents = self.jpadFile.read()
|
self.jpadFile = open(str(self.jpadFile), "r")
|
||||||
self.textPad.delete(0.0, END)
|
self.contents = self.jpadFile.read()
|
||||||
self.textPad.insert(0.0, self.contents)
|
self.textPad.delete(0.0, END)
|
||||||
self.jpadFile.close()
|
self.textPad.insert(0.0, self.contents)
|
||||||
|
self.jpadFile.close()
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
self.textPad.pack(expand=YES, fill=BOTH)
|
self.textPad.pack(expand=YES, fill=BOTH)
|
||||||
|
|
||||||
def createWindow(self):
|
def createWindow(self):
|
||||||
self.window = Tk()
|
self.window = Toplevel(self.master)
|
||||||
self.sWidth = self.window.winfo_screenwidth()
|
self.sWidth = self.window.winfo_screenwidth()
|
||||||
self.sHeight = self.window.winfo_screenheight()
|
self.sHeight = self.window.winfo_screenheight()
|
||||||
self.window.title("Jpad")
|
self.window.title("Jpad")
|
||||||
|
@ -191,23 +196,21 @@ class jpadEditor:
|
||||||
|
|
||||||
self.window.mainloop()
|
self.window.mainloop()
|
||||||
|
|
||||||
def __init__(self, file=None):
|
def __init__(self, master, file=None):
|
||||||
self.recentAdd = open("JDE/Recent", "a")
|
|
||||||
self.recentAdd.write("\n")
|
|
||||||
self.recentAdd.write("jpad")
|
|
||||||
self.recentAdd.close()
|
|
||||||
self.jpadFile = file
|
self.jpadFile = file
|
||||||
|
self.master = master
|
||||||
self.width = "500"
|
self.width = "500"
|
||||||
self.height = "400"
|
self.height = "400"
|
||||||
self.appFocus = 1
|
self.appFocus = 1
|
||||||
self.widthHeight = self.width + "x" + self.height
|
self.widthHeight = self.width + "x" + self.height
|
||||||
self.menuColour = config["colour"].replace("\n", "")
|
try:
|
||||||
|
self.menuColour = config["colour"].replace("\n", "")
|
||||||
|
except:
|
||||||
|
self.menuColour = None
|
||||||
self.font = ["Arial", "11", "normal"]
|
self.font = ["Arial", "11", "normal"]
|
||||||
|
|
||||||
try:
|
|
||||||
self.appIcon = Button(self.toolbar, text="Jpad", command=self.focusApp)
|
|
||||||
self.appIcon.pack(side=LEFT, fill=Y)
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
|
|
||||||
self.createWindow()
|
self.createWindow()
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
jpadEditor(None)
|
||||||
|
|
|
@ -3,7 +3,7 @@ from tkinter import *
|
||||||
from tkinter import messagebox
|
from tkinter import messagebox
|
||||||
|
|
||||||
|
|
||||||
def mine_sweeper(colour="#39d972"):
|
def mine_sweeper(master, colour="#39d972"):
|
||||||
class MineSweeperCell(Label):
|
class MineSweeperCell(Label):
|
||||||
'''Creates a minesweeper square that is part of a grid'''
|
'''Creates a minesweeper square that is part of a grid'''
|
||||||
|
|
||||||
|
@ -256,7 +256,7 @@ def mine_sweeper(colour="#39d972"):
|
||||||
height = 10
|
height = 10
|
||||||
numBombs = 30
|
numBombs = 30
|
||||||
global root
|
global root
|
||||||
root = Tk()
|
root = Toplevel(master)
|
||||||
root.maxsize(270, 335)
|
root.maxsize(270, 335)
|
||||||
root.minsize(270, 335)
|
root.minsize(270, 335)
|
||||||
root.title('Minesweeper')
|
root.title('Minesweeper')
|
||||||
|
@ -264,7 +264,4 @@ def mine_sweeper(colour="#39d972"):
|
||||||
game = MineSweeperGrid(root, width, height, numBombs)
|
game = MineSweeperGrid(root, width, height, numBombs)
|
||||||
game.mainloop()
|
game.mainloop()
|
||||||
|
|
||||||
__init__()
|
__init__()
|
||||||
|
|
||||||
|
|
||||||
mine_sweeper()
|
|
|
@ -1 +1 @@
|
||||||
test
|
test
|
Reference in a new issue