Ejemplo n.º 1
0
def gen_s(tab, root, nom):
    old_locale = locale.getlocale()
    locale.setlocale(locale.LC_ALL, "C")

    #tab=ser.read_s()
    k = len(tab)
    f = open(find_resource(os.path.join("hsqc", "resources", 'entete.txt')),
             'r')
    l = f.readlines()
    f.close()
    f = open(os.path.join(root, nom), 'w')
    l1 = f.writelines(l)
    #l1=f.writelines('\n')
    for h in range(k):
        m1 = '<Peak2D F1="'
        m2 = str(tab[h][0])
        m3 = '" F2="'
        m4 = str(tab[h][1])
        m5 = '" annotation="'
        m6 = str(tab[h][2])
        m7 = '" intensity="'
        m8 = str(tab[h][3])
        m9 = '" type="0"/>\n'
        m = m1 + m2 + m3 + m4 + m5 + m6 + m7 + m8 + m9
        l1 = f.writelines(m)
    l1 = f.writelines('</PeakList2D> \n')
    l1 = f.writelines('</PeakList> \n')
    f.close()

    locale.setlocale(locale.LC_ALL, old_locale)
Ejemplo n.º 2
0
    def __init__(self, parent=None, *args, **kwargs):

        resource = wx.xrc.EmptyXmlResource()
        resource.InsertHandler(medipy.gui.xrc_wrapper.DirectoryXMLHandler())
        resource.InsertHandler(medipy.gui.xrc_wrapper.FileXMLHandler())

        file = open(find_resource("resources/gui/spectro_dialog.xrc"))
        resource.LoadFromString(file.read())

        dialog = resource.LoadDialog(parent, "main_dialog")
        medipy.gui.xrc_wrapper.Dialog.__init__(self, dialog, *args, **kwargs)

        controls = [
            "dir_dialog", "dir_listbox", "image_listbox", "reference_listbox",
            "annotations_listbox", "annotations_checkbox", "file_dialog",
            "open_button", "cancel_button"
        ]

        for control in controls:
            setattr(self, "_" + control, wx.xrc.XRCCTRL(self, control))

        self.SetTitle("Load spectroscopy image")
        self._open_button.Disable()

        # Attributes initialization
        self._patient_dirname = None
        self._image_dict = {}
        self._rect_dict = {}
        self._image_path = None
        self._reference_path = None
        self._annotations_path = None
        self._file_dialog._wildcard = "Annotation file|*.xml"
        self._file_dialog._button.Disable()

        # Events
        self.Bind(wx.EVT_CLOSE, self.OnClose)
        self._dir_listbox.Bind(wx.EVT_LISTBOX, self.OnDirChosen)
        self._image_listbox.Bind(wx.EVT_LISTBOX, self.OnImageChosen)
        self._reference_listbox.Bind(wx.EVT_LISTBOX, self.OnReferenceChosen)
        self._annotations_listbox.Bind(wx.EVT_LISTBOX, self.OnAnnotationChosen)
        self._annotations_checkbox.Bind(wx.EVT_CHECKBOX, self.OnCustomChecked)
        self._open_button.Bind(wx.EVT_BUTTON, self.OnOpenClicked)
        self._cancel_button.Bind(wx.EVT_BUTTON, self.OnCancelClicked)

        self._dir_dialog.add_observer("value", self.OnPathChanged)
        self._file_dialog.add_observer("value", self.OnCustomPathChanged)
Ejemplo n.º 3
0
            elif level > other_level:
                # Went too far, in another menu
                break

    return [
        build_hierarchy(lines, x, top_level, first_children, first_siblings)
        for x in top_level
    ]


if __name__ == "__main__":
    import wx
    from medipy.base import find_resource
    from medipy.gui.menu_builder import fill_treectrl

    menu = build_menu(find_resource("gui/full.menu"))

    app = wx.PySimpleApp()
    frame = wx.Frame(None)
    sizer = wx.BoxSizer()
    frame.SetSizer(sizer)

    treectrl = wx.TreeCtrl(frame,
                           style=wx.TR_DEFAULT_STYLE | wx.TR_HAS_BUTTONS
                           | wx.TR_SINGLE | wx.TR_HIDE_ROOT)
    fill_treectrl(menu, treectrl)
    sizer.Add(treectrl, 1, wx.EXPAND)

    frame.Show()
    app.MainLoop()
Ejemplo n.º 4
0
    def __init__(self, parent, *args, **kwargs):

        self._timer = wx.Timer()
        self._delay = None
        self._parent = parent
        self._animated_objects_3d = []
        self._visible_objects_3d = []
        self._stop_flag = True

        wx.Dialog.__init__(self,
                           parent,
                           style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER,
                           *args,
                           **kwargs)

        dialog_file = find_resource(
            os.path.join("resources", "gui", "cine_3d_dialog.xrc"))
        self._dialog_xml = xml.dom.minidom.parse(dialog_file)

        self._dialog_xrc = wx.xrc.XmlResource("")
        self._dialog_xrc.LoadFromString(str(self._dialog_xml.toxml()))

        # Widgets
        self._panel = self._dialog_xrc.LoadPanel(self, "main_panel")

        for control in [
                "objects_check_list_box", "type_combo_box", "cursor_slider",
                "cursor_text", "speed_slider", "speed_text",
                "play_pause_button", "stop_button", "close_button"
        ]:
            setattr(self, "_" + control, wx.xrc.XRCCTRL(self, control))

        self._speed_slider.SetValue(5)
        self._speed_text.SetValue(str(self._speed_slider.GetValue()))

        self._play_bitmap = wx.Bitmap(
            find_resource(
                os.path.join("resources", "gui", "media-playback-start.png")))
        self._pause_bitmap = wx.Bitmap(
            find_resource(
                os.path.join("resources", "gui", "media-playback-pause.png")))
        stop_bitmap = wx.Bitmap(
            find_resource(
                os.path.join("resources", "gui", "media-playback-stop.png")))

        self._play_pause_button.SetBitmapLabel(self._play_bitmap)

        self._stop_button.SetBitmapLabel(stop_bitmap)

        # Layout
        global_sizer = wx.BoxSizer(wx.VERTICAL)
        global_sizer.Add(self._panel, 1, wx.EXPAND)

        self.SetTitle("Cine 3D")
        self.SetSizer(global_sizer)
        global_sizer.Layout()
        self.Fit()

        # Events
        self.Bind(wx.EVT_CLOSE, self.OnClose)
        self._timer.Bind(wx.EVT_TIMER, self.OnTimer)
        self._type_combo_box.Bind(wx.EVT_COMBOBOX, self.OnComboBox)
        self._cursor_slider.Bind(wx.EVT_SLIDER, self.OnCursorSlider)
        self._cursor_text.Bind(wx.EVT_TEXT, self.OnCursorText)
        self._speed_slider.Bind(wx.EVT_SLIDER, self.OnSpeedSlider)
        self._speed_text.Bind(wx.EVT_TEXT, self.OnSpeedText)
        self._play_pause_button.Bind(wx.EVT_BUTTON,
                                     self.OnPlayPauseButtonClick)
        self._stop_button.Bind(wx.EVT_BUTTON, self.OnStopButtonClick)
        self._close_button.Bind(wx.EVT_BUTTON, lambda event: self.Close())

        self._parent._objects_check_list_box.Bind(
            wx.EVT_CHECKLISTBOX, self._on_cine_objects_3d_modified)
        self._parent.objects_3d.add_observer("any",
                                             self._on_cine_objects_3d_modified)

        self._objects_check_list_box.Bind(wx.EVT_CHECKLISTBOX,
                                          self._on_fixed_objects_3d_modified)

        self._set_animated_objects()
        self._set_cursor_slider()
        self._update_objects_check_list_box()
        self._reset_animation()

        self._set_fps(self._speed_slider.GetValue())

        self.stop()
Ejemplo n.º 5
0
    def __init__(self,
                 parent,
                 wx_id=wx.ID_ANY,
                 pos=wx.DefaultPosition,
                 size=wx.DefaultSize,
                 style=wx.DEFAULT_DIALOG_STYLE,
                 name="cine_dialog"):

        self._timer = wx.Timer()
        self._delay = None
        self._image = None
        self._current_layer = 0
        self._status = "stop"

        super(CineDialog, self).__init__(parent, wx_id, "", pos, size, style,
                                         name)

        # Resources
        self._play_bitmap = wx.Bitmap(
            find_resource(
                os.path.join("resources", "gui", "media-playback-start.png")))
        self._pause_bitmap = wx.Bitmap(
            find_resource(
                os.path.join("resources", "gui", "media-playback-pause.png")))
        stop_bitmap = wx.Bitmap(
            find_resource(
                os.path.join("resources", "gui", "media-playback-stop.png")))

        # Widgets
        self._layer = Int(self, 1, (1, 1))
        self._speed = Int(self, 1, (1, 20))

        self._play_pause = wx.BitmapButton(self, wx.ID_ANY, self._play_bitmap)
        self._stop = wx.BitmapButton(self, wx.ID_ANY, stop_bitmap)
        #        self.close = wx.Button(self, wx.ID_ANY, "Close")

        # Layout
        layer_speed_sizer = wx.FlexGridSizer(2, 2)
        layer_speed_sizer.AddGrowableCol(1)

        layer_speed_sizer.Add(wx.StaticText(self, wx.ID_ANY, "Layer : "),
                              flag=wx.ALIGN_CENTER)
        layer_speed_sizer.Add(self._layer, 1)

        layer_speed_sizer.Add(wx.StaticText(self, wx.ID_ANY, "Speed : "),
                              flag=wx.ALIGN_CENTER)
        layer_speed_sizer.Add(self._speed, 1)

        buttons_sizer = wx.BoxSizer(wx.HORIZONTAL)
        buttons_sizer.Add(self._play_pause)
        buttons_sizer.Add(self._stop)
        #        buttons_sizer.AddStretchSpacer(1)
        #        buttons_sizer.Add(self.close, flag=wx.ALIGN_CENTER)

        main_sizer = wx.BoxSizer(wx.VERTICAL)
        main_sizer.Add(layer_speed_sizer, 0, wx.EXPAND)
        main_sizer.Add(buttons_sizer, 0, wx.EXPAND)

        self.SetSizer(main_sizer)
        main_sizer.SetSizeHints(self)

        # Events
        self.Bind(wx.EVT_CLOSE, self.OnClose)
        self._timer.Bind(wx.EVT_TIMER, self.OnTimer)

        self._layer.add_observer("value", self.on_layer)
        self._speed.add_observer("value", self.on_speed)
        self._play_pause.Bind(wx.EVT_BUTTON, self.OnPlayPauseClicked)
        self._stop.Bind(wx.EVT_BUTTON, self.OnStopClicked)

        self._set_fps(self._speed.value)