On Thu, 21 Dec 2017 16:31:11 -0800 T C <tsc.v...@gmail.com> wrote: > That clears it up a lot - I'm looking forward to the upcomming > snippet, though!
Here's some code that adds a `get-db-stuff` command to Leo, which can be run with Alt-X. ---cut here--- from leo.core.leoQt import QtWidgets class GetDBStuff(QtWidgets.QWidget): def __init__(self, *args, **kwargs): self.c = kwargs['c'] del kwargs['c'] super(GetDBStuff, self).__init__(*args, **kwargs) self.setLayout(QtWidgets.QVBoxLayout()) buttonA = QtWidgets.QPushButton('Pick File') buttonB = QtWidgets.QPushButton('Run action on file') self.layout().addWidget(buttonA) self.layout().addWidget(buttonB) buttonA.clicked.connect(self.callback_A) buttonB.clicked.connect(self.callback_B) self.label = QtWidgets.QLabel("<file name>") self.layout().addWidget(self.label) def callback_A(self, clicked): g.es('A') filepath = g.app.gui.runOpenFileDialog(c, "Select a file", []) self.label.setText(filepath) def callback_B(self, clicked): g.es('B') filepath = self.label.text() # do stuff here with self.c, filepath, etc. node = c.p.insertAfter() node.h = 'DB tables' node.b = "Tables for %s" % filepath self.c.redraw() self.close() @g.command('get-db-stuff') def get_db_stuff(event): gds = GetDBStuff(c=c) gds.show() # without this persistant reference gds gets garbage collected c.__gds = gds ---cut here--- Cheers -Terry -- You received this message because you are subscribed to the Google Groups "leo-editor" group. To unsubscribe from this group and stop receiving emails from it, send an email to leo-editor+unsubscr...@googlegroups.com. To post to this group, send email to leo-editor@googlegroups.com. Visit this group at https://groups.google.com/group/leo-editor. For more options, visit https://groups.google.com/d/optout.