Skip to content

Instantly share code, notes, and snippets.

@Phuket2
Created August 5, 2018 04:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Phuket2/98c45711aee984707bf799c79273c28d to your computer and use it in GitHub Desktop.
Save Phuket2/98c45711aee984707bf799c79273c28d to your computer and use it in GitHub Desktop.
Recreate table cursor in toga
import toga
from toga.style.pack import *
def table_callback(widget, **kwargs):
x = kwargs.get('row')._source
print(dir(x))
class MyApp(toga.App):
def startup(self):
self.main_window = toga.MainWindow(title=self.name)
data = [('One', 'Two'), ('Three', 'Four'), ('Five', 'Six')]
vb = toga.Box()
st = Pack(padding_top=10, padding_left=25, padding_right=25, height=300, width=100, direction=ROW)
tb = toga.Table(['Heading 1', 'Heading 2'],
id=None, style=st,
data=data, accessors=None, multiple_select=False,
on_select=table_callback, factory=None)
vb.add(tb)
self.main_window.content = vb
self.main_window.show()
def main():
return MyApp('Table Example', 'org.pybee.graze')
if __name__ == '__main__':
print(toga.__version__)
main().main_loop()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment