Ejemplo n.º 1
0
    def get_tabcontent(self, chessfile):
        tabcontent = createAlignment(0, 0, 0, 0)
        hbox = Gtk.HBox()
        hbox.set_spacing(4)
        hbox.pack_start(createImage(pgn_icon), False, True, 0)

        close_button = Gtk.Button()
        close_button.set_property("can-focus", False)
        close_button.add(createImage(gtk_close))
        close_button.set_relief(Gtk.ReliefStyle.NONE)
        close_button.set_size_request(20, 18)
        close_button.connect("clicked", self.close)
        hbox.pack_end(close_button, False, True, 0)

        name, ext = os.path.splitext(chessfile.path)
        basename = os.path.basename(name)
        info = "%s.%s" % (basename, ext[1:])
        tooltip = _("%(path)s\ncontaining %(count)s games") % (
            {
                "path": chessfile.path,
                "count": chessfile.count
            })
        tabcontent.set_tooltip_text(tooltip)

        label = Gtk.Label(info)
        hbox.pack_start(label, False, True, 0)

        tabcontent.add(hbox)
        tabcontent.show_all()
        return tabcontent, close_button
Ejemplo n.º 2
0
    def get_tabcontent(self, chessfile):
        tabcontent = createAlignment(0, 0, 0, 0)
        hbox = Gtk.HBox()
        hbox.set_spacing(4)
        hbox.pack_start(createImage(pgn_icon), False, True, 0)

        close_button = Gtk.Button()
        close_button.set_property("can-focus", False)
        close_button.add(createImage(gtk_close))
        close_button.set_relief(Gtk.ReliefStyle.NONE)
        close_button.set_size_request(20, 18)
        close_button.connect("clicked", self.close)
        hbox.pack_end(close_button, False, True, 0)

        name, ext = os.path.splitext(chessfile.path)
        basename = os.path.basename(name)
        info = "%s.%s" % (basename, ext[1:])
        tooltip = "%s\ncontaining %s games" % (chessfile.path, chessfile.count)
        tabcontent.set_tooltip_text(tooltip)

        label = Gtk.Label(info)
        hbox.pack_start(label, False, True, 0)

        tabcontent.add(hbox)
        tabcontent.show_all()
        return tabcontent, close_button
Ejemplo n.º 3
0
    def initTabcontents(self):
        tabcontent = createAlignment(0, 0, 0, 0)
        hbox = Gtk.HBox()
        hbox.set_spacing(4)
        hbox.pack_start(createImage(light_off), False, True, 0)
        close_button = Gtk.Button()
        close_button.set_property("can-focus", False)
        close_button.add(createImage(gtk_close))
        close_button.set_relief(Gtk.ReliefStyle.NONE)
        close_button.set_size_request(20, 18)

        self.cids[close_button] = close_button.connect(
            "clicked", self.on_game_close_clicked)

        hbox.pack_end(close_button, False, True, 0)
        text_hbox = Gtk.HBox()
        white_label = Gtk.Label(label="")
        text_hbox.pack_start(white_label, False, True, 0)
        text_hbox.pack_start(Gtk.Label(label=" - "), False, True, 0)
        black_label = Gtk.Label(label="")
        text_hbox.pack_start(black_label, False, True, 0)
        gameinfo_label = Gtk.Label(label="")
        text_hbox.pack_start(gameinfo_label, False, True, 0)
        #        label.set_alignment(0,.7)
        hbox.pack_end(text_hbox, True, True, 0)
        tabcontent.add(hbox)
        tabcontent.show_all()  # Gtk doesn't show tab labels when the rest is
        return tabcontent, white_label, black_label, gameinfo_label
Ejemplo n.º 4
0
 def light_on_off(self, on):
     child = self.tabcontent.get_child()
     if child:
         child.remove(child.get_children()[0])
         if on:
             # child.pack_start(createImage(light_on, True, True, 0), expand=False)
             child.pack_start(createImage(light_on), True, True, 0)
         else:
             # child.pack_start(createImage(light_off, True, True, 0), expand=False)
             child.pack_start(createImage(light_off), True, True, 0)
     self.tabcontent.show_all()
Ejemplo n.º 5
0
    def __init__(self, name, label):
        self.name = name
        self.label = label
        self.default = False
        self.widget = Gtk.Alignment()
        self.widget.show()
        self.toolbuttons = []
        self.menuitems = []
        self.docks = {}
        self.main_notebook = None

        if getattr(sys, 'frozen', False) and not MSYS2:
            zip_path = os.path.join(os.path.dirname(sys.executable),
                                    "library.zip")
            importer = zipimport.zipimporter(zip_path +
                                             "/pychess/perspectives/%s" % name)
            postfix = "Panel.pyc"
            with zipfile.ZipFile(zip_path, 'r') as myzip:
                names = [
                    f[:-4].split("/")[-1] for f in myzip.namelist()
                    if f.endswith(postfix) and "/%s/" % name in f
                ]
            self.sidePanels = [importer.load_module(name) for name in names]
        else:
            path = "%s/%s" % (os.path.dirname(__file__), name)
            ext = ".pyc" if getattr(sys, 'frozen', False) and MSYS2 else ".py"
            postfix = "Panel%s" % ext
            files = [
                f[:-len(ext)] for f in os.listdir(path) if f.endswith(postfix)
            ]
            self.sidePanels = [
                importlib.import_module("pychess.perspectives.%s.%s" %
                                        (name, f)) for f in files
            ]

        for panel in self.sidePanels:
            close_button = Gtk.Button()
            close_button.set_property("can-focus", False)
            close_button.add(createImage(gtk_close))
            close_button.set_relief(Gtk.ReliefStyle.NONE)
            close_button.set_size_request(20, 18)
            close_button.connect("clicked", self.on_clicked, panel)

            menu_item = Gtk.CheckMenuItem(label=panel.__title__)
            menu_item.name = panel_name(panel.__name__)
            # if menu_item.name != "LecturesPanel":
            #    menu_item.set_active(True)
            menu_item.connect("toggled", self.on_toggled, panel)
            self.menuitems.append(menu_item)
            panel.menu_item = menu_item

            box = dock_panel_tab(panel.__title__, panel.__desc__,
                                 panel.__icon__, close_button)
            self.docks[panel_name(panel.__name__)] = [box, None, menu_item]
Ejemplo n.º 6
0
    def __init__(self, name, label):
        self.name = name
        self.label = label
        self.default = False
        self.widget = Gtk.Alignment()
        self.widget.show()
        self.toolbuttons = []
        self.menuitems = []
        self.docks = {}
        self.main_notebook = None

        if getattr(sys, 'frozen', False) and not MSYS2:
            zip_path = os.path.join(os.path.dirname(sys.executable), "library.zip")
            importer = zipimport.zipimporter(zip_path + "/pychess/perspectives/%s" % name)
            postfix = "Panel.pyc"
            with zipfile.ZipFile(zip_path, 'r') as myzip:
                names = [f[:-4].split("/")[-1] for f in myzip.namelist() if f.endswith(postfix) and "/%s/" % name in f]
            self.sidePanels = [importer.load_module(name) for name in names]
        else:
            path = "%s/%s" % (os.path.dirname(__file__), name)
            ext = ".pyc" if getattr(sys, 'frozen', False) and MSYS2 else ".py"
            postfix = "Panel%s" % ext
            files = [f[:-len(ext)] for f in os.listdir(path) if f.endswith(postfix)]
            self.sidePanels = [importlib.import_module("pychess.perspectives.%s.%s" % (name, f)) for f in files]

        for panel in self.sidePanels:
            close_button = Gtk.Button()
            close_button.set_property("can-focus", False)
            close_button.add(createImage(gtk_close))
            close_button.set_relief(Gtk.ReliefStyle.NONE)
            close_button.set_size_request(20, 18)
            close_button.connect("clicked", self.on_clicked, panel)

            menu_item = Gtk.CheckMenuItem(label=panel.__title__)
            menu_item.name = panel_name(panel.__name__)
            # if menu_item.name != "LecturesPanel":
            #    menu_item.set_active(True)
            menu_item.connect("toggled", self.on_toggled, panel)
            self.menuitems.append(menu_item)
            panel.menu_item = menu_item

            box = dock_panel_tab(panel.__title__, panel.__desc__, panel.__icon__, close_button)
            self.docks[panel_name(panel.__name__)] = [box, None, menu_item]