class MangaReader: """Manga Reader Tool""" if platform.system() == 'Linux': glade_file_path = "../Glade_GUI/Manga_Reader_GUI.glade" else: glade_file_path = "../Glade_GUI/Manga_Reader_GUI_win.glade" QDTO = QueryDTO() HANDLER = None MANGA_LIST = gtk.ListStore(gobject.TYPE_INT, gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_STRING) def __init__(self): builder = gtk.Builder() builder.add_from_file(self.glade_file_path) self.HANDLER = ActionHandler(builder) handlers = { "on_label_size_allocate": self.HANDLER.label_resize, "on_tree_size_allocate": self.HANDLER.tree_resize, "on_manga_list_size_allocate": self.HANDLER.manga_list_resize, "on_chapter_activate": self.HANDLER.chapter_activate, "on_manga_activate": self.HANDLER.manga_activate } builder.connect_signals(handlers) window = builder.get_object("MangaReader") window.connect("destroy", self._destroy) window.set_title("Manga Reader") # window.set_icon_from_file("teat.png") self.MANGA_LIST = builder.get_object("MangaListData") for row in self.get_manga_list(): self.MANGA_LIST.append([row[0], row[1], row[2], row[3], row[4], row[5]]) window.show_all() manga_tree = builder.get_object("MangaTreeView") manga_tree.get_selection().select_path((0,)) self.HANDLER.manga_activate(manga_tree) builder.get_object("ChapterImages").hide() # builder.get_object("ChapterImagesTree").get_selection().set_mode(gtk.SELECTION_NONE) window.set_size_request(800, 500) gtk.main() def get_manga_list(self): return self.QDTO.get_manga_list() def _destroy(self, *args): self.QDTO.destroy(commit=False) gtk.main_quit(args)
def __init__(self): builder = gtk.Builder() builder.add_from_file(self.glade_file_path) self.HANDLER = ActionHandler(builder) handlers = { "on_label_size_allocate": self.HANDLER.label_resize, "on_tree_size_allocate": self.HANDLER.tree_resize, "on_manga_list_size_allocate": self.HANDLER.manga_list_resize, "on_chapter_activate": self.HANDLER.chapter_activate, "on_manga_activate": self.HANDLER.manga_activate } builder.connect_signals(handlers) window = builder.get_object("MangaReader") window.connect("destroy", self._destroy) window.set_title("Manga Reader") # window.set_icon_from_file("teat.png") self.MANGA_LIST = builder.get_object("MangaListData") for row in self.get_manga_list(): self.MANGA_LIST.append([row[0], row[1], row[2], row[3], row[4], row[5]]) window.show_all() manga_tree = builder.get_object("MangaTreeView") manga_tree.get_selection().select_path((0,)) self.HANDLER.manga_activate(manga_tree) builder.get_object("ChapterImages").hide() # builder.get_object("ChapterImagesTree").get_selection().set_mode(gtk.SELECTION_NONE) window.set_size_request(800, 500) gtk.main()
def createCustomContextMenu(self, pos) -> QtWidgets.QMenu: menu = self.createStandardContextMenu() menu.addSeparator() add_icon = QtGui.QIcon( get_resource(CONSTANTS.icons["plus"][CONSTANTS.theme])) if sys.platform != "win32": # Don't add plus icon on windows (looks ugly) menu.addAction(add_icon, "Insert Image", self.insert_image) else: menu.addAction("Insert Image", self.insert_image) menu.addSeparator() self.word_cursor = self.cursorForPosition(pos) self.word_cursor.select(QtGui.QTextCursor.WordUnderCursor) # Find misspelled word in highlighted text misspelled = [ token[0] for token in self.spell_tknzr(self.word_cursor.selectedText()) if token[0][0].islower() and not spell_dict.check(token[0]) ] # If there is a misspelled word and the word matches the whole of the highlighted text if len(misspelled ) > 0 and misspelled[0] == self.word_cursor.selectedText(): # Add 'Add to Dictionary option' self.add_to_dict_action_handler = ActionHandler( menu.addAction("Add to dictionary"), self.add_to_word_list) menu.addSeparator() spell_suggestion_handlers = [] # Get spelling suggestions spell_suggestions = spell_dict.suggest(misspelled[0]) # Add suggestions to menu until there is no more left or a maximum of 10 while len(spell_suggestion_handlers) < 10 and len( spell_suggestion_handlers) < len(spell_suggestions): for suggestion in spell_suggestions: new_action = menu.addAction(suggestion) spell_suggestion_handlers.append( ActionHandler(new_action, self.replace_selection)) # Save suggestion handlers to object so they persist self.spell_suggestion_handlers = spell_suggestion_handlers if len(self.spell_suggestion_handlers) == 0: no_suggestions = menu.addAction("No Suggestions") no_suggestions.setEnabled(False) return menu
def __init__(self, file_name, index): # Action handling self.action_handler = ActionHandler() # Create mapview self.view = MapView(self.action_handler, index) # Dictionary self.dct = {-1: Border, 1: Floor, 2: partial(self.build_goal, 1), 3: partial(self.build_goal, 2), 4: partial(self.build_player, 1), 5: partial(self.build_player, 2), 6: Block, 7: Hole, 8: "mirrorDU", 9: "mirrorUD", 10: "memory", 11: "p1Wall", 12: "p2Wall" } # Parse file self.mat = add_border(parse(file_name)) self.width = TileView.nb_lines = len(self.mat) self.height = len(self.mat[0]) self.players = {} self.goals = {} self.tiles = {pos: self.dct[element](pos, self.get_id(pos)) for i, line in enumerate(self.mat) for j, element in enumerate(line) for pos in [(i,j)]} for id_player, player in self.players.items(): self.action_handler.add_player(id_player, player)
from resources.lib import TheMovieDB as tmdb from resources.lib.WindowManager import wm from DialogVideoInfo import DialogVideoInfo from kodi65 import imagetools from kodi65 import utils from ActionHandler import ActionHandler ID_LIST_YOUTUBE = 350 ID_LIST_CREW = 750 ID_LIST_ACTORS = 1000 ID_LIST_VIDEOS = 1150 ID_LIST_BACKDROPS = 1350 ID_BUTTON_RATED = 6006 ch = ActionHandler() def get_window(window_type): class DialogEpisodeInfo(DialogVideoInfo, window_type): TYPE = "Episode" TYPE_ALT = "episode" LISTS = [(ID_LIST_ACTORS, "actors"), (ID_LIST_CREW, "crew"), (ID_LIST_VIDEOS, "videos"), (ID_LIST_BACKDROPS, "images")] @utils.busy_dialog def __init__(self, *args, **kwargs): super(DialogEpisodeInfo, self).__init__(*args, **kwargs) self.tvshow_id = kwargs.get('tvshow_id') data = tmdb.extended_episode_info(tvshow_id=self.tvshow_id, season=kwargs.get('season'),
class Map: def __init__(self, file_name, index): # Action handling self.action_handler = ActionHandler() # Create mapview self.view = MapView(self.action_handler, index) # Dictionary self.dct = {-1: Border, 1: Floor, 2: partial(self.build_goal, 1), 3: partial(self.build_goal, 2), 4: partial(self.build_player, 1), 5: partial(self.build_player, 2), 6: Block, 7: Hole, 8: "mirrorDU", 9: "mirrorUD", 10: "memory", 11: "p1Wall", 12: "p2Wall" } # Parse file self.mat = add_border(parse(file_name)) self.width = TileView.nb_lines = len(self.mat) self.height = len(self.mat[0]) self.players = {} self.goals = {} self.tiles = {pos: self.dct[element](pos, self.get_id(pos)) for i, line in enumerate(self.mat) for j, element in enumerate(line) for pos in [(i,j)]} for id_player, player in self.players.items(): self.action_handler.add_player(id_player, player) def build_player(self, player_id, pos, pid): floor = Floor(pos, pid) self.players[player_id] = Player(player_id, pos, self, floor) return floor def build_goal(self, goal_id, pos, pid): self.goals[goal_id] = Goal(goal_id, pos, pid) return self.goals[goal_id] def get_id(self, pos): pos = XY(*pos) return pos.x * self.width + pos.y def projection(self, player_id): # Init variables result = [] player = self.players[player_id] current_pos = player.pos other_pos = next(p.pos for i,p in self.players.items() if i!=player_id) # Loop over valid positions stop = False while not stop: # Append and update current position result.append(current_pos) current_pos += player.dir # Test new position next_tile = self.tiles[current_pos] stop = isinstance(next_tile, (Block, Border, Hole)) stop = stop or current_pos == other_pos # Black hole case if isinstance(next_tile, Hole): result.append(current_pos) # Return result return result def get_success(self): # Inint result result = [] # Get results for i in (1,2): goal = self.goals[i] player = self.players[i] success = (goal.pos == player.pos) goal.set_active(success) result.append(success) # Return the result return tuple(result) def win(self): self.view.win() def lose(self, nb_tiles): self.view.lose(nb_tiles)