Exemplo n.º 1
0
def run_tool(window_parent, device):
    logger.log("PulsedExperiment tool running", "", logger.INFO)

    # ask user for selected channels
    choices = []
    channels = []
    plotChannels = []
    for key, c in device.analogIn.iteritems():
        choices.append("Analog input " + str(c.idx))
        channels.append(c)

    dlg = wx.MultiChoiceDialog(window_parent,
                               message="Select which inputs to sample",
                               caption="Input Selection",
                               choices=choices)
    dlg.SetSelections([0])
    if dlg.ShowModal() == wx.ID_OK:
        selection = dlg.GetSelections()
        for idx in selection:
            plotChannels.append(channels[idx])
    else:
        return
    dlg.Destroy()

    # ask user for trigger pins
    choices = []
    channels = []
    triggers = []
    for n in range(0, 4):
        choices.append("Digital input " + str(n))

    dlg = wx.MultiChoiceDialog(window_parent,
                               message="Select which pins to trigger",
                               caption="Trigger Selection",
                               choices=choices)
    dlg.SetSelections([0])
    if dlg.ShowModal() == wx.ID_OK:
        selection = dlg.GetSelections()
        for idx in selection:
            triggers.append(idx + 4)
    else:
        return
    dlg.Destroy()

    mask = 0
    for pin in triggers:
        mask = mask | (1 << pin)
    device.setNAvg(1)
    device.propCom.send("resetevents")

    win = PulsedExperiment(window_parent,
                           device,
                           channels=plotChannels,
                           triggers=triggers)
    win.Show()
Exemplo n.º 2
0
 async def on_MultiChoiceDialog(self, event):
     dlg = wx.MultiChoiceDialog(self,
                                "message",
                                "caption", ["One", "Two", "Three"],
                                style=wx.CHOICEDLG_STYLE,
                                pos=wx.DefaultPosition)
     await self.ShowDialog(dlg)
Exemplo n.º 3
0
 def viewmenu_vehicle_handler(self, event):
     labels = [str(v) for v in common.vehicle_list]
     dialog = wx.MultiChoiceDialog(self, '', 'View Vehicles', labels)
     dialog.ShowModal()
     selections = dialog.GetSelections()  # indexes of the selections
     for i in selections:
         common.vehicle_list[i].edit_traits()
Exemplo n.º 4
0
 def viewmenu_switch_handler(self, event):
     labels = [str(sw) for sw in common.switch_list]
     dialog = wx.MultiChoiceDialog(self, '', 'View Stations', labels)
     dialog.ShowModal()
     selections = dialog.GetSelections()  # indexes of the selections
     for i in selections:
         common.switch_list[i].edit_traits()
 def OnAttributeButton(self, event=None):
     dlg = wx.MultiChoiceDialog(
         self.thisPanel, "Only selected attributes will be displayed",
         "Object Attributes", self.resultList.headers)
     ## Pre-select what is currently displayed
     dlg.SetSelections(self.resultList.resultAttrs)
     if (dlg.ShowModal() == wx.ID_OK):
         self.resultList.resultAttrs = dlg.GetSelections()
         self.resultList.headersActive = [
             self.resultList.headers[x] for x in self.resultList.resultAttrs
         ]
         self.logger.debug("New attribute list for headers: {}".format(
             self.resultList.headersActive))
     dlg.Destroy()
     ## Force the resultsActive to get all column values before updating; do
     ## this in case a new column was shown instead of just hid; need to
     ## update the dataset given to the MixIn that enables column sorting.
     self.UpdateResultsActive()
     self.resultList.OnUpdateColumns()
     self.resultList.PopulateList()
     ## Now update the ColumnSorterMixin references for future column touches
     self.resultList.SetColumnCount(len(self.resultList.headersActive))
     self.resultList.itemDataMap = self.resultList.resultsActive
     ## Send a size event to refresh the scroll bar
     self.resultList.list.SendSizeEvent()
     self.thisPanel.SendSizeEvent()
Exemplo n.º 6
0
 def excludeChannels(self, event):
     if self.Data.Datasets != []:
         channels = ReadEEG(self.Data.Datasets[0].filename).labelsChannel
         dlg = wx.MultiChoiceDialog(
             self,
             caption="Select channels to exclude",
             message='Which channels should be excluded?',
             choices=channels)
         selected = [
             i for i, e in enumerate(channels)
             if e in self.Data.Specs.channels2exclude
         ]
         dlg.SetSelections(selected)
         if dlg.ShowModal() == wx.ID_OK:
             self.Data.Specs.channels2exclude = [
                 channels[x] for x in dlg.GetSelections()
             ]
             sampleRate = self.Data.Datasets[0].sampleRate
             filelist = [f.filename for f in self.Data.Datasets]
             newfiles = [
                 ReadEEG(f, sampleRate, self.Data.Specs.channels2exclude)
                 for f in filelist
             ]
             self.Data.Datasets = newfiles
             del self.Data.Results.matrixSelected
             self.Data.Results.updateAll(self.Data)
         dlg.Destroy()
     event.Skip()
Exemplo n.º 7
0
    def OnScan(self, event):
	dlg = wx.MultiChoiceDialog(self, "What would you like to scan?", "Scan Options", ['ID Cards', 'Assignment Notice', \
				   'Release of Information', 'Consult Note', 'Old Records', 'Insurance Info', 'Labs', \
				   'Radiology', 'Other'])
	if dlg.ShowModal() == wx.ID_OK:
	    if dlg.GetSelections() == [0]:
		EMR_utilities.Scan(185, 65, self.ptID, "Insurance", "card", mode='duplex')
	    elif dlg.GetSelections() == [1]:
		EMR_utilities.Scan(215, 278, self.ptID, "Insurance", "notice")
	    elif dlg.GetSelections() == [2]:
		EMR_utilities.Scan(215, 278, self.ptID, "Other", "ROI", mode='ADF')
	    elif dlg.GetSelections() == [3]:
		EMR_utilities.Scan(215, 278, self.ptID, "Consults", "note", mode='ADF')
	    elif dlg.GetSelections() == [4]:
		EMR_utilities.Scan(215, 278, self.ptID, "Old_Records", "rec", mode='ADF')
	    elif dlg.GetSelections() == [5]:
		EMR_utilities.Scan(215, 278, self.ptID, "Insurance", "misc", mode='ADF')
	    elif dlg.GetSelections() == [6]:
		EMR_utilities.Scan(215, 278, self.ptID, "Labs", "lab", mode='ADF')
	    elif dlg.GetSelections() == [7]:
		EMR_utilities.Scan(215, 278, self.ptID, "Radiology", "rads", mode='ADF')
	    elif dlg.GetSelections() == [8]:
		EMR_utilities.Scan(215, 278, self.ptID, "Other", "misc", mode='ADF')
	else: 
	    wx.MessageBox("If you need to scan, hit the scan button again and select what you want to scan", '', wx.OK)
Exemplo n.º 8
0
def getMultiChoiceDlg(parent=None, title='', prompt_text='', choices=()):
    """
    Multiple choice dialog.

    :param parent: Parent form.
    :param title: Dialog form title.
    :param prompt_text: Dialog form prompt text.
    :param choices: List of selection lines as tuple in format ((True/False, 'line text'),...).
    :return: Selected chices as tuple ((True/False, 'line text'),...).
    """
    dlg = None
    win_clear = False
    try:
        if parent is None:
            parent = wx.Frame(None, -1, '')
            win_clear = True

        choice_list = [row[1] for row in choices]
        dlg = wx.MultiChoiceDialog(parent, prompt_text, title, choice_list)
        selections = [i for i, row in enumerate(choices) if row[0]]
        dlg.SetSelections(selections)

        if dlg.ShowModal() == wx.ID_OK:
            selections = dlg.GetSelections()
            result = [(bool(i in selections), txt)
                      for i, txt in enumerate(choice_list)]
            return result
    finally:
        if dlg:
            dlg.Destroy()
        if win_clear:
            parent.Destroy()
    return None
Exemplo n.º 9
0
    def OnEvent(self, propgrid, primaryEditor, event):
        if event.GetEventType() == wx.wxEVT_COMMAND_BUTTON_CLICKED:
            dlg = wx.MultiChoiceDialog(
                propgrid, 'Check all wanted %ss below:' % self.GetLabel(),
                'Make Choices', self.choices)
            if len(self.m_value.strip()) > 0:
                sels = [
                    self.choices.index(x.strip())
                    for x in self.m_value.split(',')
                ]
                dlg.SetSelections(sels)

            if dlg.ShowModal() == wx.ID_OK:
                sels = dlg.GetSelections()
                if len(sels) == 0:
                    self.m_value = ''
                    return True
                v = ''
                for idx in sels:
                    v += self.choices[idx] + ', '
                v = v[:-2]

                self.m_value = v
                self.SetValueInEvent(v)
                return True

        return False
Exemplo n.º 10
0
  def OnAddMember(self, evt):
    lv=self['Members']

    res=self.GetServer().SearchSubConverted("(uid=*)", "uid cn displayName")

    candidates=[]
    for _dn, info in res:
      uid=info['uid'][0]
      name=info.get("displayName")
      if not name:
        name=info.get('cn')
      if name:
        name=name[0]
      if lv.FindItem(-1, uid) < 0:
        if uid == name:
          candidates.append(uid)
        else:
          candidates.append("%s %s" % (uid, name))
    candidates.sort(key=unicode.lower)
    
    dlg=wx.MultiChoiceDialog(self, xlt("Add member"), xlt("Add member to group"), candidates)
    if dlg.ShowModal() == wx.ID_OK:
      uids=[]
      for row in range(lv.GetItemCount()):
        uids.append(lv.GetItemText(row, 0))
      for i in dlg.GetSelections():
        cr=candidates[i].split()
        uid=cr[0]
        row=lv.AppendItem(-1, uid)
        lv.SetStringItem(row, 1, " ".join(cr[1:]))
        lv.SetItemData(row, -1)
        uids.append(uid)

      self.dialog.SetValue(self.memberUidOid, uids, self)
Exemplo n.º 11
0
    def OnAddSong(self, event):
        choices = [i.split('$')[0] for i in self.musicList]
        dlg = wx.MultiChoiceDialog(None,
                                   'Choose Songs',
                                   'Songs',
                                   choices=choices,
                                   style=wx.OK | wx.CANCEL | wx.OK_DEFAULT)

        dlg.Centre()
        if dlg.ShowModal() == wx.ID_OK:
            songs = set(self.musicList[i] for i in dlg.GetSelections())

            for item in range(self._listCtrl.GetItemCount()):
                if self._listCtrl.IsItemChecked(item):
                    text = self._listCtrl.GetItemText(item)
                    self.playlist[text] = self.playlist[text].union(songs)

        self._leftPanel.Freeze()
        self._rightPanel.Freeze()
        self.createSideControls()
        try:
            self._listCtrl.Destroy()
        except RuntimeError:
            pass
        self.createPlaylistPanel()
        self._leftPanel.Thaw()
        self._rightPanel.Thaw()
Exemplo n.º 12
0
    def createListBox(self, dataFrame, kindofBox):
        print " total no of columns are", len(dataFrame.columns)
        columnList = dataFrame.columns.values
        #         isLabel = False
        if kindofBox == 'multi':
            listBox = wx.MultiChoiceDialog(self,
                                           message='List of Columns',
                                           caption='Select Columns to Drop',
                                           choices=columnList)
            listBox.ShowModal()
            selectedIndexes = listBox.GetSelections()
            print " total columns selected are", len(selectedIndexes)
            selectedItems = [columnList[index] for index in selectedIndexes]

            print "selected items are", selectedItems
            dataFrame = dataFrame.drop(selectedItems, axis=1)

        elif kindofBox == 'single':
            listBox = wx.SingleChoiceDialog(self,
                                            message='List of Columns',
                                            caption='Select Label Column',
                                            choices=columnList)
            listBox.ShowModal()
            selectedItem = columnList[listBox.GetSelection()]

            print "selected items are", selectedItem
            dataFrame = dataFrame[selectedItem]
            print len(dataFrame)
#             print "columns in label training dataFrame", len(dataFrame.columns)

        return dataFrame
Exemplo n.º 13
0
def icMultiChoiceDlg(Parent_=None, Title_='', Text_='', Choice_=()):
    """
    Диалог множественного выбора.
    @param Parent_: Родительское окно.
    @param Title_: Заголовок диалогового окна.
    @param Text_: Текст диалога.
    @param Choice_: Список выбора.Кортеж выбора в формате ((True/False,'Текст'),...).
    @return: Кортеж выбора в формате ((True/False,'Текст'),...).
    """
    dlg = None
    win_clear = False
    try:
        if Parent_ is None:
            Parent_ = wx.Frame(None, -1, '')
            win_clear = True

        choice_list = [row[1] for row in Choice_]
        dlg = wx.MultiChoiceDialog(Parent_, Text_, Title_, choice_list)
        # Установить выбор по умолчанию
        selections = [i for i, row in enumerate(Choice_) if row[0]]
        dlg.SetSelections(selections)

        if dlg.ShowModal() == wx.ID_OK:
            selections = dlg.GetSelections()
            result = [(bool(i in selections), txt)
                      for i, txt in enumerate(choice_list)]
            return result
    finally:
        if dlg:
            dlg.Destroy()
        # Удаляем созданное родительское окно
        if win_clear:
            Parent_.Destroy()
    return None
Exemplo n.º 14
0
def MChoiceDialog(message, caption, choices=None):
    """
    display a dialog box with drop down list containing items in a list,
    return the item selected by user, return None if click Cancel

    reconcile expectation of singleChoiceDialog by converting choices into a list
    of strings if choices is a list containing something else.
    """
    if choices is None:
        choices = []
    t_choices = dict((str(i), i) for i in choices)
    user_choice = ''
    selection = None
    app = wx.PySimpleApp()
    dialog = wx.MultiChoiceDialog(None, message, caption, map(str, choices))
    # dialog = singleChoiceDialog ( None, message, caption, map(str, choices))
    # using map(str, choices) instead of t_choices.keys() because former list is sorted
    if dialog.ShowModal() == wx.ID_OK:
        selection = [choices[r] for r in dialog.GetSelections()]
        # pick up the corresponding item from the list
        # this may be necessary if the choices do not contain strings
    # The user exited the dialog without pressing the "OK" button
    else:
        pass
    return selection
Exemplo n.º 15
0
    def on_switch_button(self, event):
        """Handle the event when the user clicks the switch button."""
        self.print(_(u"Setting switches"))

        switch_list = []
        switch_id = self.devices.find_devices(self.devices.SWITCH)
        for i in range(len(switch_id)):
            k = self.names.get_name_string(switch_id[i])
            if k is not None:
                switch_list.append(k)

        switch_dialog = wx.MultiChoiceDialog(self,
                                             _(u"Set switches On/Off"),
                                             _(u"Set switches"),
                                             switch_list,
                                             style=wx.OK)
        switch_dialog.SetSelections(self.switch_selections)

        if switch_dialog.ShowModal() == wx.ID_OK:
            self.switch_selections = switch_dialog.GetSelections()

        switch_state = [0] * len(switch_list)

        for i in range(len(self.switch_selections)):
            switch_state[self.switch_selections[i]] = 1

        for i in range(len(switch_list)):
            state = self.devices.set_switch(switch_id[i], switch_state[i])
            if self.logging is True:
                if state:
                    print("Successfully set switch.")
                else:
                    print("Error! Invalid switch.")
Exemplo n.º 16
0
    def videoRecordDevice(self, event):
        """ Video Record all devices connected and place the output at root"""
        self.videobutton.Disable()

        deviceModel, deviceID = self.getDevices()
        deviceIDModel = []

        if not deviceModel or not deviceID:
            self.SetStatusText("No Android devices detected")
            self.videobutton.Enable()
            return

        for everyi in deviceModel:
            for everym in deviceID:
                deviceIDModel = [everym + " " + everyi]

        try:
            dialog = wx.MultiChoiceDialog(self, "Pick your devices", "caption",
                                          deviceIDModel, wx.OK | wx.CANCEL)
        except UnboundLocalError:
            self.SetStatusText(f"No Devices Detected")
            self.videobutton.Enable()
            return

        instance = dialog.ShowModal()
        devices = dialog.GetSelections()

        listLength = len(devices)
        dialog.Destroy()

        if instance == wx.ID_OK:
            video = wx.TextEntryDialog(
                self, "", "How long do you want to record for in seconds?", "",
                wx.OK | wx.CANCEL)

            instance = video.ShowModal()
            videoLength = video.GetValue()
            video.Destroy()

            if instance == wx.ID_OK:
                for i in range(listLength):
                    self.SetStatusText(
                        f"Video Recording {devices[i]} {i+1}/{listLength}")
                    subprocess.call(
                        f"adb -s {deviceID[i]} shell screenrecord /sdcard/{deviceModel[i]}.mp4 --time {videoLength}"
                    )
                    subprocess.call(
                        fr"adb -s {deviceID[i]} pull /sdcard/{deviceModel[i]}.mp4 C:\ADBscripts\PhoneVideos"
                    )

                if listLength > 1:
                    self.SetStatusText(
                        f"Recorded a {videoLength} second video on {listLength} devices"
                    )
                else:
                    self.SetStatusText(
                        f"Recorded a {videoLength} second video on {listLength} device"
                    )

        self.videobutton.Enable()
Exemplo n.º 17
0
    def hideMarkers(self, event):

        if self.Data.Datasets != []:
            if not hasattr(self.Data.Results, 'collapsedMarkers'):
                markers = np.copy(self.Data.Results.markers)
            else:
                markers = self.Data.Results.collapsedMarkers
            markers = np.unique(markers)
            markers = markers.tolist() + self.Data.markers2hide
            markers = np.unique(markers).tolist()
            markers.sort()
            markerTxt = [str(m) for m in markers]
            dlg = wx.MultiChoiceDialog(
                self, caption="Select markers to hide",
                message='Which markers should be hidden ' +
                        'from further analysis?',
                choices=markerTxt)
            if self.Data.markers2hide == []:
                selected = []
            else:
                selected = [i for i, e in enumerate(markers)
                            if e in self.Data.markers2hide]
            dlg.SetSelections(selected)
            if dlg.ShowModal() == wx.ID_OK:
                if len(markers) != len(dlg.GetSelections()):
                    self.Data.markers2hide = [markers[x]
                                              for x in dlg.GetSelections()]
                    self.redrawFigures(event)

            dlg.Destroy()
        event.Skip()
Exemplo n.º 18
0
    def onTierCheck(self, event):
        """Fix the list of tiers to Show/Hide."""

        if self._trsctrl is None: return

        # Get the list of tiers' names
        lst = self._trsctrl.GetTierNames()
        if len(lst) == 0: return # hum... just to be sure

        dlg = wx.MultiChoiceDialog(self,
                                   "Check the tiers to show:",
                                   "Tiers to show/hide", lst)
        dlg.SetSelections(self._trsctrl.GetTierIdxChecked())

        if dlg.ShowModal() == wx.ID_OK:
            # get the list of tiers' names that are checked
            selections = dlg.GetSelections()
            checked = [lst[x] for x in selections]

            if len(checked) == 0:
                ShowInformation(self, self._prefsIO, "At least one tier must be checked!", wx.ICON_INFORMATION)
            else:
                # send the list to the trsctrl instance, then redraw
                self._trsctrl.SetTierChecked(checked)

        dlg.Destroy()
Exemplo n.º 19
0
 def test_choicdlgMulti(self):
     d = wx.MultiChoiceDialog(self.frame, 'message', 'caption',
                              choices="one two three four five".split())
     d.SetSelections([2, 4])
     s = d.GetSelections()
     #self.assertEqual(s, [2,4])   the internal list isn't updated right away, can't test this here
     d.Destroy()
Exemplo n.º 20
0
    def on_click_more(self, event):
        if not self.cats:
            files = self.file_list.GetStrings()
            if not files:
                return
            cols = []
            for f in files:
                rdr = multiplierz.mzReport.reader(f)
                cols.append(rdr.columns[:])
                rdr.close()
            cats = reduce(set.intersection, [set(c) for c in cols])

            self.cats = sorted(c for c in cats.difference(
                set(self.option_list_data + ['Experimental mz'])) if c)

        more_cats = wx.MultiChoiceDialog(None,
                                         "Choose Columns To Match:",
                                         "More Fields",
                                         choices=self.cats)
        if more_cats.ShowModal() == wx.ID_OK:
            defaults = self.category_list.GetStrings()[:4]
            checked_defs = [
                d for i, d in enumerate(defaults)
                if self.category_list.IsChecked(i)
            ]

            checked_cats = [self.cats[i] for i in more_cats.GetSelections()]

            self.category_list.SetItems(defaults + checked_cats)
            self.category_list.SetCheckedStrings(checked_defs + checked_cats)

        more_cats.Destroy()
Exemplo n.º 21
0
    def OnEvent(self, propgrid, primaryEditor, event):
        
        if event.GetEventType() in [wx.wxEVT_BUTTON, wx.wxEVT_LEFT_UP, wx.wxEVT_RIGHT_UP]:
            
            dlg = wx.MultiChoiceDialog(propgrid, message='Check all wanted %ss below:'%self.GetLabel(),
                                        caption='Make Choices', choices=self.choices.GetLabels())

            if dlg.ShowModal() == wx.ID_OK:
                sels = dlg.GetSelections()
                v = ''
                if len(sels) == 0:
                    self.m_value = ''
                    # return True
                else:
                    for idx in sels:
                        v += self.choices.GetLabels()[idx] +', '
                    v = v[:-2]

                self.m_value = v
                self.SetValueInEvent(v)
                return True
            
            elif dlg.ShowModal() in [wx.ID_CANCEL, wx.ID_EXIT]:
                self.m_value = None
            
            if self.m_value:
                if len(self.m_value.strip()) > 0:
                    sels = [ self.choices.index(x.strip()) for x in self.m_value.split(',') ]
                    dlg.SetSelections(sels)
                
        return False    
Exemplo n.º 22
0
    def OnOpenRecentButton(self,
                           event=None
                           ):  # handle user request to Open Recent Project
        self.DisableKeypresses()
        OpenSuccess = False  # whether valid project files are identified for opening
        # read recent projects list from cache file
        try:
            recent_projects_list = self.settings_manager.get_config(
                'RecentProjectsList')
        except KeyError:
            #recent_projects_list does not exist - so create it
            recent_projects_list = []
            self.settings_manager.set_value('RecentProjectsList',
                                            recent_projects_list)

        RPDisplayList = [
        ]  # build list of recent projects in display-friendly format
        for ProjFilename in reversed(recent_projects_list):
            RPDisplayList.append(
                _('%s in %s') % (os.path.basename(ProjFilename),
                                 os.path.dirname(ProjFilename)))
        DialogueBox = wx.MultiChoiceDialog(
            self, _('Which project(s) would you like to open?'),
            _('Choose a vizop project file to open'),
            RPDisplayList)  # set up standard selection dialogue
        if DialogueBox.ShowModal() == wx.ID_OK:  # user clicked OK
            FilenamesSelected = []  # make list of filenames selected
            for index in DialogueBox.GetSelections():
                FilenamesSelected.append(recent_projects_list[index])
            OpenableProjFiles, ProjOpenData = self.HandleOpenFileRequest(
                FilenamesSelected)
            OpenSuccess = bool(OpenableProjFiles)
        # allow user to continue working in Welcome Frame if no projects can be opened. TODO give user feedback
        if not OpenSuccess:
            self.ReinstateKeypresses()
Exemplo n.º 23
0
 def OnLeftLink(self, event):
     """ Sélectionner les données à importer """
     # Préparation de la liste des données
     listeDonnees = []
     listePreSelections = []
     index = 0
     for nomCategorie, tables, selection in self.listeTablesImportation :
         listeDonnees.append(nomCategorie)
         if selection == True :
             listePreSelections.append(index)
         index += 1
                                       
     # Boîte de dialogue sélections multiples
     titre = _(u"Importation des données")
     message = _(u"Sélectionnez les données que vous souhaitez importer :")
     dlg = wx.MultiChoiceDialog(self, message, titre, listeDonnees, wx.CHOICEDLG_STYLE)
     # Coche ceux qui doivent être déjà sélectionnés dans la liste
     dlg.SetSelections(listePreSelections)
     
     # Résultats
     if dlg.ShowModal() == wx.ID_OK:
         listeSelections = dlg.GetSelections()
         index = 0
         for categorie in self.listeTablesImportation :
             if index in listeSelections :
                 self.listeTablesImportation[index][2] = True
             else:
                 self.listeTablesImportation[index][2] = False
             index += 1
         
         if len(listeSelections) == 0 :
             self.checkbox_details.SetValue(False)
         dlg.Destroy()
     else:
         dlg.Destroy()
    def RetirerPiece(self, event):
        """ Retirer pièces """
        if len(self.Selection()) == 0:
            dlg = wx.MessageDialog(
                self,
                _(u"Vous devez d'abord sélectionner un destinataire dans la liste !"
                  ), _(u"Erreur de saisie"), wx.OK | wx.ICON_EXCLAMATION)
            dlg.ShowModal()
            dlg.Destroy()
            return
        track = self.Selection()[0]
        if track.pieces == []:
            dlg = wx.MessageDialog(self,
                                   _(u"Il n'y a aucune pièce à retirer !"),
                                   _(u"Erreur de saisie"),
                                   wx.OK | wx.ICON_EXCLAMATION)
            dlg.ShowModal()
            dlg.Destroy()
            return

        dlg = wx.MultiChoiceDialog(
            self, _(u"Cochez les pièces personnelles à retirer :"),
            _(u"Retirer des pièces personnelles"), track.listeLabelsPieces)
        if dlg.ShowModal() == wx.ID_OK:
            selections = dlg.GetSelections()
            for index in selections:
                track.pieces.pop(index)
                self.memoire_pieces[track.adresse] = track.pieces
            self.MAJ()
        dlg.Destroy()
    def BeginEdit(self, row, col, grid):
        """
        Fetch the value from the table and prepare the edit control
        to begin editing.  Set the focus to the edit control.
        *Must Override*
        """
        # should be a list of enum
        at = grid.GetTable().get_attr_type(row, col)
        val = grid.GetTable().GetValue(row, col)    
                        
        # print at,type(at),at.name
        self._ctrl.SetLabel(at.str(val, grid.editor_context.project))        
        
        # show dialog
        enum = at.element_type.enum        
        dlg = wx.MultiChoiceDialog(self, "", at.name, enum.names)
        dlg.SetSelections([enum.names.index(v) for v in val])

        if dlg.ShowModal() == wx.ID_OK:
            selections = dlg.GetSelections()
            self._result = [enum.names[x] for x in selections]            

        dlg.Destroy()
        
        # end edit, right after Dialog closes
        grid.DisableCellEditControl()
Exemplo n.º 26
0
def E4072():
    """ Suppression des prestations sans consommations associées """    
    print "Lancement de la procedure E4072..."
    DB = GestionDB.DB()
    
    # Récupération des prestations
    req = """SELECT IDprestation, label FROM prestations;""" 
    DB.ExecuterReq(req)
    listePrestations = DB.ResultatReq()
    
    # Récupération des consommations
    req = """SELECT IDconso, IDprestation FROM consommations;""" 
    DB.ExecuterReq(req)
    listeConsommations = DB.ResultatReq()
    DB.Close()
    
    # Analyse
    dictPrestations = {}
    for IDconso, IDprestation in listeConsommations :
        if dictPrestations.has_key(IDprestation) == False :
            dictPrestations[IDprestation] = []
        dictPrestations[IDprestation].append(IDconso)
    
    dictResultats = {}
    for IDprestation, label in listePrestations :
        if dictPrestations.has_key(IDprestation) == False :
            if dictResultats.has_key(label) == False :
                dictResultats[label] = []
            dictResultats[label].append(IDprestation)
    
    listeDonnees = []
    for label, listePrestationsTemp in dictResultats.iteritems() :
        texte = _(u"%s (%d prestations)") % (label, len(listePrestationsTemp))
        listeDonnees.append((texte, label, listePrestationsTemp))
    listeDonnees.sort() 
    
    listeLabels = []
    for texte, label, listePrestationsTemp in listeDonnees :
        listeLabels.append(texte)
    
    message = _(u"Cochez les prestations sans consommations associées que vous souhaitez supprimer.\n(Pensez à sauvegarder votre fichier avant d'effectuer cette procédure !)")
    dlg = wx.MultiChoiceDialog(None, message, _(u"Suppression des prestations sans consommations associées"), listeLabels)
    dlg.SetSize((450, 500))
    dlg.CenterOnScreen() 
    if dlg.ShowModal() == wx.ID_OK:
        import wx.lib.agw.pybusyinfo as PBI
        message = _(u"Veuillez patienter durant la procédure...")
        dlgAttente = PBI.PyBusyInfo(message, parent=None, title=_(u"Procédure"), icon=wx.Bitmap(Chemins.GetStaticPath("Images/16x16/Logo.png"), wx.BITMAP_TYPE_ANY))
        wx.Yield() 
        selections = dlg.GetSelections()
        DB = GestionDB.DB()
        for index in selections :
            texte, label, listePrestationsTemp = listeDonnees[index]
            for IDprestation in listePrestationsTemp :
                DB.ReqDEL("prestations", "IDprestation", IDprestation)
        DB.Close()
        del dlgAttente
    dlg.Destroy()
    print "Fin de la procedure E4072."
Exemplo n.º 27
0
def ShowSigTrendGraphLISA(self):
    # self is Main.py
    if not self.shapefiles or len(self.shapefiles) < 1:
        return
    shp_list = [shp.name for shp in self.shapefiles]
    dlg = wx.SingleChoiceDialog(
        self, 'Select a POINT or Polygon(with time field) shape file:',
        'LISA Trend Graph', shp_list, wx.CHOICEDLG_STYLE)
    if dlg.ShowModal() == wx.ID_OK:
        idx = dlg.GetSelection()
        shp = self.shapefiles[idx]
        background_shapes = FilterShapeList(self.shapefiles, stars.SHP_POLYGON)
        if shp.shape_type == stars.SHP_POINT:
            # create Markov LISA from points
            gi_dlg = SigTrendGraphLISAQueryDialog(
                self,
                "LISA Trend Graph:" + shp.name,
                shp,
                background_shps=background_shapes,
                size=stars.DIALOG_SIZE_QUERY_MARKOV_LISA)
            gi_dlg.Show()
        elif shp.shape_type == stars.SHP_POLYGON:
            # bring up a dialog and let user select
            # the time field in POLYGON shape file
            dbf_field_list = shp.dbf.header
            timedlg = wx.MultiChoiceDialog(
                self, 'Select TIME fields to generate LISA Trend Graph:',
                'DBF fields view', dbf_field_list)
            if timedlg.ShowModal() == wx.ID_OK:
                selections = timedlg.GetSelections()
                # compose lisa_data_dict
                dbf = shp.dbf
                lisa_data_dict = {}
                count = 0
                lbls = []
                for idx in selections:
                    lisa_data_dict[count] = np.array(
                        dbf.by_col(dbf.header[idx]))
                    lbls.append(dbf.header[idx])
                    count += 1
                gi_spacetime_widget = PlotWidget(self,
                                                 shp,
                                                 None,
                                                 SigTrendGraphLISA,
                                                 query_data=lisa_data_dict,
                                                 lbls=lbls,
                                                 size=(800, 650),
                                                 start=1,
                                                 end=count - 1,
                                                 step_by='',
                                                 step=1)
                gi_spacetime_widget.Show()
            timedlg.Destroy()
        else:
            self.ShowMsgBox(
                "File type error. Should be a POINT or POLYGON shapefile.")
            dlg.Destroy()
            return
    dlg.Destroy()
Exemplo n.º 28
0
 def OnGetChoices(self, event):
     msg = "Pick the are resources to view."
     ids = [x for x in dir(wx) if x.startswith("ART_")]
     dlg = wx.MultiChoiceDialog(self, msg, "Pick Images", ids)
     if (dlg.ShowModal() == wx.ID_OK):
         for selection in dlg.GetSelections():
             theId = getattr(wx, ids[selection])
             self.panel.AddBitmap(theId)
Exemplo n.º 29
0
 def viewmenu_passenger_handler(self, event):
     pax_list = sorted(common.passengers.itervalues())
     labels = [str(p) for p in pax_list]
     dialog = wx.MultiChoiceDialog(self, '', 'View Passengers', labels)
     dialog.ShowModal()
     selections = dialog.GetSelections()  # indexes of the selections
     for i in selections:
         pax_list[i].edit_traits()
Exemplo n.º 30
0
def ask(choices, parent=None, message='', title=''):
    #    dlg = wx.TextEntryDialog(parent, message, defaultValue=default_value)
    dlg = wx.MultiChoiceDialog(parent, message, title, choices)
    dlg.ShowModal()
    result = dlg.GetSelections()
    selection = result
    dlg.Destroy()
    return selection