예제 #1
0
def run_tool(window_parent, device):
    availIdx = []
    availChoice = []
    for idx in device.analogIn:
        availIdx.append(device.channels[idx])
        availChoice.append("Analog Input " + str(idx))
    chan = wx.GetSingleChoiceIndex("Select which input to display", "Input",
                                   availChoice, window_parent)
    chan = availIdx[chan]
    billboard = BillboardDialog(window_parent, device, 1, chan)
    billboard.Show()
예제 #2
0
def popup_menu(data, label=""):
    choices = []
    for item in data:
        if isinstance(item, tuple):
            item = ": ".join(item)
        choices.append(item)

    index = wx.GetSingleChoiceIndex(label, "Choice", choices)
    if index >= 0:
        return index
    else:
        return None
예제 #3
0
    def tableHistogramAverage(self, modelId, methodId):
        # The model and output.
        state = self.application.state
        model = state.models[modelId]
        output = state.output[(modelId, methodId)]

        # Choose between showing the estimated error or the histogram.
        index = wx.GetSingleChoiceIndex('Choose table content.', 'Table', [
            'Estimated error', 'Mean and standard deviation',
            'Histogram bin values'
        ])

        if index == 0:
            # Show the errors.
            title = 'Estimated errors for model: ' + modelId + ', method: ' +\
                methodId + '.'
            TableErrorAverageFrame(model, output, title, self).Show()
        elif index == 1:
            # Show population statistics.
            title = 'Statistics for model: ' + modelId + ', method: ' +\
                methodId + '.'
            TableHistogramAverageStatistics(model, output, title, self).Show()
        elif index == 2:
            # Select a species.
            choices = [
                model.speciesIdentifiers[_i] for _i in output.recordedSpecies
            ]
            selection = wx.GetSingleChoiceIndex('Choose a species.', 'Species',
                                                choices)
            if selection < 0:
                return
            # Show the histogram.
            speciesId =\
                model.speciesIdentifiers[output.recordedSpecies[selection]]
            title = 'Histogram for model: ' + modelId + ', method: ' +\
                methodId + ', species: ' + speciesId + '.'
            TableHistogramFrame(output.histograms[selection], title,
                                self).Show()
예제 #4
0
    def tableHistogramFrames(self, modelId, methodId):
        # The model and output.
        state = self.application.state
        model = state.models[modelId]
        output = state.output[(modelId, methodId)]

        # Choose between showing the estimated error or the histogram.
        index = wx.GetSingleChoiceIndex('Choose table content.', 'Table', [
            'Estimated error', 'Mean and standard deviation',
            'Histogram bin values'
        ])

        if index == 0:
            # Show the errors.
            title = 'Estimated errors for model: ' + modelId + ', method: ' +\
                methodId + '.'
            TableErrorFrame(model, output, title, self).Show()
        elif index == 1:
            # Show population statistics.
            title = 'Statistics for model: ' + modelId + ', method: ' +\
                methodId + '.'
            TableHistogramFramesStatistics(model, output, title, self).Show()
        elif index == 2:
            # Select a species and frame.
            dialog = SpeciesFrameDialog(self, model, output)
            result = dialog.ShowModal()
            species = dialog.getSpecies()
            frame = dialog.getFrame()
            dialog.Destroy()
            if result != wx.ID_OK:
                return
            # Show the histogram.
            speciesId =\
                model.speciesIdentifiers[output.recordedSpecies[species]]
            title = 'Histogram for model: ' + modelId + ', method: ' +\
                methodId + ', species: ' + speciesId +\
                ', frame: ' + str(output.frameTimes[frame]) + '.'
            TableHistogramFrame(output.histograms[frame][species], title,
                                self).Show()
예제 #5
0
    def OnInit(self):


        demoMode = wx.GetSingleChoiceIndex(_("Select the demo mode"),
                                           _("wxPython DocView Demo"),
                                           [_("SDI Single Document"), _("SDI"), _("MDI")])

        if demoMode == 0 or demoMode == 1:
            flags = wx.lib.docview.DOC_SDI
        elif demoMode == 2:
            flags = wx.lib.docview.DOC_MDI
        else:
            return False

        self.SetAppName(_("DocView Demo"))

        docManager = wx.lib.docview.DocManager(flags = flags)
        docManager.AssociateTemplate(wx.lib.docview.DocTemplate(docManager,
                                                         _("Text"),
                                                         "*.text;*.txt",
                                                         _("Text"),
                                                         _(".txt"),
                                                         _("Text Document"),
                                                         _("Text View"),
                                                         TextEditDocument,
                                                         TextEditView))
        #if wx.Platform == "__WXMAC__":
        #     wx.FileName.MacRegisterDefaultTypeAndCreator("txt", 'TEXT', 'WXMA')

        if demoMode == 0:
            docManager.SetMaxDocsOpen(1)

        if demoMode == 2:  # MDI
            self._frame = MyMDIFrame(docManager, None, -1, _("DocView Demo"), (0, 0), (500, 400), wx.DEFAULT_FRAME_STYLE)
        else:  # SDI
            self._frame = MyFrame(docManager, None, -1, _("DocView Demo"), (0, 0), (500, 400), wx.DEFAULT_FRAME_STYLE)

        fileMenu = wx.Menu()
        editMenu = None

        fileMenu.Append(wx.ID_NEW, _("&New..."))
        fileMenu.Append(wx.ID_OPEN, _("&Open..."))

        if demoMode == 2:  # MDI
            fileMenu.Append(wx.ID_CLOSE, _("&Close"))
            fileMenu.AppendSeparator()

        if demoMode == 0 or demoMode == 2:  # Single Doc or MDI
            fileMenu.Append(wx.ID_SAVE, _("&Save"))
            fileMenu.Append(wx.ID_SAVEAS, _("Save &As"))
            fileMenu.AppendSeparator()
            fileMenu.Append(wx.ID_PRINT, _("&Print"))
            fileMenu.Append(wx.ID_PRINT_SETUP, _("Page &Setup"))
            fileMenu.Append(wx.ID_PREVIEW, _("Print Pre&view"))

            editMenu = wx.Menu()
            editMenu.Append(wx.ID_UNDO, _("&Undo"))
            editMenu.Append(wx.ID_REDO, _("&Redo"))

            self._frame.editMenu = editMenu

        fileMenu.AppendSeparator()
        fileMenu.Append(wx.ID_EXIT, _("E&xit"))

        docManager.FileHistoryUseMenu(fileMenu)

        helpMenu = wx.Menu()
        helpMenu.Append(wx.ID_ABOUT, _("&About"))

        menuBar = wx.MenuBar()
        menuBar.Append(fileMenu, _("&File"))
        if editMenu:
            menuBar.Append(editMenu, _("&Edit"))
        menuBar.Append(helpMenu, _("&Help"))

        self._frame.SetMenuBar(menuBar)
        self._frame.Centre(wx.BOTH)
        self._frame.Show(True)

        self.SetTopWindow(self._frame)

        if demoMode == 0:  # Single doc
            docManager.OnFileNew(None)

        return True
예제 #6
0
    def tableTimeSeriesFrames(self, modelId, methodId):
        state = self.application.state
        model = state.models[modelId]
        output = state.output[(modelId, methodId)]
        # There must be recorded species or reactions.
        assert output.recordedSpecies or output.recordedReactions

        choices = []
        populations = 'Populations'
        if output.recordedSpecies:
            choices.extend([populations])
        binned = 'Binned reaction counts'
        cumulative = 'Cumulative reaction counts'
        if output.recordedReactions:
            choices.extend([binned, cumulative])

        data = wx.GetSingleChoiceIndex('Choose data to display.', 'Table',
                                       choices)
        title = ' for Model: ' + modelId + ', Method: ' +\
            methodId + '.'
        if populations in choices and data == choices.index(populations):
            style = wx.GetSingleChoiceIndex\
                ('Choose how to display the populations', 'Table',
                 ['Statistics for all frames',
                  'Statistics for the last frame',
                  'Ensemble showing all frames',
                  'Ensemble showing the last frame'])
            if style == 0:
                TfFrame(model, output, 'PopulationStatisticsAll',
                        'Population statistics' + title, self).Show()
            elif style == 1:
                TfFrame(model, output, 'PopulationStatisticsLast',
                        'Population statistics' + title, self).Show()
            elif style == 2:
                TfFrame(model, output, 'PopulationsAll', 'Populations' + title,
                        self).Show()
            elif style == 3:
                TfFrame(model, output, 'PopulationsLast',
                        'Populations' + title, self).Show()
        elif binned in choices and data == choices.index(binned):
            style = wx.GetSingleChoiceIndex\
                ('Choose how to display the binned reaction counts',
                 'Table', ['Statistics', 'Ensemble'])
            if style == 0:
                TfFrame(model, output, 'ReactionStatisticsBinned',
                        'Binned reaction count statistics' + title,
                        self).Show()
            elif style == 1:
                TfFrame(model, output, 'ReactionsBinned',
                        'Binned reaction counts' + title, self).Show()
        elif cumulative in choices and data == choices.index(cumulative):
            style = wx.GetSingleChoiceIndex\
                ('Choose how to display the cumulative reaction counts',
                 'Table',
                 ['Statistics for all frames',
                  'Statistics for the last frame',
                  'Ensemble showing all frames',
                  'Ensemble showing the last frame'])
            if style == 0:
                TfFrame(model, output, 'ReactionStatisticsAll',
                        'Cumulative reaction count statistics' + title,
                        self).Show()
            elif style == 1:
                TfFrame(model, output, 'ReactionStatisticsLast',
                        'Cumulative reaction count statistics' + title,
                        self).Show()
            elif style == 2:
                TfFrame(model, output, 'ReactionsAll',
                        'Cumulative reaction counts' + title, self).Show()
            elif style == 3:
                TfFrame(model, output, 'ReactionsLast',
                        'Cumulative reaction counts' + title, self).Show()
예제 #7
0
#! /usr/bin/env python
# coding:utf-8

import wx

if __name__ == "__main__":
    app = wx.PySimpleApp()
    app.MainLoop()

    choices = ['Alpha', 'Beker', 'Charlie', 'Delta']
    dialog = wx.SingleChoiceDialog(None, 'Pick A Work', 'Choices', choices)
    dialog.SetSelection(1)
    if dialog.ShowModal() == wx.ID_OK:
        print 'You selected: %s\n' % dialog.GetStringSelection()

    dialog.Destroy()

    # 函数 两类:一个返回所选字符串,一个返回索引值
    ret = []
    ret.append(wx.GetSingleChoice('Pick A Work', 'Choices', choices))
    ret.append(wx.GetSingleChoiceIndex('Pick A Work', 'Choices', choices))
    print(ret)