def __init__(self, parent, id, style): super(RightMainPanel, self).__init__(parent, id, style=style) # setup ui splitter = wx.SplitterWindow(self, -1, style=wx.SP_LIVE_UPDATE) self.topPanel = scrolled.ScrolledPanel(splitter, -1, \ style=wx.BORDER_SUNKEN) self.topSizer = wx.FlexGridSizer(cols=2, hgap=2, vgap=2) self.topSizer.SetFlexibleDirection(wx.HORIZONTAL) self.topSizer.AddGrowableCol(1, 1) self.topPanel.SetSizer(self.topSizer) self.topPanel.SetupScrolling(scroll_x = False) self.bottomText = BottomTextCtrl(splitter, -1, \ style=wx.TE_MULTILINE|wx.BORDER_SUNKEN) sizer = wx.BoxSizer(wx.VERTICAL) topHeight = registry.config.getint('gui', 'question-panel-height') splitter.SetMinimumPaneSize(200) splitter.SetSashGravity(0.0) splitter.SplitHorizontally(self.topPanel, self.bottomText, topHeight) debug.trace("Height configuration value: %s" % topHeight) sizer.Add(splitter, 1, wx.EXPAND) self.SetSizer(sizer) sizer.Fit(self) self.Fit() debug.trace("RightMainPanel height: %s" % \ self.GetClientSize().GetHeight())
def __init__(self, parent, question, ans_getter, ans_setter): super(BaseCtrl, self).__init__(parent) debug.trace("%s.__init__" % self.__class__.__name__) self.parent = parent self.question = question self.ans_getter = ans_getter self.ans_setter = ans_setter self.setupControl()
def OnInit(self): self.SetAppName('ucc') # used by wx.StandardPaths # load configuration registry.config = ucc.config.load() debug.trace('Configration loaded') # setup registry registry.app = self # IDs for events registry.ID_OPEN = wx.NewId() registry.ID_SAVE_ALL = wx.NewId() registry.ID_SAVE_WORD = wx.ID_SAVE registry.ID_COMPILE = wx.NewId() registry.ID_LOAD = wx.NewId() registry.ID_VERIFY = wx.NewId() registry.ID_PUSH = wx.NewId() registry.ID_ABOUT = wx.ID_ABOUT registry.ID_EXIT = wx.ID_EXIT # standard app controls registry.mainFrame = None registry.mainMenuBar = None registry.mainToolbar = None registry.mainPanel = None registry.leftTreePanel = None registry.rightMainPanel = None registry.wordTreeCtrl = None # package information registry.mode = None # current mode of operation registry.currentPackage = None # full absolute path to package directory registry.top_package = None # ucc.word.top_package.top instance registry.currentWord = None # current word loaded in rightMainPanel # process input arguments for package/mode, if not ask for package/mode if not self.packagePath: self.packagePath = self.pickMode() self.processPath(self.packagePath) self.initPackage() # setup the mainFrame to start the app registry.mainFrame = MainFrame(None, -1, u"\xb5CC Package Editor") self.SetTopWindow(registry.mainFrame) return True
def onChange(self, event): debug.trace("Optional pane changed: %s" % self.cp.IsExpanded()) if self.cp.IsExpanded(): if self.ans_getter() is None: self.ans_setter(self.question.make_default_answer()) self.subctrl.setInitialValue() self.cp.SetLabel(self.labelDisable) else: self.ans_setter(None) self.cp.SetLabel(self.labelEnable) self.parent.Layout()
def onLoad(self, event): from ucc.parser import load kw_args = dict((param, registry.config.get('arduino', param)) for param in ( 'install_dir', 'avrdude_port', 'mcu', 'avr_dude_path', 'avr_config_path', 'avrdude_programmer', 'upload_rate' ) if registry.config.has_option('arduino', param) ) load_path = registry.currentPackage for memory_type in 'flash', 'eeprom': if os.path.exists(os.path.join(load_path, memory_type + '.hex')): debug.trace("Loading " + memory_type + '.hex') load.run(load_path=load_path, memory_type=memory_type, **kw_args)
def buildWord(self): debug.trace("RightMainPanel.buildWord") # setup word controls if registry.currentWord: for question in registry.currentWord.kind_obj.questions or (): self.topSizer.Add(wx.StaticText(self.topPanel, -1, \ "%s: " % question.label)) if not hasattr(question, 'control'): msg = "<%s %s> has no control" % \ (question.__class__.__name__, question.name) debug.warn(msg) self.topSizer.Add(wx.StaticText(self.topPanel, -1, msg)) else: cls = getattr(controls, question.control) debug.trace('%s is being renderd as %s' % \ (question.name, cls.__name__)) self.topSizer.Add( cls.makeControl( self.topPanel, question, lambda question=question: registry.currentWord.get_answer(question.name), lambda new_ans, question=question: registry.currentWord.set_answer(question.name, new_ans))) # setup bottom text self.bottomText.ClearAll() source_filename = registry.currentWord.get_filename() if source_filename and os.path.exists(source_filename): if registry.currentWord.source_text: self.bottomText.SetText(registry.currentWord.source_text) debug.trace('loaded from source_text') else: self.bottomText.LoadFile(source_filename) debug.trace('loaded from file') else: debug.notice('No word currently selected')
def setInitialValue(self): debug.trace("%s.setInitialValue" % self.__class__.__name__) if self.ans_getter() is None: debug.trace("Answer is None") self.cp.SetLabel(self.labelEnable) self.cp.Collapse(True) else: debug.trace("Answer is not None") self.cp.SetLabel(self.labelDisable) self.cp.Expand() if self.cp.IsExpanded(): self.subctrl.setInitialValue()
def setInitialValue(self): debug.trace("%s.setInitialValue %s=%s" % (self.__class__.__name__, self.question.name, self.ans_getter().get_value())) self.spinCtrl.SetValue(self.ans_getter().get_value())
def setInitialValue(self): debug.trace("%s.setInitialValue %s=%s" % (self.__class__.__name__, self.question.name, self.get_value())) self.ch.SetLabel(self.ans_getter().value)
def paint(self): debug.trace("Painting leftTreePanel") self.drawTree()
def paint(self): debug.trace("Painting mainFrame") registry.leftTreePanel.paint() registry.rightMainPanel.paint()