Created
August 5, 2018 04:38
-
-
Save Phuket2/98c45711aee984707bf799c79273c28d to your computer and use it in GitHub Desktop.
Recreate table cursor in toga
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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