def on_add_term(self, term): box = gui.Box(self.box, 'vertical', expand=True, stretch=0) bpx = gui.Box(box, 'horizontal', expand=True, stretch=0) term._butt = gui.Button(bpx, term.name, toggle=True) term._butt.connect('toggled', lambda on: self.on_toggled(term, on), True) term._butt.connect('double-clicked', lambda: self.on_btn_doubleclicked(term), True) t = gui.Toolbar(bpx, expand=False, stretch=0) term._act = gui.Command('x', '', lambda checked: self.on_use(term, checked), '16/down.png', type='check') t.append(term._act) t.append(gui.Command('x', '', lambda: self.on_close(term), 'close.png')) t._widget.Realize() term._box = box term._tx = None self.create_parambox(term) if sum((hasattr(t, '_butt') and t._butt.state) for t in self.function.terms) == 0: self.function.terms[0]._butt.state = True self.graph.selected_function = self.function.terms[0] term._act.state = True
def on_set_value(self): row, col = self.clickcell dlg = gui.Dialog(None) box = gui.Box(dlg, 'vertical', stretch=1) editor = gui.PythonEditor(box) auto = gui.Checkbox(box, 'Auto', stretch=0) btnbox = gui.Box(box, 'horizontal', stretch=0) ok = gui.Button(btnbox, 'OK', stretch=0) cancel = gui.Button(btnbox, 'Cancel', stretch=0) cancel.connect('clicked', dlg.close) ok.connect('clicked', dlg.close) expr = self.worksheet[col].expr auto.state = not expr == '' editor.text = expr dlg._widget.ShowModal() Worksheet.record = set() if auto.state: self.worksheet[col].expr = editor.text else: self.worksheet[col].expr = '' if editor.text.strip() != '': try: self.worksheet[col] = self.worksheet.evaluate(editor.text) except ValueError: print >> sys.stderr, "error" Worksheet.record = None dlg._widget.Destroy()
def main(): gui.images.register('close', Image.open('../data/images/close.png')) gui.images.register_dir('../data/images/') win = gui.Window(title='Mingui doc/demo', size=(640, 480)) gui.base.app.mainwin = win box = gui.Box(win.place(), 'vertical') split = gui.Splitter(box.place(), 'vertical') panel = Panel(split.place(width=100), 'top') btn = gui.Button(panel.place(image='close'), 'arse') tree = gui.Tree(panel.place(image='open'), columns=['Topics']) root = gui.TreeNode() child = gui.TreeNode() root.append(child) tree.append(root) panel.toolbar.Realize() split2 = gui.Splitter(split.place(), 'horizontal') panel2 = Panel(split2.place(width=100), 'left') btn = gui.Button(panel2.place(image='close'), 'arse') panel2.toolbar.Realize() book = gui.Notebook(split2.place()) html = gui.Html(book.place(label='text')) html.SetPage('html/index.html') code = gui.Text(book.place(label='code'), multiline=True, text='hello!') demo = gui.Box(book.place(label='demo')) button = gui.Button(demo.place(expand=False, stretch=0), 'button') toggle = gui.Button(demo.place(expand=False, stretch=0), 'button', toggle=True) toggle.connect('toggled', handler) toggle.connect('clicked', handler) bar = gui.Menubar(win.place()) menu = gui.Menu(bar, 'Foo') menu.append(callable) toggle.text = 'aaa' def on_changed(): split.resize_child(tree, 100) btn = gui.Button(box.place(stretch=0), 'Close', connect={'clicked': win.close}) btn = gui.Button(box.place(stretch=0), 'Change', connect={'clicked': on_changed}) gui.run(win)
def __init__(self): gui.Window.__init__(self, title='Functions', size=(500, 300)) box = gui.Box(self, 'horizontal') # split = gui.Splitter(box, 'horizontal', stretch=1) # self.categories = gui.List(split) self.category = gui.List(box, model=RegModel(registry), stretch=1) self.category.connect('selection-changed', self.on_select_function) self.category.connect('item-activated', self.on_item_activated) rbox = gui.Box(box, 'vertical', stretch=2) toolbar = gui.Toolbar(rbox, stretch=0) toolbar.append(gui.Command('New', '', self.on_new, 'new.png')) toolbar.append(gui.Command('Delete', '', self.on_remove, 'remove.png')) toolbar.append(gui.Command('Save', '', self.on_save, 'save.png')) toolbar._widget.Realize() book = gui.Notebook(rbox) edit = gui.Box(book, 'vertical', page_label='edit') g = gui.Grid(edit, 2, 2, stretch=0, expand=True) g.layout.AddGrowableCol(1) gui.Label(g, 'Name', pos=(0, 0)) gui.Label(g, 'Parameters', pos=(1, 0)) self.name = gui.Text(g, pos=(0, 1), expand=True) self.params = gui.Text(g, pos=(1, 1), expand=True) # self.text = gui.Text(edit, multiline=True, stretch=1) self.text = gui.PythonEditor(edit, stretch=1) extra = gui.Box(book, 'vertical', page_label='extra') # self.extra = gui.Text(extra, multiline=True, stretch=1) self.extra = gui.PythonEditor(extra, stretch=1) self.functions = functions self.function = None
def __init__(self, typ, value, tback): mingui.Dialog.__init__(self, title=random.choice( reduce(list.__add__, [[t[0]] * t[1] for t in titles]))) box = mingui.Box(self.place(), 'vertical') hbox = mingui.Box(box.place(), 'horizontal') mingui.Image( hbox.place(stretch=0), Image.open( os.path.join(settings.DATADIR, 'data', 'images', 'vogel.png'))) book = mingui.Notebook(hbox.place(stretch=1)) mingui.Label(book.place(label='Main'), "An error has occured!\nThis should not happen.") mingui.Text(book.place(label='Traceback'), multiline=True, text=''.join(traceback.format_exception(typ, value, tback)), enabled=False) details = mingui.Text(book.place(label='Details'), multiline=True, text=VerboseTB('NoColor').text(typ, value, tback, context=7), enabled=False) details.SetFont(wx.Font(8, wx.MODERN, wx.NORMAL, wx.NORMAL)) button = mingui.Button(box.place(stretch=0), "That's OK", connect={'clicked': self.close})
def __init__(self, func, graph, parent, **place): gui.Box.__init__(self, parent, 'vertical', **place) self.graph = graph self.toolbar = gui.Toolbar(self, stretch=0) self.scroll = gui.Scrolled(self) self.box = gui.Box(self.scroll, 'vertical') self.toolbar.append( gui.Command('Add term', '', self.do_add, 'function.png')) self.toolbar.append( gui.Command('Fit properties', '', self.do_configure, 'properties.png')) self.toolbar.append(gui.Command('Fit', '', self.do_fit, 'manibela.png')) self.toolbar.append( gui.Command('Save parameters', '', self.do_fit, 'pencil.png')) self.toolbar._widget.Realize() self.set_function(func)
def __binit__(self, parent, graph, **place): gui.Box.__init__(self, parent, 'horizontal', **place) self.graph = graph tbbox = gui.Box(self, 'horizontal', stretch=0) def set_graph_mode(mode): def _set(): self.graph.prev_mode = self.graph.mode self.graph.mode = mode cur = { 'arrow': wx.CURSOR_ARROW, 'hand': wx.CURSOR_HAND, 'zoom': wx.CURSOR_MAGNIFIER, 'range': wx.CURSOR_SIZEWE, 'd-reader': wx.CURSOR_CROSS, 's-reader': wx.CURSOR_CROSS, 'draw-text': wx.CURSOR_IBEAM, 'draw-line': wx.CURSOR_PENCIL, 'none': wx.CURSOR_NONE }[mode] self.glwidget._widget.SetCursor(wx.StockCursor(cur)) self.graph.emit('redraw') return _set graph.show() self.toolbar = gui.Toolbar(tbbox, orientation='vertical', stretch=1) self.toolbar.append( gui.Command('Arrow', '', set_graph_mode('arrow'), 'arrow.png', type='radio')) self.toolbar.append( gui.Command('Hand', '', set_graph_mode('hand'), 'hand.png', type='radio')) self.toolbar.append( gui.Command('Zoom', '', set_graph_mode('zoom'), 'zoom.png', type='radio')) self.toolbar.append( gui.Command('Range', '', set_graph_mode('range'), 'range.png', type='radio')) self.toolbar.append( gui.Command('Data reader', '', set_graph_mode('d-reader'), 'dreader.png', type='radio')) self.toolbar.append( gui.Command('Screen reader', '', set_graph_mode('s-reader'), 'sreader.png', type='radio')) self.toolbar.append(None) self.toolbar.append( gui.Command('Line', '', set_graph_mode('draw-line'), 'stock_draw-line.png')) self.toolbar.append( gui.Command('Text', '', set_graph_mode('draw-text'), 'stock_draw-text.png')) self.toolbar.append(None) self.toolbar.append( gui.Command('Select all datasets', '', self.on_selectall, 'stock_select-all.png')) self.toolbar._widget.Realize() # self.closebar = gui.Toolbar(tbbox, stretch=0) # self.closebar.append(gui.Command('Close', 'Close this worksheet', # self.on_close, 'close.png')) # self.closebar._widget.Realize() self.panel = gui.MainPanel(self) self.box = gui.Splitter(self.panel, 'vertical', proportion=0.8) self.scrolled = gui.Scrolled(self.box) self.glwidget = gui.OpenGLWidget(self.scrolled) self.glwidget.min_size = (400, 200) self.glwidget.connect('initialize-gl', self.graph.init) self.glwidget.connect('resize-gl', self.graph.reshape) self.glwidget.connect('paint-gl', self.graph.display) self.glwidget.connect('button-pressed', self.graph.button_press) self.glwidget.connect('button-released', self.graph.button_release) self.glwidget.connect('button-doubleclicked', self.graph.button_doubleclick) self.glwidget.connect('mouse-moved', self.graph.button_motion) self.glwidget.connect('key-down', self.graph.key_down) self.graph.connect('redraw', self.glwidget.redraw) self.graph.connect('object-doubleclicked', self.on_object_doubleclicked) self.graph.connect('right-clicked', self.on_right_clicked) self.legend = gui.List(self.box, model=LegendModel(self.graph)) #, stretch=0) self.legend.connect('selection-changed', self.on_legend_select) self.graphdata = GraphDataPanel(self.graph, self, self.panel.right_panel, page_label='Data', page_pixmap='worksheet.png') self.style = GraphStylePanel(self.graph, self, self.panel.right_panel, page_label='Style', page_pixmap='style.png') self.axes = GraphAxesPanel(self.graph, self, self.panel.right_panel, page_label='Axes', page_pixmap='axes.png') self.fit = GraphFunctionsPanel(self.graph.functions[0].func, self.graph, self.panel.right_panel, page_label='Fit', page_pixmap='function.png') self.panel.right_panel._widget.toolbar.Realize() self.graph.connect('request-cursor', self.on_request_cursor) self.object = self.graph self.graph.connect('rename', self.on_rename) self.legend.connect('right-click', self.on_legend_right_click)
def __qinit__(self, graph, view, parent, **place): gui.Box.__init__(self, parent, 'vertical', **place) self.graph = graph self.view = view # Symbol self.symbol = gui.Frame(self, 'vertical', title='Symbol', stretch=0.) grid = self.symbol_grid = gui.Grid( self.symbol, 3, 3, expand=False) #, expand=True, stretch=1.) grid.layout.AddGrowableCol(2) # symbol type self.symbol = gui.PixmapChoice(grid, pos=(0, 2)) self.symbol.label = gui.Label(grid, 'Symbol', pos=(0, 1)) self.symbol.check = gui.Checkbox(grid, pos=(0, 0)) self.symbol.min_size = (10, self.symbol.min_size[1]) for symbol in Style.symbols: self.symbol.append(symbol + '.png') self.symbol.value = 0 self.symbol.connect( 'select', lambda value: self.on_select_property('symbol', value), True) # symbol color self.color = gui.PixmapChoice(grid, pos=(1, 2)) self.color.label = gui.Label(grid, 'Color', pos=(1, 1)) self.color.check = gui.Checkbox(grid, pos=(1, 0)) self.color.min_size = (10, self.color.min_size[1]) for color in Style.colors: self.color.append(self.color.create_colored_bitmap((20, 10), color)) self.color.value = 0 self.color.connect( 'select', lambda value: self.on_select_property('color', value), True) # symbol size self.symbol_size = gui.Spin(grid, pos=(2, 2)) self.symbol_size.label = gui.Label(grid, 'Size', pos=(2, 1)) self.symbol_size.check = gui.Checkbox(grid, pos=(2, 0)) self.symbol_size.min_size = (10, self.symbol_size.min_size[1]) self.symbol_size.value = 5 self.symbol_size.connect( 'modified', lambda value: self.on_select_property('symbol_size', value), True) # Line self.line = gui.Frame(self, 'vertical', title='Line', stretch=0.) grid = self.line_grid = gui.Grid(self.line, 3, 3) #, expand=True, stretch=1.) grid.layout.AddGrowableCol(2) # Line type self.line_type = gui.Choice(grid, pos=(0, 2)) self.line_type.label = gui.Label(grid, 'Type', pos=(0, 1)) self.line_type.check = gui.Checkbox(grid, pos=(0, 0)) self.line_type.min_size = (10, self.line_type.min_size[1]) for t in Style.line_types: self.line_type.append(t) self.line_type.value = 0 self.line_type.connect( 'select', lambda value: self.on_select_property('line_type', value), True) # Line style self.line_style = gui.Choice(grid, pos=(1, 2)) self.line_style.label = gui.Label(grid, 'Style', pos=(1, 1)) self.line_style.check = gui.Checkbox(grid, pos=(1, 0)) self.line_style.min_size = (10, self.line_style.min_size[1]) for p in Style.line_styles: self.line_style.append(p) self.line_style.value = 0 self.line_style.connect( 'select', lambda value: self.on_select_property('line_style', value), True) # Line width self.line_width = gui.Spin(grid, pos=(2, 2)) self.line_width.label = gui.Label(grid, 'Width', pos=(2, 1)) self.line_width.check = gui.Checkbox(grid, pos=(2, 0)) self.line_width.min_size = (10, self.line_width.min_size[1]) self.line_width.value = 1 self.line_width.connect( 'modified', lambda value: self.on_select_property('line_width', value), True) self.settings_widgets = [ self.symbol, self.color, self.symbol_size, self.line_type, self.line_style, self.line_width ] self.show_checks(False) self.symbol.prop = 'symbol' self.symbol_size.prop = 'symbol_size' self.color.prop = 'color' self.line_width.prop = 'line_width' self.line_type.prop = 'line_type' self.line_style.prop = 'line_style' b = gui.Box(self, 'horizontal', expand=True, stretch=0) gui.Label(b, 'Group', stretch=0) self.multi = gui.Choice(b, stretch=1) self.multi.append('identical') self.multi.append('series') self.multi.value = 0 self.multi.connect('select', self.on_select_multi) maxminw = max( [w.label._widget.GetBestSize()[0] for w in self.settings_widgets]) for widget in self.settings_widgets: widget.check.connect( 'modified', lambda state, widget=widget: self.on_check(widget, state), True) widget.label.min_size = (maxminw, widget.label.min_size[1])