Esempio n. 1
0
from __future__ import absolute_import
from gi.repository import Gtk

from pychess.System import uistuff
from pychess.System.prefix import addDataPrefix

from pychess.Utils.Piece import Piece, KING, QUEEN, ROOK, BISHOP, KNIGHT
from pychess.Utils.const import *

from .PieceWidget import PieceWidget


uistuff.cacheGladefile("promotion.glade")

class PromotionDialog:
    
    def __init__(self):
        self.widgets = uistuff.GladeWidgets("promotion.glade")
        self.dialog = self.widgets["promotionDialog"]
        
        self.color = None
        
        self.widgets["knightDock"].add(PieceWidget(Piece(WHITE, KNIGHT)))
        self.widgets["knightDock"].get_child().show()
        self.widgets["bishopDock"].add(PieceWidget(Piece(WHITE, BISHOP)))
        self.widgets["bishopDock"].get_child().show()
        self.widgets["rookDock"].add(PieceWidget(Piece(WHITE, ROOK)))
        self.widgets["rookDock"].get_child().show()
        self.widgets["queenDock"].add(PieceWidget(Piece(WHITE, QUEEN)))
        self.widgets["queenDock"].get_child().show()
        self.widgets["kingDock"].add(PieceWidget(Piece(WHITE, KING)))
    def onTextviewKeypress (cls, textview, event, widgets):
        if event.state & gtk.gdk.CONTROL_MASK:
            if event.keyval in (ord("f"), ord("F")):
                widgets["findbar"].props.visible = not widgets["findbar"].props.visible
                if widgets["findbar"].props.visible:
                    signal = widgets["searchEntry"].connect_after("expose-event",
                            lambda w,e: w.grab_focus() or
                            widgets["searchEntry"].disconnect(signal))
    
    @classmethod
    def onFindbarKeypress (cls, findbar, event):
        if gtk.gdk.keyval_name(event.keyval) == "Escape":
            findbar.props.visible = False
    
    
uistuff.cacheGladefile("findbar.glade")

################################################################################
# Add early messages and connect for new                                       #
################################################################################

InformationWindow._init()

import gobject
def addMessages2 (messages):
    gobject.idle_add(addMessages2, messages)

def addMessages (messages):
    for task, timestamp, message, type in messages:
        InformationWindow.newMessage (task, timestamp, message, type)
from Throbber import Throbber
from pychess.Players.engineNest import discoverer
from pychess.System import conf, uistuff
from pychess.System.glock import glock_connect
from pychess.System.prefix import addDataPrefix
import gtk.glade
import os

 


uistuff.cacheGladefile("discovererDialog.glade")

class DiscovererDialog:
    
    @classmethod
    def init (cls, discoverer):
        assert not hasattr(cls, "widgets"), "Show can only be called once"
        cls.widgets = uistuff.GladeWidgets("discovererDialog.glade")
        
        #=======================================================================
        # Clear glade defaults
        #=======================================================================
        for child in cls.widgets["enginesTable"].get_children():
            cls.widgets["enginesTable"].remove(child)
        
        #=======================================================================
        # Connect us to the discoverer
        #=======================================================================
        glock_connect(discoverer, "discovering_started", cls._onDiscoveringStarted)
        glock_connect(discoverer, "engine_discovered", cls._onEngineDiscovered)
Esempio n. 4
0
        if event.state & gtk.gdk.CONTROL_MASK:
            if event.keyval in (ord("f"), ord("F")):
                widgets["findbar"].props.visible = not widgets[
                    "findbar"].props.visible
                if widgets["findbar"].props.visible:
                    signal = widgets["searchEntry"].connect_after(
                        "expose-event", lambda w, e: w.grab_focus() or widgets[
                            "searchEntry"].disconnect(signal))

    @classmethod
    def onFindbarKeypress(cls, findbar, event):
        if gtk.gdk.keyval_name(event.keyval) == "Escape":
            findbar.props.visible = False


uistuff.cacheGladefile("findbar.glade")

################################################################################
# Add early messages and connect for new                                       #
################################################################################

InformationWindow._init()

import gobject


def addMessages2(messages):
    gobject.idle_add(addMessages2, messages)


def addMessages(messages):
Esempio n. 5
0
import os
from pychess.System import conf
from pychess.System import uistuff
from pychess.System.prefix import addDataPrefix
from random import randrange

uistuff.cacheGladefile("tipoftheday.glade")


class TipOfTheDay:
    @classmethod
    def _init(cls):
        cls.widgets = uistuff.GladeWidgets("tipoftheday.glade")

        uistuff.keepWindowSize("tipoftheday", cls.widgets["window1"],
                               (320, 240), uistuff.POSITION_CENTER)

        cls.widgets["checkbutton1"].set_active(
            conf.get("show_tip_at_startup", False))
        cls.widgets["checkbutton1"].connect(
            "toggled",
            lambda w: conf.set("show_tip_at_startup", w.get_active()))

        cls.widgets["close_button"].connect(
            "clicked",
            lambda w: cls.widgets["window1"].emit("delete-event", None))
        cls.widgets["window1"].connect(
            "delete_event", lambda w, a: cls.widgets["window1"].hide())

        cls.widgets["back_button"].connect(
            "clicked", lambda w: cls.set_currentIndex(cls.currentIndex - 1))
Esempio n. 6
0
from Throbber import Throbber
from pychess.Players.engineNest import discoverer
from pychess.System import conf, uistuff
from pychess.System.glock import glock_connect
from pychess.System.prefix import addDataPrefix
import gtk.glade
import os

uistuff.cacheGladefile("discovererDialog.glade")


class DiscovererDialog:
    @classmethod
    def init(cls, discoverer):
        assert not hasattr(cls, "widgets"), "Show can only be called once"
        cls.widgets = uistuff.GladeWidgets("discovererDialog.glade")

        #=======================================================================
        # Clear glade defaults
        #=======================================================================
        for child in cls.widgets["enginesTable"].get_children():
            cls.widgets["enginesTable"].remove(child)

        #=======================================================================
        # Connect us to the discoverer
        #=======================================================================
        glock_connect(discoverer, "discovering_started",
                      cls._onDiscoveringStarted)
        glock_connect(discoverer, "engine_discovered", cls._onEngineDiscovered)
        glock_connect(discoverer, "all_engines_discovered",
                      cls._onAllEnginesDiscovered)
Esempio n. 7
0
import os
from pychess.System import conf
from pychess.System import uistuff
from pychess.System.prefix import addDataPrefix
from random import randrange

uistuff.cacheGladefile("tipoftheday.glade")

class TipOfTheDay:
    
    @classmethod
    def _init (cls):
        cls.widgets = uistuff.GladeWidgets("tipoftheday.glade")
        
        uistuff.keepWindowSize("tipoftheday", cls.widgets["window1"],
                               (320,240), uistuff.POSITION_CENTER)
        
        cls.widgets["checkbutton1"].set_active(conf.get("show_tip_at_startup", False))
        cls.widgets["checkbutton1"].connect("toggled",
            lambda w: conf.set("show_tip_at_startup", w.get_active()))
        
        cls.widgets["close_button"].connect("clicked",
            lambda w: cls.widgets["window1"].emit("delete-event", None))
        cls.widgets["window1"].connect("delete_event",
            lambda w, a: cls.widgets["window1"].hide())
        
        cls.widgets["back_button"].connect("clicked",
            lambda w: cls.set_currentIndex(cls.currentIndex-1))
        cls.widgets["forward_button"].connect("clicked",
            lambda w: cls.set_currentIndex(cls.currentIndex+1))