Last active
August 18, 2017 07:24
-
-
Save Dayof/cd11e9ec0150251d392461d597e94530 to your computer and use it in GitHub Desktop.
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 | |
class StartApp(toga.App): | |
def startup(self): | |
# Main window | |
self.main_window = toga.MainWindow(self.name) | |
self.main_window.app = self | |
# Tree widget from Toga | |
self.tree = toga.Tree(['Navigate']) | |
# Add top level nodes on the tree | |
self.tree.insert('root1') | |
self.tree.insert('root2') | |
r3 = self.tree.insert('root3') | |
# Children nodes | |
sub_r3 = self.tree.insert('sub_r3', r3) | |
self.tree.insert('sub_sub_r3', sub_r3) | |
# Add icons in some nodes | |
r3.icon = 'icon.png' | |
sub_r3.icon = 'icon.png' | |
# Update the tree layout | |
self.tree.apply_layout() | |
# 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 icons', '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