<commit_before>#!/usr/bin/env python3

import glooey
import pyglet
import autoprop

# Import everything from glooey into this namespace.  We'll overwrite the 
# widgets we want to overwrite and everything else will be directly available.
from glooey import *

# Create a resource loader that knows where the Golden assets are stored.
from glooey.themes import ResourceLoader
assets = ResourceLoader('golden')
assets.add_font('fonts/m5x7.ttf')

@autoprop
class Gui(glooey.Gui):
    custom_cursor = 'gold'
        
    def __init__(self, window, *, batch=None, cursor=None):
        super().__init__(window, batch)
        self.set_cursor(cursor or self.custom_cursor)

    def set_cursor(self, cursor):
        try:
            super().set_cursor(
                    assets.image(f'cursors/{cursor}.png'),
                    assets.yaml(f'cursors/hotspots.yml')[cursor],
            )
        except pyglet.resource.ResourceNotFoundException:
            raise UsageError(f"The Golden theme doesn't have a cursor named '{cursor}'")


class Label(glooey.Label):
    custom_font_name = 'm5x7'
    custom_color = '#deeed6'

class Form(glooey.Form):

    class Label(glooey.EditableLabel):
        custom_font_name = 'm5x7'
        custom_color = '#deeed6'
        custom_selection_color = '#595652'
        custom_padding = 2
        custom_left_padding = 4

    class Base(glooey.Background):
        custom_top = assets.texture('frames/mini/top_left.png')
        custom_left = assets.texture('frames/mini/top_left.png')
        custom_top_left = assets.image('frames/mini/top_left.png')
        custom_bottom = assets.texture('frames/mini/bottom_right.png')
        custom_right = assets.texture('frames/mini/bottom_right.png')
        custom_bottom_right = assets.image('frames/mini/bottom_right.png')


@autoprop
class RoundButton(glooey.Button):
    custom_color = 'red'
    custom_icon = None

    def __init__(self, color=None, icon=None):
        super().__init__()
        self.color = color or self.custom_color
        self.icon = icon or self.custom_icon

    def get_color(self):
        return self._color

    def set_color(self, color):
        try:
            self._color = color
            self.set_background(
                    base_image=assets.image(f'buttons/round/{color}_base.png'),
                    over_image=assets.image(f'buttons/round/{color}_over.png'),
                    down_image=assets.image(f'buttons/round/{color}_down.png'),
            )
        except pyglet.resource.ResourceNotFoundException:
            raise UsageError(f"the Golden theme doesn't have a '{color}' button.")

    def get_icon(self):
        return self._icon

    def set_icon(self, name):
        if name is None:
            return self.del_image()
        try:
            self._icon = name
            self.set_image(
                    assets.image(f'buttons/round/icon_{name}.png'),
            )
        except pyglet.resource.ResourceNotFoundException:
            raise UsageError(f"the Golden theme doesn't have a '{name}' icon.")

    def del_icon(self):
        self.del_image()


@autoprop
class BasicButton(glooey.Button):

    class Label(Label):
        custom_horz_padding = 12
        custom_bottom_padding = 3
        custom_alignment = 'center'

    class Base(glooey.Background):
        custom_left=assets.image(f'buttons/basic/base_left.png')
        custom_center=assets.texture('buttons/basic/base_center.png')
        custom_right=assets.image(f'buttons/basic/base_right.png')

    class Down(glooey.Background):
        custom_left=assets.image(f'buttons/basic/down_left.png')
        custom_center=assets.texture('buttons/basic/down_center.png')
        custom_right=assets.image(f'buttons/basic/down_right.png')


@autoprop
class FancyButton(glooey.Button):

    class Label(glooey.Label):
        # "Wellmere Sans" is proprietary, so it cannot be included with glooey.
        custom_font_name = 'wellmere_sans_bold'
        custom_color = '#140c1c'
        custom_alignment = 'center'
        custom_horz_padding = 30<commit_msg>Restyle the FancyButton widget in the golden theme.<commit_after>#!/usr/bin/env python3

import glooey
import pyglet
import autoprop

# Import everything from glooey into this namespace.  We'll overwrite the 
# widgets we want to overwrite and everything else will be directly available.
from glooey import *

# Create a resource loader that knows where the assets for this theme are 
# stored.
from glooey.themes import ResourceLoader
assets = ResourceLoader('golden')
assets.add_font('fonts/m5x7.ttf')

@autoprop
class Gui(glooey.Gui):
    custom_cursor = 'gold'
        
    def __init__(self, window, *, batch=None, cursor=None):
        super().__init__(window, batch)
        self.set_cursor(cursor or self.custom_cursor)

    def set_cursor(self, cursor):
        try:
            super().set_cursor(
                    assets.image(f'cursors/{cursor}.png'),
                    assets.yaml(f'cursors/hotspots.yml')[cursor],
            )
        except pyglet.resource.ResourceNotFoundException:
            raise UsageError(f"The Golden theme doesn't have a cursor named '{cursor}'")


class Label(glooey.Label):
    custom_font_name = 'm5x7'
    custom_color = '#deeed6'

class Form(glooey.Form):

    class Label(glooey.EditableLabel):
        custom_font_name = 'm5x7'
        custom_color = '#deeed6'
        custom_selection_color = '#595652'
        custom_padding = 2
        custom_left_padding = 4

    class Base(glooey.Background):
        custom_top = assets.texture('frames/mini/top_left.png')
        custom_left = assets.texture('frames/mini/top_left.png')
        custom_top_left = assets.image('frames/mini/top_left.png')
        custom_bottom = assets.texture('frames/mini/bottom_right.png')
        custom_right = assets.texture('frames/mini/bottom_right.png')
        custom_bottom_right = assets.image('frames/mini/bottom_right.png')


@autoprop
class RoundButton(glooey.Button):
    custom_color = 'red'
    custom_icon = None

    def __init__(self, color=None, icon=None):
        super().__init__()
        self.color = color or self.custom_color
        self.icon = icon or self.custom_icon

    def get_color(self):
        return self._color

    def set_color(self, color):
        try:
            self._color = color
            self.set_background(
                    base_image=assets.image(f'buttons/round/{color}_base.png'),
                    over_image=assets.image(f'buttons/round/{color}_over.png'),
                    down_image=assets.image(f'buttons/round/{color}_down.png'),
            )
        except pyglet.resource.ResourceNotFoundException:
            raise UsageError(f"the Golden theme doesn't have a '{color}' button.")

    def get_icon(self):
        return self._icon

    def set_icon(self, name):
        if name is None:
            return self.del_image()
        try:
            self._icon = name
            self.set_image(
                    assets.image(f'buttons/round/icon_{name}.png'),
            )
        except pyglet.resource.ResourceNotFoundException:
            raise UsageError(f"the Golden theme doesn't have a '{name}' icon.")

    def del_icon(self):
        self.del_image()


@autoprop
class BasicButton(glooey.Button):

    class Label(Label):
        custom_horz_padding = 12
        custom_bottom_padding = 3
        custom_alignment = 'center'

    class Base(glooey.Background):
        custom_left=assets.image(f'buttons/basic/base_left.png')
        custom_center=assets.texture('buttons/basic/base_center.png')
        custom_right=assets.image(f'buttons/basic/base_right.png')

    class Down(glooey.Background):
        custom_left=assets.image(f'buttons/basic/down_left.png')
        custom_center=assets.texture('buttons/basic/down_center.png')
        custom_right=assets.image(f'buttons/basic/down_right.png')


@autoprop
class FancyButton(glooey.Button):

    class Label(Label):
        custom_color = '#140c1c'
        custom_alignment = 'center'
        custom_horz_padding = 30
        custom_font_size = 12
{'fraction_non_alphanumeric': 0.10469135802469136, 'fraction_numerical': 0.006666666666666667, 'mean_word_length': 2.7245977011494253, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '776538', 'n_tokens_mistral': 2536, 'n_tokens_neox': 2378, 'n_words': 482}