Esempio n. 1
0
	def attach_background_panel(self, parent, canvas, zoom_getter, frame_getter, fish):
		#for now, accepting frame_getter as an argument because maybe the child class has animated backgrounds or something
		BACKGROUND_DROPDOWN_WIDTH = 25
		PANEL_HEIGHT = 25
		self.canvas = canvas
		self.zoom_getter = zoom_getter
		self.frame_getter = frame_getter
		self.background_datas = {"filename":{},"title":{}}
		self.current_background_title = None
		self.last_known_zoom = None

		background_panel = tk.Frame(parent, name="background_panel")
		widgetlib.right_align_grid_in_frame(background_panel)
		background_label = tk.Label(background_panel, text=fish.translate("meta","meta","background") + ':')
		background_label.grid(row=0, column=1)
		self.background_selection = tk.StringVar(background_panel)

		background_manifests = common.get_all_resources([self.console_name,self.internal_name,"backgrounds"],"backgrounds.json")
		for background_manifest in background_manifests:
			with open(background_manifest) as f:
				background_data = json.load(f)
				for background in background_data["backgrounds"]:
					self.background_datas["filename"][background["filename"]] = background["title"]
					self.background_datas["title"][background["title"]] = background["filename"]
		background_prettynames = list(self.background_datas["title"].keys())
		self.background_selection.set(random.choice(background_prettynames))

		background_dropdown = tk.ttk.Combobox(background_panel, state="readonly", values=background_prettynames, name="background_dropdown")
		background_dropdown.configure(width=BACKGROUND_DROPDOWN_WIDTH, exportselection=0, textvariable=self.background_selection)
		background_dropdown.grid(row=0, column=2)

		widgetlib.leakless_dropdown_trace(self, "background_selection", "set_background")

		parent.add(background_panel,minsize=PANEL_HEIGHT)
		return background_panel
Esempio n. 2
0
	def attach_animation_panel(self, parent, canvas, overview_canvas, zoom_getter, frame_getter, coord_getter, coord_setter, fish):
		ANIMATION_DROPDOWN_WIDTH = 25
		PANEL_HEIGHT = 25
		self.canvas = canvas
		self.overview_canvas = overview_canvas
		self.zoom_getter = zoom_getter
		self.frame_getter = frame_getter
		self.coord_getter = coord_getter
		self.coord_setter = coord_setter
		self.game.coord_setter = coord_setter
		self.current_animation = None
		self.pose_number = None
		self.palette_number = None

		animation_panel = tk.Frame(parent, name="animation_panel")
		widgetlib.right_align_grid_in_frame(animation_panel)
		animation_label = tk.Label(animation_panel, text=fish.translate("meta","meta","animations") + ':')
		animation_label.grid(row=0, column=1)
		self.animation_selection = tk.StringVar(animation_panel)

		self.animation_selection.set(random.choice(list(self.animations.keys())))

		animation_dropdown = tk.ttk.Combobox(animation_panel, state="readonly", values=list(self.animations.keys()), name="animation_dropdown")
		animation_dropdown.configure(width=ANIMATION_DROPDOWN_WIDTH, exportselection=0, textvariable=self.animation_selection)
		animation_dropdown.grid(row=0, column=2)
		self.set_animation(self.animation_selection.get())

		widgetlib.leakless_dropdown_trace(self, "animation_selection", "set_animation")

		parent.add(animation_panel,minsize=PANEL_HEIGHT)

		direction_panel, height, new_spiffy_dict = self.get_direction_buttons(parent,fish).get_panel()
		self.spiffy_dict = {**self.spiffy_dict, **new_spiffy_dict}   #merge all the stringvars into this dict


		parent.add(direction_panel, minsize=height)

		spiffy_panel, height, new_spiffy_dict = self.get_spiffy_buttons(parent,fish).get_panel()
		self.spiffy_dict = {**self.spiffy_dict, **new_spiffy_dict}   #merge all the stringvars into this dict

		parent.add(spiffy_panel,minsize=height)

		self.update_overview_panel()

		return animation_panel
    def attach_tile_details_panel(self, parent, fish):
        tile_details_panel = tk.Frame(parent, name="tile_details_panel")
        widgetlib.right_align_grid_in_frame(tile_details_panel)

        # Step: <step_number_label> / <step_total_label>
        # Tiles: <tile_list>
        LABEL_HEIGHT = 16
        step_panel = tk.Frame(parent, name="step_panel", height=LABEL_HEIGHT)
        widgetlib.right_align_grid_in_frame(step_panel)
        step_label = tk.Label(step_panel,
                              text=fish.translate("meta", "meta", "step") +
                              ':')
        step_label.grid(row=0, column=1)

        self.step_number_label = tk.Label(step_panel, text='0')
        self.step_number_label.grid(row=0, column=2)

        step_sep = tk.Label(step_panel, text='/')
        step_sep.grid(row=0, column=3)

        self.step_total_label = tk.Label(step_panel, text='0')
        self.step_total_label.grid(row=0, column=4)

        parent.add(step_panel)

        tiles_list_panel = tk.Frame(parent, name="tiles_list_panel")
        widgetlib.right_align_grid_in_frame(tiles_list_panel)
        self.tiles_list_label = tk.Label(tiles_list_panel,
                                         text='',
                                         justify=tk.RIGHT)
        self.tiles_list_label.grid(row=1, column=2)

        parent.add(tiles_list_panel)

        return tile_details_panel