示例#1
0
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)
示例#2
0
    def on_btn_doubleclicked(self, term):
        if term._tx is None:
            term._tx = gui.Text(term._butt.parent.parent, align='center')

            term._tx._widget.SetPosition(term._butt._widget.GetPosition())
            term._tx._widget.SetSize(term._butt._widget.GetSize())

            term._tx.connect('enter', lambda: self.on_done(term), True)
            term._tx.connect('kill-focus', lambda: self.on_done(term), True)
            term._tx.min_size = (1, 1)

        term._tx.show()
        term._tx.text = term.name
        term._tx._widget.SetFocus()
示例#3
0
    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
示例#4
0
    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})
示例#5
0
    def create_parambox(self, term):
        parambox = gui.Grid(term._box, len(term.parameters), 3, expand=True)
        parambox.layout.AddGrowableCol(1)
        term._text = []
        term._lock = []
        for n, par in enumerate(term.function.parameters):
            gui.Label(parambox, par, pos=(n, 0))
            text = gui.Text(parambox, pos=(n, 1))
            text.connect('character',
                         lambda char: self.on_activate(term, n, char), True)
            text.connect('kill-focus', lambda: self.on_activate(term, n), True)
            text.text = str(term.parameters[n])
            term._text.append(text)
            lock = gui.Checkbox(parambox, pos=(n, 2))
            term._lock.append(lock)
        term._parambox = parambox

        self.update_widget()
示例#6
0
    def __init__(self, graph, view, parent, **place):
        gui.Box.__init__(self, parent, "vertical", **place)
        self.graph, self.view = graph, view

        xframe = gui.Frame(self, 'vertical', title='X axis', stretch=0.)
        grid = gui.Grid(xframe, 4, 2, expand=False)
        grid.layout.AddGrowableCol(1)
        gui.Label(grid, 'Title', pos=(0, 0))
        self.x_title = gui.Text(grid, pos=(0, 1))
        self.x_title.text = self.graph.xtitle
        self.x_title.connect(['enter', 'kill-focus'], self.on_x_title)
        gui.Label(grid, 'From', pos=(1, 0))
        x_from = gui.Text(grid, pos=(1, 1))
        gui.Label(grid, 'To', pos=(2, 0))
        x_to = gui.Text(grid, pos=(2, 1))
        gui.Label(grid, 'Type', pos=(3, 0))
        x_type = self.x_type = gui.Choice(grid, pos=(3, 1))
        x_type.append('Linear')
        x_type.append('Logarithmic')
        x_type.value = ['linear', 'log'].index(self.graph.xtype)
        x_type.connect('select', lambda value: self.on_set_xtype(value), True)

        yframe = gui.Frame(self, 'vertical', title='Y axis', stretch=0.)
        grid = gui.Grid(yframe, 4, 2, expand=False)
        grid.layout.AddGrowableCol(1)
        gui.Label(grid, 'Title', pos=(0, 0))
        self.y_title = gui.Text(grid, pos=(0, 1))
        self.y_title.text = self.graph.ytitle
        self.y_title.connect(['enter', 'kill-focus'], self.on_y_title)
        gui.Label(grid, 'From', pos=(1, 0))
        y_from = gui.Text(grid, pos=(1, 1))
        gui.Label(grid, 'To', pos=(2, 0))
        y_to = gui.Text(grid, pos=(2, 1))
        gui.Label(grid, 'Type', pos=(3, 0))
        y_type = self.y_type = gui.Choice(grid, pos=(3, 1))
        y_type.append('Linear')
        y_type.append('Logarithmic')
        y_type.value = ['linear', 'log'].index(self.graph.ytype)
        y_type.connect('select', lambda value: self.on_set_ytype(value), True)

        for w in [
                self.x_title, x_from, x_to, x_type, self.y_title, y_from, y_to,
                y_type
        ]:
            w.min_size = (10, w.min_size[1])