Mastering Python Design Patterns by Ayeva Kamon; Kasampalis Sakis;

Mastering Python Design Patterns by Ayeva Kamon; Kasampalis Sakis;

Author:Ayeva, Kamon; Kasampalis, Sakis;
Language: eng
Format: epub
Publisher: Packt Publishing, Limited
Published: 2018-08-31T07:41:46+00:00


def handle_default(self, event):

print(f'MainWindow Default: {event}')

SendDialog can handle only the paint event:

class SendDialog(Widget):

def handle_paint(self, event):

print(f'SendDialog: {event}')

Finally, MsgText can handle only the down event:

class MsgText(Widget):

def handle_down(self, event):

print(f'MsgText: {event}')

The main() function shows how we can create a few widgets and events, and how the widgets react to those events. All events are sent to all the widgets. Note the parent relationship of each widget. The sd object (an instance of SendDialog) has as its parent the mw object (an instance of MainWindow). However, not all objects need to have a parent that is an instance of MainWindow. For example, the msg object (an instance of MsgText) has the sd object as a parent:

def main():

mw = MainWindow()

sd = SendDialog(mw)

msg = MsgText(sd)



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.