Skip to content

Commit

Permalink
fix version selection bug, clean up imports
Browse files Browse the repository at this point in the history
  • Loading branch information
LyfeOnEdge committed Jan 24, 2020
1 parent 5d820da commit 375e75b
Show file tree
Hide file tree
Showing 11 changed files with 98 additions and 77 deletions.
3 changes: 2 additions & 1 deletion HBUpdater/HBUpdater.py
Expand Up @@ -116,7 +116,8 @@ def do_error_function(reason):

try:
version = repo_entry["github_content"][version_index]["tag_name"]
except:
except Exception as e:
print("Error installing package ~ {}".format(e))
do_progress_function("Error - package version not found in repo data. No data has been lost.", 25)
do_error_function("Error - package version not found in repo data. Not continuing with install. No data has been lost.")
return
Expand Down
17 changes: 13 additions & 4 deletions HBUpdaterGUI.py
Expand Up @@ -3,11 +3,16 @@
version = "2.4"
print("HBUpdater version %s" % version)

import os, sys, platform, json, threading, argparse
import os
import sys
import platform
import json
import threading
import argparse
from timeit import default_timer as timer
#print version, exit if minimum version requirements aren't met
print("Using Python {}.{}".format(sys.version_info[0],sys.version_info[1]))
if sys.version_info[0] < 3 or sys.version_info[1] < 6: #Trying to import tkinter in the new syntax after python 2 causes a crash
if sys.hexversion < 0x03060000: #Trying to import tkinter in the new syntax after python 2 causes a crash
sys.exit("Python 3.6 or greater is required to run this program.")

#This is called before the below module imports to ensure no exception is encountered trying to import tk
Expand All @@ -33,7 +38,7 @@
sys.exit()

#Import local modules
from customwidgets import frameManager
from widgets import frameManager
from appstore import getPackageIcon
from HBUpdater import repo_parser, store_handler, local_packages_handler
from webhandler import getJson, getCachedJson
Expand Down Expand Up @@ -107,7 +112,11 @@ def startGUI(args = None):
#frameManager serves to load all pages and stack them on top of each other (all 2 of them)
#also serves to make many important objects and functions easily available to children frames
gui = frameManager(pagelist,
args
args,
{
"width" : settings.get_setting("width"),
"height" : settings.get_setting("height")
}
)

#Set title formatted with version
Expand Down
1 change: 0 additions & 1 deletion customwidgets/__init__.py
Expand Up @@ -2,5 +2,4 @@
from .installed_categoryframe import installed_categoryFrame
from .injector_categoryframe import injector_categoryFrame
from .storeappsquare import storeAppSquare
from .framemanager import frameManager
from .progressframe import progressFrame
51 changes: 0 additions & 51 deletions customwidgets/framemanager.py

This file was deleted.

2 changes: 1 addition & 1 deletion fusee_wrapper/__init__.py
Expand Up @@ -45,4 +45,4 @@ def create_arg_parser():
fusee = fusee_object(print)
fusee.inject(payload)
else:
injector = fusee_object()
injector = fusee_object()
4 changes: 2 additions & 2 deletions pages/detailpage.py
Expand Up @@ -281,13 +281,13 @@ def reload_function(self):
self.reload()

def trigger_install(self):
index = 0
index = self.version_index or 0
if not self.appstore_handler.check_path():
self.set_sd()
if self.appstore_handler.check_path():
if self.appstore_handler.check_if_get_init():
if self.repo:
threader.do_async(self.appstore_handler.install_package, [self.repo, self.version_index, self.progress_bar.update, self.reload_function, self.progress_bar.set_title], priority = "high")
threader.do_async(self.appstore_handler.install_package, [self.repo, index, self.progress_bar.update, self.reload_function, self.progress_bar.set_title], priority = "high")
else:
self.yesnoPage.getanswer("The homebrew appstore has not been initiated here yet, would you like to initiate it?", self.init_get_then_continue)

Expand Down
1 change: 1 addition & 0 deletions todo.md
Expand Up @@ -11,6 +11,7 @@ Hekete ini editor

Alert when files collide

github oauth token for more local apps

System-specific:
- Linux
Expand Down
57 changes: 57 additions & 0 deletions widgets/Button.py
@@ -0,0 +1,57 @@
import tkinter as tk
#Custom button
#A tkinter label with a bound on-click event to fix some issues
#that were happening with normal tkinter buttons on MacOS.
#Unfortunately MacOS was causing a weird white translucent
#effect to be applied to all classes that used the tk.Button Widget.
#This fixes it but making our own "button" by binding a callback to
#an on_click event. Feel free to use this in other projects where mac
#compatibility is an issue, also special thanks to Kabiigon for testing
#this widget until I got it right since I don't have a mac
#Copywrite LyfeOnEdge 2019
#GPL3
class button(tk.Label):
def __init__(self, frame, callback = None, tk_image_object = None, text = None, background = "white", foreground = "black", font = ("Corbel",10), anchor = "center", borderwidth = 0):
self.callback = callback
self.background = background
self.selected = False

tk.Label.__init__(self,frame,
background = self.background,
foreground = "white",
borderwidth = borderwidth,
activebackground = "black",
image = tk_image_object,
text = text,
font = font,
anchor = anchor
)
self.bind('<Button-1>', self.on_click)

#Use callback when our makeshift "button" clicked
def on_click(self, event = None):
self.configure(background = lg)
if not self.selected:
self.after(100, self.on_click_color_change)
if self.callback:
self.callback()

#Function to set the button's image
def setimage(self,image):
self.configure(image = image)

#Function to set the button's text
def settext(self,text):
self.configure(text = text)

def select(self):
self.selected = True
self.configure(background = "grey")

def deselect(self):
self.selected = False
self.configure(background = self.background)

def on_click_color_change(self):
if not self.selected:
self.configure(background = self.background)
1 change: 1 addition & 0 deletions widgets/__init__.py
Expand Up @@ -9,4 +9,5 @@
from .tk_image_sharer import icon_dict
from .tooltips import tooltip
from .safe_button import button
# from .Button import button
image_sharer = icon_dict()
36 changes: 20 additions & 16 deletions widgets/framemanager.py
@@ -1,19 +1,19 @@
#Heavily customized class to manage frames in the outermost layer
import tkinter as tk

#Frame handler, raises and pages in z layer,
#also
#also handles making core components like package handlers,
#parsers, and other library-driven functions available to subsystems
class frameManager(tk.Tk):
def __init__(self,
def __init__(self,
pages, #List of pages to put in outermost z-layer
geometry, #Startup size
version,
update_status = None, #Whether or not the app needs an update
):
args,
geometry
): #Passed args to be accessed globally

tk.Tk.__init__(self)
self.update_status = update_status
self.geometry("{}x{}".format(geometry["width"],geometry["height"]))
self.version_string = None
self.args = args
self.version = None
self.geometry("{}x{}".format(geometry["width"],geometry["height"]))
# self.resizable(False, False)

# the container is where we'll stack a bunch of frames
Expand All @@ -35,14 +35,18 @@ def __init__(self,
#place the frame to fill the whole window, stack them all in the same place
frame.grid(row=0, column=0, sticky="nsew")
else:
print("No pages found")

def set_version(self, title):
self.version_string = title
self.title(title)
print("No pages to initialize.")

def show_frame(self, page_name):
#Show frame for the given page name
frame = self.frames[page_name]
frame.event_generate("<<ShowFrame>>")
frame.tkraise()
frame.tkraise()
print("raised - {}".format(page_name))

def set_version(self, version_string):
self.version = version_string

if __name__ == "__main__":
app = App()
app.mainloop()
2 changes: 1 addition & 1 deletion widgets/safe_button.py
Expand Up @@ -10,7 +10,7 @@
#compatibility is an issue, also special thanks to Kabiigon for testing
#this widget until I got it right since I don't have a mac
class button(tk.Label):
def __init__(self,frame,callback=None,image_object= None,text_string=None,background=color_2, font=smallboldtext, borderwidth = 0):
def __init__(self,frame,callback=None,image_object= None,text_string=None,background=w, font=smallboldtext, borderwidth = 0):
self.callback = callback
self.background = background
self.selected = False
Expand Down

0 comments on commit 375e75b

Please sign in to comment.