Exemplo n.º 1
0
 def on_roses(self, event):
     """TO DO"""
     season = wx.GetSingleChoice("Select a season to analyze:",
                                 "Select season",
                                 ["Winter", "Summer", "Spring", "Fall"])
     if season:
         ms = MONTHS[season]
         str_coords = wx.GetTextFromUser("Coordinates (lon, lat):",
                                         default_value="-74.85,11.11")
         str_lon, str_lat = str_coords.split(",")
         lon = float(str_lon)
         lat = float(str_lat)
         if lon < 0:
             lon = 360 + lon
         progress_dlg = wx.ProgressDialog(
             "Read and analyze", "Reading and analyzing wave data...")
         progress_dlg.Pulse()
         fname = f"tmp/dp-hs-{season}-{lon}-{lat}.tmp"
         try:
             dp_hs = load_obj(fname)
         except FileNotFoundError:
             dp_hs = joint_distribution(["dp", "hs"], ms, lon, lat)
             save_obj(dp_hs, fname)
         progress_dlg.Update(100)
         frm_canvas = FrameCanvas(None, title="Wave Rose")
         ax = frm_canvas.fig.add_subplot(projection="windrose")
         dp, hs = dp_hs
         ax.bar(dp, hs, normed=True)
         ax.set_title("Significant Wave Height Rose")
         ax.set_legend(title="$H_s$ (m)")
         frm_canvas.Show()
Exemplo n.º 2
0
def 组件_单选列表对话框(提示="", 标题="请选择", 选择项=['未设置'], 初始选中=0, 父窗口=None):
    "弹出一个单选列表对话框,选择后返回选中的文本内容,取消返回空,选择项必须是文本型列表,初始选中从0开始"
    return wx.GetSingleChoice(message=提示,
                              caption=标题,
                              choices=选择项,
                              initialSelection=初始选中,
                              parent=父窗口)
Exemplo n.º 3
0
    def InitLanguage(self):
        langsAvail = {
            "System default": self.sysLng,
            "English": wx.LANGUAGE_ENGLISH,
            "French": wx.LANGUAGE_FRENCH,
            "German": wx.LANGUAGE_GERMAN,
            "Italian": wx.LANGUAGE_ITALIAN,
        }

        sel = wx.GetSingleChoice("Please choose language:", "Language",
                                 list(langsAvail.keys()))
        if sel == "":
            sel = "System default"

        lang = langsAvail[sel]
        # We don't have to do anything if the selected language is english
        # As the strings of this app have been written in this lang
        if lang == wx.LANGUAGE_ENGLISH:
            return

        wx.Locale.AddCatalogLookupPathPrefix("../langs")
        self.locale = wx.Locale()
        if not self.locale.Init(lang):
            wx.LogWarning("This language is not supported by the system.")
        if not self.locale.AddCatalog("internat"):
            wx.LogError(
                "Couldn't find/load the 'internat' catalog for locale '" +
                self.locale.GetCanonicalName() + "'.")
Exemplo n.º 4
0
    def EvtSelTmplist(self, event):
	lt = "/home/mb/Desktop/GECKO/wellchild/%s.txt"
	at = ""
	wt = "C:\Documents and Settings\mbarron\My Documents\GECKO\wellchild\%s.txt"
	if event.GetString() == 'generic':
	    gen_note = EMR_formats.note(self.PtID)
	    if wx.GetTopLevelParent(self).nb.GetPage(2).reviewed == 1:
		gen_note = gen_note.replace('Meds', 'Meds(reviewed today)')
		gen_note = gen_note.replace('Allergies', 'Allergies(reviewed today)')
	    self.newsoapNote.SetValue(gen_note)
	    self.not_billable = 0
	elif event.GetString() == 'prenatal':
	    self.newsoapNote.SetValue(EMR_formats.prenatal(self.PtID))
	elif event.GetString() == 'procedure':
	    self.newsoapNote.SetValue(EMR_formats.procedure(self.PtID))
	elif event.GetString() == 'phonecon':
	    self.newsoapNote.SetValue(EMR_formats.phonecon(self.PtID))
	    self.not_billable = 1
	elif event.GetString() == 'well child':
	    choice = wx.GetSingleChoice('What age child?', "", ['Wt Check', '2 month', '4 month', '6 month', '9 month',
		'12 month', '15 month', '18 month', '2 year', '3-4 year', '6-7_yr_old', '7-8 year', '10-11_yr_old', 
		'12-13_yr_old', '9-12 year', '13-15 year'])
	    string = open(EMR_utilities.platformText(lt, at, wt) % choice, 'r')
	    s = string.read()
	    string.close()
	    result = s % (EMR_utilities.getAge(self.PtID), EMR_utilities.getSex(self.PtID), 
		EMR_formats.getVitals(self.PtID, baby=1))
	    self.newsoapNote.SetValue(result)
	    self.not_billable = 0
	else: pass
Exemplo n.º 5
0
 def on_period_exceedance(self, event):
     """Plots Probability of Exceedance Estimates of mean peak period for a season."""
     season = wx.GetSingleChoice("Select a season to analyze:",
                                 "Select season",
                                 ["Winter", "Summer", "Spring", "Fall"])
     if season:
         ms = MONTHS[season]
         str_coords = wx.GetTextFromUser("Coordinates (lon, lat):",
                                         default_value="-74.85,11.11")
         str_lon, str_lat = str_coords.split(",")
         lon = float(str_lon)
         lat = float(str_lat)
         if lon < 0:
             lon = 360 + lon
         progress_dlg = wx.ProgressDialog(
             "Read and analyze", "Reading and analyzing wave data...")
         progress_dlg.Pulse()
         fname = f"tmp/tp-{season}-{lon}-{lat}.tmp"
         try:
             x, p = load_obj(fname)
         except FileNotFoundError:
             data = frequency_curve("tp", ms, lon, lat)
             save_obj(data, fname)
             x, p = data
         progress_dlg.Update(100)
         frm_canvas = FrameCanvas(
             None, title="Probability of Exceedance for Peak Period")
         ax = frm_canvas.fig.add_subplot()
         ax.semilogy(x, p, "o")
         ax.set_xlabel("Peak Period (s)")
         ax.set_ylabel("Probability of Exceedance")
         ax.set_title(season)
         ax.grid(True)
         frm_canvas.Show()
Exemplo n.º 6
0
 def on_weibull(self, event):
     """Extreme value analysis - Maximum Weibull distribution"""
     season = wx.GetSingleChoice("Select a season to analyze:",
                                 "Select season",
                                 ["Winter", "Summer", "Spring", "Fall"])
     if season:
         ms = MONTHS[season]
         str_coords = wx.GetTextFromUser("Coordinates (lon, lat):",
                                         default_value="-74.85,11.11")
         str_lon, str_lat = str_coords.split(",")
         lon = float(str_lon)
         lat = float(str_lat)
         if lon < 0:
             lon = 360 + lon
         progress_dlg = wx.ProgressDialog(
             "Read and analyze", "Reading and analyzing wave data...")
         progress_dlg.Pulse()
         fname = f"tmp/hs-peaks-{season}-{lon}-{lat}.tmp"
         try:
             peaks_hs = load_obj(fname)
         except FileNotFoundError:
             peaks_hs = weibull_data("hs", ms, lon, lat)
             save_obj(peaks_hs, fname)
         progress_dlg.Update(100)
         analysis = weibull.Analysis(peaks_hs, unit="m")
         analysis.fit()
         analysis.probplot()
Exemplo n.º 7
0
 def selectBibDeskFile(self, event):
   docnames = [ d.name.get() for d in bibdesk.documents.get() ]
   assert len(docnames) > 0, 'Please open a bibliography document in BibDesk first.'
   docnames.sort()
   bibfile = wx.GetSingleChoice('Please select the BibDesk document to use:', caption='BibDesk to Word', parent=self, choices=docnames)
   if bibfile != '':
     self.wxbibfile.SetLabel(bibfile)
Exemplo n.º 8
0
    def _onLoadLayout(self, event):
        choice = wx.GetSingleChoice(message='Select layout to load',
                                    caption='Load Layout',
                                    parent=self,
                                    choices=self._layoutCfgs.keys())

        if 0 != len(choice):
            self._loadLayout(self._layoutCfgs[choice])
Exemplo n.º 9
0
    def DoShowDialog(self, propGrid, property):
        s = wx.GetSingleChoice("Choose Smoother", "Smoother...", self.choices)

        if s:
            self.SetValue(s)
            return True

        return False
Exemplo n.º 10
0
    def DoShowDialog(self, propGrid, property):
        s = wx.GetSingleChoice("Message", "Caption", self.choices)

        if s:
            self.SetValue(s)
            return True

        return False
Exemplo n.º 11
0
 def onClick_GetSingleChoice(self, event):
     code = ["Python", "Shell", "Java"]
     choice = wx.GetSingleChoice(message="Which do you like best ?",
                                 caption="GetSingleChoice",
                                 aChoices=code)  # 可选择的列表
     if choice is "":
         print("Nothing.")
     else:
         print("Your choice is", choice)
Exemplo n.º 12
0
 def OnAlign(self, evt):
     reference = wx.GetSingleChoice(
         "Select a reference track",
         self.m_alignBtn.GetLabel(),
         TrackList.track_names(),
         parent=self
     )
     if reference:
         tracks = self.GetSelectedTrackNames() or TrackList.track_names()
         for path in tracks:
             TrackList.align_track(reference, path)
Exemplo n.º 13
0
    def OnRemoveChannel(self, event: wx.CommandEvent) -> None:
        """Remove one channel."""
        if not wx.GetApp().Channels.Names:
            wx.MessageBox('There are no channels to be removed.',
                          caption='Failed to remove channel', style=wx.OK)
            return

        name = wx.GetSingleChoice('Choose channel to be removed:',
                                  caption='Remove a channel',
                                  aChoices=wx.GetApp().Channels.Names)
        if not name:
            return
        wx.GetApp().Channels.Remove(name)
Exemplo n.º 14
0
    def OnPerspectiveMenu(self, evt):
        """Handles menu events generated by the managers control menu.
        @param evt: event that called this handler

        """
        e_id = evt.GetId()
        if e_id == ID_SAVE_PERSPECTIVE:
            name = wx.GetTextFromUser(_("Perspective Name"), \
                                      _("Save Perspective"))
            if name:
                self.AddPerspective(name, p_data=None)
                self.SavePerspectives()
                Profile_Set('DEFAULT_VIEW', name)

                # It may make sense to update all windows to use this
                # perspective at this point but it may be an unexpected
                # event to happen when there is many windows open. Will
                # leave this to future consideration.
                for mainw in wx.GetApp().GetMainWindows():
                    mainw.AddPerspective(name, self._viewset[name])

        elif e_id == ID_DELETE_PERSPECTIVE:
            views = [
                view for view in self._viewset.keys()
                if view != AUTO_PERSPECTIVE
            ]
            name = wx.GetSingleChoice(_("Perspective to Delete"),
                                      _("Delete Perspective"), views)

            if name:
                self.RemovePerspective(name)
                self.SavePerspectives()
                for mainw in wx.GetApp().GetMainWindows():
                    mainw.RemovePerspective(name)
            else:
                pass

            # Update all windows data sets
            for mainw in wx.GetApp().GetMainWindows():
                mainw.LoadPerspectives()

        elif e_id in self._ids + [ID_AUTO_PERSPECTIVE]:
            if e_id == ID_AUTO_PERSPECTIVE:
                Profile_Set('DEFAULT_VIEW', AUTO_PERSPECTIVE)
                self.SetAutoPerspective()
            else:
                self.SetPerspectiveById(e_id)
        else:
            evt.Skip()
Exemplo n.º 15
0
    def _onDeleteLayout(self, event):
        choice = wx.GetSingleChoice(message='Select layout to delete',
                                    caption='Delete Layout',
                                    parent=self,
                                    choices=self._layoutCfgs.keys())

        if 0 != len(choice):
            # Remove item from menu
            mb = self.GetMenuBar()
            menu = mb.GetMenu(mb.FindMenu("Layouts"))
            menuItemId = menu.FindItem(choice)
            menu.Delete(menuItemId)
            mb.Refresh()

            # Remove from cfgs
            del self._layoutCfgs[choice]
Exemplo n.º 16
0
 def on_height_joint(self, event):
     """TO DO"""
     season = wx.GetSingleChoice("Select a season to analyze:",
                                 "Select season",
                                 ["Winter", "Summer", "Spring", "Fall"])
     if season:
         ms = MONTHS[season]
         str_coords = wx.GetTextFromUser("Coordinates (lon, lat):",
                                         default_value="-74.85,11.11")
         str_lon, str_lat = str_coords.split(",")
         lon = float(str_lon)
         lat = float(str_lat)
         if lon < 0:
             lon = 360 + lon
         progress_dlg = wx.ProgressDialog(
             "Read and analyze", "Reading and analyzing wave data...")
         progress_dlg.Pulse()
         fname = f"tmp/dp-hs-{season}-{lon}-{lat}.tmp"
         try:
             dp_hs = load_obj(fname)
         except FileNotFoundError:
             dp_hs = joint_distribution(["dp", "hs"], ms, lon, lat)
             save_obj(dp_hs, fname)
         progress_dlg.Update(100)
         frm_canvas = FrameCanvas(None, title="Joint Probability of Hs - θ")
         ax = frm_canvas.fig.add_subplot()
         kernel = stats.gaussian_kde(dp_hs)
         dp, hs = dp_hs
         dp, hs = np.meshgrid(np.linspace(dp.min(), dp.max(), N),
                              np.linspace(hs.min(), hs.max(), N // 2))
         p = np.reshape(kernel(np.vstack([dp.flatten(),
                                          hs.flatten()])), (N // 2, N))
         im = ax.imshow(p,
                        origin="lower",
                        extent=(0, 360, hs.min(), hs.max()),
                        aspect="auto",
                        cmap="jet")
         cbar = frm_canvas.fig.colorbar(im)
         cbar.ax.set_ylabel("Probability")
         cs = ax.contour(dp, hs, p, colors="k", levels=4, linewidths=1)
         ax.clabel(cs, inline_spacing=0.1)
         ax.set_xlabel("Average direction at the peak period (deg)")
         ax.set_ylabel("Significant Wave Height (m)")
         ax.set_title(season)
         ax.grid(True)
         frm_canvas.Show()
Exemplo n.º 17
0
    def OnRemoveChannel(self, event: wx.CommandEvent) -> None:
        """Remove one channel."""
        if not self._channels:
            wx.MessageBox('There are no channels to be removed.',
                          caption='Failed to remove channel',
                          parent=self,
                          style=wx.OK)
            return

        name = wx.GetSingleChoice('Choose channel to be removed:',
                                  caption='Remove a channel',
                                  aChoices=list(self._channels.keys()),
                                  parent=self)
        if not name:
            return

        menu = event.GetEventObject()
        menu.DestroyItem(menu.FindItemById(menu.FindItem(name)))
        self._channels.pop(name)
Exemplo n.º 18
0
    def OnPerspectiveMenu(self, evt):
        """Handles menu events generated by the managers control
        menu.
        @param evt: event that called this handler
        
        """
        e_id = evt.GetId()
        if e_id in [ID_SAVE_PERSPECTIVE, ID_DELETE_PERSPECTIVE]:
            if e_id == ID_SAVE_PERSPECTIVE:
                name = wx.GetTextFromUser(_("Perspective Name"), \
                                          _("Save Perspective"))
                if name:
                    self.AddPerspective(name, p_data=None)
                    self.SavePerspectives()

                    for mainw in wx.GetApp().GetMainWindows():
                        mainw.AddPerspective(name, self._viewset[name])

            elif e_id == ID_DELETE_PERSPECTIVE:
                name = wx.GetSingleChoice(_("Perspective to Delete"),
                                          _("Delete Perspective"),
                                          self._viewset.keys())
                if name:
                    self.RemovePerspective(name)
                    self.SavePerspectives()
                    for mainw in wx.GetApp().GetMainWindows():
                        mainw.RemovePerspective(name)
            else:
                pass

            # Update all windows data sets
            for mainw in wx.GetApp().GetMainWindows():
                mainw.LoadPerspectives()
        elif e_id in self._ids:
            self.SetPerspectiveById(e_id)
        else:
            evt.Skip()
Exemplo n.º 19
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)
Exemplo n.º 20
0
 def on_serial_port(self, event):
     sp = wx.GetSingleChoice('Select a serial port', 'Serial port', [x for x, y, z in list_ports.comports()])
     if sp:
         self.serial_reader.open(sp, 115200)
         self.status_bar.SetStatusText(sp, 1)
Exemplo n.º 21
0
 def OnRemoveWatch(self, evt):
     ch = wx.GetSingleChoice("Select watch dir to remove", "Remove Watch",
                             self.ftree.WatchDirs, self)
     if ch:
         self.ftree.RemoveWatchDirectory(ch)
Exemplo n.º 22
0
    def fetchExamResults(self, event):
        if not self.examsOLV.GetSelectedObject():
            dlg = wx.MessageDialog(
                None, "Click on a row first in order to view exam results.",
                'Error Message.', wx.OK | wx.ICON_ERROR)
            dlg.ShowModal()
            dlg.Destroy()
        else:
            rowObj = self.examsOLV.GetSelectedObject()

            form = getFormsInExam(rowObj['exam_id'])

            if form == "All":
                choices = [u"Form 1", u"Form 2", u"Form 3", u"Form 4"]

                formChosen = wx.GetSingleChoice(
                    message="Select Form to View Results",
                    caption="Exam Results.",
                    choices=choices,
                    parent=None)
            else:
                formChosen = form

            if formChosen == "Form 1" or formChosen == "One":
                formChosen = 1
            elif formChosen == "Form 2" or formChosen == "Two":
                formChosen = 2
            elif formChosen == "Form 3" or formChosen == "Three":
                formChosen = 3
            elif formChosen == "Form 4" or formChosen == "Four":
                formChosen = 4

            subjectChoices = getActiveSubjectAliases()
            subjectChoices = subjectChoices['aliases']
            subjectChoices.insert(0, "All Subjects")

            subjectChosen = wx.GetSingleChoice(message="Select Subject.",
                                               caption="Exam Results.",
                                               choices=subjectChoices,
                                               parent=None)

            if subjectChosen == "All Subjects":
                alias = "All"
                subjects = getActiveSubjectAliases()
                subjects = subjects['aliases']
            else:
                alias = subjectChosen
                subjects = [subjectChosen]

            self.exam_data = {
                "exam_id": rowObj['exam_id'],
                "class_id": 0,
                "form": formChosen,
                "subject_alias": alias,
                "year": rowObj['year'],
                "term": rowObj['term'],
                "exam_name": rowObj['exam_name'],
            }

            data = getExamResults(self.exam_data, subjects)
            if data:
                self.edit_exam_panel.Hide()
                # self.show_results.Hide()
                #
                # self.show_results = ViewResults(self, self.exam_data)
                # self.show_results.setExamResults()
                # self.show_results.updateResultsOLV("")
                # self.show_results.Show()
                #
                # self.Layout()

                if self.show_results_panel_added == 0:
                    self.show_results = ViewResults(self, self.exam_data)
                    self.right_sizer.Add(self.show_results, 1, wx.EXPAND)

                    self.Layout()

                    self.show_results_panel_added = 1
                else:
                    self.show_results.Destroy()
                    self.show_results = ViewResults(self, self.exam_data)
                    self.right_sizer.Add(self.show_results, 1, wx.EXPAND)

                    self.Layout()
            else:
                dlg = wx.MessageDialog(None, "No results for selected exam.",
                                       'Error Message.', wx.OK | wx.ICON_ERROR)
                dlg.ShowModal()
                dlg.Destroy()

                self.show_results.Hide()
                self.edit_exam_panel.Show()

                self.Layout()
Exemplo n.º 23
0
 def five_play(self, event):
     list1 = ('1', '2', '3', '4', '9')
     data2 = wx.GetSingleChoice("what do you what:", "12345", list1)
     print data2