Exemplo n.º 1
0
 def __init__(self, parent):
     Canvas.__init__(self, width=WIDTH, height=HEIGHT, 
         background="black", highlightthickness=0)
      
     self.parent = parent 
     self.initGame()
     self.pack()
Exemplo n.º 2
0
 def __init__(self, *args, **kwargs):
     Canvas.__init__(self, *args, **kwargs)
     self.graphs = []
     self.x = Axis()
     self.y = Axis()
     self.y.direction = -1
     self.bind("<Configure>", lambda ev: self.after_idle(self.__onConfigure__))
Exemplo n.º 3
0
    def __init__(self, master=None, cnf=None, **kw):
        if not cnf:
            cnf = {}
        Canvas.__init__(self, master, cnf, **kw)

        self._polygons = list()
        self._layer = None
        self._image = None
Exemplo n.º 4
0
 def __init__(self, master, controller, *, height, width, background):
   self.height = height
   self.width = width
   self.controller = controller
   self.viewports = []
   Canvas.__init__(self, master, height=height, width=width, background=background)
   self.SetupMenu(master)
   self.SetNamedView(FLAGS.gui_initial_view or self.default_initial_view)
Exemplo n.º 5
0
 def __init__(self, parent):
     """Simple Canvas class."""
     Canvas.__init__(self, parent)
     self.parent = parent
     self.config(background="white", width=960, height=640)
     self.num = 1
     self.pack()
     self.element_list = []
     self.bindings()
Exemplo n.º 6
0
    def __init__(self, **kwargs):
        """
        Constructor

        root - reference to the widget containing this widget
        """
        Canvas.__init__(self, **kwargs)
        self["bg"] = DEAD_COLOUR
        GolCell.__init__(self)
Exemplo n.º 7
0
 def __init__(self, master=None, cnf={}, **kw):
     Canvas.__init__(self, master, cnf, **kw)
     Observable.__init__(self)
     self.__boxId    = None
     self.__start_x   = None
     self.__start_y   = None
     
     self.bind('<Button-1>', self.onButton1Press)
     self.bind('<B1-Motion>', self.onMouseMove)
     self.bind('<ButtonRelease-1>', self.onButton1Release)
Exemplo n.º 8
0
 def __init__(self, master=None, data=None, cell_size=10, color='green'):
     self.cell = data if data else [[False]]
     self._grid_width = len(self.cell)
     self._grid_height = len(self.cell[0])
     self._width = self._grid_width * cell_size
     self._height = self._grid_height * cell_size
     Canvas.__init__(self, master, width=self._width, height=self._height)
     self.cell_size = cell_size
     self.color = color
     self.bind('<Button-1>', self.on_click)
     self.bind('<B1-Motion>', partial(self.on_click, motion=True))
     self.draw()
Exemplo n.º 9
0
 def __init__(self, master, controller, *, height, width, background):
   self.is_history_displayed = False
   self.height = height
   self.width = width
   self.controller = controller
   self.viewports = []
   Canvas.__init__(
       self, master, height=height, width=width, background=background)
   self.SetupMenu(master)
   self.SetNamedView(farg_flags.FargFlags.gui_initial_view or
                     self.default_initial_view)
   if farg_flags.FargFlags.history:
     self.TurnOnHistoryGUI(master)
Exemplo n.º 10
0
 def __init__(self, parent, name, size):
     Canvas.__init__(self, parent)
     self.parent = parent
     self.name = name
     self.background = "white"
     self.size = size
     self.width = size[0]
     self.height = size[1]
     self.info = defaultdict(dict)
     self.num = defaultdict(int)
     self.sticky_size = (250, 220)
     self.stickies = []
     self.lines = {}
     self.bind("<ButtonPress-1>", self.smark)
     self.bind("<B1-Motion>", self.sdrag)
     self.bind("<Button-3>", self.insert_node)
Exemplo n.º 11
0
 def __init__(self, parent, name):
     Canvas.__init__(self, parent)
     self.parent = parent
     self.name = name
     self.config(bg="white")
     self.info = defaultdict(dict)
     self.marked = None
     self.sticky_size = (250, 220)
     self.stickies = {}
     self.lines = {}
     self.scale_by = 0
     self.bind("<ButtonPress-2>", self.smark)
     self.bind("<B2-Motion>", self.sdrag)
     self.bind("<Button-3>", self.insert_node)
     self.bind("<Button-4>", self.zoom_up)
     self.bind("<Button-5>", self.zoom_down)
Exemplo n.º 12
0
    def __init__(self, master, image):
        Canvas.__init__(self, master, width=image.size[0], height=image.size[1])

        # fill the canvas
        self.tile = {}
        self.tilesize = tilesize = 32
        xsize, ysize = image.size
        for x in range(0, xsize, tilesize):
            for y in range(0, ysize, tilesize):
                box = x, y, min(xsize, x+tilesize), min(ysize, y+tilesize)
                tile = ImageTk.PhotoImage(image.crop(box))
                self.create_image(x, y, image=tile, anchor=NW)
                self.tile[(x, y)] = box, tile

        self.image = image

        self.bind("<B1-Motion>", self.paint)
Exemplo n.º 13
0
    def __init__(self, master):
        Canvas.__init__(self, master, bg="white", height=CANVAS_HEIGHT)

        self.create_rectangle(MAIN_REC_X,
                              MAIN_REC_Y,
                              MAIN_REC_X + MAIN_REC_WIDTH,
                              MAIN_REC_Y + MAIN_REC_HEIGHT,
                              fill="gray")
        self.create_text(MAIN_REC_X + (MAIN_REC_WIDTH / 2),
                         MAIN_REC_Y + (TEXT_HEIGHT / 2),
                         text="SystemCoreClock",
                         fill="#000000",
                         font=("Consolas", 10))

        self.selected_globals = GlobalVarSampling()

        self.pack(fill="none")
Exemplo n.º 14
0
 def __init__(self, parent: tk.Frame = None, interval=20, linenum=10, save=True, drag=True, adaptation=True, lengthx=20000):
     Canvas.__init__(self, parent, bg='#345', closeenough=2)
     parent.update_idletasks()
     self.pack(fill=tk.BOTH, expand=True)
     self.update_idletasks()
     self.hScroll = Scrollbar(parent, orient='horizontal',
                              command=self.hScrolled)
     self.hScroll.pack(side=tk.BOTTOM, fill=tk.X)
     self.configure(yscrollcommand=None,
                    xscrollcommand=self._canvashScrolled)
     self.bind("<Button-1>", self.__mouseDown)
     self.bind("<MouseWheel>", self.__mouseScale)
     self.bind("<B1-Motion>", self.__mouseDownMove)
     self.bind("<B1-ButtonRelease>", self.__mouseUp)
     self.bind("<Enter>", self.__mouseEnter)
     self.bind("<Leave>", self.__mouseLeave)
     self.bind("<Motion>", self.__mouseHoverMove)
     self["xscrollincrement"] = 1
     self["yscrollincrement"] = 1
     self.__dataList = []
     self._rulerdata = [0]*linenum
     self.x = 0
     self.scrollx = 3.0
     self.offsety = 0
     self._interval = interval  # main loop interval to handle input data
     self._lengthx = lengthx  # scrollregion x
     self._rulerOn = False
     self._dragOn = drag  # enable mouse move items
     self._gridOn = True  # draw grid lines
     self._loopOn = True
     self._tipOn = False
     self._adaptation = adaptation
     self._ruler = None
     self._rulerX = -1
     self._save = save  # 保存数据
     self._dataWriter = None  # 数据保存writer
     self._datafile = ''  # 保存文件名称
     self._scrollOn = False
     self._lineNum = linenum
     self._firststart = True
     self._scrollDelay = 0
     # this data is used to keep track of an item being dragged
     # in this app, only vertical position
     self._drag_data = {"sx": 0, "sy": 0, "x": 0, "y": 0, "item": None}
     self._lines = []
     self.after(200, self.__initCanvas)
Exemplo n.º 15
0
 def __init__(self, size, values):
     Canvas.__init__(self)
     self.config(width = size, height = size)
     self.size = size
     sudoku.font = Font(size = int(32 * self.size / 600))
     self.values = values
     self.curyx = (4, 4)
     sudoku.INDEXES = [(x, y) for x in range(9) for y in range(9)]
     self.pack()
     self.init_graphics()
     self.event_add('<<digit>>', *['<KeyPress-{}>'.format(i) for i in range(1, 10)])
     self.bind_all('<<digit>>', self.write_digit)
     self.bind_all('s', self.solve)
     self.bind_all('c', self.clear)
     self.bind('<Motion>', self.on_mouse_motion)
     self.bind('<Button-1>', self.on_mouse_click1)
     self.bind('<Button-3>', self.on_mouse_click3)
Exemplo n.º 16
0
    def __init__(self, master, image):
        Canvas.__init__(self, master, width=image.size[0], height=image.size[1])

        # fill the canvas
        self.tile = {}
        self.tilesize = tilesize = 32
        xsize, ysize = image.size
        for x in range(0, xsize, tilesize):
            for y in range(0, ysize, tilesize):
                box = x, y, min(xsize, x+tilesize), min(ysize, y+tilesize)
                tile = ImageTk.PhotoImage(image.crop(box))
                self.create_image(x, y, image=tile, anchor=NW)
                self.tile[(x, y)] = box, tile

        self.image = image

        self.bind("<B1-Motion>", self.paint)
Exemplo n.º 17
0
    def __init__(self,
                 parent,
                 igrac1,
                 igrac2,
                 naziv_fajla,
                 stampaj_vrednosti_svih_poteza,
                 crtaj_svaki_korak=True):
        """Konstruktor klase IgraCanvas, inicijalizuje potrebne atribute.
        
        :param parent: Roditeljski widget u kojem se crta IgraCanvas
        :type parent: Widget
        :param igrac1: Tip prvog igraca
        :type igrac1: str
        :param igrac2: Tip drugog igraca
        :type igrac2: str
        :param naziv_fajla: Putanja do falja iz kojeg se citaju potezi ili u kojem se upisuju potezi
        :type naziv_fajla: str
        :param stampaj_vrednosti_svih_poteza: Da li treba stampati vrednosti svih mogucih poteza za AI
        :type stampaj_vrednosti_svih_poteza: bool
        :param crtaj_svaki_korak: Kad igraju AI vs AI da li treba prikazivati svaki potez ili samo rezultat njihovog meca, defaults to True
        :type crtaj_svaki_korak: bool, optional
        """
        Canvas.__init__(self, parent)
        self.config(width=500, height=550)
        self.bind("<Button-1>", self.mouse_click)

        self.crtaj_svaki_korak = crtaj_svaki_korak

        # postavljanje tip igraca koji su prosledjeni kao parametri
        self.plavi_AI = self.odaberi_AI(igrac1, stampaj_vrednosti_svih_poteza)
        self.crveni_AI = self.odaberi_AI(igrac2, stampaj_vrednosti_svih_poteza)

        # inicijalizacije matrice
        self.tabla = Tabla()
        self.na_potezu = None  # da napisem dobar komentar za ovo
        self.game_state = GameState.POSTAVLJANJE_FIGURA  # u pocetku svi igraci postavljaju svoje figure na tablu
        self.broj_figura = 0  # treba mi za prvu fazu gde se postavljaju figure
        self.selektovana_figura = (-2, -2)

        # otvaranje fajla, citanje i izvrsavanje poteza ako ih ima u njemu
        self.procitaj_fajl_i_popuni_tabelu(naziv_fajla)
        # otvaranje fajla za pisanje sad, svaki put kad se izvrsi neki potez on se upisuje u fajl
        self.f = open(naziv_fajla, "a")

        self.crtaj()
        self.zameni_igraca()
Exemplo n.º 18
0
    def __init__(self,
                 boss=None,
                 largeur=400,
                 hauteur=300,
                 xmin=-10,
                 ymin=-10,
                 xmax=10,
                 ymax=10,
                 background='white',
                 axes=True):
        Canvas.__init__(self, boss)
        self.configure(width=largeur,
                       height=hauteur,
                       bg=background,
                       border=5,
                       relief=RIDGE)
        self.x1 = 0
        self.y2 = 0
        self.axes = axes
        self.xmin, self.ymin, self.xmax, self.ymax = xmin, ymin, xmax, ymax
        self.largeur = largeur  # int(self.cget('width'))
        self.hauteur = hauteur  # int(self.cget('height'))
        self.o2, self.p, self.inv_p = self._initialize_matrix(
            xmin, ymin, xmax, ymax, largeur, hauteur)
        self.pasU = self._reglage_pas()
        self.flag = 0  # pas de déplacement d'objets au départ
        border_w = self.winfo_reqwidth() - self.largeur  # largeur intérieure
        border_h = self.winfo_reqheight() - self.hauteur  # hauteur intérieure
        self.border = (border_w / 2, border_h / 2)  # taille du bord

        # où l'on stocke les différents objets dessinés pour la
        # réactualisation:
        self.objets = []
        # [ tag, nature, xmin, ymin, xmax, ymax, couleur, epaisseur, remplissage ]
        self.redraw()

        self.bind('<Configure>', self._config)
        self.bind('<Button-1>', self.mouseDown)
        boss.bind('<Double-Button-1>', self.dblclic)
        self.bind('<Button1-Motion>', self.mouseMove)
        self.bind('<Button1-ButtonRelease>', self.mouseUp)
        self.bind('<Button-4>', self.wheel)  # roulette pour linux
        self.bind('<Button-5>', self.wheel)  # roulette pour linux
        boss.bind('<MouseWheel>', self.wheel)  # pour windows
        self.master.protocol("WM_DELETE_WINDOW", self.fermeture)
Exemplo n.º 19
0
    def __init__(self,
                 tk_instance,
                 *geometry,
                 fp="background.png",
                 animation_speed=50):

        #Verifica se o parâmetro tk_instance é uma instância de Tk
        if not isinstance(tk_instance, Tk):
            raise TypeError(
                "The tk_instance argument must be an instance of Tk.")

        #Recebe o caminho de imagem e a velocidade da animação
        self.image_path = fp
        self.animation_speed = animation_speed

        #Recebe a largura e altura do widget
        self.__width = geometry[0]
        self.__height = geometry[1]

        #Inicializa o construtor da classe Canvas
        Canvas.__init__(self,
                        master=tk_instance,
                        width=self.__width,
                        height=self.__height)

        #Carrega a imagem que será usada no plano de fundo
        self.__bg_image = self.getPhotoImage(image_path=self.image_path,
                                             width=self.__width,
                                             height=self.__height,
                                             closeAfter=True)[0]

        #Cria uma imagem que será fixa, ou seja, que não fará parte da animação e serve em situações de bugs na animação
        self.__background_default = self.create_image(self.__width // 2,
                                                      self.__height // 2,
                                                      image=self.__bg_image)

        #Cria as imagens que serão utilizadas na animação do background
        self.__background.append(
            self.create_image(self.__width // 2,
                              self.__height // 2,
                              image=self.__bg_image))
        self.__background.append(
            self.create_image(self.__width + (self.__width // 2),
                              self.__height // 2,
                              image=self.__bg_image))
    def __init__(self,
                 master,
                 stationId,
                 dateFrom=datetime.today(),
                 dateTo=datetime.today(),
                 statisticType='day'):
        '''
        Parameters
        ----------
        master : frame
            Frame where the canvas set
        dateFrom : datetime
            Statistic start date
        dateTo : datetime
            Statistic end date
        statisticType : string
            Set display type (day,month,year)
        '''

        # Statistic size
        self.width = 1000
        self.height = 800
        self.lineColors = ['#FF0000', '#00FF00', '#0000FF', '#FFFF00']

        Canvas.__init__(self, master, width=self.width, height=self.height)

        # Db
        self.db = Db()

        # Statistic border
        Border = namedtuple('Border', 'top bottom left right')
        self.border = Border(5, 50, 50, 5)

        # Statistic coordinations
        Statistic = namedtuple('Statistic',
                               'top left right bottom height width')
        self.statistic = Statistic(
            self.border.top, self.border.left, self.width - self.border.right,
            self.height - self.border.bottom,
            self.height - self.border.top - self.border.bottom,
            self.width - self.border.left - self.border.right)

        self.pack(expand=1, side='bottom')

        self.set(stationId, dateFrom, dateTo, statisticType)
Exemplo n.º 21
0
    def __init__(self, parent, radius, color_on, o_color_on, color_off, o_color_off, off_or_on):
        Canvas.__init__(self, parent, borderwidth=0, highlightthickness=0, bg='sky blue')
        padding = 0

        self.color_on = color_on
        self.color_off = color_off
        self.o_color_on = o_color_on
        self.o_color_off = o_color_on

        self.current_color = color_on
        self.outline_color = o_color_on

        self.light = self.create_oval((3, 3, radius, radius), width=radius/5, fill=self.current_color)

        self.set_state(off_or_on)
        (x0, y0, x1, y1) = self.bbox("all")
        radius = (x1-x0) + padding
        self.configure(width=radius, height=radius)
Exemplo n.º 22
0
Arquivo: render.py Projeto: Vekkt/2048
    def __init__(self, root):
        Canvas.__init__(self, width = 400 ,height = 400, bg=bg)
        self.root = root
        self.board = Board(self)

        for i in range(4):
            for j in range(4):
                rect = self.create_rectangle(
                    j*100 + 8, i*100 + 8, 
                    j*100+98, i*100+98, 
                    fill=tile_bg, 
                    outline="")
                self.tag_lower(rect)

        root.bind("<Up>", lambda event: self.step((-1, 0)))
        root.bind("<Down>", lambda event: self.step((1, 0)))
        root.bind("<Left>", lambda event: self.step((0, -1)))
        root.bind("<Right>", lambda event: self.step((0, 1)))
Exemplo n.º 23
0
 def __init__(self, parent: Widget, width: int, height: int):
     """Initialize chart canvas.
     
     Args:
         parent: tkinter widget canvas should belong to
         width: pixel width of candle area
         height: pixel height of candle area
     Attributes (not all set upon initialization).
     """
     Canvas.__init__(
         self,
         master=parent,
         background=Color.BACKGROUND,
         borderwidth=0,
         bd=0,
         highlightthickness=0,
         width=width,
         height=height,
     )
Exemplo n.º 24
0
    def __init__(self, parent, title, value, textColor=None):
        Canvas.__init__(self,
                        parent,
                        bd=-2,
                        width=0,
                        height=0,
                        highlightthickness=0)

        self.config = ConfigValues()

        if textColor:
            self.textColor = textColor
        else:
            self.textColor = self.config.values['colors']['green']

        self.text = None

        self.setBackgroundColor(self.config.values['colors']['darkBlue'])
        self.setText(title, value)
Exemplo n.º 25
0
 def __init__(self, parent, doc, **kw):
     kw['width'] = 512
     kw['height'] = 480
     kw['relief']='raised'
     kw['highlightthickness'] = 0
     Canvas.__init__(self, parent, **kw)
     self.doc = doc
     self.tile = []
     im = PILImage.new('RGB', (32, 32))
     for y in range(15):
         row = []
         for x in range(16):
             tile = ImageTk.PhotoImage(im)
             if True or ((x ^ y) & 1) == 0:
                 self.create_image(x * 32, y * 32, image=tile, anchor=NW)
             row.append(tile)
         self.tile.append(row)
     self.updating = False
     self.updScreen()
Exemplo n.º 26
0
    def __init__(self, master, node_map, **options):
        # Initialize canvas
        Canvas.__init__(self, master, **options)  # Initialize parent class
        self.grid(row=0, column=0)

        self.last_update = current_time_millis()  # FPS

        # Control variables
        self.x_offset, self.y_offset = 0, 0
        self.scale = 1

        self.node_map = node_map

        # Mouse events
        self.mouse_x_offset, self.mouse_y_offset = 0, 0
        self.bind("<Button-1>", self.mouse1_down)
        self.bind("<B1-Motion>", self.mouse1_drag)
        self.bind("<MouseWheel>", self.mouse_scroll)  # Windows
        self.bind("<Button-4>", self.mouse_scroll)  # Linux
        self.bind("<Button-5>", self.mouse_scroll)  # Linux
Exemplo n.º 27
0
    def __init__(self, parent: Tk, width_in_pixels: int, height_in_pixels: int, block_size: int,
                 board_width: int, board_height: int, grid_row: int, grid_column: int):
        self.parent = parent

        self.width_in_pixels = width_in_pixels
        self.height_in_pixels = height_in_pixels

        Canvas.__init__(self, parent, width=self.width_in_pixels, height=self.height_in_pixels, bg=self.board_colour)

        self.num_circles_horizontal = board_width
        self.num_circles_vertical = board_height

        self.circle_diameter = (8 / 10) * block_size
        self.padding = (1 / 10) * block_size
        self.drop_distance = block_size

        self.grid(row=grid_row, column=grid_column, columnspan=self.num_circles_horizontal)
        self.draw_bg_circles()

        self.animation_in_progress = False  # Used to tell parent that it should wait until animation over
Exemplo n.º 28
0
    def __init__(self, master=None, **kw):
        self.log = logging.getLogger(__name__)
        self.min = 0
        self.max = 100
        if "min" in kw:
            self.min = kw['min']
            del kw['min']
        if "max" in kw:
            self.max = kw['max']
            del kw['max']

        if "width" not in kw:
            kw['width'] = 100
        if "height" not in kw:
            kw['height'] = 10
        if "background" not in kw:
            kw['background'] = "black"

        self.rect = None
        Canvas.__init__(*(self, master), **kw)
Exemplo n.º 29
0
    def __init__(self, tk_instance, *geometry, fp="background.png", animation_speed=50):

        if not isinstance(tk_instance, Tk): raise TypeError("The tk_instance argument must be an instance of Tk.")

        self.image_path = fp
        self.animation_speed = animation_speed

        self.__width = geometry[0]
        self.__height = geometry[1]

        Canvas.__init__(self, master=tk_instance, width=self.__width, height=self.__height)

        self.__bg_image = \
        self.getPhotoImage(image_path=self.image_path, width=self.__width, height=self.__height, closeAfter=True)[0]

        self.__background_default = self.create_image(self.__width // 2, self.__height // 2, image=self.__bg_image)

        self.__background.append(self.create_image(self.__width // 2, self.__height // 2, image=self.__bg_image))
        self.__background.append(
            self.create_image(self.__width + (self.__width // 2), self.__height // 2, image=self.__bg_image))
Exemplo n.º 30
0
    def __init__(self, parent, **kwargs):
        """
        Custom scrollbar, using canvas. It can be configured with fg, bg and command

        :param parent:
        :param kwargs:
        """

        self.command = kwargs.pop("command", None)
        kw = kwargs.copy()
        bd = 0
        hlt = 0
        if "fg" in kw.keys():
            del kw["fg"]
        if "bd" in kw.keys():
            bd = kw.pop("bd")
        if "border" in kw.keys():
            bd = kw.pop("border")
        if "highlightthickness" in kw.keys():
            hlt = kw.pop("highlightthickness")
        Canvas.__init__(self,
                        parent,
                        **kw,
                        highlightthickness=hlt,
                        border=bd,
                        bd=bd)
        if "fg" not in kwargs.keys():
            kwargs["fg"] = "darkgray"

        # coordinates are irrelevant; they will be recomputed
        # in the 'set' method\
        self.old_y = 0
        self._id = self.create_rectangle(0,
                                         0,
                                         1,
                                         1,
                                         fill=kwargs["fg"],
                                         outline=kwargs["fg"],
                                         tags=("thumb", ))
        self.bind("<ButtonPress-1>", self.on_press)
        self.bind("<ButtonRelease-1>", self.on_release)
Exemplo n.º 31
0
    def __init__(self, master, layout, margin=20, caption=None, **kw):
        Canvas.__init__(self,
                        master,
                        width=int(layout.size.x + 2 * margin),
                        height=int(layout.size.y + 2 * margin),
                        **kw)

        self.__margin = margin

        self._vertex_label_mode = "auto"
        # map value -> Vertex object
        self._vertices = dict()
        self._layout = layout
        self._picked_vertex_state = PickedState()
        self._create_vertex_shape = (
            lambda vertex: shapes.create_default_shape(self, vertex))
        self.update()

        self._caption = self.create_caption(caption) if caption else None

        # self._translate = (0, 0)

        self._mouse_plugin = MousePlugin().apply(self)

        # makes vertex shape change appearing if it was picked
        # also sets layout lock for picked vertices
        def createListener():
            state = self._picked_vertex_state
            layout = self.layout

            def listener(vertex):
                picked = state.is_picked(vertex)
                vertex.shape.set_selection(picked)
                layout.set_lock(layout.graph.index(vertex.value), picked)

            return listener

        self._picked_vertex_state.add_listener(createListener())

        # handle resize
        self.bind("<Configure>", lambda event: self._on_configure())
Exemplo n.º 32
0
    def __init__(self,
                 parent,
                 main_window,
                 col=None,
                 bg="#009900",
                 diameter=50,
                 mode="game",
                 command=None):
        Canvas.__init__(self, parent, width=diameter, height=diameter)
        self.configure(highlightthickness=1,
                       highlightbackground="black",
                       borderwidth=1,
                       bg=bg)

        self.Main_Window = main_window

        # Do we create the disc initially or not?
        if col == None:
            self.Visible = False
        else:
            self.Visible = True
        if self.Visible:
            self.Disc = self.create_oval((0, 0, diameter, diameter),
                                         fill=col,
                                         tags="Disc")
        else:
            self.Disc = None

        self.Mode = mode

        # Display Attributes
        self.diameter = diameter

        # Disc Attribute
        self.Current_Color = col

        # Binds
        self.command = command
        self.bind("<Button-1>", self._Onclick)

        self.bind("<Configure>", self._Onresize)
Exemplo n.º 33
0
 def __init__(self,
              master=None,
              chosen_color="red",
              rows=2000,
              columns=2000):
     Canvas.__init__(self, master)
     self.bind("<Button-1>", self.click)
     self.bind("<B1-Motion>", self.hold_down_cell)
     self.bind("<Button-3>", self.right_click)
     self.bind("<B3-Motion>", self.right_move)
     self.cell_width = 15
     self.cell_height = 15
     self.cell_draws = [[None for c in range(columns)] for r in range(rows)]
     self.DEAD_COLOR = "white"
     self.chosen_pattern = "cell"
     self.chosen_color = chosen_color
     self.patterns = self._load_patterns()
     self.matrix = GameMatrix(rows=rows, columns=columns)
     self._create_grid()
     self.shift_x = 0
     self.shift_y = 0
Exemplo n.º 34
0
    def __init__(self, master, row_number, column_number, cell_size):
        Canvas.__init__(self,
                        master,
                        width=cell_size * column_number,
                        height=cell_size * row_number)

        self.cellSize = cell_size

        self.grid = [[
            Cell(self, column, row, cell_size)
            for column in range(column_number)
        ] for row in range(row_number)]

        self.switched = [
        ]  # avoid multi switching of state during mouse motion.

        self.bind("<Button-1>", self.handle_mouse_click)
        self.bind("<B1-Motion>", self.handle_mouse_motion)
        self.bind("<ButtonRelease-1>", lambda event: self.switched.clear())

        self.draw()
Exemplo n.º 35
0
 def __init__(self, master, size, color, secondary_color, last_roll):
     Canvas.__init__(self,
                     master=master,
                     width=size,
                     height=size,
                     bd=1,
                     relief=RIDGE)
     self._current_value = last_roll
     self._size = size
     self._color = color
     self._secondary_color = secondary_color
     self._dot_list = []
     self._dot_locations = [[(5, 5)], [(2, 2), (8, 8)],
                            [(8, 2), (5, 5), (2, 8)],
                            [(2, 2), (2, 8), (8, 2), (8, 8)],
                            [(5, 5), (2, 2), (2, 8), (8, 2), (8, 8)],
                            [(2, 2), (2, 8), (8, 2), (8, 8), (2, 5),
                             (8, 5)]]
     self._x = self._y = self._c = self._size / 2
     self._show()
     self._dot_radius = self._size / 10
     self._show_dots()
Exemplo n.º 36
0
 def __init__(self, master):
     Canvas.__init__(self, master)
     self.master = master
     self.nivel = 1
     self.cabeza_coordenadas = self.genera_comida_aleatoria_inicio()
     self.cuerpo_coordenadas = [
         self.cabeza_coordenadas,
         (self.cabeza_coordenadas[0] - 20, self.cabeza_coordenadas[1])
     ]
     self.comida_coordenadas = self.genera_comida_aleatoria()
     self.color_cabeza = constantes.color_cabeza
     self.direcciones_posibles = constantes.DIRECCIONES_FLECHAS
     # Si se quiere que empiece con una direccion aleatoria automaticamente cambiar self.direccion = random.choice(self.direcciones_posibles)
     self.direccion = ''
     self.bind_all('<Key>', self.presiona_tecla)
     self.cargar_imagenes_cuerpo_cabeza()
     self.cargar_vivorita()
     self.cargar_comida()
     self.mover_vivorita()
     self.after(self.master.master.velocidad.get(), self.bucle_juego)
     self.reproductor = Reproductor()
     self.reproductor.reproducir_musica(constantes.musica_en_juego, 0.04)
Exemplo n.º 37
0
    def __init__(self, master=None, **kw):

        Canvas.__init__(self, master, kw)
        self.doIdleRedraw = 0
        self.doIdleSWCursor = 0
        self.ignoreNextRedraw = 0
        # Add a placeholder software cursor attribute. If it is None,
        # that means no software cursor is in effect. If it is not None,
        # then it will be used to render the cursor.
        self._isSWCursorActive = 0
        self._SWCursor = None
        self.initialised = 0

        # to save last cursor position if switching to another window
        self.lastX = None
        self.lastY = None
        self.width = self.winfo_width()  # to avoid repeated calls
        self.height = self.winfo_height()

        # Basic bindings for the virtual trackball
        self.bind('<Expose>', self.tkExpose)
        self.bind('<Configure>', self.tkExpose)
Exemplo n.º 38
0
    def __init__(self, master, widget, **kwargs):
        Canvas.__init__(self, master, **kwargs)

        self._marks = {'warning': [], 'error': [], 'sep': []}

        self.widget = widget
        self.colors = {'warning': 'orange', 'error': 'red', 'sep': 'blue'}
        self.active_colors = {
            'warning': '#FFC355',
            'error': '#FF5555',
            'sep': '#5555FF'
        }
        self.update_idletasks()
        self._highlight_img = Image.new('RGBA', (1, 1), "#ffffff88")
        self._highlight_photoimg = ImageTk.PhotoImage(self._highlight_img,
                                                      master=self)
        self.highlight = self.create_image(0,
                                           0,
                                           anchor='nw',
                                           image=self._highlight_photoimg)
        self.bind('<1>', self.on_click)
        self.bind('<Map>', self.update_positions)
Exemplo n.º 39
0
    def __init__(self,
                 master=None,
                 *ap,
                 foreground="black",
                 rows,
                 columns,
                 cell,
                 **an):
        """Init screen function"""
        self.foreground = StringVar()
        self.foreground.set(foreground)
        Canvas.__init__(self, master, *ap, **an)

        self.rows = rows
        self.columns = columns
        self.cell_width = cell
        self.cell_height = cell

        self.matrix = []
        for _ in range(self.columns):
            column_arr = ["gray" for _ in range(self.rows)]
            self.matrix.append(column_arr)
        self.rects = {}
Exemplo n.º 40
0
    def __init__(self, parent, controller):
        
        # create canvas
        Canvas.__init__(self,master=parent,scrollregion=(0,0,3000,200))
        self.controller = controller        

        # create subframe
        self.lFrame = ListsFrame(parent=self,controller=self.controller)        
                                
        # create scrollbar        
        self.hBar=Scrollbar(master=parent,orient=HORIZONTAL)    

        # place subframe        
        self.lFrame.pack(fill=BOTH)
        
        # place scrollbar
        self.hBar.pack(side=BOTTOM,fill=X)
        
        # configure scrollbar
        self.hBar.config(command=self.xview)  
                        
        # configure canvas        
        self.config(xscrollcommand=self.hBar.set)                
Exemplo n.º 41
0
 def __init__(self, parent, square: Square) :
     # Init
     Canvas.__init__(self, parent, width=SQUARE_SIZE, height=SQUARE_SIZE)
     self.parent = parent
     # Square attribute
     self.square = square
     self.selected = False
     self.highlighted = False
     # Graphical piece
     self.piece_gui = None
     # Position on the board canvas
     x_position = 1/8 * self.square.get_file()
     y_position = 1 - (1/8 * (self.square.get_rank() + 1))
     self.place(relx=x_position, rely=y_position)
     # Configure square background
     if self.square.get_color() == SquareColor.DARK.value :
         self.base_color = SquareGui.DARK_BG
     else :
         self.base_color = SquareGui.LIGHT_BG
     self.configure(bg=self.base_color)
     # Button bindings
     self.bind("<Button-1>", self.on_left_click)
     self.bind("<Button-3>", self.on_right_click)
Exemplo n.º 42
0
    def __init__(self, master, listaComics=None, session = None, cnf={}, **kw):
        Canvas.__init__(self, master, cnf, **kw)
        self.size = self.size = (int(320 / 2), int(496 / 2))
        self.space = 58
        if session is not None:
            self.session = session
        else:
            self.session = Entidades.Init.Session()
        self.pahThumnails = self.session.query(Setup).first().directorioBase+ os.path.sep +"images"+os.path.sep +"coverIssuesThumbnails"+os.path.sep

        print(self.pahThumnails)

        print(self.size[0])
        self.listaComics = listaComics
        self.thumbnail = []
        self.comicsSelected=[]
        self.tagAndComic = []
        self.halfSize = (int(self.size[0] / 2), int(self.size[1] / 2))
        self.bind("<Button-1>", self.comicClicked)
        self.bind('<Shift-Button-1>', self.multipleComicsClicked)
        self.bind('<Control-Button-1>', self.addComicClicked)

        self.paginaDoblada = Iconos().pilImagePaginaDoblada
        self.cantidadColumnas = 6
Exemplo n.º 43
0
 def __init__(self, master):
     Canvas.__init__(self, master)
     self.initializeComponents()
Exemplo n.º 44
0
 def __init__(self, frame, window, background):
     self.window = window
     Canvas.__init__(self, frame, background=background)
Exemplo n.º 45
0
	def __init__(self):
		Canvas.__init__(self)