def __init__(self, target): wx.Panel.__init__(self, koko.CANVAS) self.target = target sizer = wx.FlexGridSizer( rows=len(target.PARAMETERS)+2, cols = 2) txt = wx.StaticText(self, label='type', size=(-1, 25), style=wx.ALIGN_RIGHT|wx.ST_NO_AUTORESIZE) sizer.Add(txt, border=3, flag=wx.BOTTOM|wx.TOP|wx.RIGHT|wx.EXPAND) # Add this panel's class classTxt = wx.StaticText(self, size=(-1, 25), label=target.__class__.__name__) classTxt.SetFont(wx.Font(14, family=wx.FONTFAMILY_DEFAULT, style=wx.ITALIC, weight=wx.BOLD)) sizer.Add(classTxt, border=1, flag=wx.BOTTOM|wx.TOP|wx.LEFT|wx.EXPAND) boxes = [] for p in target.PARAMETERS: boxes.append(self.add_row(sizer, p)) self.update = lambda: [b.pull() for b in boxes] outer = wx.BoxSizer() outer.Add(sizer, border=10, flag=wx.ALL) self.SetSizerAndFit(outer) APP_THEME.apply(self) koko.CANVAS.Refresh()
def invalidate(self, event=None): """ @brief Invalidates final panel in workflow @details Disables Save and Start buttons, and deletes paths from canvases to indicate that a generated path is no longer valid. """ APP_THEME.apply(self) if isinstance(self.panels[-1], OutputPanel): self.panels[-1].invalidate() koko.CANVAS.clear_path() koko.GLCANVAS.clear_path() if event: event.Skip()
def __init__(self, title, filename=None): wx.Frame.__init__(self, koko.FRAME, title=title) # Create text pane. self.txt = koko.editor.Editor(self, style=wx.NO_BORDER, size=(600, 400)) self.txt.SetCaretLineVisible(0) self.txt.SetReadOnly(True) if filename is not None: with open(filename, 'r') as f: self.txt.text = f.read() sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(self.txt, 1, wx.EXPAND | wx.ALL, border=5) self.SetSizerAndFit(sizer) APP_THEME.apply(self) self.Show()
def regenerate(self, input, output): """ @brief Regenerates the workflow UI @param input Input data structure @param output Output module """ self.input = [i for i in INPUTS if i.TYPE == type(input)][0] # Make sure we can find a path from the start panel to # the desired path panel. if output.INPUT in self.input.WORKFLOWS: self.output = output # If that fails, then load the None machine as our output else: self.output = MACHINES[0] for p in self.panels: p.Destroy() if self.defaults: self.defaults.Destroy() self.panels = [] self.defaults = None if self.output.DEFAULTS: self.defaults = DefaultSelector(self, output.DEFAULTS) self.sizer.Add(self.defaults, flag=wx.EXPAND|wx.TOP, border=10) workflow = ( self.input.WORKFLOWS[self.output.INPUT] + (self.output.INPUT, self.output.PANEL) ) for p in workflow: if p is None: continue panel = p(self) self.panels.append(panel) self.sizer.Add(panel, flag=wx.EXPAND|wx.TOP, border=10) APP_THEME.apply(self) self.Layout()
def __init__(self, target): wx.Panel.__init__(self, koko.CANVAS) self.target = target sizer = wx.FlexGridSizer(rows=len(target.PARAMETERS) + 2, cols=2) txt = wx.StaticText(self, label='type', size=(-1, 25), style=wx.ALIGN_RIGHT | wx.ST_NO_AUTORESIZE) sizer.Add(txt, border=3, flag=wx.BOTTOM | wx.TOP | wx.RIGHT | wx.EXPAND) # Add this panel's class classTxt = wx.StaticText(self, size=(-1, 25), label=target.__class__.__name__) classTxt.SetFont( wx.Font(14, family=wx.FONTFAMILY_DEFAULT, style=wx.ITALIC, weight=wx.BOLD)) sizer.Add(classTxt, border=1, flag=wx.BOTTOM | wx.TOP | wx.LEFT | wx.EXPAND) boxes = [] for p in target.PARAMETERS: boxes.append(self.add_row(sizer, p)) self.update = lambda: [b.pull() for b in boxes] outer = wx.BoxSizer() outer.Add(sizer, border=10, flag=wx.ALL) self.SetSizerAndFit(outer) APP_THEME.apply(self) koko.CANVAS.Refresh()
def __init__(self, app): wx.Frame.__init__(self, parent=None) # Build menus and bind callback self.build_menus(app) # Bind idle callback self.Bind(wx.EVT_IDLE, app.idle) # The main sizer for the application sizer = wx.BoxSizer(wx.VERTICAL) version = '%s %s' % (koko.NAME, koko.VERSION) sizer.Add(wx.StaticText(self, label=version), flag=wx.ALIGN_RIGHT | wx.ALL, border=5) # Horizontal sizer that contains script, output, and canvases core = wx.BoxSizer(wx.HORIZONTAL) koko.IMPORT = ImportPanel(app, self) editor_panel = wx.Panel(self) editor_sizer = wx.BoxSizer(wx.VERTICAL) # Vertical sizer that contains the editor and the output panel koko.EDITOR = Editor(editor_panel, style=wx.NO_BORDER, size=(300, 400)) koko.EDITOR.load_template() koko.EDITOR.bind_callbacks(app) editor_sizer.Add(koko.EDITOR, proportion=2, flag=wx.EXPAND) self.show_editor = lambda b: editor_sizer.ShowItems(b) self._output = Editor(editor_panel, margins=False, style=wx.NO_BORDER, size=(300, 100)) self._output.SetWrapStartIndent(4) self._output.SetReadOnly(True) self._output.SetCaretLineVisible(False) self._output.SetWrapMode(wx.stc.STC_WRAP_WORD) editor_sizer.Add(self._output, proportion=1, border=10, flag=wx.EXPAND | wx.TOP) editor_panel.SetSizerAndFit(editor_sizer) self.show_editor = lambda b: editor_panel.Show(b) # Vertical / Horizontal sizer that contains the two canvases canvas_sizer = wx.BoxSizer(wx.VERTICAL) self.set_canvas_orientation = lambda o: canvas_sizer.SetOrientation(o) koko.CANVAS = Canvas(self, app, size=(300, 300)) canvas_sizer.Add(koko.CANVAS, proportion=1, flag=wx.EXPAND) koko.GLCANVAS = GLCanvas(self, size=(300, 300)) canvas_sizer.Add(koko.GLCANVAS, proportion=1, flag=wx.EXPAND) koko.GLCANVAS.Hide() core.Add(koko.IMPORT, flag=wx.EXPAND | wx.RIGHT, border=20) koko.IMPORT.Hide() core.Add(editor_panel, proportion=4, flag=wx.EXPAND | wx.RIGHT, border=10) core.Add(canvas_sizer, proportion=6, flag=wx.EXPAND | wx.RIGHT, border=10) koko.FAB = FabWorkflowPanel(self) core.Add(koko.FAB, proportion=3, flag=wx.EXPAND | wx.RIGHT, border=10) koko.FAB.Hide() sizer.Add(core, proportion=1, flag=wx.EXPAND) bottom_sizer = wx.BoxSizer(wx.HORIZONTAL) self._hint = wx.lib.stattext.GenStaticText(self) bottom_sizer.Add(self._hint, proportion=1) self._status = wx.lib.stattext.GenStaticText(self, style=wx.ALIGN_RIGHT | wx.ST_NO_AUTORESIZE) bottom_sizer.Add(self._status, proportion=1) sizer.Add(bottom_sizer, flag=wx.EXPAND | wx.ALL, border=10) self.SetSizerAndFit(sizer) APP_THEME.apply(self) self._status.SetForegroundColour(wx.Colour(100, 100, 100)) # By default, hide the output panel self._output.Hide() self.Layout() """ # Settings for screen recording self.SetClientSize((1280, 720)) self.SetPosition((0,wx.DisplaySize()[1] - self.GetSize()[1])) """ self.Maximize()
def __init__(self, app): wx.Frame.__init__(self, parent=None) # Build menus and bind callback self.build_menus(app) # Bind idle callback self.Bind(wx.EVT_IDLE, app.idle) # The main sizer for the application sizer = wx.BoxSizer(wx.VERTICAL) version = '%s %s' % (koko.NAME, koko.VERSION) sizer.Add(wx.StaticText(self, label=version), flag=wx.ALIGN_RIGHT|wx.ALL, border=5) # Horizontal sizer that contains script, output, and canvases core = wx.BoxSizer(wx.HORIZONTAL) koko.IMPORT = ImportPanel(app, self) editor_panel = wx.Panel(self) editor_sizer = wx.BoxSizer(wx.VERTICAL) # Vertical sizer that contains the editor and the output panel koko.EDITOR = Editor(editor_panel, style=wx.NO_BORDER, size=(300, 400)) koko.EDITOR.load_template() koko.EDITOR.bind_callbacks(app) editor_sizer.Add(koko.EDITOR, proportion=2, flag=wx.EXPAND) self.show_editor = lambda b: editor_sizer.ShowItems(b) self._output = Editor(editor_panel, margins=False, style=wx.NO_BORDER, size=(300, 100)) self._output.SetWrapStartIndent(4) self._output.SetReadOnly(True) self._output.SetCaretLineVisible(False) self._output.SetWrapMode(wx.stc.STC_WRAP_WORD) editor_sizer.Add(self._output, proportion=1, border=10, flag=wx.EXPAND|wx.TOP) editor_panel.SetSizerAndFit(editor_sizer) self.show_editor = lambda b: editor_panel.Show(b) # Vertical / Horizontal sizer that contains the two canvases canvas_sizer = wx.BoxSizer(wx.VERTICAL) self.set_canvas_orientation = lambda o: canvas_sizer.SetOrientation(o) koko.CANVAS = Canvas(self, app, size=(300, 300)) canvas_sizer.Add(koko.CANVAS, proportion=1, flag=wx.EXPAND) # wx.glcanvas is terrible on wx-gtk. The command to check whether # various attributes are supported doesn't actually work, so we'll do # it experimentally: try to construct a GLCanvas with various # depth buffer sizes, stopping when one of them works. for d in [32, 24, 16, 8]: try: koko.GLCANVAS = GLCanvas(self, size=(300, 300), depth=d) except: continue else: break canvas_sizer.Add(koko.GLCANVAS, proportion=1, flag=wx.EXPAND) koko.GLCANVAS.Hide() core.Add(koko.IMPORT, flag=wx.EXPAND|wx.RIGHT, border=20) koko.IMPORT.Hide() core.Add(editor_panel, proportion=4, flag=wx.EXPAND|wx.RIGHT, border=10) core.Add(canvas_sizer, proportion=6, flag=wx.EXPAND|wx.RIGHT, border=10) koko.FAB = FabWorkflowPanel(self) core.Add(koko.FAB, proportion=3, flag=wx.EXPAND|wx.RIGHT, border=10) koko.FAB.Hide() sizer.Add(core, proportion=1, flag=wx.EXPAND) bottom_sizer = wx.BoxSizer(wx.HORIZONTAL) self._hint = wx.lib.stattext.GenStaticText(self) bottom_sizer.Add(self._hint, proportion=1) self._status = wx.lib.stattext.GenStaticText( self, style=wx.ALIGN_RIGHT|wx.ST_NO_AUTORESIZE ) bottom_sizer.Add(self._status, proportion=1) sizer.Add(bottom_sizer, flag=wx.EXPAND|wx.ALL, border=10) self.SetSizerAndFit(sizer) APP_THEME.apply(self) self._status.SetForegroundColour(wx.Colour(100, 100, 100)) # By default, hide the output panel self._output.Hide() self.Layout() """ # Settings for screen recording self.SetClientSize((1280, 720)) self.SetPosition((0,wx.DisplaySize()[1] - self.GetSize()[1])) """ self.Maximize()