""" Documentation for egui - Simple Python GUI extension developer: Michael Schneider start development: 07th Dez. 2008 intention ========= The objective of this module is to provide a simpler handling and more generic approach in terms of an advanced styles management. Style classes ------------- In the original SPG package, all styles are original dictionaries. That is a good way to keep things very simple, but it denies the real power of Pythons class extension capabilities (like callable instances). 1. Subclassing will be used to build up a hierarchy, simulating groups of similar Styles. For example a special style for all widgets in a certain window that would use the same background color. Afterwards you can affect all widgets' attributes by modifying only the class-attributes of the subclass instead of all instances' attributes. 2. There will be a config-method that can be used to configure the style instance, setting all attributes at once instead of updating the attributes one-by-one. This comes similar to the Tkinter widget configuration. Attributes containing hyphens will be represented by their equivalents with the hyphens replaced by underscores. example: test.config(border_width=3) # setting the border-width of style named 'test' 3. When a Style is instanciated, the given keyword-arguments are directly passed to the new instance's config method. This results in a new instance of the desired Style-Class with customized attributes. 4. To change the appearance of an individual instance, you can use the config method or direct attribute assignment. To make it look like its basic style (= reset the individual look), just delete the customized attribute from the instance. This will not trash your style (all attributes must be contained), but dispose the individual instance name and use the class-attribute again. 5. The createXxxStyle-functions are now included as class-methods of Style. The method name will be simplified to the xxx indicating the new widget. Return value will be a new subclass of the current class, which must be instanciated for use as widget-style arguments. """ from gui import * import os class Style(dict): path = os.path.dirname(__file__) #Surface Loading button_surf = pygame.image.load(os.path.join(path,'art/button.png')).convert_alpha() close_surf = pygame.image.load(os.path.join(path,'art/closebutton.png')).convert_alpha() shade_surf = pygame.image.load(os.path.join(path,'art/shadebutton.png')).convert_alpha() check_surf = pygame.image.load(os.path.join(path,'art/checkbox.png')).convert_alpha() option_surf = pygame.image.load(os.path.join(path,'art/optionbox.png')).convert_alpha() combo_surf = pygame.image.load(os.path.join(path,'art/combobox.png')).convert_alpha() default_font = pygame.font.SysFont("Arial", 12) def button(cls, font=default_font, fontcolor=(0,0,0), surface=button_surf, spaces=(4,1,4,4,1,4,4,1,4,4,1,4)): new_button_style = createButtonStyle(font, fontcolor, surface, *spaces) class NewButton(cls): """Button subclass of %s""" % repr(cls) NewButton.update(new_button_style) return NewButton