diff --git a/.gitignore b/.gitignore index 0a67a0a..b8f2494 100644 --- a/.gitignore +++ b/.gitignore @@ -56,122 +56,6 @@ titledb/AU.en.json titledb/AT.de.json titledb/AR.es.json titledb/AR.en.json -nut/blawar-nut-60bf4e3/titledb/ZA.en.json -nut/blawar-nut-60bf4e3/titledb/versions.txt -nut/blawar-nut-60bf4e3/titledb/US.es.json -nut/blawar-nut-60bf4e3/titledb/US.en.json -nut/blawar-nut-60bf4e3/titledb/SE.en.json -nut/blawar-nut-60bf4e3/titledb/RU.ru.json -nut/blawar-nut-60bf4e3/titledb/PT.pt.json -nut/blawar-nut-60bf4e3/titledb/PL.en.json -nut/blawar-nut-60bf4e3/titledb/PE.es.json -nut/blawar-nut-60bf4e3/titledb/PE.en.json -nut/blawar-nut-60bf4e3/titledb/NZ.en.json -nut/blawar-nut-60bf4e3/titledb/NO.en.json -nut/blawar-nut-60bf4e3/titledb/NL.nl.json -nut/blawar-nut-60bf4e3/titledb/MX.es.json -nut/blawar-nut-60bf4e3/titledb/MX.en.json -nut/blawar-nut-60bf4e3/titledb/languages.json -nut/blawar-nut-60bf4e3/titledb/KR.ko.json -nut/blawar-nut-60bf4e3/titledb/JP.ja.json -nut/blawar-nut-60bf4e3/titledb/IT.it.json -nut/blawar-nut-60bf4e3/titledb/HU.en.json -nut/blawar-nut-60bf4e3/titledb/HK.zh.json -nut/blawar-nut-60bf4e3/titledb/GR.en.json -nut/blawar-nut-60bf4e3/titledb/GB.en.json -nut/blawar-nut-60bf4e3/titledb/FR.fr.json -nut/blawar-nut-60bf4e3/titledb/FI.en.json -nut/blawar-nut-60bf4e3/titledb/ES.es.json -nut/blawar-nut-60bf4e3/titledb/DK.en.json -nut/blawar-nut-60bf4e3/titledb/demos.us.txt -nut/blawar-nut-60bf4e3/titledb/demos.jp.txt -nut/blawar-nut-60bf4e3/titledb/demos.gb.txt -nut/blawar-nut-60bf4e3/titledb/demos.au.txt -nut/blawar-nut-60bf4e3/titledb/DE.de.json -nut/blawar-nut-60bf4e3/titledb/CZ.en.json -nut/blawar-nut-60bf4e3/titledb/CO.es.json -nut/blawar-nut-60bf4e3/titledb/CO.en.json -nut/blawar-nut-60bf4e3/titledb/CL.es.json -nut/blawar-nut-60bf4e3/titledb/CL.en.json -nut/blawar-nut-60bf4e3/titledb/CA.fr.json -nut/blawar-nut-60bf4e3/titledb/CA.en.json -nut/blawar-nut-60bf4e3/titledb/BE.nl.json -nut/blawar-nut-60bf4e3/titledb/BE.fr.json -nut/blawar-nut-60bf4e3/titledb/AU.en.json -nut/blawar-nut-60bf4e3/titledb/AT.de.json -nut/blawar-nut-60bf4e3/titledb/AR.es.json -nut/blawar-nut-60bf4e3/titledb/AR.en.json -nut/blawar-nut-60bf4e3/Ticket.tik -nut/blawar-nut-60bf4e3/Server/Controller/Api.py -nut/blawar-nut-60bf4e3/Server/Controller/__init__.py -nut/blawar-nut-60bf4e3/Server/__init__.py -nut/blawar-nut-60bf4e3/server.py -nut/blawar-nut-60bf4e3/README.md -nut/blawar-nut-60bf4e3/README-Pt-Br.md -nut/blawar-nut-60bf4e3/public_html/style/reset.css -nut/blawar-nut-60bf4e3/public_html/style/default.css -nut/blawar-nut-60bf4e3/public_html/script/jquery-3.3.1.min.js -nut/blawar-nut-60bf4e3/public_html/script/default.js -nut/blawar-nut-60bf4e3/public_html/index.html -nut/blawar-nut-60bf4e3/public_html/images/update_white.png -nut/blawar-nut-60bf4e3/public_html/images/update.png -nut/blawar-nut-60bf4e3/public_html/images/ss.jpg -nut/blawar-nut-60bf4e3/public_html/images/queue.png -nut/blawar-nut-60bf4e3/public_html/images/nutserver.png -nut/blawar-nut-60bf4e3/public_html/images/logo.jpg -nut/blawar-nut-60bf4e3/public_html/images/gear.png -nut/blawar-nut-60bf4e3/public_html/images/flags/US.png -nut/blawar-nut-60bf4e3/public_html/images/flags/TW.png -nut/blawar-nut-60bf4e3/public_html/images/flags/KR.png -nut/blawar-nut-60bf4e3/public_html/images/flags/JP.png -nut/blawar-nut-60bf4e3/public_html/images/flags/HK.png -nut/blawar-nut-60bf4e3/public_html/images/flags/GR.png -nut/blawar-nut-60bf4e3/public_html/images/flags/GB.png -nut/blawar-nut-60bf4e3/public_html/images/flags/FR.png -nut/blawar-nut-60bf4e3/public_html/images/flags/EU.png -nut/blawar-nut-60bf4e3/public_html/images/flags/ES.png -nut/blawar-nut-60bf4e3/public_html/images/flags/DE.png -nut/blawar-nut-60bf4e3/public_html/images/flags/CH.png -nut/blawar-nut-60bf4e3/public_html/images/flags/AU.png -nut/blawar-nut-60bf4e3/public_html/images/favicon.ico -nut/blawar-nut-60bf4e3/public_html/images/download_white.png -nut/blawar-nut-60bf4e3/public_html/images/download.png -nut/blawar-nut-60bf4e3/public_html/images/close.png -nut/blawar-nut-60bf4e3/nut/Users.py -nut/blawar-nut-60bf4e3/nut/Usb.py -nut/blawar-nut-60bf4e3/nut/Titles.py -nut/blawar-nut-60bf4e3/nut/Title.py -nut/blawar-nut-60bf4e3/nut/Status.py -nut/blawar-nut-60bf4e3/nut/Print.py -nut/blawar-nut-60bf4e3/nut/Nsps.py -nut/blawar-nut-60bf4e3/nut/Keys.py -nut/blawar-nut-60bf4e3/nut/Hex.py -nut/blawar-nut-60bf4e3/nut/Config.py -nut/blawar-nut-60bf4e3/nut/blockchain.py -nut/blawar-nut-60bf4e3/nut/aes128.py -nut/blawar-nut-60bf4e3/nut/__init__.py -nut/blawar-nut-60bf4e3/nut.py -nut/blawar-nut-60bf4e3/Fs/Xci.py -nut/blawar-nut-60bf4e3/Fs/Type.py -nut/blawar-nut-60bf4e3/Fs/Ticket.py -nut/blawar-nut-60bf4e3/Fs/Rom.py -nut/blawar-nut-60bf4e3/Fs/Pfs0.py -nut/blawar-nut-60bf4e3/Fs/Nsp.py -nut/blawar-nut-60bf4e3/Fs/Nca.py -nut/blawar-nut-60bf4e3/Fs/Nacp.py -nut/blawar-nut-60bf4e3/Fs/Ivfc.py -nut/blawar-nut-60bf4e3/Fs/Hfs0.py -nut/blawar-nut-60bf4e3/Fs/File.py -nut/blawar-nut-60bf4e3/Fs/BaseFs.py -nut/blawar-nut-60bf4e3/Fs/__init__.py -nut/blawar-nut-60bf4e3/edge.token -nut/blawar-nut-60bf4e3/dz/README.md -nut/blawar-nut-60bf4e3/cron -nut/blawar-nut-60bf4e3/conf/whitelist.txt -nut/blawar-nut-60bf4e3/conf/users.conf -nut/blawar-nut-60bf4e3/conf/retailOnly.blacklist -nut/blawar-nut-60bf4e3/conf/nut.default.conf -nut/blawar-nut-60bf4e3/conf/blacklist.txt -nut/blawar-nut-60bf4e3/CDNSP.py +nut/* conf/nut.conf conf/users.conf diff --git a/HBUpdaterGUI.py b/HBUpdaterGUI.py index e5c8325..b95d129 100644 --- a/HBUpdaterGUI.py +++ b/HBUpdaterGUI.py @@ -31,7 +31,7 @@ import mainpage as mp import settingspage as sp import addrepopage as ar - +import nutpage as np #Main frame handler, raises and pages in z layer class FrameManager(tk.Tk): def __init__(self, *args, **kwargs): @@ -40,6 +40,10 @@ def __init__(self, *args, **kwargs): if platform.system() == 'Windows': print("Windows detected, setting icon") self.iconbitmap(homebrewcore.joinpaths(homebrewcore.assetfolder, 'HBUpdater.ico')) + elif platform.system() == "Linux": + print("Linux detected, setting icon") + self.iconbitmap(homebrewcore.joinpaths(homebrewcore.assetfolder, 'HBUpdater.xbm')) + # self.resizable(False,False) self.geometry("790x510") #startup size 720p @@ -57,7 +61,7 @@ def __init__(self, *args, **kwargs): self.frames = {} #Add frames to dict, with keyword being the name of the frame - for F in (mp.mainPage,ip.injectorScreen,sp.settingsPage,ar.addRepoScreen): + for F in (mp.mainPage,ip.injectorScreen,sp.settingsPage,ar.addRepoScreen,np.nutPage): page_name = F.__name__ frame = F(parent=container, controller=self,back_command = lambda: self.controller.show_frame("mainPage")) self.frames[page_name] = frame diff --git a/assets/HBUpdater.xbm b/assets/HBUpdater.xbm new file mode 100644 index 0000000..3ba1631 --- /dev/null +++ b/assets/HBUpdater.xbm @@ -0,0 +1,32 @@ +#define HBUpdater_width 64 +#define HBUpdater_height 64 +static unsigned short HBUpdater_bits[] = { + 0x8000, 0xc0ff, 0xff03, 0x0001, 0xfc00, 0x60ff, 0xff06, 0x003f, 0xfe00, + 0x30ff, 0xff0c, 0x007f, 0x7f00, 0x18ef, 0xff18, 0x00ff, 0x8f80, 0x0cd0, + 0xff30, 0x01ff, 0xafc0, 0x06d6, 0x5760, 0x03fd, 0x55e0, 0x03e9, 0xafc0, + 0x07f5, 0xa9f0, 0x01ca, 0x5780, 0x0fed, 0x4a78, 0x00f5, 0xaf00, 0x1faa, + 0x5578, 0x0065, 0xae00, 0x1faa, 0x2ab8, 0x0039, 0xbc00, 0x1ebe, 0xa538, + 0x001a, 0xb800, 0x1fbf, 0x5abc, 0x000f, 0xf000, 0x3d7e, 0x7a7c, 0x0002, + 0xc000, 0x3f5f, 0xfebc, 0x03ff, 0xffc0, 0x3fff, 0xfeac, 0x02c3, 0xff40, + 0x3feb, 0xff5c, 0x02eb, 0xff40, 0x3ff7, 0xff1c, 0x02cb, 0xff40, 0x3ffa, + 0xff6c, 0x02f3, 0xff40, 0x3ff7, 0xfe5c, 0x02c5, 0xfb40, 0x3dff, 0xfeac, + 0x02ea, 0xaf40, 0x3b7e, 0x789c, 0x02ca, 0xd740, 0x3eaf, 0x82ac, 0x02ea, + 0xaf40, 0x3d7f, 0xad5c, 0x02ca, 0x5740, 0x3daf, 0x52ac, 0x02f2, 0xaf40, + 0x3ead, 0x555c, 0x02c5, 0xaf40, 0x3daa, 0xaaac, 0x02ea, 0xb740, 0x3d55, + 0xa52c, 0x02ca, 0xab40, 0x3d5a, 0x7d5c, 0x02ea, 0x6f40, 0x3b55, 0xf95c, + 0x02ca, 0x5740, 0x3ebf, 0x7d2c, 0x02f2, 0xaf40, 0x3d7e, 0x795c, 0x02c5, + 0xef40, 0x3d7f, 0x97ec, 0x02ff, 0xd740, 0x3dff, 0xafdc, 0x02cf, 0xf740, + 0x3dff, 0xa7ec, 0x02ef, 0xef40, 0x3dff, 0x97dc, 0x02cf, 0xef40, 0x3dff, + 0xa7ec, 0x02ef, 0xd740, 0x3eff, 0x7c1c, 0x02c8, 0xd740, 0x3dbf, 0xfaac, + 0x02ea, 0xaf40, 0x3b7f, 0xf95c, 0x02ca, 0xb740, 0x3eae, 0x7aac, 0x02e9, + 0xaf40, 0x3d5a, 0xaaac, 0x02ca, 0xab40, 0x3db6, 0x915c, 0x02f4, 0xaf40, + 0x3eaa, 0x569c, 0x02cf, 0xeb40, 0x3dad, 0xa8ac, 0x02ff, 0xff40, 0x3b6a, + 0x2b5c, 0x02cf, 0xfb40, 0x3eab, 0x54ac, 0x02ff, 0xff40, 0x3ad7, 0x4abc, + 0x02ca, 0xff40, 0x3eb5, 0x554c, 0x02e9, 0xff40, 0x3dab, 0x94bc, 0x02ca, + 0xb740, 0x3d5a, 0x555c, 0x02e9, 0x6f40, 0x3f55, 0xaabc, 0x02ca, 0x5740, + 0x3eab, 0x5538, 0x02f5, 0xaf40, 0x3d56, 0x24f8, 0x02c5, 0x6b40, 0x1fad, + 0x5578, 0x02e9, 0xdf40, 0x1eaa, 0xaaf8, 0x02ca, 0x5740, 0x1fab, 0x4af0, + 0x02f5, 0x6f40, 0x0f6d, 0x55e0, 0x02c5, 0x5740, 0x07d5, 0xaae0, 0x02ea, + 0x6f40, 0x07f5, 0x5fc0, 0x02ca, 0x5740, 0x03f5, 0x7f80, 0x02e9, 0xaf40, + 0x01fe, 0xfe00, 0x02ef, 0xfb40, 0x007f, 0xfc00, 0x02ff, 0xff40, 0x003f, + 0xf000, 0xfeff, 0xff7f, 0x000f }; diff --git a/assets/lyfeonedge.png b/assets/lyfeonedge.png new file mode 100644 index 0000000..a294367 Binary files /dev/null and b/assets/lyfeonedge.png differ diff --git a/customwidgets.py b/customwidgets.py index e0af734..e685405 100644 --- a/customwidgets.py +++ b/customwidgets.py @@ -396,7 +396,7 @@ def __init__(self,frame,label_text,label_font=smalltext,label_color=w,text_varia textvariable = text_variable, ) -#themed author/ etc label + class themedguidelabel(tk.Label): def __init__(self,frame,label_text,label_font=smalltext,label_color=w,text_variable=None,anchor="w",background=light_color): tk.Label.__init__(self,frame, @@ -542,11 +542,62 @@ def __init__(self,frame): themedlabel.__init__(self,frame,"") -class thankyoubox(themedframe): - def __init__(self,frame,author="",thanks=""): - themedframe.__init__(self,frame) - self.author_name = columnlabel(self, author) - self.author_name.place(x=0,y=0,height=navbuttonheight,relwidth=1) - self.thanks_text = tk.Text(self,background=dark_color,foreground=lgray,borderwidth=0,highlightthickness=0,font=smallerboldtext) - self.thanks_text.place(relx=0,y=+(navbuttonheight + separatorwidth), relwidth=1,relheight=1) - self.thanks_text.insert(END,thanks) +# class thankyoubox(themedframe): +# def __init__(self,frame,author="",thanks=""): +# themedframe.__init__(self,frame) +# self.author_name = columnlabel(self, author) +# self.author_name.place(x=0,y=0,height=navbuttonheight,relwidth=1) +# self.thanks_text = tk.Text(self,background=dark_color,foreground=lgray,borderwidth=0,highlightthickness=0,font=smallerboldtext) +# self.thanks_text.place(relx=0,y=+(navbuttonheight + separatorwidth), relwidth=1,relheight=1) +# self.thanks_text.insert(END,thanks) + +# class cwlabel(tk.Label): +# def __init__(self,frame,label_text,anchor="w"): +# tk.Label.__init__(self,frame, +# background = dark_color, +# foreground = lgray, +# borderwidth = 0, +# highlightthickness = 0, +# font = mediumboldtext, +# anchor = anchor, +# text = label_text, +# ) + +class cwdevlabel(tk.Label): + def __init__(self,frame,label_text,anchor="w"): + tk.Label.__init__(self,frame, + background = dark_color, + foreground = lgray, + borderwidth = 0, + highlightthickness = 0, + font = mediumboldtext, + anchor = anchor, + text = label_text, + ) + + +class cwdevtext(tk.Text): + def __init__(self,frame): + tk.Text.__init__(self,frame, + background=dark_color, + foreground=lgray, + borderwidth = 0, + highlightthickness = 0, + font = smalltext, + ) + +class devbox(themedframe): + def __init__(self,frame,devname,devtext,devimage,command_name=None): + themedframe.__init__(self,frame,frame_borderwidth=0,frame_highlightthickness=0) + + self.devimage = navbutton(self,image_object=devimage,command_name=command_name) + self.devimage.place(x=0,y=0,width=2*navbuttonheight,height=2*navbuttonheight) + + self.devname = cwdevlabel(self,devname) + self.devname.place(x=2*navbuttonheight+separatorwidth,y=0,relwidth=1) + + self.devtext = cwdevtext(self) + self.devtext.place(x=2*navbuttonheight+separatorwidth,y=0.5*navbuttonheight+separatorwidth,relwidth=1,width=-(2*navbuttonheight+separatorwidth)) + self.devtext.insert(END,devtext) + + diff --git a/locations.py b/locations.py index 91c6a6e..3eef4a3 100644 --- a/locations.py +++ b/locations.py @@ -1,39 +1,18 @@ -#locations.py +developers = { + "LyfeOnEdge" : { + "gravatar_url" : "http://de.gravatar.com/lyfeonedge.json", + "project_page_url" : "https://discord.gg/cXtmY9M", + "dev_flavor_text" : "In Soviet Russia, switch hack you.\nColorblind.\n←Join my discord for dragons" + }, - # { - # "software" : "", - # "githubapi" : "", - # "github_asset" : None, #(none defaults to 0) - # - - # "author" : None, #(None will populate from github) - # "projectpage": None, - # "description" : "", - # "group" : , - - # "install_subfolder": None, - # "content_type" - # "zip_items": None, - # } - - #Template - # { - # "software" : "", - # "githubapi" : "", - # "github_asset" : None, - # + "pprmint" : { + "gravatar_url" : "http://de.gravatar.com/npprmint.json", + "project_page_url" : "npprmint.github.io", + "dev_flavor_text" : "UI concept and asset designer.\n\n←Click here to visit his website" + } - # "author" : None, - # "projectpage": None, - # "description" : "", - # "group" : , +} - # "install_subfolder": None, - # - # "zip_items": None, - # }, -#.zip application/x-zip-compressed -#.bin application/octet-stream GAME = "game" TOOL = "tool" RECCOMENDED = "recomended" @@ -631,4 +610,6 @@ "flask", "pyqt5" ] - } \ No newline at end of file + } + + diff --git a/mainpage.py b/mainpage.py index 9c4cd5c..e8485aa 100644 --- a/mainpage.py +++ b/mainpage.py @@ -3,7 +3,7 @@ import homebrewcore import guicore import webhandler -import nuthandler +import nutpage import tkinter as tk from tkinter.constants import * @@ -11,597 +11,564 @@ import customwidgets as cw import json - import webbrowser details_guide_text = """This menu will allow you to install older versions of apps, uninstall software, and go to the software's project page. Project pages are not currently supported for user-added content. """ class mainPage(tk.Frame,): - def __init__(self, parent, controller,back_command): - tk.Frame.__init__(self,parent) - self.bind("<>", self.on_show_frame) - self.controller = controller - - - #Shared images - self.infoimage = tk.PhotoImage(file=homebrewcore.joinpaths(homebrewcore.assetfolder,"info.png")).zoom(3).subsample(5) - self.returnimage = tk.PhotoImage(file=homebrewcore.joinpaths(homebrewcore.assetfolder,"returnbutton.png")).zoom(3).subsample(5) - self.settingsimage = tk.PhotoImage(file=homebrewcore.joinpaths(homebrewcore.assetfolder,"settings.png")) - self.nutimage = tk.PhotoImage(file=homebrewcore.joinpaths(homebrewcore.assetfolder,"nut.png")) - - #Full window frame, holds everything - self.outer_frame = cw.themedframe(self,frame_borderwidth=0,frame_highlightthickness= 0) - self.outer_frame.place(relx=0.0, rely=0.0, relheight=1.0, relwidth=1.0) - - - #page for warning users that nut isn't installed and asking if they want to install it - self.nutinstallframe = cw.themedframe(self.outer_frame,frame_borderwidth=0,frame_highlightthickness=0) - self.nutinstallframe.place(relwidth=1,relheight=1) - self.nutreturnbutton = cw.navbutton(self.nutinstallframe, image_object=self.returnimage, command_name=self.showlist) - self.nutreturnbutton.place(relx=1, rely=1, x=-(separatorwidth+navbuttonheight), y=-(separatorwidth+navbuttonheight), height=navbuttonheight, width=navbuttonheight) - - self.nuttimewarningframe= cw.themedframe(self.nutinstallframe,frame_highlightthickness=0,frame_borderwidth=0) - self.nuttimewarningframe.place(relheight=1,relwidth=1) - self.nuttimewarning = cw.themedguidelabel(self.nuttimewarningframe,"DOWNLOADING NUT SERVER AND INSTALLING DEPENDENCIES.\nTHIS CAN TAKE A WHILE, ESPECIALLY WITH SLOWER SYSTEMS.\nPLEASE BE PATIENT") - self.nuttimewarning.place(relx=0.5,rely=0.5,x=-200, width=400,height=3*navbuttonheight) - - self.nutnotdownloadedwarningframe= cw.themedframe(self.nutinstallframe,frame_highlightthickness=0,frame_borderwidth=0) - self.nutnotdownloadedwarningframe.place(relheight=1,relwidth=1) - self.nutnotdownloadedwarning = cw.themedguidelabel(self.nutnotdownloadedwarningframe,"IT LOOKS LIKE YOU DON'T HAVE NUT DOWNLOADED YET,\n WOULD YOU LIKE TO DOWNLOAD IT AND INSTALL ITS DEPENDENCIES?") - self.nutnotdownloadedwarning.place(relx=0.5,rely=0.5,x=-200, width=400,height=3*navbuttonheight) - self.installnutbutton = cw.navbutton(self.nutnotdownloadedwarningframe, command_name=self.getnut,text_string="YES") - self.installnutbutton.place(relx=0.5,rely=0.5,y=+(3*navbuttonheight + separatorwidth),width=100,x=-50) - - - - #Frame for main list, contains listboxes and scroll bar, and list titles - self.listbox_frame = cw.themedframe(self.outer_frame,frame_borderwidth=0,frame_highlightthickness= 0) - self.listbox_frame.place(relx=0.0, rely=0.0, relheight=1, relwidth=1, width=-infoframewidth,) - self.listbox_frame.configure(background=dark_color) - - #The contents of this frame are built backwards due to needing to align the searchbox with the icons - self.searchbox_frame = cw.themedframe(self.listbox_frame,frame_highlightthickness= 0,background_color=light_color, frame_borderwidth = 0) - self.searchbox_frame.place(relx=0.0, rely=0.0,height=searchboxheight, relwidth=1,) - - #Variable to track place searchbox icons in correct location - self.iconspacer = icon_and_search_bar_spacing - - self.iconspacer += searchboxheight-2*icon_and_search_bar_spacing - self.nuticon = cw.iconbutton(self.searchbox_frame,self.nutimage,command_name=self.checknutandstart) - self.nuticon.place(relx= 1, rely=.5, x=-self.iconspacer, y = -((searchboxheight)/2) + icon_and_search_bar_spacing,width = searchboxheight-2*icon_and_search_bar_spacing, height=searchboxheight-2*icon_and_search_bar_spacing) - self.iconspacer += icon_and_search_bar_spacing - - # self.iconspacer += searchboxheight-2*icon_and_search_bar_spacing - # self.settingsicon = cw.iconbutton(self.searchbox_frame,self.settingsimage,command_name=lambda: self.controller.show_frame("settingsPage")) - # self.settingsicon.place(relx= 1, rely=.5, x=-self.iconspacer, y = -((searchboxheight)/2) + icon_and_search_bar_spacing,width = searchboxheight-2*icon_and_search_bar_spacing, height=searchboxheight-2*icon_and_search_bar_spacing) - # self.iconspacer += icon_and_search_bar_spacing - - self.injectimage = tk.PhotoImage(file=homebrewcore.joinpaths(homebrewcore.assetfolder,"injector.png")) - self.injectimage = self.injectimage.subsample(2) - self.iconspacer += searchboxheight-2*icon_and_search_bar_spacing - self.injecticon = cw.iconbutton(self.searchbox_frame,self.injectimage,command_name=lambda: self.controller.show_frame("injectorScreen")) - self.injecticon.place(relx= 1, rely=.5, x=-self.iconspacer, y = -((searchboxheight)/2) + icon_and_search_bar_spacing,width = searchboxheight-2*icon_and_search_bar_spacing, height=searchboxheight-2*icon_and_search_bar_spacing) - - self.iconspacer += icon_and_search_bar_spacing - self.sdimage = tk.PhotoImage(file=homebrewcore.joinpaths(homebrewcore.assetfolder,"sd.png")) - self.sdimage = self.sdimage.subsample(2) - self.iconspacer += searchboxheight-2*icon_and_search_bar_spacing - self.sdicon = cw.iconbutton(self.searchbox_frame,self.sdimage,command_name=self.setSDpath) - self.sdicon.place(relx= 1, x=-self.iconspacer, rely=.5, y = -((searchboxheight)/2) + icon_and_search_bar_spacing,width =searchboxheight-2*icon_and_search_bar_spacing, height=searchboxheight-2*icon_and_search_bar_spacing) - - self.iconspacer += icon_and_search_bar_spacing - self.addrepoimage = tk.PhotoImage(file=homebrewcore.joinpaths(homebrewcore.assetfolder,"plus.png")) - self.addrepoimage = self.addrepoimage.subsample(2) - self.iconspacer += searchboxheight-2*icon_and_search_bar_spacing - self.repoicon = cw.iconbutton(self.searchbox_frame, self.addrepoimage,command_name=lambda: self.controller.show_frame("addRepoScreen")) - self.repoicon.place(relx= 1, rely=.5, x=-self.iconspacer, y = -((searchboxheight)/2) + icon_and_search_bar_spacing,width = searchboxheight-2*icon_and_search_bar_spacing, height=searchboxheight-2*icon_and_search_bar_spacing) - - #search box, custom class - self.iconspacer += icon_and_search_bar_spacing*2 - self.sb = cw.SearchBox(self.searchbox_frame, command=self.search, placeholder="Type and press enter to search") - self.sb.place(relx=0,rely=.5, x=+icon_and_search_bar_spacing, relwidth=1, width=-(self.iconspacer), height=searchboxheight-2*icon_and_search_bar_spacing, y=-((searchboxheight)/2) + icon_and_search_bar_spacing ) - - #Frame to hold titles of colums - self.column_title_frame=cw.themedframe(self.listbox_frame,frame_highlightthickness=0) - self.column_title_frame.place(relx=0.0, rely=0, y=+searchboxheight, height=columtitlesheight, relwidth=1) - - self.big_software_name_label_frame = cw.themedframe(self.column_title_frame) - self.big_software_name_label_frame.place(relx=0.0, rely=0.0, relheight=1, relwidth=0.44) - self.big_software_name_label = cw.columnlabel(self.big_software_name_label_frame, "NAME") - self.big_software_name_label.place(relx=0, x=+5, rely=0, relheight=1, relwidth=1, width = -5) - - self.big_genre_name_label_frame = cw.themedframe(self.column_title_frame) - self.big_genre_name_label_frame.place(relx=0.44, rely=0, relheight=1, relwidth=0.20) - self.big_genre_name_label = cw.columnlabel(self.big_genre_name_label_frame, "GENRE") - self.big_genre_name_label.place(relx=0, x=+5, rely=0, relheight=1, relwidth=1, width = -5) - - self.big_software_version_label_frame = cw.themedframe(self.column_title_frame) - self.big_software_version_label_frame.place(relx=0.64, rely=0, relheight=1, relwidth=0.18) - self.big_software_version_label = cw.columnlabel(self.big_software_version_label_frame, "LATEST") - self.big_software_version_label.place(relx=0, x=+5, rely=0, relheight=1, relwidth=1, width = -5) - - self.big_install_status_label_frame = cw.themedframe(self.column_title_frame) - self.big_install_status_label_frame.place(relx=0.82, rely=0, relheight=1, relwidth=0.18) - self.big_install_status_label = cw.columnlabel(self.big_install_status_label_frame, "INSTALLED") - self.big_install_status_label.place(relx=0, x=+5, rely=0, relheight=1, relwidth=1, width = -5) - - - #vertical scroll bar (Not placed, trying to make it only appear when needed) - self.vsb = tk.Scrollbar(self.listbox_frame,orient="vertical", command=self.OnVsb) - # self.vsb.place(relx=0.975, rely=0.15, relheight=0.94, relwidth=0.025) - - - self.list_frame = cw.themedframe(self.listbox_frame,frame_highlightthickness=0) - self.list_frame.place(relx=0,rely=0,y=searchboxheight+columtitlesheight, relheight=1, height=-(searchboxheight+columtitlesheight),relwidth=1) - - - self.listbox_list = [] - - self.homebrew_listbox_frame = cw.themedframe(self.list_frame,) - self.homebrew_listbox_frame.place(relx=0.0,rely=0,relheight=1,relwidth=0.44) - self.homebrew_listbox = cw.customlistbox(self.homebrew_listbox_frame,) - self.homebrew_listbox.place(relheight=1,relwidth=1, x=+lbcolumnoffset, width=-lbcolumnoffset) - self.homebrew_listbox.bind('', self.showdetailsevent) #Bind double-click to open details - self.homebrew_listbox.bind('<>',self.CurSelet) - self.listbox_list.append(self.homebrew_listbox) - - self.genre_listbox_frame = cw.themedframe(self.list_frame,) - self.genre_listbox_frame.place(relx=0.44,rely=0,relheight=1,relwidth=0.20) - self.genre_listbox = cw.customlistbox(self.genre_listbox_frame,) - self.genre_listbox.place(relheight=1,relwidth=1, x=+lbcolumnoffset, width=-lbcolumnoffset) - self.listbox_list.append(self.genre_listbox) - - self.version_listbox_frame = cw.themedframe(self.list_frame,) - self.version_listbox_frame.place(relx=0.64, rely=0, relheight=1, relwidth=0.18) - self.version_listbox = cw.customlistbox(self.version_listbox_frame,) - self.version_listbox.place(relheight=1,relwidth=1, x=+lbcolumnoffset, width=-lbcolumnoffset) - self.listbox_list.append(self.version_listbox) - - self.status_listbox_frame = cw.themedframe(self.list_frame,) - self.status_listbox_frame.place(relx=0.82, rely=0, relheight=1, relwidth=0.18) - self.status_listbox = cw.customlistbox(self.status_listbox_frame,) - self.status_listbox.place(relheight=1,relwidth=1, x=+lbcolumnoffset, width=-lbcolumnoffset) - self.listbox_list.append(self.status_listbox) - - #bind listboxes to move with mouse scroll - for listbox in self.listbox_list: - listbox.bind("", self.OnMouseWheel) - - # self.homebrew_listbox.bind("", self.OnMouseWheel) - # self.genre_listbox.bind("", self.OnMouseWheel) - # self.version_listbox.bind("", self.OnMouseWheel) - # self.status_listbox.bind("", self.OnMouseWheel) - - - - - #Frame for details (raised when details button clicked) - #past version tags listbox - self.details_frame = cw.themedframe(self.outer_frame) - self.details_frame.place(relx=0.0, rely=0.0, width=-infoframewidth, relheight=1, relwidth=1) - - self.tags_listbox = cw.customlistbox(self.details_frame) - self.tags_listbox.place(relx=0.0, rely=0, relheight=1, relwidth=0.2) - self.tags_listbox.configure(font=tags_listbox_font) - self.tags_listbox.configure(font=version_number_font) - self.tags_listbox.bind('<>',self.CurTagSelet) - - self.patch_notes_separator = cw.separator(self.details_frame) - self.patch_notes_separator.place(relx=0.2,width=separatorwidth, rely=0, relheight=1,) - - #patch notes - self.scrolling_patch_notes = cw.ScrolledText(self.details_frame, - highlightcolor="black", - highlightbackground="#d9d9d9", - font=version_notes_font, - selectbackground=version_notes_selection_background, - selectforeground=version_notes_selection_foreground, - background=version_notes_column_background, - foreground=version_notes_color, - wrap="none", - borderwidth=0, - highlightthickness=0, - ) - self.scrolling_patch_notes.place(relx=0.2,x=+separatorwidth, rely=0, relheight=1, relwidth=0.8,width=-separatorwidth) - - - #frame to hold subframes in far right column - self.rightcolumn = cw.themedframe(self, frame_borderwidth=0,frame_highlightthickness=0) - self.rightcolumn.place(relx=1, x=-infoframewidth, rely=0.0, relheight=1, width=infoframewidth) - - - - self.details_right_column = cw.themedframe(self.rightcolumn, frame_borderwidth=0,frame_highlightthickness=0,background_color=light_color) - self.details_right_column.place(relwidth = 1, relheight=1) - - self.details_guide = cw.ScrolledText(self.details_right_column,borderwidth=0,highlightthickness=0,background=light_color,foreground=guidetextcolor,wrap=WORD,font=details_guide_font) - self.details_guide.place(relwidth=1,relheight=1,height=-(4*(navbuttonheight+separatorwidth)+separatorwidth)) - self.details_guide.insert(END,details_guide_text) - - self.project_page_button = cw.navbutton(self.details_right_column,command_name=self.openprojectpage,image_object= None,text_string="PROJECT PAGE") - self.project_page_button.place(relx=0, rely=1, y=-4*(navbuttonheight+separatorwidth), height=navbuttonheight, x=+separatorwidth,relwidth=1, width=-(2*separatorwidth)) - - self.uninstall_button = cw.navbutton(self.details_right_column,command_name=self.uninstall,image_object= None,text_string="UNINSTALL") - self.uninstall_button.place(relx=0, rely=1, y=-3*(navbuttonheight+separatorwidth), height=navbuttonheight, x=+separatorwidth,relwidth=1, width=-(2*separatorwidth)) - - #Back to list button frame, placed first so the details button covers it - self.details_buttons =cw.navbox(self.details_right_column, - primary_button_command = self.specificinstall, - etc_button_image = self.returnimage, - etc_button_command = self.showlist, - left_context_command = self.versioncusordown, - right_context_command = self.versioncursorup, - ) - self.details_buttons.place(relx=.5, rely=1, x=-100, y=-87.5, height= 87.5, width=200) - - - self.main_right_column = cw.themedframe(self.rightcolumn, frame_borderwidth=0,frame_highlightthickness=0,background_color=light_color) - self.main_right_column.place(relwidth = 1, relheight=1) - - self.infobox = cw.infobox(self.main_right_column) - self.infobox.place(relwidth=1,relheight=1,) - - self.list_buttons_frame = cw.navbox(self.main_right_column, - primary_button_command = self.install, - etc_button_image = self.infoimage, - etc_button_command = self.showdetails, - left_context_command = self.pagedown, - right_context_command = self.pageup, - ) - self.list_buttons_frame.place(relx=.5, rely=1, x=-100, y=-87.5, height= 87.5, width=200) - - #initial update of the info frame - self.showlist() - self.updateinfo() - self.refreshdetailwindow() - self.popsoftwarelistbox() - self.main_right_column.tkraise() - - def setSDpath(self): - chosensdpath = filedialog.askdirectory(initialdir="/", title='Please select your SD card') - HBUpdater.setSDpath(chosensdpath) - if HBUpdater.sdpathset: - self.updatelistbox(None) - - def install(self): - - if HBUpdater.sdpathset: - HBUpdater.installitem(guicore.hbdict, guicore.softwarechunknumber,0) - self.updatelistbox(None) - else: - self.setSDpath() - - if HBUpdater.sdpathset: - HBUpdater.installitem(guicore.hbdict, guicore.softwarechunknumber,0) - self.updatelistbox(None) - else: - print("SD Path Not set, not installing") - - def specificinstall(self): - if HBUpdater.sdpathset: - HBUpdater.installitem(guicore.hbdict, guicore.softwarechunknumber, guicore.tagversionnumber) - self.updatelistbox(None) - else: - self.setSDpath() - - if HBUpdater.sdpathset: - HBUpdater.installitem(guicore.hbdict, guicore.softwarechunknumber, guicore.tagversionnumber) - self.updatelistbox(None) - else: - print("SD Path Not set, not installing") - - def uninstall(self): - if HBUpdater.sdpathset: - HBUpdater.uninstallsoftware(guicore.hbdict[guicore.softwarechunknumber]["software"]) - self.updatelistbox(None) - else: - self.setSDpath() - - if HBUpdater.sdpathset: - HBUpdater.uninstallsoftware(guicore.hbdict[guicore.softwarechunknumber]["software"]) - self.updatelistbox(None) - else: - print("SD Path Not set, not installing") - - def checknutandstart(self): - if not nuthandler.checkifnutdownloaded(): - self.nutnotdownloadedwarningframe.tkraise() - self.nutinstallframe.tkraise() - return - self.startnut() - - def startnut(self): - nuthandler.startnut() - - def getnut(self): - self.nuttimewarningframe.tkraise() - nuthandler.downloadnutandinstalldependencies() - self.nutnotdownloadedwarningframe.tkraise() - self.showlist() - - - - #raises the details frame - def showdetails(self): - self.details_frame.tkraise() - self.details_right_column.tkraise() - def showdetailsevent(self,event): - self.showdetails() + def __init__(self, parent, controller,back_command): + tk.Frame.__init__(self,parent) + self.bind("<>", self.on_show_frame) + self.controller = controller + + + #Shared images + self.infoimage = tk.PhotoImage(file=homebrewcore.joinpaths(homebrewcore.assetfolder,"info.png")).zoom(3).subsample(5) + self.returnimage = tk.PhotoImage(file=homebrewcore.joinpaths(homebrewcore.assetfolder,"returnbutton.png")).zoom(3).subsample(5) + self.settingsimage = tk.PhotoImage(file=homebrewcore.joinpaths(homebrewcore.assetfolder,"settings.png")) + self.nutimage = tk.PhotoImage(file=homebrewcore.joinpaths(homebrewcore.assetfolder,"nut.png")) + + #Full window frame, holds everything + self.outer_frame = cw.themedframe(self,frame_borderwidth=0,frame_highlightthickness= 0) + self.outer_frame.place(relx=0.0, rely=0.0, relheight=1.0, relwidth=1.0) + + + #Frame for main list, contains listboxes and scroll bar, and list titles + self.listbox_frame = cw.themedframe(self.outer_frame,frame_borderwidth=0,frame_highlightthickness= 0) + self.listbox_frame.place(relx=0.0, rely=0.0, relheight=1, relwidth=1, width=-infoframewidth,) + self.listbox_frame.configure(background=dark_color) + + #The contents of this frame are built backwards due to needing to align the searchbox with the icons + self.searchbox_frame = cw.themedframe(self.listbox_frame,frame_highlightthickness= 0,background_color=light_color, frame_borderwidth = 0) + self.searchbox_frame.place(relx=0.0, rely=0.0,height=searchboxheight, relwidth=1,) + + #Variable to track place searchbox icons in correct location + self.iconspacer = icon_and_search_bar_spacing + + self.iconspacer += searchboxheight-2*icon_and_search_bar_spacing + self.nuticon = cw.iconbutton(self.searchbox_frame,self.nutimage,command_name=self.checknutandstart) + self.nuticon.place(relx= 1, rely=.5, x=-self.iconspacer, y = -((searchboxheight)/2) + icon_and_search_bar_spacing,width = searchboxheight-2*icon_and_search_bar_spacing, height=searchboxheight-2*icon_and_search_bar_spacing) + self.iconspacer += icon_and_search_bar_spacing + + self.iconspacer += searchboxheight-2*icon_and_search_bar_spacing + self.settingsicon = cw.iconbutton(self.searchbox_frame,self.settingsimage,command_name=lambda: self.controller.show_frame("settingsPage")) + self.settingsicon.place(relx= 1, rely=.5, x=-self.iconspacer, y = -((searchboxheight)/2) + icon_and_search_bar_spacing,width = searchboxheight-2*icon_and_search_bar_spacing, height=searchboxheight-2*icon_and_search_bar_spacing) + self.iconspacer += icon_and_search_bar_spacing + + self.injectimage = tk.PhotoImage(file=homebrewcore.joinpaths(homebrewcore.assetfolder,"injector.png")) + self.injectimage = self.injectimage.subsample(2) + self.iconspacer += searchboxheight-2*icon_and_search_bar_spacing + self.injecticon = cw.iconbutton(self.searchbox_frame,self.injectimage,command_name=lambda: self.controller.show_frame("injectorScreen")) + self.injecticon.place(relx= 1, rely=.5, x=-self.iconspacer, y = -((searchboxheight)/2) + icon_and_search_bar_spacing,width = searchboxheight-2*icon_and_search_bar_spacing, height=searchboxheight-2*icon_and_search_bar_spacing) + + self.iconspacer += icon_and_search_bar_spacing + self.sdimage = tk.PhotoImage(file=homebrewcore.joinpaths(homebrewcore.assetfolder,"sd.png")) + self.sdimage = self.sdimage.subsample(2) + self.iconspacer += searchboxheight-2*icon_and_search_bar_spacing + self.sdicon = cw.iconbutton(self.searchbox_frame,self.sdimage,command_name=self.setSDpath) + self.sdicon.place(relx= 1, x=-self.iconspacer, rely=.5, y = -((searchboxheight)/2) + icon_and_search_bar_spacing,width =searchboxheight-2*icon_and_search_bar_spacing, height=searchboxheight-2*icon_and_search_bar_spacing) + + self.iconspacer += icon_and_search_bar_spacing + self.addrepoimage = tk.PhotoImage(file=homebrewcore.joinpaths(homebrewcore.assetfolder,"plus.png")) + self.addrepoimage = self.addrepoimage.subsample(2) + self.iconspacer += searchboxheight-2*icon_and_search_bar_spacing + self.repoicon = cw.iconbutton(self.searchbox_frame, self.addrepoimage,command_name=lambda: self.controller.show_frame("addRepoScreen")) + self.repoicon.place(relx= 1, rely=.5, x=-self.iconspacer, y = -((searchboxheight)/2) + icon_and_search_bar_spacing,width = searchboxheight-2*icon_and_search_bar_spacing, height=searchboxheight-2*icon_and_search_bar_spacing) + + #search box, custom class + self.iconspacer += icon_and_search_bar_spacing*2 + self.sb = cw.SearchBox(self.searchbox_frame, command=self.search, placeholder="Type and press enter to search") + self.sb.place(relx=0,rely=.5, x=+icon_and_search_bar_spacing, relwidth=1, width=-(self.iconspacer), height=searchboxheight-2*icon_and_search_bar_spacing, y=-((searchboxheight)/2) + icon_and_search_bar_spacing ) + + #Frame to hold titles of colums + self.column_title_frame=cw.themedframe(self.listbox_frame,frame_highlightthickness=0) + self.column_title_frame.place(relx=0.0, rely=0, y=+searchboxheight, height=columtitlesheight, relwidth=1) + + self.big_software_name_label_frame = cw.themedframe(self.column_title_frame) + self.big_software_name_label_frame.place(relx=0.0, rely=0.0, relheight=1, relwidth=0.44) + self.big_software_name_label = cw.columnlabel(self.big_software_name_label_frame, "NAME") + self.big_software_name_label.place(relx=0, x=+5, rely=0, relheight=1, relwidth=1, width = -5) + + self.big_genre_name_label_frame = cw.themedframe(self.column_title_frame) + self.big_genre_name_label_frame.place(relx=0.44, rely=0, relheight=1, relwidth=0.20) + self.big_genre_name_label = cw.columnlabel(self.big_genre_name_label_frame, "GENRE") + self.big_genre_name_label.place(relx=0, x=+5, rely=0, relheight=1, relwidth=1, width = -5) + + self.big_software_version_label_frame = cw.themedframe(self.column_title_frame) + self.big_software_version_label_frame.place(relx=0.64, rely=0, relheight=1, relwidth=0.18) + self.big_software_version_label = cw.columnlabel(self.big_software_version_label_frame, "LATEST") + self.big_software_version_label.place(relx=0, x=+5, rely=0, relheight=1, relwidth=1, width = -5) + + self.big_install_status_label_frame = cw.themedframe(self.column_title_frame) + self.big_install_status_label_frame.place(relx=0.82, rely=0, relheight=1, relwidth=0.18) + self.big_install_status_label = cw.columnlabel(self.big_install_status_label_frame, "INSTALLED") + self.big_install_status_label.place(relx=0, x=+5, rely=0, relheight=1, relwidth=1, width = -5) + + + #vertical scroll bar (Not placed, trying to make it only appear when needed) + self.vsb = tk.Scrollbar(self.listbox_frame,orient="vertical", command=self.OnVsb) + # self.vsb.place(relx=0.975, rely=0.15, relheight=0.94, relwidth=0.025) + + + self.list_frame = cw.themedframe(self.listbox_frame,frame_highlightthickness=0) + self.list_frame.place(relx=0,rely=0,y=searchboxheight+columtitlesheight, relheight=1, height=-(searchboxheight+columtitlesheight),relwidth=1) + + + self.listbox_list = [] + + self.homebrew_listbox_frame = cw.themedframe(self.list_frame,) + self.homebrew_listbox_frame.place(relx=0.0,rely=0,relheight=1,relwidth=0.44) + self.homebrew_listbox = cw.customlistbox(self.homebrew_listbox_frame,) + self.homebrew_listbox.place(relheight=1,relwidth=1, x=+lbcolumnoffset, width=-lbcolumnoffset) + self.homebrew_listbox.bind('', self.showdetailsevent) #Bind double-click to open details + self.homebrew_listbox.bind('<>',self.CurSelet) + self.listbox_list.append(self.homebrew_listbox) + + self.genre_listbox_frame = cw.themedframe(self.list_frame,) + self.genre_listbox_frame.place(relx=0.44,rely=0,relheight=1,relwidth=0.20) + self.genre_listbox = cw.customlistbox(self.genre_listbox_frame,) + self.genre_listbox.place(relheight=1,relwidth=1, x=+lbcolumnoffset, width=-lbcolumnoffset) + self.listbox_list.append(self.genre_listbox) + + self.version_listbox_frame = cw.themedframe(self.list_frame,) + self.version_listbox_frame.place(relx=0.64, rely=0, relheight=1, relwidth=0.18) + self.version_listbox = cw.customlistbox(self.version_listbox_frame,) + self.version_listbox.place(relheight=1,relwidth=1, x=+lbcolumnoffset, width=-lbcolumnoffset) + self.listbox_list.append(self.version_listbox) + + self.status_listbox_frame = cw.themedframe(self.list_frame,) + self.status_listbox_frame.place(relx=0.82, rely=0, relheight=1, relwidth=0.18) + self.status_listbox = cw.customlistbox(self.status_listbox_frame,) + self.status_listbox.place(relheight=1,relwidth=1, x=+lbcolumnoffset, width=-lbcolumnoffset) + self.listbox_list.append(self.status_listbox) + + #bind listboxes to move with mouse scroll + for listbox in self.listbox_list: + listbox.bind("", self.OnMouseWheel) + + # self.homebrew_listbox.bind("", self.OnMouseWheel) + # self.genre_listbox.bind("", self.OnMouseWheel) + # self.version_listbox.bind("", self.OnMouseWheel) + # self.status_listbox.bind("", self.OnMouseWheel) + + + + + #Frame for details (raised when details button clicked) + #past version tags listbox + self.details_frame = cw.themedframe(self.outer_frame) + self.details_frame.place(relx=0.0, rely=0.0, width=-infoframewidth, relheight=1, relwidth=1) + + self.tags_listbox = cw.customlistbox(self.details_frame) + self.tags_listbox.place(relx=0.0, rely=0, relheight=1, relwidth=0.2) + self.tags_listbox.configure(font=tags_listbox_font) + self.tags_listbox.configure(font=version_number_font) + self.tags_listbox.bind('<>',self.CurTagSelet) + + self.patch_notes_separator = cw.separator(self.details_frame) + self.patch_notes_separator.place(relx=0.2,width=separatorwidth, rely=0, relheight=1,) + + #patch notes + self.scrolling_patch_notes = cw.ScrolledText(self.details_frame, + highlightcolor="black", + highlightbackground="#d9d9d9", + font=version_notes_font, + selectbackground=version_notes_selection_background, + selectforeground=version_notes_selection_foreground, + background=version_notes_column_background, + foreground=version_notes_color, + wrap="none", + borderwidth=0, + highlightthickness=0, + ) + self.scrolling_patch_notes.place(relx=0.2,x=+separatorwidth, rely=0, relheight=1, relwidth=0.8,width=-separatorwidth) + + + #frame to hold subframes in far right column + self.rightcolumn = cw.themedframe(self, frame_borderwidth=0,frame_highlightthickness=0) + self.rightcolumn.place(relx=1, x=-infoframewidth, rely=0.0, relheight=1, width=infoframewidth) + + + + self.details_right_column = cw.themedframe(self.rightcolumn, frame_borderwidth=0,frame_highlightthickness=0,background_color=light_color) + self.details_right_column.place(relwidth = 1, relheight=1) + + self.details_guide = cw.ScrolledText(self.details_right_column,borderwidth=0,highlightthickness=0,background=light_color,foreground=guidetextcolor,wrap=WORD,font=details_guide_font) + self.details_guide.place(relwidth=1,relheight=1,height=-(4*(navbuttonheight+separatorwidth)+separatorwidth)) + self.details_guide.insert(END,details_guide_text) + + self.project_page_button = cw.navbutton(self.details_right_column,command_name=self.openprojectpage,image_object= None,text_string="PROJECT PAGE") + self.project_page_button.place(relx=0, rely=1, y=-4*(navbuttonheight+separatorwidth), height=navbuttonheight, x=+separatorwidth,relwidth=1, width=-(2*separatorwidth)) + + self.uninstall_button = cw.navbutton(self.details_right_column,command_name=self.uninstall,image_object= None,text_string="UNINSTALL") + self.uninstall_button.place(relx=0, rely=1, y=-3*(navbuttonheight+separatorwidth), height=navbuttonheight, x=+separatorwidth,relwidth=1, width=-(2*separatorwidth)) + + #Back to list button frame, placed first so the details button covers it + self.details_buttons =cw.navbox(self.details_right_column, + primary_button_command = self.specificinstall, + etc_button_image = self.returnimage, + etc_button_command = self.showlist, + left_context_command = self.versioncusordown, + right_context_command = self.versioncursorup, + ) + self.details_buttons.place(relx=.5, rely=1, x=-100, y=-87.5, height= 87.5, width=200) + + + self.main_right_column = cw.themedframe(self.rightcolumn, frame_borderwidth=0,frame_highlightthickness=0,background_color=light_color) + self.main_right_column.place(relwidth = 1, relheight=1) + + self.infobox = cw.infobox(self.main_right_column) + self.infobox.place(relwidth=1,relheight=1,) + + self.list_buttons_frame = cw.navbox(self.main_right_column, + primary_button_command = self.install, + etc_button_image = self.infoimage, + etc_button_command = self.showdetails, + left_context_command = self.pagedown, + right_context_command = self.pageup, + ) + self.list_buttons_frame.place(relx=.5, rely=1, x=-100, y=-87.5, height= 87.5, width=200) + + #initial update of the info frame + self.showlist() + self.updateinfo() + self.refreshdetailwindow() + self.popsoftwarelistbox() + self.main_right_column.tkraise() + + def setSDpath(self): + chosensdpath = filedialog.askdirectory(initialdir="/", title='Please select your SD card') + HBUpdater.setSDpath(chosensdpath) + if HBUpdater.sdpathset: + self.updatelistbox(None) + + def install(self): + + if HBUpdater.sdpathset: + HBUpdater.installitem(guicore.hbdict, guicore.softwarechunknumber,0) + self.updatelistbox(None) + else: + self.setSDpath() + + if HBUpdater.sdpathset: + HBUpdater.installitem(guicore.hbdict, guicore.softwarechunknumber,0) + self.updatelistbox(None) + else: + print("SD Path Not set, not installing") + + def specificinstall(self): + if HBUpdater.sdpathset: + HBUpdater.installitem(guicore.hbdict, guicore.softwarechunknumber, guicore.tagversionnumber) + self.updatelistbox(None) + else: + self.setSDpath() + + if HBUpdater.sdpathset: + HBUpdater.installitem(guicore.hbdict, guicore.softwarechunknumber, guicore.tagversionnumber) + self.updatelistbox(None) + else: + print("SD Path Not set, not installing") + + def uninstall(self): + if HBUpdater.sdpathset: + HBUpdater.uninstallsoftware(guicore.hbdict[guicore.softwarechunknumber]["software"]) + self.updatelistbox(None) + else: + self.setSDpath() + + if HBUpdater.sdpathset: + HBUpdater.uninstallsoftware(guicore.hbdict[guicore.softwarechunknumber]["software"]) + self.updatelistbox(None) + else: + print("SD Path Not set, not installing") + + def checknutandstart(self): + if not nutpage.checkifnutdownloaded(): + self.controller.show_frame("nutPage") + return + nutpage.startnut() + + #raises the details frame + def showdetails(self): + self.details_frame.tkraise() + self.details_right_column.tkraise() + def showdetailsevent(self,event): + self.showdetails() #raises the list frame - def showlist(self): - self.listbox_frame.tkraise() - self.main_right_column.tkraise() - def showlistevent(self,event): - self.showlist() + def showlist(self): + self.listbox_frame.tkraise() + self.main_right_column.tkraise() + def showlistevent(self,event): + self.showlist() #listbox scrollbar - def OnVsb(self, *args): - self.homebrew_listbox.yview(*args) - self.status_listbox.yview(*args) - self.version_listbox.yview(*args) - self.genre_listbox.yview(*args) - - #-event.delta makes the boxes scroll in the right direction - def OnMouseWheel(self, event): - for listbox in self.listbox_list: - listbox.yview("scroll", -event.delta,"units") - # this prevents default bindings from firing, which - # would end up scrolling the widget twice - return "break" - - #fill the listboxes with data - def popsoftwarelistbox(self,): - for softwarechunk in guicore.hbdict: - softwarename = softwarechunk["software"] - self.homebrew_listbox.insert(END, softwarename) - # self.homebrew_listbox.itemconfig(END, foreground=font_color) - with open(softwarechunk["githubjson"]) as json_file: #jsonfile is path, json_file is file obj - jfile = json.load(json_file) - version = jfile[0]["tag_name"] - self.version_listbox.insert(END, version) - # self.version_listbox.itemconfig(END, foreground=font_color) - - self.status_listbox.insert(END, "not installed") - - group = softwarechunk["group"] - self.genre_listbox.insert(END, group) - - self.genre_listbox.configure(state=DISABLED) - self.version_listbox.configure(state=DISABLED) - self.status_listbox.configure(state=DISABLED) - - def updatelistbox(self,searchterm): - for listbox in self.listbox_list: - listbox.configure(state=NORMAL) - listbox.delete(0,END) - - - for softwarechunk in guicore.hbdict: - softwarename = softwarechunk["software"] - self.homebrew_listbox.insert(END, softwarename) - - - - # self.homebrew_listbox.itemconfig(END, foreground=font_color) - with open(softwarechunk["githubjson"]) as json_file: #jsonfile is path, json_file is file obj - jfile = json.load(json_file) - version = jfile[0]["tag_name"] - self.version_listbox.insert(END, version) - # self.version_listbox.itemconfig(END, foreground=font_color) - - installedversion = HBUpdater.checkversion(softwarechunk["software"]) - - if installedversion == version: - self.status_listbox.insert(END, checkmark) - self.status_listbox.itemconfig(END, foreground="white") - else: - self.status_listbox.insert(END, installedversion) - - group = softwarechunk["group"] - self.genre_listbox.insert(END, group) - - if searchterm == None: - self.homebrew_listbox.itemconfig(END,foreground=listbox_font_color) - else: - if searchterm.lower() in softwarename.lower() or searchterm.lower() in group.lower() or version.lower().startswith(searchterm.lower()): - self.homebrew_listbox.itemconfig(END,foreground=listbox_font_color) - else: - self.homebrew_listbox.itemconfig(END,foreground=dark_listbox_font_color) - - self.genre_listbox.configure(state=DISABLED) - self.version_listbox.configure(state=DISABLED) - self.status_listbox.configure(state=DISABLED) - - - def search(self, searchstring): - self.updatelistbox(searchstring) - - - #get current selection from list box - def CurSelet(self, event): - widget = event.widget - selection=widget.curselection() - picked = widget.get(selection[0]) - guicore.softwarechunknumber = widget.get(0, "end").index(picked) - self.updateinfo() - self.refreshdetailwindow() - - - #INFOBOX UPDATE - #update title information - def updatetitle(self,title): - self.infobox.titlevar.set(title) - - #update author information - def updateauthor(self,author): - self.infobox.authorvar.set("by {}".format(author)) - - #update project description - def updatedescription(self, desc): - self.project_description.configure(state=NORMAL) - self.project_description.delete('1.0', END) - self.project_description.insert(END, desc) - self.project_description.configure(state=DISABLED) - - #update all info in the info box - def updateinfo(self): - self.homebrew_listbox.selection_clear(0,guicore.dictlen-1) - self.homebrew_listbox.selection_set(guicore.softwarechunknumber) - self.homebrew_listbox.see(guicore.softwarechunknumber) - self.version_listbox.selection_clear(0,guicore.dictlen-1) - self.version_listbox.selection_set(guicore.softwarechunknumber) - self.version_listbox.see(guicore.softwarechunknumber) - self.status_listbox.selection_clear(0,guicore.dictlen-1) - self.status_listbox.selection_set(guicore.softwarechunknumber) - self.status_listbox.see(guicore.softwarechunknumber) - self.genre_listbox.selection_clear(0,guicore.dictlen-1) - self.genre_listbox.selection_set(guicore.softwarechunknumber) - self.genre_listbox.see(guicore.softwarechunknumber) - - if not guicore.hbdict == {}: - - softwarename = guicore.hbdict[guicore.softwarechunknumber]["software"] - self.infobox.updatetitle(softwarename) - - with open(guicore.hbdict[guicore.softwarechunknumber]["githubjson"]) as json_file: #jsonfile is path, json_file is file obj - jfile = json.load(json_file) - - #update author - author = jfile[0]["author"]["login"] - self.infobox.updateauthor(author) - - self.updateAuthorImage() - - self.infobox.updatedescription(guicore.hbdict[guicore.softwarechunknumber]["description"]) - - - - - def updateAuthorImageEvent(self,event): - self.updateAuthorImage() - - - def updateAuthorImage(self): - softwarename = guicore.hbdict[guicore.softwarechunknumber]["software"] - photopath = homebrewcore.checkphoto(homebrewcore.imagecachefolder, softwarename) - - if guicore.hbdict[guicore.softwarechunknumber]["photopath"] == None: - guicore.hbdict[guicore.softwarechunknumber]["photopath"] = photopath - - if not photopath == None: - photopath = homebrewcore.joinpaths(homebrewcore.imagecachefolder, photopath) - photoexists = homebrewcore.exists(photopath) - else: - photoexists = False - - if not photoexists: - try: - with open(guicore.hbdict[guicore.softwarechunknumber]["githubjson"]) as json_file: #jsonfile is path, json_file is file obj - jfile = json.load(json_file) - url = jfile[0]["author"]["avatar_url"] - photopath = webhandler.cacheimage(url,softwarename) - guicore.hbdict[guicore.softwarechunknumber]["photopath"] = photopath - except: - print("could not download icon image (you can safely ignore this error)") - photopath = homebrewcore.joinpaths(homebrewcore.assetfolder,notfoundimage) - try: - project_image = tk.PhotoImage(file=photopath) - - except: - # print(exc) - photopath = homebrewcore.joinpaths(homebrewcore.assetfolder,notfoundimage) - project_image = tk.PhotoImage(file=photopath) - print("used not-found image due to error (you can safely ignore this error)") - - self.infobox.updateimage(art_image = project_image) - - - #movement buttons, moves through homebrewlist or brew version - def pageup(self): - if guicore.softwarechunknumber < guicore.dictlen-1: - guicore.softwarechunknumber += 1 - self.updateinfo() - self.refreshdetailwindow() - - def pagedown(self): - if guicore.softwarechunknumber > 0: - guicore.softwarechunknumber -= 1 - self.updateinfo() - self.refreshdetailwindow() - - - #movement buttons, moves through homebrewlist or brew version - def versioncursorup(self): - if guicore.tagversionnumber < guicore.taglen-1: - guicore.tagversionnumber += 1 - self.updatetagsbox() - self.updatetagnotes() - - def versioncusordown(self): - if guicore.tagversionnumber > 0: - guicore.tagversionnumber -= 1 - self.updatetagsbox() - self.updatetagnotes() - - def updatetagsbox(self): - self.tags_listbox.selection_clear(0,END) - self.tags_listbox.selection_set(guicore.tagversionnumber) - self.tags_listbox.see(guicore.tagversionnumber) - - def updatetagnotes(self): - with open(guicore.hbdict[guicore.softwarechunknumber]["githubjson"]) as json_file: #jsonfile is path, json_file is file obj - jfile = json.load(json_file) - tagnotes = jfile[guicore.tagversionnumber]["body"] - self.scrolling_patch_notes.configure(state=NORMAL) - self.scrolling_patch_notes.delete('1.0', END) - self.scrolling_patch_notes.insert(END, tagnotes) - self.scrolling_patch_notes.configure(state=DISABLED) - - def gettagdescription(self,index_string): - with open(guicore.hbdict[guicore.softwarechunknumber]["githubjson"]) as json_file: #jsonfile is path, json_file is file obj - jfile = json.load(json_file) - - for version in jfile: - if index_string == version["tag_name"]: - tagnotes = version["body"] - - self.updatetagnotes() - - - def refreshdetailwindow(self,): - guicore.taglen = 0 - guicore.tagversionnumber = 0 - self.tags_listbox.delete(0,END) - if not guicore.hbdict == {}: - with open(guicore.hbdict[guicore.softwarechunknumber]["githubjson"]) as json_file: #jsonfile is path, json_file is file obj - jfile = json.load(json_file) - - for version in jfile: - guicore.taglen+=1 - tag = version["tag_name"] - self.tags_listbox.insert(END, tag) - - self.updatetagsbox() - self.updatetagnotes() - - def CurTagSelet(self, event): - try: - widget = event.widget - guicore.tagversionnumber=widget.curselection()[0] - self.updatetagsbox() - self.updatetagnotes() - except: - pass - - def openprojectpage(self): - try: - url = guicore.hbdict[guicore.softwarechunknumber]["projectpage"] - webbrowser.open_new_tab(url) - except: - print("invalid or non-existant project page url") - - #whenever we return to the main page reload it - def on_show_frame(self,event): - self.updatelistbox(None) \ No newline at end of file + def OnVsb(self, *args): + self.homebrew_listbox.yview(*args) + self.status_listbox.yview(*args) + self.version_listbox.yview(*args) + self.genre_listbox.yview(*args) + + #-event.delta makes the boxes scroll in the right direction + def OnMouseWheel(self, event): + for listbox in self.listbox_list: + listbox.yview("scroll", -event.delta,"units") + # this prevents default bindings from firing, which + # would end up scrolling the widget twice + return "break" + + #fill the listboxes with data + def popsoftwarelistbox(self,): + for softwarechunk in guicore.hbdict: + softwarename = softwarechunk["software"] + self.homebrew_listbox.insert(END, softwarename) + # self.homebrew_listbox.itemconfig(END, foreground=font_color) + with open(softwarechunk["githubjson"]) as json_file: #jsonfile is path, json_file is file obj + jfile = json.load(json_file) + version = jfile[0]["tag_name"] + self.version_listbox.insert(END, version) + # self.version_listbox.itemconfig(END, foreground=font_color) + + self.status_listbox.insert(END, "not installed") + + group = softwarechunk["group"] + self.genre_listbox.insert(END, group) + + self.genre_listbox.configure(state=DISABLED) + self.version_listbox.configure(state=DISABLED) + self.status_listbox.configure(state=DISABLED) + + def updatelistbox(self,searchterm): + for listbox in self.listbox_list: + listbox.configure(state=NORMAL) + listbox.delete(0,END) + + + for softwarechunk in guicore.hbdict: + softwarename = softwarechunk["software"] + self.homebrew_listbox.insert(END, softwarename) + + + + # self.homebrew_listbox.itemconfig(END, foreground=font_color) + with open(softwarechunk["githubjson"]) as json_file: #jsonfile is path, json_file is file obj + jfile = json.load(json_file) + version = jfile[0]["tag_name"] + self.version_listbox.insert(END, version) + # self.version_listbox.itemconfig(END, foreground=font_color) + + installedversion = HBUpdater.checkversion(softwarechunk["software"]) + + if installedversion == version: + self.status_listbox.insert(END, checkmark) + self.status_listbox.itemconfig(END, foreground="white") + else: + self.status_listbox.insert(END, installedversion) + + group = softwarechunk["group"] + self.genre_listbox.insert(END, group) + + if searchterm == None: + self.homebrew_listbox.itemconfig(END,foreground=listbox_font_color) + else: + if searchterm.lower() in softwarename.lower() or searchterm.lower() in group.lower() or version.lower().startswith(searchterm.lower()): + self.homebrew_listbox.itemconfig(END,foreground=listbox_font_color) + else: + self.homebrew_listbox.itemconfig(END,foreground=dark_listbox_font_color) + + self.genre_listbox.configure(state=DISABLED) + self.version_listbox.configure(state=DISABLED) + self.status_listbox.configure(state=DISABLED) + + + def search(self, searchstring): + self.updatelistbox(searchstring) + + + #get current selection from list box + def CurSelet(self, event): + widget = event.widget + selection=widget.curselection() + picked = widget.get(selection[0]) + guicore.softwarechunknumber = widget.get(0, "end").index(picked) + self.updateinfo() + self.refreshdetailwindow() + + + #INFOBOX UPDATE + #update title information + def updatetitle(self,title): + self.infobox.titlevar.set(title) + + #update author information + def updateauthor(self,author): + self.infobox.authorvar.set("by {}".format(author)) + + #update project description + def updatedescription(self, desc): + self.project_description.configure(state=NORMAL) + self.project_description.delete('1.0', END) + self.project_description.insert(END, desc) + self.project_description.configure(state=DISABLED) + + #update all info in the info box + def updateinfo(self): + self.homebrew_listbox.selection_clear(0,guicore.dictlen-1) + self.homebrew_listbox.selection_set(guicore.softwarechunknumber) + self.homebrew_listbox.see(guicore.softwarechunknumber) + self.version_listbox.selection_clear(0,guicore.dictlen-1) + self.version_listbox.selection_set(guicore.softwarechunknumber) + self.version_listbox.see(guicore.softwarechunknumber) + self.status_listbox.selection_clear(0,guicore.dictlen-1) + self.status_listbox.selection_set(guicore.softwarechunknumber) + self.status_listbox.see(guicore.softwarechunknumber) + self.genre_listbox.selection_clear(0,guicore.dictlen-1) + self.genre_listbox.selection_set(guicore.softwarechunknumber) + self.genre_listbox.see(guicore.softwarechunknumber) + + if not guicore.hbdict == {}: + + softwarename = guicore.hbdict[guicore.softwarechunknumber]["software"] + self.infobox.updatetitle(softwarename) + + with open(guicore.hbdict[guicore.softwarechunknumber]["githubjson"]) as json_file: #jsonfile is path, json_file is file obj + jfile = json.load(json_file) + + #update author + author = jfile[0]["author"]["login"] + self.infobox.updateauthor(author) + + self.updateAuthorImage() + + self.infobox.updatedescription(guicore.hbdict[guicore.softwarechunknumber]["description"]) + + + + + def updateAuthorImageEvent(self,event): + self.updateAuthorImage() + + + def updateAuthorImage(self): + softwarename = guicore.hbdict[guicore.softwarechunknumber]["software"] + photopath = homebrewcore.checkphoto(homebrewcore.imagecachefolder, softwarename) + + if guicore.hbdict[guicore.softwarechunknumber]["photopath"] == None: + guicore.hbdict[guicore.softwarechunknumber]["photopath"] = photopath + + if not photopath == None: + photopath = homebrewcore.joinpaths(homebrewcore.imagecachefolder, photopath) + photoexists = homebrewcore.exists(photopath) + else: + photoexists = False + + if not photoexists: + try: + with open(guicore.hbdict[guicore.softwarechunknumber]["githubjson"]) as json_file: #jsonfile is path, json_file is file obj + jfile = json.load(json_file) + url = jfile[0]["author"]["avatar_url"] + photopath = webhandler.cacheimage(url,softwarename) + guicore.hbdict[guicore.softwarechunknumber]["photopath"] = photopath + except: + print("could not download icon image (you can safely ignore this error)") + photopath = homebrewcore.joinpaths(homebrewcore.assetfolder,notfoundimage) + try: + project_image = tk.PhotoImage(file=photopath) + + except: + # print(exc) + photopath = homebrewcore.joinpaths(homebrewcore.assetfolder,notfoundimage) + project_image = tk.PhotoImage(file=photopath) + print("used not-found image due to error (you can safely ignore this error)") + + self.infobox.updateimage(art_image = project_image) + + + #movement buttons, moves through homebrewlist or brew version + def pageup(self): + if guicore.softwarechunknumber < guicore.dictlen-1: + guicore.softwarechunknumber += 1 + self.updateinfo() + self.refreshdetailwindow() + + def pagedown(self): + if guicore.softwarechunknumber > 0: + guicore.softwarechunknumber -= 1 + self.updateinfo() + self.refreshdetailwindow() + + + #movement buttons, moves through homebrewlist or brew version + def versioncursorup(self): + if guicore.tagversionnumber < guicore.taglen-1: + guicore.tagversionnumber += 1 + self.updatetagsbox() + self.updatetagnotes() + + def versioncusordown(self): + if guicore.tagversionnumber > 0: + guicore.tagversionnumber -= 1 + self.updatetagsbox() + self.updatetagnotes() + + def updatetagsbox(self): + self.tags_listbox.selection_clear(0,END) + self.tags_listbox.selection_set(guicore.tagversionnumber) + self.tags_listbox.see(guicore.tagversionnumber) + + def updatetagnotes(self): + with open(guicore.hbdict[guicore.softwarechunknumber]["githubjson"]) as json_file: #jsonfile is path, json_file is file obj + jfile = json.load(json_file) + tagnotes = jfile[guicore.tagversionnumber]["body"] + self.scrolling_patch_notes.configure(state=NORMAL) + self.scrolling_patch_notes.delete('1.0', END) + self.scrolling_patch_notes.insert(END, tagnotes) + self.scrolling_patch_notes.configure(state=DISABLED) + + def gettagdescription(self,index_string): + with open(guicore.hbdict[guicore.softwarechunknumber]["githubjson"]) as json_file: #jsonfile is path, json_file is file obj + jfile = json.load(json_file) + + for version in jfile: + if index_string == version["tag_name"]: + tagnotes = version["body"] + + self.updatetagnotes() + + + def refreshdetailwindow(self,): + guicore.taglen = 0 + guicore.tagversionnumber = 0 + self.tags_listbox.delete(0,END) + if not guicore.hbdict == {}: + with open(guicore.hbdict[guicore.softwarechunknumber]["githubjson"]) as json_file: #jsonfile is path, json_file is file obj + jfile = json.load(json_file) + + for version in jfile: + guicore.taglen+=1 + tag = version["tag_name"] + self.tags_listbox.insert(END, tag) + + self.updatetagsbox() + self.updatetagnotes() + + def CurTagSelet(self, event): + try: + widget = event.widget + guicore.tagversionnumber=widget.curselection()[0] + self.updatetagsbox() + self.updatetagnotes() + except: + pass + + def openprojectpage(self): + try: + url = guicore.hbdict[guicore.softwarechunknumber]["projectpage"] + webbrowser.open_new_tab(url) + except: + print("invalid or non-existant project page url") + + #whenever we return to the main page reload it + def on_show_frame(self,event): + self.updatelistbox(None) \ No newline at end of file diff --git a/nuthandler.py b/nutpage.py similarity index 52% rename from nuthandler.py rename to nutpage.py index f0b8a46..0ee850a 100644 --- a/nuthandler.py +++ b/nutpage.py @@ -2,27 +2,49 @@ from zipfile import ZipFile import sys, os, json, subprocess,imp import threading - - +import tkinter as tk +import customwidgets as cw +from format import * nutfolder = homebrewcore.get_path("nut") if not os.path.isdir(nutfolder): os.mkdir(nutfolder) print("initializing nut folder") +class nutPage(tk.Frame,): + def __init__(self, parent, controller,back_command): + tk.Frame.__init__(self,parent) + self.controller = controller -def checkifnutdownloaded(): - if guicore.checkguitag("nut", "version") == "not installed" or guicore.checkguitag("nut", "version") == "none": - return True - return False + self.returnimage = tk.PhotoImage(file=homebrewcore.joinpaths(homebrewcore.assetfolder,"returnbutton.png")).zoom(3).subsample(5) + + #page for warning users that nut isn't installed and asking if they want to install it + self.nutinstallframe = cw.themedframe(self,frame_borderwidth=0,frame_highlightthickness=0) + self.nutinstallframe.place(relwidth=1,relheight=1) + self.nutreturnbutton = cw.navbutton(self.nutinstallframe, image_object=self.returnimage, command_name=self.controller.show_frame("mainPage")) + self.nutreturnbutton.place(relx=1, rely=1, x=-(separatorwidth+navbuttonheight), y=-(separatorwidth+navbuttonheight), height=navbuttonheight, width=navbuttonheight) + + self.nutnotdownloadedwarningframe= cw.themedframe(self.nutinstallframe,frame_highlightthickness=0,frame_borderwidth=0) + self.nutnotdownloadedwarningframe.place(relheight=1,relwidth=1) + self.nutnotdownloadedwarning = cw.themedguidelabel(self.nutnotdownloadedwarningframe,"IT LOOKS LIKE YOU DON'T HAVE NUT DOWNLOADED YET,\n WOULD YOU LIKE TO DOWNLOAD IT AND INSTALL ITS DEPENDENCIES?",anchor="center") + self.nutnotdownloadedwarning.place(relx=0.5,rely=0.5,x=-250, width=500,height=3*navbuttonheight,y=-(1.5*navbuttonheight)) + self.installnutbutton = cw.navbutton(self.nutnotdownloadedwarningframe, command_name=self.getnut,text_string="YES") + self.installnutbutton.place(relx=0.5,rely=0.5,y=+(2*navbuttonheight + separatorwidth),width=100,x=-50) + + self.cancelbutton = cw.navbutton(self.nutnotdownloadedwarningframe, command_name=lambda: self.controller.show_frame("mainPage"),text_string="NO") + self.cancelbutton.place(relx=0.5,rely=0.5,y=+(3*navbuttonheight + separatorwidth),width=100,x=-50) + + + self.nutnotdownloadedwarningframe.tkraise() + + def getnut(self): + downloadthread = threading.Thread(target=downloadnutandinstalldependencies) + downloadthread.start() + downloadthread.join() + + self.controller.show_frame("mainPage") + startnut() -def checkifmoduleinstalled(module): - try: - imp.find_module(module) - return True - except ImportError: - print("module {} not installed".format(module)) - return False def installpipmodule(module): @@ -33,7 +55,20 @@ def installpipmodule(module): except: print("Error installing module") return(False) + +def checkifmoduleinstalled(module): + try: + imp.find_module(module) + return True + except ImportError: + print("module {} not installed".format(module)) + return False + +def checkifnutdownloaded(): + if guicore.checkguitag("nut", "version") == "not installed" or guicore.checkguitag("nut", "version") == "none": + return False + return True def downloadnutandinstalldependencies(): nutjson = webhandler.getJson("nut", locations.nutserverdict["githubapi"]) @@ -92,13 +127,10 @@ def downloadnutandinstalldependencies(): for thread in threads: thread.join() - def startnut(): - if checkifnutdownloaded(): - print("Nut server not installed, downloading") - downloadnutandinstalldependencies() - - + if not checkifnutdownloaded(): + nutnotdownloadedwarningframe.tkraise() + return script_path = guicore.checkguitag("nut", "location") print("starting nut server") subprocess.Popen([sys.executable,script_path]) \ No newline at end of file diff --git a/settingspage.py b/settingspage.py index 2e6f87b..1c94beb 100644 --- a/settingspage.py +++ b/settingspage.py @@ -2,11 +2,21 @@ from format import * import homebrewcore import webhandler +import locations +import webbrowser + import tkinter as tk from tkinter.constants import * import customwidgets as cw +thankyoutext = """Ktempkin and Qyraid, for writing and maintaining fusee-launcher.py, and making it available via the github api upon my request. + +Blarwar (Vertigo) for for writing and maintaining nut, you can find more of his software at https://github.com/blawar. + +HBG Discord, /r/SwitchPirates, and the members of GBAtemp for their ideas, critiques, and testing. +""" + class settingsPage(tk.Frame): def __init__(self, parent, controller,back_command): tk.Frame.__init__(self,parent) @@ -19,5 +29,52 @@ def __init__(self, parent, controller,back_command): self.returnimage = tk.PhotoImage(file=homebrewcore.joinpaths(homebrewcore.assetfolder,"returnbutton.png")) self.returnimage = self.returnimage.zoom((3)).subsample(5) + self.settingsframe = cw.themedframe(self.outer_frame,background_color=light_color,frame_highlightthickness=0,frame_borderwidth=0) + self.settingsframe.place(relwidth=1,relheight=1,width=-1.5*infoframewidth) + + self.creditsframe = cw.themedframe(self.outer_frame,frame_highlightthickness=0,frame_borderwidth=0) + self.creditsframe.place(relx=1,y=0,relheight=1,x=-1.5*infoframewidth,width=1.5*infoframewidth) + + self.devlabel = cw.columnlabel(self.creditsframe,"DEVELOPERS",anchor="center") + self.devlabel.place(y=+separatorwidth,x=(2*separatorwidth+0.5*navbuttonheight),relwidth=1,width=-2*(2*separatorwidth+0.5*navbuttonheight)) + + #I get an object named after me :D + self.lyfeonedgeimage = tk.PhotoImage(file=webhandler.grabgravatar(locations.developers["LyfeOnEdge"]["gravatar_url"])) + self.lyfeonedge = cw.devbox(self.creditsframe,"LyfeOnEdge",locations.developers["LyfeOnEdge"]["dev_flavor_text"],self.lyfeonedgeimage,command_name=lambda: webbrowser.open_new_tab(locations.developers["LyfeOnEdge"]["project_page_url"])) + self.lyfeonedge.place(y=+2*separatorwidth+0.5*navbuttonheight,x=separatorwidth,relwidth=1,width=-2*separatorwidth,height=3*navbuttonheight) + + # try: + self.pprmintimage = tk.PhotoImage(file=webhandler.grabgravatar(locations.developers["pprmint"]["gravatar_url"])) + self.pprmint = cw.devbox(self.creditsframe,"pprmint",locations.developers["pprmint"]["dev_flavor_text"],self.pprmintimage,command_name=lambda: webbrowser.open_new_tab(locations.developers["pprmint"]["project_page_url"])) + self.pprmint.place(y=+3*navbuttonheight+separatorwidth,x=separatorwidth,relwidth=1,width=-2*separatorwidth,height=3*navbuttonheight) + # except: + # self.pprmint = tk.PhotoImage(file=webhandler.grabgravatar(locations.gravatars["pprmint"])) + + + + self.creditsseparator = cw.separator(self.creditsframe) + self.creditsseparator.place(y=+(infoframewidth+3*separatorwidth),x=+separatorwidth,relwidth=1,width=-2*separatorwidth,height=separatorwidth) + + # self.prevbutton = cw.navbutton(self.creditsframe, command_name=self.prevcredit, text_string="<") + # self.prevbutton.place(y=+(infoframewidth+separatorwidth),x=+separatorwidth,width=0.5*navbuttonheight,height=navbuttonheight) + + # self.nextbutton = cw.navbutton(self.creditsframe, command_name=self.nextcredit, text_string=">") + # self.nextbutton.place(y=+(infoframewidth+separatorwidth),relx=1,x=-(separatorwidth+0.5*navbuttonheight),width=0.5*navbuttonheight,height=navbuttonheight) + + self.thankslabel = cw.columnlabel(self.creditsframe,"SPECIAL THANKS",anchor="center") + self.thankslabel.place(y=+(infoframewidth+4*separatorwidth),x=(2*separatorwidth+0.5*navbuttonheight),relwidth=1,width=-2*(2*separatorwidth+0.5*navbuttonheight),height=navbuttonheight) + + self.thankstext = cw.ScrolledText(self.creditsframe,background=dark_color,borderwidth=0,highlightthickness=0,foreground=lgray,font=smallboldtext,wrap="word") + self.thankstext.place(y=+(infoframewidth+5*separatorwidth+navbuttonheight),x=separatorwidth,relwidth=1,width=-(2*separatorwidth),relheight=1,height=-(infoframewidth+3*separatorwidth+navbuttonheight)) + self.thankstext.insert(END, thankyoutext) + self.backtomain_button = cw.navbutton(self.outer_frame, image_object=self.returnimage, command_name=lambda: controller.show_frame("mainPage")) - self.backtomain_button.place(relx=1, rely=1, x=-(separatorwidth+navbuttonheight), y=-(separatorwidth+navbuttonheight), height=navbuttonheight, width=navbuttonheight) \ No newline at end of file + self.backtomain_button.place(relx=1, rely=1, x=-(separatorwidth+navbuttonheight), y=-(separatorwidth+navbuttonheight), height=navbuttonheight, width=navbuttonheight) + + + + def prevcredit(self): + print("dunnit") + + def nextcredit(self): + print("ndunnit") \ No newline at end of file diff --git a/webhandler.py b/webhandler.py index b04bc4d..8c92a0f 100644 --- a/webhandler.py +++ b/webhandler.py @@ -22,18 +22,19 @@ def downloadFile(fileURL, filename): #Download return False def download(fileURL): - try: + try: downloadedfile, headers = urllib.request.urlretrieve(fileURL) + print(headers) filename = headers["Content-Disposition"].split("filename=",1)[1] downloadlocation = homebrewcore.joinpaths(homebrewcore.downloadsfolder,filename) shutil.move(downloadedfile, downloadlocation) print("downloaded {} from url {}".format(filename, fileURL)) return filename - except: + except Exception as e: + print(e) return None -#Will properly download files now def cacheimage(url,softwarename): try: with urllib.request.urlopen(url) as response: @@ -122,5 +123,17 @@ def parse_standard_github_to_api(url): except: return None +def grabgravatar(url): + downloadedfile = urllib.request.urlretrieve(url)[0] + dljsonfile = url.rsplit("/",1)[1] + downloadlocation = homebrewcore.joinpaths(homebrewcore.downloadsfolder,dljsonfile) + shutil.move(downloadedfile, downloadlocation) + with open(downloadlocation) as jsonfile: + jfile = json.load(jsonfile) + avatarurl = jfile["entry"][0]["thumbnailUrl"] + return cacheimage(avatarurl,dljsonfile) + + + + -# def get_new_repo(repo):