Skip to content

Instantly share code, notes, and snippets.

@Dayof
Last active August 18, 2017 07:20
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 Dayof/3f47ea4401828326efff82775a5eb255 to your computer and use it in GitHub Desktop.
Save Dayof/3f47ea4401828326efff82775a5eb255 to your computer and use it in GitHub Desktop.
import toga
class StartApp(toga.App):
def startup(self):
# Main window
self.main_window = toga.MainWindow(self.name)
self.main_window.app = self
# Tree data source
# A dictionary data source construction need to following the format:
# { str : {} or str }
tree_data = {
'root1' : {},
'root2': {
'sub1_root2' : {},
'sub2_root2' : 'sub2_sub1_root2'
},
'root3': 'sub1_root3',
}
# Tree widget from Toga
self.tree = toga.Tree(['Navigate'], data=tree_data)
# Add the main widget inside of the main application
self.main_window.content = self.tree
# Show the application
self.main_window.show()
def main():
# Start the application with the title and the name of the organization
app = StartApp('Test Tree, using dictionary data source construction',
'org.pybee.test')
app.main_loop()
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment