""" Documentation for Style - Simple Python GUI style class 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 default 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. Subclasses of basic class Style will be used to diffentiate between the styles for each widget. Modifying widget class attributes affects new widgets (used as default values) as well as all uncopied styles.s 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 defaultStyle import * class Style(dict): VALID_KEYS = {} default_font = pygame.font.SysFont("Arial", 12) class LabelStyle(Style): "" ALIAS_KEY_MAP = { 'font_color':'font-color', 'font':'font', 'autosize':'autosize', 'antialias':'antialias', 'border_width':'border-width', 'border_color':'border-color', 'wordwrap':'wordwrap'} class ButtonStyle(Style): "" ALIAS_KEY_MAP = { 'font':'font', 'font_color':'font-color', 'left_normal':'left-normal', 'middle_normal':'middle-normal', 'right_normal':'right-normal'} class WindowStyle(Style): "" ALIAS_KEY_MAP = { 'font':'font', 'font_color':'font-color', 'bg_color':'bg-color', 'shaded_bg_color':'shaded-bg-color', 'shaded_font_color':'shaded-font-color', 'border_width':'border-width', 'border_color':'border-color', 'offset':'offset', 'close_button_style':'close-button-style', 'shade_button_style':'shade-button-style'} class TextBoxStyle(Style): "" ALIAS_KEY_MAP = { 'font':'font', 'font_color':'font-color', 'bg_color_normal':'bg-color-normal', 'bg_color_focus':'bg-color-focus', 'border_color_normal':'border-color-normal', 'border_color_focus':'border-color-focus', 'border_width':'border-width', 'appearence':'appearence', 'antialias':'antialias', 'offset':'offset'} class CheckBoxStyle(Style): "" ALIAS_KEY_MAP = { 'font':'font', 'font_color':'font-color', 'disabled_font_color':'disabled-font-color', 'antialias':'antialias', 'autosize':'autosize', 'wordwrap':'wordwrap', 'border_width':'border-width', 'bordercolor':'border-color', 'border_color':'border-color', 'spacing':'spacing' 'unchecked_normal':'unchecked-normal', 'unchecked_over':'unchecked-over', 'unchecked_down':'unchecked-down', 'unchecked_disabled':'unchecked-disabled', 'checked_normal':'checked-normal', 'checked_over':'checked-over', 'checked_down':'checked-down', 'checked_disabled':'checked-disabled'} class OptionBoxStyle(Style): "" ALIAS_KEY_MAP = { 'font':'font', 'font_color':'font-color', 'disabled_font_color':'disabled-font-color', 'antialias':'antialias', 'autosize':'autosize', 'wordwrap':'wordwrap', 'border_width':'border-width', 'bordercolor':'border-color', 'border_color':'border-color', 'spacing':'spacing' 'unchecked_normal':'unchecked-normal', 'unchecked_over':'unchecked-over', 'unchecked_down':'unchecked-down', 'checked_normal':'checked-normal', 'checked_over':'checked-over', 'checked_down':'checked-down', 'disabled':'disabled'} class ListBoxStyle(Style): "" ALIAS_KEY_MAP = { 'font':'font', 'font_color_over':'font-color-over', 'font_color_selected':'font-color-selected', 'bg_color':'bg-color', 'bg_color_selected':'bg-color-selected', 'item_height':'item-height', 'padding':'padding', 'antialias':'antialias'} class ComboBoxStyle(Style): "" ALIAS_KEY_MAP = { 'font':'font', 'font_color':'font-color', 'antialias':'antialias', 'border_width':'border-width', 'bordercolor':'border-color', 'border_color':'border-color', 'normal':'checked-normal', 'over':'checked-over', 'down':'checked-down', 'disabled':'checked-disabled'}