Skip to content

Instantly share code, notes, and snippets.

@stevemolloy
Created September 24, 2017 20:49
Show Gist options
  • Save stevemolloy/1ff2d8d7f43aae7079f619db1e7bcb0c to your computer and use it in GitHub Desktop.
Save stevemolloy/1ff2d8d7f43aae7079f619db1e7bcb0c to your computer and use it in GitHub Desktop.
Initial attempt to make a window with Toga
import toga
from colosseum import CSS
class Duvet(toga.App):
def startup(self):
main_window = toga.Window(self.name, size=(1024, 768))
main_window.app = self
main_box = toga.Box()
main_box.add(self.make_toolbar())
main_box.add(self.make_maincontent())
main_window.content = main_box
main_window.show()
@staticmethod
def make_toolbar():
toolbar_box = toga.Box(style=CSS(
flex_direction='row',
justify_content='space-between',
padding=5,
))
refresh_btn = toga.Button('Refresh')
summary_label = toga.Label('???%', alignment=toga.RIGHT_ALIGNED)
toolbar_box.add(refresh_btn)
toolbar_box.add(summary_label)
return toolbar_box
@staticmethod
def make_maincontent():
split = toga.SplitContainer(style=CSS(flex=1))
split.content = [toga.Label('Hello'), Duvet.make_codebox()]
return split
@staticmethod
def make_codebox():
code_box = toga.Box(style=CSS(flex=1))
code_text = toga.MultilineTextInput(
readonly = True,
style=CSS(flex=1),
)
code_box.add(code_text)
return code_box
if __name__ == '__main__':
app = Duvet('Duvet', 'org.pybee.duvet')
app.main_loop()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment