GCodegraphics LoadProgram

More
01 Nov 2019 18:30 #149383 by satiowadahc
In gcode_graphics.py (I'm using 2.8, looks like its on master as well)
github.com/LinuxCNC/linuxcnc/blob/master...ts/gcode_graphics.py
```
def load_program(self, g, fname):
LOG.debug('load the display: {}'.format(fname))
self._reload_filename = fname
self.load(fname)
STATUS.emit('graphics-gcode-properties',self.gcode_properties)
```

Whats the purpose of 'g'?

Please Log in or Create an account to join the conversation.

More
01 Nov 2019 21:54 #149393 by cmorley
Replied by cmorley on topic GCodegraphics LoadProgram
load_program is called by the STATUS message system which uses GObject.
By this command:
 STATUS.connect('file-loaded', self.load_program) 

By default GObject includes the object that sent the message.
The g is there so the function signature agrees with message GObjects sends.

Sometimes you see that the object is stripped off before sending the function with this style:
STATUS.connect('file-loaded', lambda: g,f: self.load_program(f)) 
Often because this function will be called from a non-GObject function (saves you from adding None to cover for the g.

Chris

Please Log in or Create an account to join the conversation.

Time to create page: 0.074 seconds
Powered by Kunena Forum