Changeset 220

Show
Ignore:
Timestamp:
07/25/2008 12:06:47 PM (4 months ago)
Author:
funkiedamouse
Message:

Changed comments to fit PEP 8 better.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/examples/examplewm.py

    r218 r220  
    1919#    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
    2020 
    21 """ Example PLWM window manager 
     21"""Example PLWM window manager 
    2222 
    2323This example demonstrates basic window manager construction and some of the 
     
    2626 
    2727""" 
    28  
    2928import sys 
    3029import os 
     
    5453               outline.XorOutlineClient, 
    5554               modestatus.ModeFocusedTitleClient): 
    56     """ Example client class 
     55    """Example client class 
    5756 
    5857    This class adds an XOR outline for moving/resizing windows and a hook to 
     
    6362 
    6463    """ 
    65  
    6664    # Put a frame around all client windows 
    6765    window_proxy_class = frame.FrameProxy 
     
    7977               views.XMW_ViewHandler, 
    8078               modestatus.ModeFocusedTitleScreen): 
    81     """ Example screen class 
     79    """Example screen class 
    8280 
    8381    This class adds support for colors(FIXME), views, and a mode window, and 
     
    8785 
    8886    """ 
    89  
    9087    view_always_visible_clients = Or(name('XClock'), 
    9188                                     name('XBiff'), 
     
    9390 
    9491class WMConfig: 
    95     """ Example window manager configuration class 
     92    """Example window manager configuration class 
    9693 
    9794    Installs the BasicKeys key map into the window manager. 
     
    10097 
    10198    """ 
    102  
    10399    def __wm_init__(self): 
    104100        # Install the basic key map 
     
    114110           inspect.InspectServer, 
    115111           WMConfig): 
    116     """ Example window manager class 
     112    """Example window manager class 
    117113 
    118114    This class sets up the configuration for the window manager, including font 
     
    122118 
    123119    """ 
    124  
    125120    client_class = MyClient 
    126121    screen_class = MyScreen 
     
    128123 
    129124class BasicKeys(keys.KeyHandler): 
    130     """ Basic key bindings 
     125    """Basic key bindings 
    131126 
    132127    This class defines all key-bindings for the example window manager. 
    133128 
    134129    """ 
    135  
    136130    def F1(self, event): 
    137         """ Find a view containing an XTerm. 
    138         """ 
    139  
     131        """Find a view containing an XTerm.""" 
    140132        self.wm.current_screen.view_find_with_client(name('XTerm')) 
    141133 
    142134    def S_F1(self, event): 
    143         """ Start an XTerm. 
    144         """ 
    145  
     135        """Start an XTerm.""" 
    146136        self.wm.system('xterm -geometry 80x50+200+100') 
    147137 
    148138    def C_S_F1(self, event): 
    149         """ Start an XTerm in a new view. 
    150         """ 
    151  
     139        """Start an XTerm in a new view.""" 
    152140        self.wm.current_screen.view_new() 
    153141        self.wm.system('xterm -geometry 80x50+200+100') 
    154142 
    155143    def F2(self, event): 
    156         """ Find a view containing an Emacs window. 
    157         """ 
    158  
     144        """Find a view containing an Emacs window.""" 
    159145        self.wm.current_screen.view_find_with_client(name('Emacs')) 
    160146 
    161147    def S_F2(self, event): 
    162         """ Start Emacs. 
    163         """ 
    164  
     148        """Start Emacs.""" 
    165149        self.wm.system('emacs') 
    166150 
    167151    def C_S_F2(self, event): 
    168         """ Start Emacs in a new view. 
    169         """ 
    170  
     152        """Start Emacs in a new view.""" 
    171153        self.wm.current_screen.view_new() 
    172154        self.wm.system('emacs') 
    173155 
    174156    def F3(self, event): 
    175         """ Find a view containing a Netscape window. 
    176         """ 
    177  
     157        """Find a view containing a Netscape window.""" 
    178158        self.wm.current_screen.view_find_with_client(name('Netscape')) 
    179159 
    180160    def S_F3(self, event): 
    181         """ Start Netscape. 
    182         """ 
    183  
     161        """Start Netscape.""" 
    184162        self.wm.system('netscape') 
    185163 
    186164    def C_S_F3(self, event): 
    187         """ Start Netscape in a new view. 
    188         """ 
    189  
     165        """Start Netscape in a new view.""" 
    190166        self.wm.current_screen.view_new() 
    191167        self.wm.system('netscape') 
    192168 
    193169    def F5(self, event): 
    194         """ Switch to the next view with the tag 'F5'. 
    195         """ 
    196  
     170        """Switch to the next view with the tag 'F5'.""" 
    197171        self.wm.current_screen.view_find_tag('F5') 
    198172 
    199173    def S_F5(self, event): 
    200         """ Set the current view's tag to 'F5'. 
    201         """ 
    202  
     174        """Set the current view's tag to 'F5'.""" 
    203175        self.wm.current_screen.view_tag('F5') 
    204176 
    205177    def F6(self, event): 
    206         """ Switch to the next view with the tag 'F6'. 
    207         """ 
    208  
     178        """Switch to the next view with the tag 'F6'.""" 
    209179        self.wm.current_screen.view_find_tag('F6') 
    210180 
    211181    def S_F6(self, event): 
    212         """ Set the current view's tag to 'F6'. 
    213         """ 
    214  
     182        """Set the current view's tag to 'F6'.""" 
    215183        self.wm.current_screen.view_tag('F6') 
    216184 
    217185    def F7(self, event): 
    218         """ Switch to the next view with the tag 'F7'. 
    219         """ 
    220  
     186        """Switch to the next view with the tag 'F7'.""" 
    221187        self.wm.current_screen.view_find_tag('F7') 
    222188 
    223189    def S_F7(self, event): 
    224         """ Set the current view's tag to 'F7'. 
    225         """ 
    226  
     190        """Set the current view's tag to 'F7'.""" 
    227191        self.wm.current_screen.view_tag('F7') 
    228192 
    229193    def F8(self, event): 
    230         """ Switch to the next view with the tag 'F8'. 
    231         """ 
    232  
     194        """Switch to the next view with the tag 'F8'.""" 
    233195        self.wm.current_screen.view_find_tag('F8') 
    234196 
    235197    def S_F8(self, event): 
    236         """ Set the current view's tag to 'F8'. 
    237         """ 
    238  
     198        """Set the current view's tag to 'F8'.""" 
    239199        self.wm.current_screen.view_tag('F8') 
    240200 
    241201    # Simulate mouse clicks 
    242202    def Any_F9(self, evt): 
    243         """ Simulate a primary (usually, left) mouse button click. 
     203        """Simulate a primary (usually, left) mouse button click.""" 
     204        self.wm.fake_button_click(1) 
     205 
     206    def Any_F10(self, evt): 
     207        """Simulate a secondary (usually, right) mouse button click.""" 
     208        self.wm.fake_button_click(2) 
     209 
     210    def Any_F11(self, evt): 
     211        """Simulate a tertiary (usually, middle) mouse button click.""" 
     212        self.wm.fake_button_click(3) 
     213 
     214 
     215    def F12(self, evt): 
     216        """Toggle inspect mode.""" 
     217        self.wm.inspect_toggle() 
     218 
     219    def S_F12(self, evt): 
     220        """Toggle inspect mode, forcing if needed.""" 
     221        self.wm.inspect_toggle(force = 1) 
     222 
     223    def S_Pause(self, evt): 
     224        """Drop all keygrabs until Scroll_Lock is pressed again. 
     225 
     226        Allows clients to recieve keys used by plwm. 
     227 
    244228        """ 
    245  
    246         self.wm.fake_button_click(1) 
    247  
    248     def Any_F10(self, evt): 
    249         """ Simulate a secondary (usually, right) mouse button click. 
    250         """ 
    251  
    252         self.wm.fake_button_click(2) 
    253  
    254     def Any_F11(self, evt): 
    255         """ Simulate a tertiary (usually, middle) mouse button click. 
    256         """ 
    257  
    258         self.wm.fake_button_click(3) 
    259  
    260  
    261     def F12(self, evt): 
    262         """ Toggle inspect mode. 
    263         """ 
    264  
    265         self.wm.inspect_toggle() 
    266  
    267     def S_F12(self, evt): 
    268         """ Toggle inspect mode, forcing if needed. 
    269         """ 
    270  
    271         self.wm.inspect_toggle(force = 1) 
    272  
    273     def S_Pause(self, evt): 
    274         """ Drop all keygrabs until Scroll_Lock is pressed again. 
    275  
    276         Allows clients to recieve keys used by plwm. 
    277         """ 
    278  
    279229        wmanager.debug('keys', 'dropping keygrabs temporarily') 
    280230 
     
    287237 
    288238    def KP_Begin(self, event): 
    289         """ Start moving / resizing the current window. 
    290         """ 
    291  
     239        """Start moving / resizing the current window.""" 
    292240        MyMoveResizeKeys(self, event) 
    293241 
    294242 
    295243    def C_Tab(self, event): 
    296         """ Cycle through minimized windows. 
    297         """ 
    298  
     244        """Cycle through minimized windows.""" 
    299245        CycleUMKeys(self, event) 
    300246 
    301247    def KP_Insert(self, event): 
    302         """ Iconify the current window. 
    303         """ 
    304  
     248        """Iconify the current window.""" 
    305249        wmanager.debug('keys', 'Iconifying') 
    306250        if self.wm.current_client: 
     
    308252 
    309253    def KP_Subtract(self, event): 
    310         """ Switch to the previous view. 
    311         """ 
    312  
     254        """Switch to the previous view.""" 
    313255        wmanager.debug('keys', 'Prev view') 
    314256        self.wm.current_screen.view_prev() 
    315257 
    316258    def KP_Add(self, event): 
    317         """ Switch to the next view. 
    318         """ 
    319  
     259        """Switch to the next view.""" 
    320260        wmanager.debug('keys', 'Next view') 
    321261        self.wm.current_screen.view_next() 
    322262 
    323263    def C_KP_Add(self, event): 
    324         """ Create a new view. 
    325         """ 
    326  
     264        """Create a new view.""" 
    327265        wmanager.debug('keys', 'New view') 
    328266        self.wm.current_screen.view_new() 
    329267 
    330268    def KP_Left(self, event): 
    331         """ Move the pointer to the left. 
    332         """ 
    333  
     269        """Move the pointer to the left.""" 
    334270        self.wm.display.warp_pointer(-delta.get(event.time), 0) 
    335271 
    336272    def KP_Right(self, event): 
    337         """ Move the pointer to the right. 
    338         """ 
    339  
     273        """Move the pointer to the right.""" 
    340274        self.wm.display.warp_pointer(delta.get(event.time), 0) 
    341275 
    342276    def KP_Up(self, event): 
    343         """ Move the pointer up. 
    344         """ 
    345  
     277        """Move the pointer up.""" 
    346278        self.wm.display.warp_pointer(0, -delta.get(event.time)) 
    347279 
    348280    def KP_Down(self, event): 
    349         """ Move the pointer down. 
    350         """ 
    351  
     281        """Move the pointer down.""" 
    352282        self.wm.display.warp_pointer(0, delta.get(event.time)) 
    353283 
    354284    def KP_Home(self, event): 
    355         """ Move the pointer up and to the left. 
    356         """ 
    357  
     285        """Move the pointer up and to the left.""" 
    358286        d = delta.get(event.time) 
    359287        self.wm.display.warp_pointer(-d, -d) 
    360288 
    361289    def KP_End(self, event): 
    362         """ Move the pointer down and to the left. 
    363         """ 
    364  
     290        """Move the pointer down and to the left.""" 
    365291        d = delta.get(event.time) 
    366292        self.wm.display.warp_pointer(-d, d) 
    367293 
    368294    def KP_Prior(self, event): 
    369         """ Move the pointer up and to the right. 
    370         """ 
    371  
     295        """Move the pointer up and to the right.""" 
    372296        d = delta.get(event.time) 
    373297        self.wm.display.warp_pointer(d, -d) 
    374298 
    375299    def KP_Next(self, event): 
    376         """ Move the pointer down and to the right. 
    377         """ 
    378  
     300        """Move the pointer down and to the right.""" 
    379301        d = delta.get(event.time) 
    380302        self.wm.display.warp_pointer(d, d) 
    381303 
    382304    def KP_Enter(self, event): 
    383         """ Raise or lower the current window. 
    384         """ 
    385  
     305        """Raise or lower the current window.""" 
    386306        if self.wm.current_client: 
    387307            self.wm.current_client.raiselower() 
     
    391311 
    392312    def C_KP_Subtract(self, event): 
    393         """ Lock the screen with xlock. 
    394         """ 
    395  
     313        """Lock the screen with xlock.""" 
    396314        self.wm.system('xlock -mode blank') 
    397315 
    398316    def C_M_Escape(self, event): 
    399         """ Quit the window manager. 
    400         """ 
    401  
     317        """Quit the window manager.""" 
    402318        self.wm.quit() 
    403319 
    404320    def C_KP_Delete(self, event): 
    405         """ Close the current window. 
    406         """ 
    407  
     321        """Close the current window.""" 
    408322        if self.wm.current_client: 
    409323            self.wm.current_client.delete(1) 
    410324 
    411325    def C_S_KP_Delete(self, event): 
    412         """ Kill the current client. 
    413         """ 
    414  
     326        """Kill the current client.""" 
    415327        if self.wm.current_client: 
    416328            self.wm.current_client.destroy() 
    417329 
    418330    def C_KP_Left(self, event): 
    419         """ Focus the next window to the left of the current one. 
    420         """ 
    421  
     331        """Focus the next window to the left of the current one.""" 
    422332        self.wm.move_focus(focus.MOVE_LEFT) 
    423333 
    424334    def C_KP_Right(self, event): 
    425         """ Focus the next window to the right of the current one. 
    426         """ 
    427  
     335        """Focus the next window to the right of the current one.""" 
    428336        self.wm.move_focus(focus.MOVE_RIGHT) 
    429337 
    430338    def C_KP_Up(self, event): 
    431         """ Focus the next window above the current one. 
    432         """ 
    433  
     339        """Focus the next window above the current one.""" 
    434340        self.wm.move_focus(focus.MOVE_UP) 
    435341 
    436342    def C_KP_Down(self, event): 
    437         """ Focus the next window below the current one. 
    438         """ 
    439  
     343        """Focus the next window below the current one.""" 
    440344        self.wm.move_focus(focus.MOVE_DOWN) 
    441345 
    442346    def C_less(self, event): 
    443         """ Focus the next window to the left of the current one. 
    444         """ 
    445  
     347        """Focus the next window to the left of the current one.""" 
    446348        self.wm.move_focus(focus.MOVE_LEFT) 
    447349 
    448350    def C_S_less(self, event): 
    449         """ Focus the next window to the right of the current one. 
    450         """ 
    451  
     351        """Focus the next window to the right of the current one.""" 
    452352        self.wm.move_focus(focus.MOVE_RIGHT) 
    453353 
    454354 
    455355class BypassHandler(keys.KeyHandler): 
    456     """ Surrogate key handler to bypass the window manager's key bindings. 
     356    """Surrogate key handler to bypass the window manager's key bindings. 
    457357 
    458358    Allows clients to receive key presses normally handled by the WM. 
    459359 
    460360    """ 
    461  
    462361    propagate_keys = 0 
    463362 
     
    470369 
    471370    def Pause(self, evt): 
    472         """ Restore normal key bindings. 
    473         """ 
    474  
     371        """Restore normal key bindings.""" 
    475372        wmanager.debug('keys', 'reinstalling keygrabs') 
    476373 
     
    492389 
    493390class MyMoveResizeKeys(MoveResizeKeys): 
    494     """ Keys for moving and resizing the current window. 
    495     """ 
    496  
     391    """Keys for moving and resizing the current window.""" 
    497392    KP_Left  = MoveResizeKeys._move_w 
    498393    KP_Right = MoveResizeKeys._move_e 
     
    531426 
    532427class CycleUMKeys(CycleKeys): 
    533     """ Keys to cycle through all iconified windows. 
    534     """ 
    535  
     428    """Keys to cycle through all iconified windows.""" 
    536429    _cycle_filter = iconified 
    537430