Last active
July 13, 2017 08:33
-
-
Save Dayof/37363d46c08ea2b36794b6ad2b88a54a 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): | |
self.main_window = toga.MainWindow(self.name) | |
self.main_window.app = self | |
self.tree = toga.Tree(['Navigate']) | |
self.root_one_id = self.tree.insert(None, None, 'root') | |
self.root_two_id = self.tree.insert(None, None, 'inner_root') | |
self.sub_root_two_id = self.tree.insert(self.root_two_id, None, | |
'inner_root2') | |
button_f = toga.Button('Set Icon Root 1', | |
on_press=self.callbackIconOne) | |
button_s = toga.Button('Set Icon Root 2', | |
on_press=self.callbackIconTwo) | |
button_t = toga.Button('Set Icon Sub Root 2', | |
on_press=self.callbackIconThree) | |
button_all = toga.Button('Set Icon Tree', | |
on_press=self.callbackIconAll) | |
self.box = toga.Box() | |
self.box.add(button_f) | |
self.box.add(button_s) | |
self.box.add(button_t) | |
self.box.add(button_all) | |
container = toga.SplitContainer() | |
container.content = [self.tree, self.box] | |
self.main_window.content = container | |
self.main_window.show() | |
def callbackIconOne(self, event): | |
self.tree.set_icon('icon.png', self.root_one_id) | |
def callbackIconTwo(self, event): | |
self.tree.set_icon('icon.png', self.root_two_id) | |
def callbackIconThree(self, event): | |
self.tree.set_icon('icon.png', self.sub_root_two_id) | |
def callbackIconAll(self, event): | |
self.tree.set_icon('icon.png') | |
def main(): | |
app = StartApp('Tree Test', '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