def __init__(self, parent, controller, framework, category_frame, repo, callback, status_handler): self.controller = controller self.parent = parent self.framework = framework self.category_frame = category_frame self.repo = repo self.name = repo["name"] self.callback = callback self.status_handler = status_handler self.active = True self.image_sharer = image_sharer self.imageset = False self.base_x = None #Stores the base x location to build the button from for dynamic building self.base_y = None #Stores the base y location to build the button from for dynamic building self.canvas = None self.placed = False self.thumbnailheight = None self.thumbnailwidth = None ThemedFrame.__init__(self, parent, background=style.w) self.buttonobj = button(self, image_object=None, callback=lambda: self.callback(repo), background=style.color_2) self.buttonobj.place(relheight=1, relwidth=1) #Placeholders used by the category frame when building the button, fixes the disappearing text issue self.buttontitlelabel = None #Placeholder used for the button title self.buttonauthorlabel = None #Placeholder for the button author self.buttonversionlabel = None #Placeholder for the current cersion self.buttonseparator = None #Placeholder for underline in each button self.buttonstatuslabel = None #Placeholder for download / version status self.update_button_sizes()
def __init__(self, parent, controller): self.controller = controller self.appstore_handler = controller.appstore_handler self.repo_parser = controller.repo_parser self.preset_json = None #Holds the value of the json, makes it easy to "reset" self.unsaved_preset_json = None ThemedFrame.__init__(self,parent) self.unincluded_packages_listbox = ThemedListbox(self,foreground=style.b) self.included_packages_listbox = ThemedListbox(self, foreground=style.b): self.author_name = entrybox(self, placeholder = "Preset Author") self.preset_name = entrybox(self, placeholder = "Preset Package Name") self.preset_package_version = entrybox(self, placeholder = "Preset Package Version (Optional)") self.output_json = themedScrollingText(self) save config button reset config button back button
def __init__(self, frame): ThemedFrame.__init__(self, frame, background=style.color_2) self.text = scrolledText(self, wrap='word', font=style.mediumtext, background=style.color_2, foreground=style.w, borderwidth=0, highlightthickness=0) self.text.place(relwidth=1, relheight=1)
def __init__(self, parent, controller): self.controller = controller self.appstore_handler = store_handler self.repo_parser = repo_parser self.current_file_path = None self.originaljson = None self.currentjson = None self.ok_to_load = True self.json_name = None self.changes = None self.progress_string = None self.gui_title = None self.errors = [] ThemedFrame.__init__(self, parent, background=style.color_2) self.bind("<<ShowFrame>>", self.update_apply_frame) #LEFT COLUMN________________________________ self.presets_listbox_label = ThemedLabel( self, label_text="Bundles:", background=style.color_2, foreground=style.lg, label_font=style.largeboldtext) self.presets_listbox_label.place(relx=0.0, relwidth=0.5, height=style.buttonsize - 2 * style.offset, x=+style.offset, width=-2 * style.offset) image_file = os.path.join(assetsfolder, "trash.png") button_image = Image.open(image_file) buttonsize = style.buttonsize - 4 * style.offset #Resizes and saves image if it's the wrong size for faster loads in the future if not button_image.size[0] == [buttonsize, buttonsize]: button_image = button_image.resize((buttonsize, buttonsize), Image.ANTIALIAS) self.trash_image = ImageTk.PhotoImage(button_image) self.delete_preset_button = button(self, callback=self.delete, image_object=self.trash_image, background=style.color_1) self.delete_preset_button.place( relx=0.5, x=-(style.buttonsize - 2 * style.offset), y=+style.offset, width=style.buttonsize - 3 * style.offset, height=style.buttonsize - 3 * style.offset) self.presets_listbox = scrollingTkListbox(self, borderwidth=0, highlightthickness=0, background=style.w, foreground=style.b, exportselection=False) self.presets_listbox.place( relx=0.0, relwidth=0.5, relheight=1, y=style.buttonsize - style.offset, x=+style.offset, width=-2 * style.offset, height=-(2.5 * style.buttonsize + 2 * style.offset)) self.new_preset_entry = entrybox( self, placeholder="New bundle name (No extension)", callback=self.update_json) self.new_preset_entry.place( relx=0.0, x=+style.offset, relwidth=0.5, height=0.5 * style.buttonsize, rely=1, y=-(2 * style.offset + 1.5 * style.buttonsize), width=-(3 * style.offset + 0.5 * style.buttonsize)) self.new_preset_button = button(self, callback=self.new, text_string="+", background=style.color_1) self.new_preset_button.place( relx=0.5, x=-(style.offset + 0.5 * style.buttonsize), width=0.5 * style.buttonsize, height=0.5 * style.buttonsize, rely=1, y=-(2 * style.offset + 1.5 * style.buttonsize)) self.loadbutton = button(self, callback=self.load, text_string="Load", background=style.color_1) self.loadbutton.place(relx=0.0, x=+style.offset, relwidth=0.5, height=style.buttonsize, rely=1, y=-(style.offset + style.buttonsize), width=-2 * style.offset) self.divider = ThemedFrame(self, background=style.lg) self.divider.place(relx=0.5, width=2, relheight=1, height=-2 * style.offset, y=+style.offset, x=-1) self.column_select_frame = ThemedFrame(self, background=style.color_2) self.column_select_frame.place(relx=0.5, x=+style.offset, width=-2 * style.offset, relwidth=0.5, height=style.buttonsize, y=+style.offset) self.editor_button = button(self.column_select_frame, callback=lambda: self.show_frame("editor"), text_string="Edit", background=style.color_1, borderwidth=1) self.editor_button.place(relheight=1, relwidth=0.33, relx=0, width=-0.5 * style.offset) self.applier_button = button( self.column_select_frame, callback=lambda: self.show_frame("applier"), text_string="Apply", background=style.color_1, borderwidth=1) self.applier_button.place(relheight=1, relwidth=0.34, relx=0.33, x=+0.5 * style.offset, width=-style.offset) self.build_button = button(self.column_select_frame, callback=lambda: self.show_frame("builder"), text_string="Build", background=style.color_1, borderwidth=1) self.build_button.place(relheight=1, relwidth=0.33, relx=0.67, x=+0.5 * style.offset, width=-0.5 * style.offset) self.buttonmap = { "editor": self.editor_button, "applier": self.applier_button, "builder": self.build_button } self.button_divider = ThemedFrame(self, background=style.lg) self.button_divider.place(relx=0.5, x=+style.offset, width=-2 * style.offset, relwidth=0.5, height=1, y=style.buttonsize + 2 * style.offset) self.content_frame = ThemedFrame(self, background=style.color_2) self.content_frame.place( relx=0.5, relwidth=0.5, width=-2 * style.offset, x=+style.offset, relheight=1, y=style.buttonsize + 3 * style.offset + 1, height=-(style.buttonsize + 4 * style.offset + 1)) #EDITOR COLUMN________________________________ self.editor_frame = ThemedFrame(self.content_frame, background=style.color_2) self.preset_name = entrybox(self.editor_frame, placeholder="Bundle Name", callback=self.update_json) self.preset_name.place(height=0.5 * style.buttonsize, relwidth=1) self.author_name = entrybox(self.editor_frame, placeholder="Bundle Author", callback=self.update_json) self.author_name.place(y=1 * (style.offset + 0.5 * style.buttonsize), height=0.5 * style.buttonsize, relwidth=1) self.preset_package_version = entrybox( self.editor_frame, placeholder="Bundle Package Version", callback=self.update_json) self.preset_package_version.place( y=2 * (style.offset + 0.5 * style.buttonsize), height=0.5 * style.buttonsize, relwidth=1) self.packages_listbox_and_json_output_preview_frame = ThemedFrame( self.editor_frame, background=style.color_2) self.packages_listbox_and_json_output_preview_frame.place( y=3 * (style.offset + 0.5 * style.buttonsize), relheight=1, height=-(2 * style.buttonsize + 7 * style.offset), relwidth=1) self.packages_listbox_label = ThemedLabel( self.packages_listbox_and_json_output_preview_frame, label_text="Packages:", background=style.color_2, foreground=style.lg, label_font=style.mediumboldtext) self.packages_listbox_label.place(relwidth=1, height=style.buttonsize - 2 * style.offset) self.packages_listbox = scrollingTkListbox( self.packages_listbox_and_json_output_preview_frame, borderwidth=0, highlightthickness=0, background=style.w, foreground=style.b, exportselection=False, selectmode='multiple') self.packages_listbox.place( y=style.buttonsize - 2 * style.offset, relwidth=1, relheight=0.5, height=-(style.offset + style.buttonsize - 2 * style.offset)) self.packages_listbox.bind('<<ListboxSelect>>', self.update_json) self.output_divider = ThemedFrame( self.packages_listbox_and_json_output_preview_frame, background=style.lg) self.output_divider.place(relwidth=1, height=1, rely=0.5) self.output_json_label = ThemedLabel( self.packages_listbox_and_json_output_preview_frame, label_text="Output:", background=style.color_2, foreground=style.lg, label_font=style.mediumboldtext) self.output_json_label.place(rely=0.5, y=+style.offset + 1, relwidth=1, height=style.buttonsize - 2 * style.offset) self.output_json = themedScrollingText( self.packages_listbox_and_json_output_preview_frame, font=style.smalltext) self.output_json.place(relwidth=1, rely=0.5, relheight=0.5, height=-(style.buttonsize + style.offset), y=style.buttonsize) self.savebutton = button(self.editor_frame, callback=self.save, text_string="Save", background=style.color_1) self.savebutton.place(relwidth=1, height=style.buttonsize, rely=1, y=-(style.buttonsize)) #APPLIER COLUMN_______________________________ self.applier_frame = ThemedFrame(self.content_frame, background=style.color_2) self.applier_bundle_label = ThemedLabel(self.applier_frame, label_text="BUNDLE: ", anchor="w", background=style.color_2, foreground=style.lg, label_font=style.smallboldtext) self.applier_bundle_label.place(height=0.5 * style.buttonsize - style.offset) self.applier_selected_bundle_label = ThemedLabel( self.applier_frame, label_text="test", anchor="e", background=style.color_2, foreground=style.w, label_font=style.smallboldtext) self.applier_selected_bundle_label.place( x=self.applier_bundle_label.winfo_reqwidth(), height=0.5 * style.buttonsize - 1 * style.offset) self.applier_sd_label = ThemedLabel(self.applier_frame, label_text="SD: ", anchor="w", background=style.color_2, foreground=style.lg, label_font=style.smallboldtext) self.applier_sd_label.place(y=0.5 * style.buttonsize, height=0.5 * style.buttonsize - 1 * style.offset) self.applier_selected_sd_label = ThemedLabel( self.applier_frame, label_text="test", anchor="e", background=style.color_2, foreground=style.w, label_font=style.smallboldtext) self.applier_selected_sd_label.place( y=0.5 * style.buttonsize, x=self.applier_sd_label.winfo_reqwidth(), height=0.5 * style.buttonsize - 1 * style.offset) self.applier_header_divider = ThemedFrame(self.applier_frame, background=style.lg) self.applier_header_divider.place(y=1 * style.buttonsize, relwidth=1, height=1) self.applier_listboxes_frame = ThemedFrame(self.applier_frame, background=style.color_2) self.applier_listboxes_frame.place( y=1 * style.buttonsize + 1 * style.offset + 1, relheight=1, height=-(2 * style.buttonsize + 1 + style.offset), relwidth=1) self.applier_to_be_installed_frame = ThemedFrame( self.applier_listboxes_frame, background=style.color_2) self.applier_to_be_installed_frame.place(relwidth=1, relheight=0.33, height=-style.offset) self.applier_to_be_installed_label = ThemedLabel( self.applier_to_be_installed_frame, label_text="To be installed:", background=style.color_2, foreground=style.lg, label_font=style.smallboldtext) self.applier_to_be_installed_label.place( relwidth=1, height=0.5 * style.buttonsize - style.offset) self.applier_to_be_installed_listbox = scrollingTkListbox( self.applier_to_be_installed_frame, borderwidth=0, highlightthickness=0, background=style.w, foreground=style.b, exportselection=False, selectmode='multiple') self.applier_to_be_installed_listbox.place( y=0.5 * style.buttonsize - 1 * style.offset, relwidth=1, relheight=1, height=-(0.5 * style.buttonsize - 3 * style.offset)) # self.applier_to_be_installed_listbox.bind('<<ListboxSelect>>', self.update_json) self.applier_to_be_updated_frame = ThemedFrame( self.applier_listboxes_frame, background=style.color_2) self.applier_to_be_updated_frame.place(relwidth=1, relheight=0.34, rely=0.33, height=-style.offset) self.applier_to_be_updated_label = ThemedLabel( self.applier_to_be_updated_frame, label_text="To be updated:", background=style.color_2, foreground=style.lg, label_font=style.smallboldtext) self.applier_to_be_updated_label.place(relwidth=1, height=0.5 * style.buttonsize - style.offset) self.applier_to_be_updated_listbox = scrollingTkListbox( self.applier_to_be_updated_frame, borderwidth=0, highlightthickness=0, background=style.w, foreground=style.b, exportselection=False, selectmode='multiple') self.applier_to_be_updated_listbox.place( y=0.5 * style.buttonsize - 1 * style.offset, relwidth=1, relheight=1, height=-(0.5 * style.buttonsize - 3 * style.offset)) # self.applier_to_be_installed_listbox.bind('<<ListboxSelect>>', self.update_json) self.applier_to_be_unchanged_frame = ThemedFrame( self.applier_listboxes_frame, background=style.color_2) self.applier_to_be_unchanged_frame.place(relwidth=1, relheight=0.33, rely=0.67, height=-style.offset) self.applier_to_be_unchanged_label = ThemedLabel( self.applier_to_be_unchanged_frame, label_text="Unchanged:", background=style.color_2, foreground=style.lg, label_font=style.smallboldtext) self.applier_to_be_unchanged_label.place( relwidth=1, height=0.5 * style.buttonsize - style.offset) self.applier_to_be_unchanged_listbox = scrollingTkListbox( self.applier_to_be_unchanged_frame, borderwidth=0, highlightthickness=0, background=style.w, foreground=style.b, exportselection=False, selectmode='multiple') self.applier_to_be_unchanged_listbox.place( y=0.5 * style.buttonsize - 1 * style.offset, relwidth=1, relheight=1, height=-(0.5 * style.buttonsize - 3 * style.offset)) # self.applier_to_be_installed_listbox.bind('<<ListboxSelect>>', self.update_json) self.applier_apply_button = button(self.applier_frame, callback=self.apply, text_string="Apply", background=style.color_1) self.applier_apply_button.place(relwidth=1, height=style.buttonsize, rely=1, y=-(style.buttonsize)) #BUILDER COLUMN_______________________________ self.builder_frame = ThemedFrame(self.content_frame, background=style.color_2) for package in self.repo_parser.all: self.packages_listbox.insert("end", package["package"]) self.frames = [{ "frame": self.editor_frame, "text": "editor", }, { "frame": self.applier_frame, "text": "applier" }, { "frame": self.builder_frame, "text": "builder" }] self.content_frames = {} def make_frames_and_add(frame_list): for f in frame_list: page_name = f["text"] frame = f["frame"] self.content_frames[page_name] = frame frame.place(relx=0, rely=0, relwidth=1, relheight=1) make_frames_and_add(self.frames) self.show_frame("editor") self.yesno = yesnoPage(self) self.usermessage = usermessagePage(self) self.progress_bar = progressFrame(self) self.update_json() self.reload_presets() self.update_sd_path()