Esempio n. 1
0
    def make_imgpanel(self, parent):
        panel = wx.Panel(parent)

        wlabel = wx.StaticText(panel, label="Save Position: ")
        self.pos_name =  wx.TextCtrl(panel, value="", size=(250, 25),
                                     style= wx.TE_PROCESS_ENTER)
        self.pos_name.Bind(wx.EVT_TEXT_ENTER, self.onSavePosition)

        imglabel  = "Select a position...\n  "
        self.info = wx.StaticText(panel,  label=imglabel)
        self.img  = wx.StaticBitmap(panel, -1,
                                    empty_bitmap(IMG_W, IMG_H, value=200))
        self.info.SetSize((IMG_W, 36))
        savebox = wx.BoxSizer(wx.HORIZONTAL)
        savebox.Add(wlabel,        1, LEFT_CEN, 1)
        savebox.Add(self.pos_name, 0, wx.EXPAND|LEFT_CEN, 1)

        sizer  = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(savebox,      0, CEN_TOP,  2)
        sizer.Add((3, 5))
        sizer.Add(self.img,     0, CEN_ALL,  5)
        sizer.Add(self.info,    0, LEFT_TOP, 2)
        sizer.Add((3, 5))

        pack(panel, sizer)
        return panel
Esempio n. 2
0
    def __init__(self, parent, prefix, pvdata, **kws):
        wx.Panel.__init__(self, parent, -1,  **kws)
        self.sizer = sizer = wx.GridBagSizer(3, 3)
        self.wids = {}
        self.prefix = prefix
        irow = -1
        for label, pvsuff, dtype, rsuff, wsize in pvdata:

            pvname = prefix + pvsuff
            ctrl  = pv_control(dtype)
            self.wids[label] = ctrl(self, pv=get_pv(pvname), size=(wsize, -1))

            title = wx.StaticText(self, label=label, size=(8*len(label), -1),
                                  style=labstyle)
            irow += 1
            sizer.Add(title, (irow, 0), (1, 1), labstyle)

            if rsuff:
                rlabel = label + rsuff
                rname = pvname + rsuff
                self.wids[rlabel] = PVStaticText(self, pv=get_pv(rname),
                                                 size=(wsize, -1))

                sizer.Add(self.wids[label], (irow, 1), (1, 1), labstyle)
                sizer.Add(self.wids[rlabel], (irow, 2), (1, 1), labstyle)
            else:
                sizer.Add(self.wids[label], (irow, 1), (1, 2), labstyle)
        pack(self, sizer)
Esempio n. 3
0
    def make_pospanel(self, parent):
        """panel of position lists, with buttons"""
        panel = wx.Panel(parent, size=(175, 200))
        btn_goto = add_button(panel, "Go To", size=(70, -1), action=self.onGo)
        btn_erase = add_button(panel,
                               "Erase",
                               size=(70, -1),
                               action=self.onErasePosition)

        brow = wx.BoxSizer(wx.HORIZONTAL)
        brow.Add(btn_goto, 0, ALL_EXP | wx.ALIGN_LEFT, 1)
        brow.Add(btn_erase, 0, ALL_EXP | wx.ALIGN_LEFT, 1)

        self.pos_list = wx.ListBox(panel)
        self.pos_list.SetBackgroundColour(wx.Colour(253, 253, 250))
        self.pos_list.Bind(wx.EVT_LISTBOX, self.onSelectPosition)
        self.pos_list.Bind(wx.EVT_RIGHT_DOWN, self.onPosRightClick)

        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(brow, 0, wx.ALIGN_LEFT | wx.ALL)
        sizer.Add(self.pos_list, 1, ALL_EXP | wx.ALIGN_CENTER, 3)

        pack(panel, sizer)
        panel.SetAutoLayout(1)
        return panel
Esempio n. 4
0
    def make_button_panel(self, parent, group='', full=True):
        panel = wx.Panel(parent)
        if full:
            sizer = wx.GridSizer(3, 3, 1, 1)
        else:
            sizer = wx.GridSizer(1, 3)
        def _btn(name):
            img = images[name].GetImage()
            btn = wx.BitmapButton(panel, -1, wx.BitmapFromImage(img),
                                style = wx.NO_BORDER)
            btn.Bind(wx.EVT_BUTTON, Closure(self.onMove,
                                            group=group, name=name))
            return btn
        if full:
            sizer.Add(_btn('nw'),     0, wx.ALL|wx.EXPAND)
            sizer.Add(_btn('nn'),     0, wx.ALL|wx.EXPAND)
            sizer.Add(_btn('ne'),     0, wx.ALL|wx.EXPAND)
            sizer.Add(_btn('ww'),     0, wx.ALL|wx.EXPAND)
            sizer.Add(_btn('camera'), 0, wx.ALL|wx.EXPAND)
            sizer.Add(_btn('ee'),     0, wx.ALL|wx.EXPAND)
            sizer.Add(_btn('sw'),     0, wx.ALL|wx.EXPAND)
            sizer.Add(_btn('ss'),     0, wx.ALL|wx.EXPAND)
            sizer.Add(_btn('se'),     0, wx.ALL|wx.EXPAND)
        else:
            sizer.Add(_btn('ww'),     0, wx.ALL|wx.EXPAND)
            sizer.Add(wx.StaticText(panel, label='', size=(1, 1)))
            sizer.Add(_btn('ee'),     0, wx.ALL|wx.EXPAND)

        pack(panel, sizer)
        return panel
Esempio n. 5
0
    def CreatePanel(self):
        " build (but do not fill in) panel components"
        wdesc, wrbv, winfo, wdrv = 200, 105, 90, 120
        if self._size == 'medium':
            wdesc, wrbv, winfo, wdrv = 140, 85, 80, 100
        elif self._size == 'small':
            wdesc, wrbv, winfo, wdrv = 50, 60, 25, 80

        self.desc = PVText(self, size=(wdesc, 25), style=LTEXT)
        self.desc.SetForegroundColour("Blue")
        font = self.desc.GetFont()
        font.PointSize -= 1
        self.desc.SetFont(font)

        self.rbv = PVText(self, size=(wrbv, 25), fg='Blue', style=RCEN)
        self.info = wx.StaticText(self, label='', size=(winfo, 25), style=RCEN)
        self.info.SetForegroundColour("Red")

        self.drive = PVFloatCtrl(self, size=(wdrv, -1), style=wx.TE_RIGHT)

        try:
            self.FillPanelComponents()
        except PyDeadObjectError:
            return

        spacer = wx.StaticText(self, label=' ', size=(5, 5), style=RIGHT)
        if self._size != 'small':
            self.__sizer.AddMany([(spacer, 0, CEN)])

        self.__sizer.AddMany([(self.desc, 1, LCEN), (self.info, 0, CEN),
                              (self.rbv, 0, CEN), (self.drive, 0, CEN)])

        if self._size == 'full':
            self.twk_list = ['', '']
            self.__twkbox = wx.ComboBox(self,
                                        value='',
                                        size=(100, -1),
                                        choices=self.twk_list,
                                        style=wx.CB_DROPDOWN
                                        | wx.TE_PROCESS_ENTER)
            self.__twkbox.Bind(wx.EVT_COMBOBOX, self.OnTweakBoxComboEvent)
            self.__twkbox.Bind(wx.EVT_TEXT_ENTER, self.OnTweakBoxEnterEvent)

            self.twr = PVButton(self, label='<', size=(30, 30))
            self.twf = PVButton(self, label='>', size=(30, 30))

            self.stopbtn = add_button(self,
                                      label=' Stop ',
                                      action=self.OnStopButton)
            self.morebtn = add_button(self,
                                      label=' More ',
                                      action=self.OnMoreButton)

            self.__sizer.AddMany([(self.twr, 0, CEN), (self.__twkbox, 0, CEN),
                                  (self.twf, 0, CEN), (self.stopbtn, 0, CEN),
                                  (self.morebtn, 0, CEN)])

        self.SetAutoLayout(1)
        print("create ", self.motor)
        pack(self, self.__sizer)
Esempio n. 6
0
    def make_button_panel(self, parent, group='', full=True):
        panel = wx.Panel(parent)
        if full:
            sizer = wx.GridSizer(3, 3, 1, 1)
        else:
            sizer = wx.GridSizer(1, 3)

        def _btn(name):
            img = images[name].GetImage()
            btn = wx.BitmapButton(panel,
                                  -1,
                                  wx.BitmapFromImage(img),
                                  style=wx.NO_BORDER)
            btn.Bind(wx.EVT_BUTTON, Closure(self.onMove,
                                            group=group,
                                            name=name))
            return btn

        if full:
            sizer.Add(_btn('nw'), 0, wx.ALL | wx.EXPAND)
            sizer.Add(_btn('nn'), 0, wx.ALL | wx.EXPAND)
            sizer.Add(_btn('ne'), 0, wx.ALL | wx.EXPAND)
            sizer.Add(_btn('ww'), 0, wx.ALL | wx.EXPAND)
            sizer.Add(_btn('camera'), 0, wx.ALL | wx.EXPAND)
            sizer.Add(_btn('ee'), 0, wx.ALL | wx.EXPAND)
            sizer.Add(_btn('sw'), 0, wx.ALL | wx.EXPAND)
            sizer.Add(_btn('ss'), 0, wx.ALL | wx.EXPAND)
            sizer.Add(_btn('se'), 0, wx.ALL | wx.EXPAND)
        else:
            sizer.Add(_btn('ww'), 0, wx.ALL | wx.EXPAND)
            sizer.Add(wx.StaticText(panel, label='', size=(1, 1)))
            sizer.Add(_btn('ee'), 0, wx.ALL | wx.EXPAND)

        pack(panel, sizer)
        return panel
Esempio n. 7
0
    def make_imgpanel(self, parent):
        panel = wx.Panel(parent)

        wlabel = wx.StaticText(panel, label="Save Position: ")
        self.pos_name = wx.TextCtrl(panel,
                                    value="",
                                    size=(250, 25),
                                    style=wx.TE_PROCESS_ENTER)
        self.pos_name.Bind(wx.EVT_TEXT_ENTER, self.onSavePosition)

        imglabel = "Select a position...\n  "
        self.info = wx.StaticText(panel, label=imglabel)
        self.img = wx.StaticBitmap(panel, -1,
                                   empty_bitmap(IMG_W, IMG_H, value=128))
        self.info.SetSize((IMG_W, 36))
        savebox = wx.BoxSizer(wx.HORIZONTAL)
        savebox.Add(wlabel, 1, LEFT_CEN, 1)
        savebox.Add(self.pos_name, 0, wx.EXPAND | LEFT_CEN, 1)

        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(savebox, 0, CEN_TOP, 2)
        sizer.Add((3, 5))
        sizer.Add(self.img, 0, CEN_ALL, 5)
        sizer.Add(self.info, 0, LEFT_TOP, 2)
        sizer.Add((3, 5))

        pack(panel, sizer)
        return panel
Esempio n. 8
0
    def __init__(self, parent, prefix, pvdata, **kws):
        wx.Panel.__init__(self, parent, -1, **kws)
        self.sizer = sizer = wx.GridBagSizer(3, 3)
        self.wids = {}
        self.prefix = prefix
        irow = -1
        for label, pvsuff, dtype, rsuff, wsize in pvdata:

            pvname = prefix + pvsuff
            ctrl = pv_control(dtype)
            self.wids[label] = ctrl(self, pv=get_pv(pvname), size=(wsize, -1))

            title = wx.StaticText(self,
                                  label=label,
                                  size=(8 * len(label), -1),
                                  style=labstyle)
            irow += 1
            sizer.Add(title, (irow, 0), (1, 1), labstyle)

            if rsuff:
                rlabel = label + rsuff
                rname = pvname + rsuff
                self.wids[rlabel] = PVStaticText(self,
                                                 pv=get_pv(rname),
                                                 size=(wsize, -1))

                sizer.Add(self.wids[label], (irow, 1), (1, 1), labstyle)
                sizer.Add(self.wids[rlabel], (irow, 2), (1, 1), labstyle)
            else:
                sizer.Add(self.wids[label], (irow, 1), (1, 2), labstyle)
        pack(self, sizer)
Esempio n. 9
0
    def create_Frame(self):
        self.nb = flat_nb.FlatNotebook(self, wx.ID_ANY,
                                       agwStyle=FNB_STYLE)

        colors = self.colors
        self.nb.SetActiveTabColour(colors.nb_active)
        self.nb.SetTabAreaColour(colors.nb_area)
        self.nb.SetNonActiveTabTextColour(colors.nb_text)
        self.nb.SetActiveTabTextColour(colors.nb_activetext)
        self.nb.SetBackgroundColour(colors.bg)

        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(self.nb, 1, wx.EXPAND)

        self.create_nbpages()

        self.SetSize((876, 351))
        self.SetMinSize((875, 350))

        pack(self, sizer)
        try:
            self.SetIcon(wx.Icon(ICON_FILE, wx.BITMAP_TYPE_ICO))
        except:
            pass
        self.Refresh()
Esempio n. 10
0
    def __init__(self, parent=None, filelist=None,
                 title='Select Instruments File'):

        wx.Dialog.__init__(self, parent, wx.ID_ANY, title=title)

        panel = wx.Panel(self)
        self.colors = GUIColors()
        panel.SetBackgroundColour(self.colors.bg)
        if parent is not None:
            self.SetFont(parent.GetFont())

        flist = []
        for fname in filelist:
            if os.path.exists(fname):
                flist.append(fname)

        self.filebrowser = FileBrowser(panel, size=(600, -1))
        self.filebrowser.SetHistory(flist)
        self.filebrowser.SetLabel('File:')
        self.filebrowser.fileMask = EIN_WILDCARD

        if filelist is not None:
            self.filebrowser.SetValue(filelist[0])
        
        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(wx.StaticText(panel, label=self.msg),
                  0, wx.ALIGN_CENTER|wx.ALL|wx.GROW, 1)
        sizer.Add(self.filebrowser, 1, wx.ALIGN_CENTER|wx.ALL|wx.GROW, 1)
        sizer.Add(self.CreateButtonSizer(wx.OK| wx.CANCEL),
                 1, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 1)
        pack(panel, sizer)
        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(panel, 0, 0, 0)
        pack(self, sizer)
Esempio n. 11
0
    def make_mainpanel(self, parent):
        "create right hand panel"
        panel = wx.Panel(parent)
        sizer =  wx.BoxSizer(wx.VERTICAL)
        fine_panel = self.group_panel(panel, label='Fine Stages',
                                      group='fine', precision=4,
                                      collapseable=True,
                                      add_buttons=[('Zero Fine Motors',
                                                   self.onZeroFineMotors)])

        sizer.Add(fine_panel,   0, ALL_EXP|LEFT_TOP)
        sizer.Add((2, 2))
        sizer.Add(wx.StaticLine(panel, size=(300, 3)), 0, CEN_TOP)
        sizer.Add(self.group_panel(panel, label='Coarse Stages',
                                   group='coarse'),  0, ALL_EXP|LEFT_TOP)
        sizer.Add((2, 2))
        sizer.Add(wx.StaticLine(panel, size=(300, 3)), 0, CEN_TOP)
        sizer.Add(self.group_panel(panel, label='Focus',
                                   group='focus'),   0, ALL_EXP|LEFT_TOP)
        sizer.Add((2, 2))
        sizer.Add(wx.StaticLine(panel, size=(300, 3)), 0, CEN_TOP)
        sizer.Add(self.group_panel(panel, label='Theta', collapseable=True,
                                   group='theta'),
                  0, ALL_EXP|LEFT_TOP)
        pack(panel, sizer)
        return panel
Esempio n. 12
0
    def make_mainpanel(self, parent):
        "create right hand panel"
        panel = wx.Panel(parent)
        sizer = wx.BoxSizer(wx.VERTICAL)
        fine_panel = self.group_panel(panel,
                                      label='Fine Stages',
                                      group='fine',
                                      precision=4,
                                      collapseable=True,
                                      add_buttons=[('Zero Fine Motors',
                                                    self.onZeroFineMotors)])

        sizer.Add(fine_panel, 0, ALL_EXP | LEFT_TOP)
        sizer.Add((2, 2))
        sizer.Add(wx.StaticLine(panel, size=(300, 3)), 0, CEN_TOP)
        sizer.Add(
            self.group_panel(panel, label='Coarse Stages', group='coarse'), 0,
            ALL_EXP | LEFT_TOP)
        sizer.Add((2, 2))
        sizer.Add(wx.StaticLine(panel, size=(300, 3)), 0, CEN_TOP)
        sizer.Add(self.group_panel(panel, label='Focus', group='focus'), 0,
                  ALL_EXP | LEFT_TOP)
        sizer.Add((2, 2))
        sizer.Add(wx.StaticLine(panel, size=(300, 3)), 0, CEN_TOP)
        sizer.Add(
            self.group_panel(panel,
                             label='Theta',
                             collapseable=True,
                             group='theta'), 0, ALL_EXP | LEFT_TOP)
        pack(panel, sizer)
        return panel
Esempio n. 13
0
    def group_panel(self,
                    parent,
                    label='Fine Stages',
                    precision=3,
                    collapseable=False,
                    add_buttons=None,
                    group='fine'):
        """make motor group panel """
        motors = self.motorgroups[group]

        is_xy = motors[1] is not None

        if collapseable:
            cpane = CP.PyCollapsiblePane(parent, agwStyle=wx.CP_GTK_EXPANDER)
            cpane.Bind(wx.EVT_COLLAPSIBLEPANE_CHANGED,
                       Closure(self.onCollapse, panel=cpane, label=label))
            cpane.Collapse(True)
            cpane.SetFont(wx.Font(11, wx.SWISS, wx.NORMAL, wx.BOLD, False))
            cpane.SetLabel('Show %s' % label)
            panel = cpane.GetPane()
        else:
            panel = wx.Panel(parent)

        self.tweaks[group] = NumericCombo(panel,
                                          self.tweaklist[group],
                                          precision=precision,
                                          init=3)

        slabel = wx.BoxSizer(wx.HORIZONTAL)
        slabel.Add(wx.StaticText(panel, label=" %s: " % label, size=(150, -1)),
                   1, wx.EXPAND | LEFT_BOT)
        slabel.Add(self.tweaks[group], 0, ALL_EXP | LEFT_TOP)

        smotor = wx.BoxSizer(wx.VERTICAL)
        smotor.Add(slabel, 0, ALL_EXP)

        for mnam in motors:
            if mnam is None: continue
            self.motorwids[mnam] = MotorPanel(panel, label=mnam, psize='small')
            self.motorwids[mnam].desc.SetLabel(mnam)
            smotor.Add(self.motorwids[mnam], 0, ALL_EXP | LEFT_TOP)

        if add_buttons is not None:
            for label, action in add_buttons:
                smotor.Add(add_button(panel, label, action=action))

        btnbox = self.make_button_panel(panel, full=is_xy, group=group)
        btnbox_style = CEN_BOT
        if is_xy:
            btnbox_style = CEN_TOP

        sizer = wx.BoxSizer(wx.HORIZONTAL)
        sizer.Add(smotor, 0, ALL_EXP | LEFT_TOP)
        sizer.Add(btnbox, 0, btnbox_style, 1)

        pack(panel, sizer)
        if collapseable:
            return cpane
        return panel
    def __init__(self, parent, url=None, **kws):
        super(ConfPanel_URL, self).__init__(parent, -1, size=(280, 300))

        title = wx.StaticText(self, label="Webcam Config", size=(285, 25))

        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(title, 0, wx.ALIGN_LEFT | wx.ALL)
        pack(self, sizer)
Esempio n. 15
0
    def __init__(self, parent, url=None, **kws):
        super(ConfPanel_URL, self).__init__(parent, -1, size=(280, 300))

        title =  wx.StaticText(self, label="Webcam Config", size=(285, 25))

        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(title,         0, wx.ALIGN_LEFT|wx.ALL)
        pack(self, sizer)
Esempio n. 16
0
    def CreatePanel(self):
        " build (but do not fill in) panel components"
        wdesc, wrbv, winfo, wdrv = 200, 105, 90, 120
        if self._size == 'medium':
            wdesc, wrbv, winfo, wdrv = 140, 85, 80, 100
        elif self._size == 'small':
            wdesc, wrbv, winfo, wdrv = 50, 60, 25, 80

        self.desc = PVText(self, size=(wdesc, 25), style=LTEXT)
        self.desc.SetForegroundColour("Blue")
        font = self.desc.GetFont()
        font.PointSize -= 1
        self.desc.SetFont(font)

        self.rbv  = PVText(self, size=(wrbv, 25), fg='Blue', style=RCEN)
        self.info = wx.StaticText(self, label='',
                                  size=(winfo, 25), style=RCEN)
        self.info.SetForegroundColour("Red")

        self.drive = PVFloatCtrl(self, size=(wdrv, -1), style = wx.TE_RIGHT)

        try:
            self.FillPanelComponents()
        except PyDeadObjectError:
            return

        spacer = wx.StaticText(self, label=' ', size=(5, 5), style=RIGHT)
        if self._size != 'small':
            self.__sizer.AddMany([(spacer,      0, CEN)])

        self.__sizer.AddMany([ (self.desc,   1, LCEN),
                               (self.info,   0, CEN),
                               (self.rbv,    0, CEN),
                               (self.drive,  0, CEN)])

        if self._size == 'full':
            self.twk_list = ['','']
            self.__twkbox = wx.ComboBox(self, value='', size=(100, -1),
                                        choices=self.twk_list,
                                        style=wx.CB_DROPDOWN|wx.TE_PROCESS_ENTER)
            self.__twkbox.Bind(wx.EVT_COMBOBOX,    self.OnTweakBoxComboEvent)
            self.__twkbox.Bind(wx.EVT_TEXT_ENTER,  self.OnTweakBoxEnterEvent)

            self.twr = PVButton(self, label='<',  size=(30, 30))
            self.twf = PVButton(self, label='>',  size=(30, 30))

            self.stopbtn = add_button(self, label=' Stop ', action=self.OnStopButton)
            self.morebtn = add_button(self, label=' More ', action=self.OnMoreButton)

            self.__sizer.AddMany([(self.twr,      0, CEN),
                                  (self.__twkbox, 0, CEN),
                                  (self.twf,      0, CEN),
                                  (self.stopbtn,  0, CEN),
                                  (self.morebtn,  0, CEN)])

        self.SetAutoLayout(1)
        print("create ", self.motor)
        pack(self, self.__sizer)
Esempio n. 17
0
    def build_dialog(self):
        positions  = self.instdb.get_positionlist(self.offline)
        panel = scrolled.ScrolledPanel(self)
        self.checkboxes = OrderedDict()
        sizer = wx.GridBagSizer(len(positions)+5, 4)
        sizer.SetVGap(2)
        sizer.SetHGap(3)
        bkws = dict(size=(95, -1))
        btn_ok     = add_button(panel, "Copy Selected", action=self.onOK, **bkws)
        btn_all    = add_button(panel, "Select All",    action=self.onAll, **bkws)
        btn_none   = add_button(panel, "Select None",   action=self.onNone,  **bkws)

        brow = wx.BoxSizer(wx.HORIZONTAL)
        brow.Add(btn_all ,  0, ALL_EXP|wx.ALIGN_LEFT, 1)
        brow.Add(btn_none,  0, ALL_EXP|wx.ALIGN_LEFT, 1)
        brow.Add(btn_ok ,   0, ALL_EXP|wx.ALIGN_LEFT, 1)

        sizer.Add(brow,   (0, 0), (1, 4),  LEFT_CEN, 2)

        sizer.Add(SimpleText(panel, ' Add Suffix:'), (1, 0), (1, 1),  LEFT_CEN, 2)

        self.suffix =  wx.TextCtrl(panel, value="", size=(150, -1))
        sizer.Add(self.suffix, (1, 1), (1, 3), LEFT_CEN, 2)

        sizer.Add(SimpleText(panel, ' Position Name'), (2, 0), (1, 1),  LEFT_CEN, 2)
        sizer.Add(SimpleText(panel, 'Copy?'),          (2, 1), (1, 1),  LEFT_CEN, 2)
        sizer.Add(SimpleText(panel, ' Position Name'), (2, 2), (1, 1),  LEFT_CEN, 2)
        sizer.Add(SimpleText(panel, 'Copy?'),          (2, 3), (1, 1),  LEFT_CEN, 2)
        sizer.Add(wx.StaticLine(panel, size=(500, 2)), (3, 0), (1, 4),  LEFT_CEN, 2)

        irow = 3
        for ip, pname in enumerate(positions):
            cbox = self.checkboxes[pname] = wx.CheckBox(panel, -1, "")
            cbox.SetValue(True)

            if ip % 2 == 0:
                irow += 1
                icol = 0
            else:
                icol = 2
            sizer.Add(SimpleText(panel, "  %s  "%pname), (irow, icol),   (1, 1),  LEFT_CEN, 2)
            sizer.Add(cbox,                              (irow, icol+1), (1, 1),  LEFT_CEN, 2)
        irow += 1
        sizer.Add(wx.StaticLine(panel, size=(500, 2)), (irow, 0), (1, 4),  LEFT_CEN, 2)

        pack(panel, sizer)
        panel.SetMinSize((700, 550))

        panel.SetupScrolling()

        mainsizer = wx.BoxSizer(wx.VERTICAL)
        mainsizer.Add(panel, 1,  ALL_EXP|wx.GROW|wx.ALIGN_LEFT, 1)
        pack(self, mainsizer)

        self.SetMinSize((700, 550))
        self.Raise()
        self.Show()
Esempio n. 18
0
    def build_dialog(self, positions):
        self.positions = positions
        panel = scrolled.ScrolledPanel(self)
        self.checkboxes = {}
        sizer = wx.GridBagSizer(len(positions)+5, 4)
        sizer.SetVGap(2)
        sizer.SetHGap(3)
        bkws = dict(size=(95, -1))
        btn_ok     = add_button(panel, "Erase Selected",   action=self.onOK, **bkws)
        btn_all    = add_button(panel, "Select All",    action=self.onAll, **bkws)
        btn_none   = add_button(panel, "Select None",   action=self.onNone,  **bkws)

        brow = wx.BoxSizer(wx.HORIZONTAL)
        brow.Add(btn_all ,  0, ALL_EXP|wx.ALIGN_LEFT, 1)
        brow.Add(btn_none,  0, ALL_EXP|wx.ALIGN_LEFT, 1)
        brow.Add(btn_ok ,   0, ALL_EXP|wx.ALIGN_LEFT, 1)

        sizer.Add(SimpleText(panel, ' Note: ERASING POSITIONS CANNOT BE UNDONE!! Use "Export Positions" to Save!',
                            colour=wx.Colour(200, 0, 0)), (0, 0), (1, 2),  LEFT_CEN, 2)
        sizer.Add(SimpleText(panel, ' Use "Export Positions" to Save Positions!',
                            colour=wx.Colour(200, 0, 0)), (1, 0), (1, 2),  LEFT_CEN, 2)

        sizer.Add(brow,   (2, 0), (1, 3),  LEFT_CEN, 2)

        sizer.Add(SimpleText(panel, ' Position Name'), (3, 0), (1, 1),  LEFT_CEN, 2)
        sizer.Add(SimpleText(panel, 'Erase?'),         (3, 1), (1, 1),  LEFT_CEN, 2)
        sizer.Add(SimpleText(panel, ' Position Name'), (3, 2), (1, 1),  LEFT_CEN, 2)
        sizer.Add(SimpleText(panel, 'Erase?'),         (3, 3), (1, 1),  LEFT_CEN, 2)
        sizer.Add(wx.StaticLine(panel, size=(500, 2)), (4, 0), (1, 4),  LEFT_CEN, 2)

        irow = 4
        for ip, pname in enumerate(positions):
            cbox = self.checkboxes[pname] = wx.CheckBox(panel, -1, "")
            cbox.SetValue(True)

            if ip % 2 == 0:
                irow += 1
                icol = 0
            else:
                icol = 2
            sizer.Add(SimpleText(panel, "  %s  "%pname), (irow, icol),   (1, 1),  LEFT_CEN, 2)
            sizer.Add(cbox,                              (irow, icol+1), (1, 1),  LEFT_CEN, 2)
        irow += 1
        sizer.Add(wx.StaticLine(panel, size=(500, 2)), (irow, 0), (1, 4),  LEFT_CEN, 2)

        pack(panel, sizer)
        panel.SetMinSize((700, 550))

        panel.SetupScrolling()

        mainsizer = wx.BoxSizer(wx.VERTICAL)
        mainsizer.Add(panel, 1,  ALL_EXP|wx.GROW|wx.ALIGN_LEFT, 1)
        pack(self, mainsizer)

        self.SetMinSize((700, 550))
        self.Raise()
        self.Show()
Esempio n. 19
0
    def build_dialog(self, positions):
        self.positions = positions
        panel = scrolled.ScrolledPanel(self)
        self.checkboxes = {}
        sizer = wx.GridBagSizer(len(positions)+5, 4)
        sizer.SetVGap(2)
        sizer.SetHGap(3)
        bkws = dict(size=(95, -1))
        btn_ok     = add_button(panel, "Erase Selected",   action=self.onOK, **bkws)
        btn_all    = add_button(panel, "Select All",    action=self.onAll, **bkws)
        btn_none   = add_button(panel, "Select None",   action=self.onNone,  **bkws)

        brow = wx.BoxSizer(wx.HORIZONTAL)
        brow.Add(btn_all ,  0, ALL_EXP|wx.ALIGN_LEFT, 1)
        brow.Add(btn_none,  0, ALL_EXP|wx.ALIGN_LEFT, 1)
        brow.Add(btn_ok ,   0, ALL_EXP|wx.ALIGN_LEFT, 1)

        sizer.Add(SimpleText(panel, ' Note: ERASING POSITIONS CANNOT BE UNDONE!! Use "Export Positions" to Save!',
                            colour=wx.Colour(200, 0, 0)), (0, 0), (1, 2),  LEFT_CEN, 2)
        sizer.Add(SimpleText(panel, ' Use "Export Positions" to Save Positions!',
                            colour=wx.Colour(200, 0, 0)), (1, 0), (1, 2),  LEFT_CEN, 2)

        sizer.Add(brow,   (2, 0), (1, 3),  LEFT_CEN, 2)

        sizer.Add(SimpleText(panel, ' Position Name'), (3, 0), (1, 1),  LEFT_CEN, 2)
        sizer.Add(SimpleText(panel, 'Erase?'),         (3, 1), (1, 1),  LEFT_CEN, 2)
        sizer.Add(SimpleText(panel, ' Position Name'), (3, 2), (1, 1),  LEFT_CEN, 2)
        sizer.Add(SimpleText(panel, 'Erase?'),         (3, 3), (1, 1),  LEFT_CEN, 2)
        sizer.Add(wx.StaticLine(panel, size=(500, 2)), (4, 0), (1, 4),  LEFT_CEN, 2)

        irow = 4
        for ip, pname in enumerate(positions):
            cbox = self.checkboxes[pname] = wx.CheckBox(panel, -1, "")
            cbox.SetValue(True)

            if ip % 2 == 0:
                irow += 1
                icol = 0
            else:
                icol = 2
            sizer.Add(SimpleText(panel, "  %s  "%pname), (irow, icol),   (1, 1),  LEFT_CEN, 2)
            sizer.Add(cbox,                              (irow, icol+1), (1, 1),  LEFT_CEN, 2)
        irow += 1
        sizer.Add(wx.StaticLine(panel, size=(500, 2)), (irow, 0), (1, 4),  LEFT_CEN, 2)

        pack(panel, sizer)
        panel.SetMinSize((700, 550))

        panel.SetupScrolling()

        mainsizer = wx.BoxSizer(wx.VERTICAL)
        mainsizer.Add(panel, 1,  ALL_EXP|wx.GROW|wx.ALIGN_LEFT, 1)
        pack(self, mainsizer)

        self.SetMinSize((700, 550))
        self.Raise()
        self.Show()
Esempio n. 20
0
    def __init__(self,
                 parent,
                 viewer,
                 config=None,
                 offline_config=None,
                 **kws):
        wx.Panel.__init__(self, parent, -1, size=(300, 500))
        self.scandb = None
        self.size = (300, 600)
        self.parent = parent
        self.viewer = viewer
        self.config = config
        self.offline_config = offline_config
        if self.offline_config is None:
            self.offline_config = {}
        self.poslist_select = None
        self.image_display = None
        self.pos_name = wx.TextCtrl(self,
                                    value="",
                                    size=(300, 25),
                                    style=wx.TE_PROCESS_ENTER)
        self.pos_name.Bind(wx.EVT_TEXT_ENTER, self.onSave1)

        tlabel = wx.StaticText(self, label="Save Position: ")

        bkws = dict(size=(55, -1))
        btn_goto = add_button(self, "Go To", action=self.onGo, **bkws)
        btn_erase = add_button(self, "Erase", action=self.onErase, **bkws)
        btn_show = add_button(self, "Show", action=self.onShow, **bkws)
        # btn_many  = add_button(self, "Erase Many",  action=self.onEraseMany,  **bkws)

        brow = wx.BoxSizer(wx.HORIZONTAL)
        brow.Add(btn_goto, 0, ALL_EXP | wx.ALIGN_LEFT, 1)
        brow.Add(btn_erase, 0, ALL_EXP | wx.ALIGN_LEFT, 1)
        brow.Add(btn_show, 0, ALL_EXP | wx.ALIGN_LEFT, 1)
        # brow.Add(btn_many,  0, ALL_EXP|wx.ALIGN_LEFT, 1)

        self.pos_list = wx.ListBox(self)
        self.pos_list.SetBackgroundColour(wx.Colour(253, 253, 250))
        self.pos_list.Bind(wx.EVT_LISTBOX, self.onSelect)
        self.pos_list.Bind(wx.EVT_RIGHT_DOWN, self.onRightClick)

        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(tlabel, 0, wx.ALIGN_LEFT | wx.ALL)
        sizer.Add(self.pos_name, 0, wx.ALIGN_LEFT | wx.ALL)
        sizer.Add(brow, 0, wx.ALIGN_LEFT | wx.ALL)
        sizer.Add(self.pos_list, 1, ALL_EXP | wx.ALIGN_CENTER, 3)

        pack(self, sizer)
        self.init_scandb()
        self.last_refresh = 0
        self.get_positions_from_db()
        self.timer = wx.Timer(self)
        self.Bind(wx.EVT_TIMER, self.onTimer, self.timer)
        self.timer.Start(2500)
Esempio n. 21
0
    def group_panel(self,
                    group='Fine Stages',
                    motorlist=None,
                    precision=3,
                    maxstep=5.01,
                    buttons=None,
                    show=True):
        """make motor group panel """
        panel = wx.Panel(self)
        self.subpanels[group] = panel

        # print 'Group Panel ', group, show
        tweaklist = make_steps(precision=precision, maxstep=maxstep)
        if group.lower().startswith('theta'):
            tweaklist.extend([10, 20, 30, 45, 90, 180])

        init_tweak = {'Focus': 5, 'Theta': 8}.get(group, 6)

        self.tweak_wids[group] = NumericCombo(panel,
                                              tweaklist,
                                              precision=precision,
                                              init=init_tweak)

        slabel = wx.BoxSizer(wx.HORIZONTAL)
        slabel.Add(wx.StaticText(panel, label=" %s: " % group, size=(120, -1)),
                   1, wx.EXPAND | LEFT_BOT)
        slabel.Add(self.tweak_wids[group], 0, ALL_EXP)

        msizer = wx.BoxSizer(wx.VERTICAL)
        msizer.Add(slabel, 0, ALL_EXP)

        for pvname, desc in motorlist:
            pvname = normalize_pvname(pvname)
            self.motor_wids[desc] = MotorPanel(panel,
                                               pvname,
                                               label=desc,
                                               psize='small')
            msizer.Add(self.motor_wids[desc], 0, ALL_EXP)

        if buttons is not None:
            for blabel, action in buttons:
                msizer.Add(add_button(panel, blabel, action=action))

        dim = len(motorlist)
        btnbox = self.make_button_panel(panel, group=group, dim=dim)

        sizer = wx.BoxSizer(wx.HORIZONTAL)
        sizer.Add(msizer, 0, ALL_EXP)
        sizer.Add(btnbox, 0, CEN_TOP, 1)
        if not show:
            panel.Disable()

        pack(panel, sizer)
        return panel
Esempio n. 22
0
    def group_panel(self, parent, label='Fine Stages',
                    precision=3, collapseable=False,
                    add_buttons=None,  group='fine'):
        """make motor group panel """
        motors = self.motorgroups[group]

        is_xy = motors[1] is not None

        if collapseable:
            cpane = CP.PyCollapsiblePane(parent,
                                         agwStyle=wx.CP_GTK_EXPANDER)
            cpane.Bind(wx.EVT_COLLAPSIBLEPANE_CHANGED,
                    Closure(self.onCollapse, panel=cpane, label=label))
            cpane.Collapse(True)
            cpane.SetFont(wx.Font(11, wx.SWISS, wx.NORMAL, wx.BOLD, False))
            cpane.SetLabel('Show %s' % label)
            panel = cpane.GetPane()
        else:
            panel  = wx.Panel(parent)

        self.tweaks[group] = NumericCombo(panel, self.tweaklist[group],
                                          precision=precision, init=3)

        slabel = wx.BoxSizer(wx.HORIZONTAL)
        slabel.Add(wx.StaticText(panel, label=" %s: " % label, size=(150,-1)),
                   1,  wx.EXPAND|LEFT_BOT)
        slabel.Add(self.tweaks[group], 0,  ALL_EXP|LEFT_TOP)

        smotor = wx.BoxSizer(wx.VERTICAL)
        smotor.Add(slabel, 0, ALL_EXP)

        for mnam in motors:
            if mnam is None: continue
            self.motorwids[mnam] = MotorPanel(panel, label=mnam, psize='small')
            self.motorwids[mnam].desc.SetLabel(mnam)
            smotor.Add(self.motorwids[mnam], 0, ALL_EXP|LEFT_TOP)

        if add_buttons is not None:
            for label, action in add_buttons:
                smotor.Add(add_button(panel, label, action=action))

        btnbox = self.make_button_panel(panel, full=is_xy, group=group)
        btnbox_style = CEN_BOT
        if is_xy:
            btnbox_style = CEN_TOP

        sizer = wx.BoxSizer(wx.HORIZONTAL)
        sizer.Add(smotor, 0, ALL_EXP|LEFT_TOP)
        sizer.Add(btnbox, 0, btnbox_style, 1)

        pack(panel, sizer)
        if collapseable:
            return cpane
        return panel
Esempio n. 23
0
    def __init__(self, parent, url=None, center_cb=None, xhair_cb=None, **kws):
        super(ConfPanel_URL, self).__init__(parent, center_cb=center_cb,
                                            xhair_cb=xhair_cb,
                                            size=(280, 300))

        title =  wx.StaticText(self, label="Webcam Config", size=(285, 25))

        sizer = self.sizer # wx.BoxSizer(wx.VERTICAL)
        sizer.Add(title,       (0, 0), (1, 3),  wx.ALIGN_LEFT|wx.ALL)
        next_row = self.show_position_info(row=2)
        pack(self, sizer)
    def CreatePanel(self):
        " build (but do not fill in) panel components"
        wdesc, wrbv, winfo, wdrv = 200, 105, 90, 120
        if self._size == "medium":
            wdesc, wrbv, winfo, wdrv = 140, 85, 80, 100
        elif self._size == "small":
            wdesc, wrbv, winfo, wdrv = 45, 70, 40, 80

        self.desc = PVText(self, size=(wdesc, 25), style=LTEXT)
        self.desc.SetForegroundColour("Blue")

        self.rbv = PVText(self, size=(wrbv, 25), fg="Blue", style=RCEN)
        self.info = wx.StaticText(self, label="", size=(winfo, 25), style=RCEN)
        self.info.SetForegroundColour("Red")

        self.drive = PVFloatCtrl(self, size=(wdrv, -1), style=wx.TE_RIGHT)

        try:
            self.FillPanelComponents()
        except PyDeadObjectError:
            return

        spacer = wx.StaticText(self, label=" ", size=(5, 5), style=RIGHT)
        self.__sizer.AddMany(
            [(spacer, 0, CEN), (self.desc, 1, LCEN), (self.info, 1, CEN), (self.rbv, 0, CEN), (self.drive, 0, CEN)]
        )

        if self._size == "full":
            self.twk_list = ["", ""]
            self.__twkbox = wx.ComboBox(
                self, value="", size=(100, -1), choices=self.twk_list, style=wx.CB_DROPDOWN | wx.TE_PROCESS_ENTER
            )
            self.__twkbox.Bind(wx.EVT_COMBOBOX, self.OnTweakBoxComboEvent)
            self.__twkbox.Bind(wx.EVT_TEXT_ENTER, self.OnTweakBoxEnterEvent)

            self.twr = PVButton(self, label="<", size=(30, 30))
            self.twf = PVButton(self, label=">", size=(30, 30))

            self.stopbtn = add_button(self, label=" Stop ", action=self.OnStopButton)
            self.morebtn = add_button(self, label=" More ", action=self.OnMoreButton)

            self.__sizer.AddMany(
                [
                    (self.twr, 0, CEN),
                    (self.__twkbox, 0, CEN),
                    (self.twf, 0, CEN),
                    (self.stopbtn, 0, CEN),
                    (self.morebtn, 0, CEN),
                ]
            )

        self.SetAutoLayout(1)
        pack(self, self.__sizer)
Esempio n. 25
0
    def __init__(self, parent, groups=None, config={}, autofocus=None):
        wx.Panel.__init__(self, parent, -1)
        self.subpanels = {}

        self.groups = groups
        self.config = config  #  json.loads(station_configs[station.upper()])
        self.tweak_wids = {}  # tweak Combobox widgets per group
        self.groupmotors = {}  # motorlist per group
        self.motor_wids = {}  # motor panel widgets, key=desc
        self.motors = {}  # epics motor,         key=desc
        self.scale = {}  # motor sign for ZFM,  key=desc
        self.af_message = None
        # self.SetMinSize((320, 200))

        sizer = wx.BoxSizer(wx.VERTICAL)
        for group in groups:
            self.groupmotors[group] = []
            motorlist = []
            maxstep = 5000
            show = 0
            prec = 4
            for name, data in config.items():
                name = normalize_pvname(name)
                if data['group'] == group:
                    self.groupmotors[group].append(data['desc'])
                    motorlist.append((name, data['desc']))
                    maxstep = min(maxstep, data['maxstep'])
                    prec = min(prec, data['prec'])
                    show = show + data['show']
            kws = {
                'motorlist': motorlist,
                'maxstep': maxstep,
                'precision': prec,
                'show': show > 0
            }
            if group.lower().startswith('fine'):
                kws['buttons'] = [('Zero Fine Motors', self.onZeroFineMotors)]
            sizer.Add((3, 3))
            sizer.Add(self.group_panel(group=group, **kws), 0, ALL_EXP)
            sizer.Add((3, 3))
            sizer.Add(wx.StaticLine(self, size=(300, 3)), 0, CEN_TOP)

        if autofocus is not None:
            self.af_button = add_button(self,
                                        "AutoFocus",
                                        action=autofocus,
                                        size=(150, -1))
            self.af_message = wx.StaticText(self, label="", size=(200, -1))
            sizer.Add(self.af_button, 0, LEFT_TOP)
            sizer.Add(self.af_message, 0, LEFT_TOP)
        pack(self, sizer)
        self.connect_motors()
Esempio n. 26
0
    def __init__(self, parent, image_panel=None, prefix=None,
                 center_cb=None, xhair_cb=None, **kws):
        super(ConfPanel_Fly2AD, self).__init__(parent, center_cb=center_cb,
                                                xhair_cb=xhair_cb)

        sizer = self.sizer
        self.image_panel = image_panel
        self.SetBackgroundColour('#EEFFE')
        self.title =  wx.StaticText(self, size=(285, 25),
                                    label="Fly2 Camera Mirror")
        labstyle  = wx.ALIGN_LEFT|wx.EXPAND|wx.ALIGN_BOTTOM
        sizer.Add(self.title,               (0, 0), (1, 3), labstyle)
        pack(self, sizer)
        self.set_prefix(prefix)
Esempio n. 27
0
    def __init__(self, parent, posname, inst, **kws):
        self.posname = posname
        self.inst = inst
        title = "Rename Position '%s' for '%s' ?" % (posname, inst.name)
        wx.Dialog.__init__(self, parent, wx.ID_ANY, title=title)
        panel = wx.Panel(self)
        colors = GUIColors()

        self.SetFont(parent.GetFont())
        titlefont = self.GetFont()
        titlefont.PointSize += 2
        titlefont.SetWeight(wx.BOLD)

        panel.SetBackgroundColour(colors.bg)
        sizer = wx.GridBagSizer(10, 3)

        labstyle = wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.ALL
        rlabstyle = wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL | wx.ALL
        tstyle = wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL

        label1 = SimpleText(panel, "Old name = %s" % posname, style=tstyle)
        label2 = SimpleText(panel, "New name = ", style=tstyle)
        self.newname = wx.TextCtrl(panel, value=posname, size=(225, 25))

        sizer.Add(label1, (0, 0), (1, 2), labstyle, 1)
        sizer.Add(label2, (1, 0), (1, 1), labstyle, 1)
        sizer.Add(self.newname, (1, 1), (1, 1), labstyle, 1)

        sizer.Add(
            wx.StaticLine(panel, size=(250, -1), style=wx.LI_HORIZONTAL),
            (2, 0),
            (1, 2),
            wx.ALIGN_CENTER | wx.GROW | wx.ALL,
            0,
        )

        btnsizer = wx.StdDialogButtonSizer()
        btn = wx.Button(panel, wx.ID_OK)
        btn.SetDefault()
        btnsizer.AddButton(btn)
        btnsizer.AddButton(wx.Button(panel, wx.ID_CANCEL))

        btnsizer.Realize()
        sizer.Add(btnsizer, (3, 0), (1, 2), wx.ALIGN_CENTER_VERTICAL | wx.ALL, 1)
        pack(panel, sizer)

        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(panel, 0, 0, 0)
        pack(self, sizer)
Esempio n. 28
0
    def __init__(self, parent, viewer, config=None, offline_config=None, **kws):
        wx.Panel.__init__(self, parent, -1, size=(300, 500))
        self.scandb = None
        self.size = (300, 600)
        self.parent = parent
        self.viewer = viewer
        self.config = config
        self.offline_config = offline_config
        if self.offline_config is None:
            self.offline_config = {}
        self.poslist_select = None
        self.image_display = None
        self.pos_name =  wx.TextCtrl(self, value="", size=(300, 25),
                                     style= wx.TE_PROCESS_ENTER)
        self.pos_name.Bind(wx.EVT_TEXT_ENTER, self.onSave1)

        tlabel = wx.StaticText(self, label="Save Position: ")

        bkws = dict(size=(55, -1))
        btn_goto  = add_button(self, "Go To", action=self.onGo,    **bkws)
        btn_erase = add_button(self, "Erase", action=self.onErase, **bkws)
        btn_show  = add_button(self, "Show",  action=self.onShow,  **bkws)
        # btn_many  = add_button(self, "Erase Many",  action=self.onEraseMany,  **bkws)

        brow = wx.BoxSizer(wx.HORIZONTAL)
        brow.Add(btn_goto,  0, ALL_EXP|wx.ALIGN_LEFT, 1)
        brow.Add(btn_erase, 0, ALL_EXP|wx.ALIGN_LEFT, 1)
        brow.Add(btn_show,  0, ALL_EXP|wx.ALIGN_LEFT, 1)
        # brow.Add(btn_many,  0, ALL_EXP|wx.ALIGN_LEFT, 1)

        self.pos_list  = wx.ListBox(self)
        self.pos_list.SetBackgroundColour(wx.Colour(253, 253, 250))
        self.pos_list.Bind(wx.EVT_LISTBOX, self.onSelect)
        self.pos_list.Bind(wx.EVT_RIGHT_DOWN, self.onRightClick)

        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(tlabel,         0, wx.ALIGN_LEFT|wx.ALL)
        sizer.Add(self.pos_name,  0, wx.ALIGN_LEFT|wx.ALL)
        sizer.Add(brow,           0, wx.ALIGN_LEFT|wx.ALL)
        sizer.Add(self.pos_list,  1, ALL_EXP|wx.ALIGN_CENTER, 3)

        pack(self, sizer)
        self.init_scandb()
        self.last_refresh = 0
        self.get_positions_from_db()
        self.timer = wx.Timer(self)
        self.Bind(wx.EVT_TIMER, self.onTimer, self.timer)
        self.timer.Start(2500)
Esempio n. 29
0
    def build_dialog(self, positions):
        self.positions = positions

        panel = scrolled.ScrolledPanel(self)
        self.checkboxes = {}
        sizer = wx.GridBagSizer(len(positions) + 2, 2)
        sizer.SetVGap(2)
        sizer.SetHGap(3)
        sizer.Add(
            SimpleText(panel, " Erase Positions?  Warning: CANNOT BE UNDONE!!", colour=wx.Colour(200, 0, 0)),
            (0, 0),
            (1, 2),
            LEFT_CEN,
            2,
        )
        sizer.Add(SimpleText(panel, " Position Name"), (1, 0), (1, 1), LEFT_CEN, 2)
        sizer.Add(SimpleText(panel, "Erase?"), (1, 1), (1, 1), LEFT_CEN, 2)
        sizer.Add(wx.StaticLine(panel, size=(300, 2)), (2, 0), (1, 2), LEFT_CEN, 2)

        irow = 2
        for pname in positions:
            irow += 1
            cbox = self.checkboxes[pname] = wx.CheckBox(panel, -1, "")
            cbox.SetValue(True)
            sizer.Add(SimpleText(panel, "  %s  " % pname), (irow, 0), (1, 1), LEFT_CEN, 2)
            sizer.Add(cbox, (irow, 1), (1, 1), LEFT_CEN, 2)
        irow += 1
        sizer.Add(wx.StaticLine(panel, size=(300, 2)), (irow, 0), (1, 2), LEFT_CEN, 2)

        pack(panel, sizer)
        panel.SetMinSize((350, 300))
        panel.SetupScrolling()
        bkws = dict(size=(55, -1))
        btn_ok = add_button(self, "OK", action=self.onOK, **bkws)
        btn_cancel = add_button(self, "Cancel", action=self.onCancel, **bkws)

        brow = wx.BoxSizer(wx.HORIZONTAL)
        brow.Add(btn_ok, 0, ALL_EXP | wx.ALIGN_LEFT, 1)
        brow.Add(btn_cancel, 0, ALL_EXP | wx.ALIGN_LEFT, 1)

        mainsizer = wx.BoxSizer(wx.VERTICAL)
        mainsizer.Add(panel, 1, 2)
        mainsizer.Add(wx.StaticLine(self, size=(300, 2)), 0, 2)
        mainsizer.Add(brow, 0, 2)
        pack(self, mainsizer)
        self.Raise()
        self.Show()
Esempio n. 30
0
    def group_panel(self, group='Fine Stages', motorlist=None,
                    precision=3, maxstep=5.01, buttons=None, show=True):
        """make motor group panel """
        panel  = wx.Panel(self)
        self.subpanels[group] = panel

        # print 'Group Panel ', group, show
        tweaklist = make_steps(precision=precision, maxstep=maxstep)
        if group.lower().startswith('theta'):
            tweaklist.extend([10, 20, 30, 45, 90, 180])

        init_tweak = {'Focus': 5, 'Theta': 8}.get(group, 6)

        self.tweak_wids[group] = NumericCombo(panel, tweaklist,
                                              precision=precision,
                                              init=init_tweak)

        slabel = wx.BoxSizer(wx.HORIZONTAL)
        slabel.Add(wx.StaticText(panel, label=" %s: " % group, size=(120,-1)),
                   1,  wx.EXPAND|LEFT_BOT)
        slabel.Add(self.tweak_wids[group], 0,  ALL_EXP)

        msizer = wx.BoxSizer(wx.VERTICAL)
        msizer.Add(slabel, 0, ALL_EXP)

        for pvname, desc in motorlist:
            pvname = normalize_pvname(pvname)
            self.motor_wids[desc] = MotorPanel(panel, pvname,
                                               label=desc, psize='small')
            msizer.Add(self.motor_wids[desc], 0, ALL_EXP)

        if buttons is not None:
            for blabel, action in buttons:
                msizer.Add(add_button(panel, blabel, action=action))

        dim=len(motorlist)
        btnbox = self.make_button_panel(panel, group=group, dim=dim)

        sizer = wx.BoxSizer(wx.HORIZONTAL)
        sizer.Add(msizer, 0, ALL_EXP)
        sizer.Add(btnbox, 0, CEN_TOP, 1)
        if not show:
            panel.Disable()

        pack(panel, sizer)
        return panel
Esempio n. 31
0
    def __init__(self, parent, groups=None, config={}, autofocus=None):
        wx.Panel.__init__(self, parent, -1)
        self.subpanels = {}

        self.groups = groups
        self.config = config #  json.loads(station_configs[station.upper()])
        self.tweak_wids  = {}   # tweak Combobox widgets per group
        self.groupmotors = {}   # motorlist per group
        self.motor_wids  = {}   # motor panel widgets, key=desc
        self.motors      = {}   # epics motor,         key=desc
        self.scale       = {}   # motor sign for ZFM,  key=desc
        self.af_message = None
        # self.SetMinSize((320, 200))

        sizer = wx.BoxSizer(wx.VERTICAL)
        for group in groups:
            self.groupmotors[group] = []
            motorlist = []
            maxstep = 5000
            show = 0
            prec = 4
            for name, data in config.items():
                name = normalize_pvname(name)
                if data['group'] == group:
                    self.groupmotors[group].append(data['desc'])
                    motorlist.append((name, data['desc']))
                    maxstep = min(maxstep, data['maxstep'])
                    prec    = min(prec, data['prec'])
                    show    = show + data['show']
            kws = {'motorlist': motorlist, 'maxstep':maxstep,
                   'precision': prec, 'show': show>0}
            if group.lower().startswith('fine'):
                kws['buttons'] = [('Zero Fine Motors', self.onZeroFineMotors)]
            sizer.Add((3, 3))
            sizer.Add(self.group_panel(group=group, **kws),   0, ALL_EXP)
            sizer.Add((3, 3))
            sizer.Add(wx.StaticLine(self, size=(300, 3)), 0, CEN_TOP)

        if autofocus is not None:
            self.af_button = add_button(self, "AutoFocus",
                                        action=autofocus, size=(125, -1))
            self.af_message = wx.StaticText(self, label="", size=(200,-1))
            sizer.Add(self.af_button, 0, LEFT_TOP)
            sizer.Add(self.af_message, 0, LEFT_TOP)
        pack(self, sizer)
        self.connect_motors()
Esempio n. 32
0
    def __init__(self, parent, posname, inst, **kws):
        self.posname = posname
        self.inst = inst
        title = "Rename Position '%s' for '%s' ?" % (posname, inst.name)
        wx.Dialog.__init__(self, parent, wx.ID_ANY, title=title)
        panel = wx.Panel(self)
        colors = GUIColors()

        self.SetFont(parent.GetFont())
        titlefont = self.GetFont()
        titlefont.PointSize += 2
        titlefont.SetWeight(wx.BOLD)

        panel.SetBackgroundColour(colors.bg)
        sizer = wx.GridBagSizer(10, 3)

        labstyle = wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.ALL
        rlabstyle = wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL | wx.ALL
        tstyle = wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL

        label1 = SimpleText(panel, 'Old name = %s' % posname, style=tstyle)
        label2 = SimpleText(panel, 'New name = ', style=tstyle)
        self.newname = wx.TextCtrl(panel, value=posname, size=(225, 25))

        sizer.Add(label1, (0, 0), (1, 2), labstyle, 1)
        sizer.Add(label2, (1, 0), (1, 1), labstyle, 1)
        sizer.Add(self.newname, (1, 1), (1, 1), labstyle, 1)

        sizer.Add(wx.StaticLine(panel, size=(250, -1), style=wx.LI_HORIZONTAL),
                  (2, 0), (1, 2), wx.ALIGN_CENTER | wx.GROW | wx.ALL, 0)

        btnsizer = wx.StdDialogButtonSizer()
        btn = wx.Button(panel, wx.ID_OK)
        btn.SetDefault()
        btnsizer.AddButton(btn)
        btnsizer.AddButton(wx.Button(panel, wx.ID_CANCEL))

        btnsizer.Realize()
        sizer.Add(btnsizer, (3, 0), (1, 2), wx.ALIGN_CENTER_VERTICAL | wx.ALL,
                  1)
        pack(panel, sizer)

        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(panel, 0, 0, 0)
        pack(self, sizer)
Esempio n. 33
0
    def create_frame(self):
        "build main frame"
        self.create_menus()
        # status bars
        self.statusbar = self.CreateStatusBar(2, wx.CAPTION|wx.THICK_FRAME)
        self.statusbar.SetStatusWidths([-4, -1])
        for index in range(2):
            self.statusbar.SetStatusText('', index)

        sizer = wx.BoxSizer(wx.HORIZONTAL)
        sizer.AddMany([
            (self.make_mainpanel(self), 0, ALL_EXP|wx.ALIGN_LEFT, 1),
            (self.make_imgpanel(self),  0, ALL_EXP|LEFT_CEN,  1),
            (self.make_pospanel(self),  1, ALL_EXP|wx.ALIGN_RIGHT, 1)])

        pack(self, sizer)

        icon = wx.Icon(ICON_FILE, wx.BITMAP_TYPE_ICO)
        self.SetIcon(icon)
Esempio n. 34
0
    def __init__(self, parent, prefix, pvdata, **kws):
        wx.Panel.__init__(self, parent, -1, **kws)
        self.sizer = sizer = wx.GridBagSizer(3, 3)
        self.wids = {}
        self.prefix = prefix
        irow = -1
        for label, pvname, use_prefix, dtype, rsuff, wsize, fontsize in pvdata:
            if use_prefix:
                pvname = prefix + pvname
            get_pv(pvname)
        poll(0.02)

        for label, pvname, use_prefix, dtype, rsuff, wsize, fontsize in pvdata:
            label = '  %s' % label
            if use_prefix:
                pvname = prefix + pvname
            ctrl = pv_control(dtype)
            opts = dict(pv=get_pv(pvname), size=(wsize, -1))

            self.wids[label] = ctrl(self, **opts)
            self.wids[label].SetFont(Font(fontsize))

            title = wx.StaticText(self,
                                  label=label,
                                  size=(8 * len(label), -1),
                                  style=labstyle)
            title.SetFont(Font(fontsize))
            irow += 1
            sizer.Add(title, (irow, 0), (1, 1), labstyle)

            if rsuff:
                rlabel = label + rsuff
                rname = pvname + rsuff
                self.wids[rlabel] = PVStaticText(self,
                                                 pv=get_pv(rname),
                                                 size=(wsize, -1))
                self.wids[rlabel].SetFont(Font(fontsize))
                sizer.Add(self.wids[label], (irow, 1), (1, 1), labstyle)
                sizer.Add(self.wids[rlabel], (irow, 2), (1, 1), labstyle)
            else:
                sizer.Add(self.wids[label], (irow, 1), (1, 2), labstyle)
        pack(self, sizer)
Esempio n. 35
0
    def make_button_panel(self, parent, group='', dim=2):
        panel = wx.Panel(parent)
        sizer = wx.GridBagSizer(3, 3)

        if dim==2:
            sizer.Add(self.arrow(panel, group, 'nw'), (0, 0), (1, 1), ALL_EXP)
            sizer.Add(self.arrow(panel, group, 'nn'), (0, 1), (1, 1), ALL_EXP)
            sizer.Add(self.arrow(panel, group, 'ne'), (0, 2), (1, 1), ALL_EXP)
            sizer.Add(self.arrow(panel, group, 'ww'), (1, 0), (1, 1), ALL_EXP)
            sizer.Add(self.arrow(panel, group, 'ee'), (1, 2), (1, 1), ALL_EXP)
            sizer.Add(self.arrow(panel, group, 'sw'), (2, 0), (1, 1), ALL_EXP)
            sizer.Add(self.arrow(panel, group, 'ss'), (2, 1), (1, 1), ALL_EXP)
            sizer.Add(self.arrow(panel, group, 'se'), (2, 2), (1, 1), ALL_EXP)
        else:
            sizer.Add(self.arrow(panel, group, 'ww'), (0, 0), (1, 1), ALL_EXP)
            sizer.Add((25, 25), (0, 1), (1, 1), ALL_EXP)
            sizer.Add(self.arrow(panel, group, 'ee'), (0, 2), (1, 1), ALL_EXP)

        pack(panel, sizer)
        return panel
Esempio n. 36
0
    def make_button_panel(self, parent, group='', dim=2):
        panel = wx.Panel(parent)
        sizer = wx.GridBagSizer(3, 3)

        if dim == 2:
            sizer.Add(self.arrow(panel, group, 'nw'), (0, 0), (1, 1), ALL_EXP)
            sizer.Add(self.arrow(panel, group, 'nn'), (0, 1), (1, 1), ALL_EXP)
            sizer.Add(self.arrow(panel, group, 'ne'), (0, 2), (1, 1), ALL_EXP)
            sizer.Add(self.arrow(panel, group, 'ww'), (1, 0), (1, 1), ALL_EXP)
            sizer.Add(self.arrow(panel, group, 'ee'), (1, 2), (1, 1), ALL_EXP)
            sizer.Add(self.arrow(panel, group, 'sw'), (2, 0), (1, 1), ALL_EXP)
            sizer.Add(self.arrow(panel, group, 'ss'), (2, 1), (1, 1), ALL_EXP)
            sizer.Add(self.arrow(panel, group, 'se'), (2, 2), (1, 1), ALL_EXP)
        else:
            sizer.Add(self.arrow(panel, group, 'ww'), (0, 0), (1, 1), ALL_EXP)
            sizer.Add((25, 25), (0, 1), (1, 1), ALL_EXP)
            sizer.Add(self.arrow(panel, group, 'ee'), (0, 2), (1, 1), ALL_EXP)

        pack(panel, sizer)
        return panel
Esempio n. 37
0
    def create_frame(self):
        "build main frame"
        self.create_menus()
        # status bars
        self.statusbar = self.CreateStatusBar(2, wx.CAPTION | wx.THICK_FRAME)
        self.statusbar.SetStatusWidths([-4, -1])
        for index in range(2):
            self.statusbar.SetStatusText('', index)

        sizer = wx.BoxSizer(wx.HORIZONTAL)
        sizer.AddMany([
            (self.make_mainpanel(self), 0, ALL_EXP | wx.ALIGN_LEFT, 1),
            (self.make_imgpanel(self), 0, ALL_EXP | LEFT_CEN, 1),
            (self.make_pospanel(self), 1, ALL_EXP | wx.ALIGN_RIGHT, 1)
        ])

        pack(self, sizer)

        icon = wx.Icon(ICON_FILE, wx.BITMAP_TYPE_ICO)
        self.SetIcon(icon)
Esempio n. 38
0
    def __init__(self,
                 parent,
                 image_panel=None,
                 prefix=None,
                 center_cb=None,
                 xhair_cb=None,
                 **kws):
        super(ConfPanel_Fly2AD, self).__init__(parent,
                                               center_cb=center_cb,
                                               xhair_cb=xhair_cb)

        sizer = self.sizer
        self.image_panel = image_panel
        self.SetBackgroundColour('#EEFFE')
        self.title = wx.StaticText(self,
                                   size=(285, 25),
                                   label="Fly2 Camera Mirror")
        labstyle = wx.ALIGN_LEFT | wx.EXPAND | wx.ALIGN_BOTTOM
        sizer.Add(self.title, (0, 0), (1, 3), labstyle)
        pack(self, sizer)
        self.set_prefix(prefix)
Esempio n. 39
0
    def make_button_panel(self, parent, group='', dim=2):
        panel = wx.Panel(parent)
        if dim==2:
            sizer = wx.GridSizer(3, 3, 1, 1)
            sizer.Add(self.arrow(panel, group, 'nw'), 0, ALL_EXP)
            sizer.Add(self.arrow(panel, group, 'nn'), 0, ALL_EXP)
            sizer.Add(self.arrow(panel, group, 'ne'), 0, ALL_EXP)
            sizer.Add(self.arrow(panel, group, 'ww'), 0, ALL_EXP)
            sizer.Add((2, 2))
            sizer.Add(self.arrow(panel, group, 'ee'), 0, ALL_EXP)
            sizer.Add(self.arrow(panel, group, 'sw'), 0, ALL_EXP)
            sizer.Add(self.arrow(panel, group, 'ss'), 0, ALL_EXP)
            sizer.Add(self.arrow(panel, group, 'se'), 0, ALL_EXP)
        else:
            sizer = wx.GridSizer(1, 3)
            sizer.Add(self.arrow(panel, group, 'ww'), 0, ALL_EXP)
            sizer.Add((2, 2))
            sizer.Add(self.arrow(panel, group, 'ee'), 0, ALL_EXP)

        pack(panel, sizer)
        return panel
Esempio n. 40
0
    def __init__(self, parent, prefix, pvdata, **kws):
        wx.Panel.__init__(self, parent, -1,  **kws)
        self.sizer = sizer = wx.GridBagSizer(3, 3)
        self.wids = {}
        self.prefix = prefix
        irow = -1
        for label, pvname, use_prefix, dtype, rsuff, wsize, fontsize in pvdata:
            if use_prefix:
                pvname = prefix + pvname
            get_pv(pvname)
        poll(0.02)

        for label, pvname, use_prefix, dtype, rsuff, wsize, fontsize in pvdata:
            label = '  %s' % label
            if use_prefix:
                pvname = prefix + pvname
            ctrl  = pv_control(dtype)
            opts = dict(pv=get_pv(pvname), size=(wsize, -1))

            self.wids[label] = ctrl(self, **opts)
            self.wids[label].SetFont(Font(fontsize))

            title = wx.StaticText(self, label=label, size=(8*len(label), -1),
                                  style=labstyle)
            title.SetFont(Font(fontsize))
            irow += 1
            sizer.Add(title, (irow, 0), (1, 1), labstyle)

            if rsuff:
                rlabel = label + rsuff
                rname = pvname + rsuff
                self.wids[rlabel] = PVStaticText(self, pv=get_pv(rname),
                                                 size=(wsize, -1))
                self.wids[rlabel].SetFont(Font(fontsize))
                sizer.Add(self.wids[label], (irow, 1), (1, 1), labstyle)
                sizer.Add(self.wids[rlabel], (irow, 2), (1, 1), labstyle)
            else:
                sizer.Add(self.wids[label], (irow, 1), (1, 2), labstyle)
        pack(self, sizer)
Esempio n. 41
0
    def make_pospanel(self, parent):
        """panel of position lists, with buttons"""
        panel = wx.Panel(parent, size=(175, 200))
        btn_goto  = add_button(panel, "Go To",  size=(70, -1), action=self.onGo)
        btn_erase = add_button(panel, "Erase",  size=(70, -1),
                            action=self.onErasePosition)

        brow = wx.BoxSizer(wx.HORIZONTAL)
        brow.Add(btn_goto,   0, ALL_EXP|wx.ALIGN_LEFT, 1)
        brow.Add(btn_erase,  0, ALL_EXP|wx.ALIGN_LEFT, 1)

        self.pos_list  = wx.ListBox(panel)
        self.pos_list.SetBackgroundColour(wx.Colour(253, 253, 250))
        self.pos_list.Bind(wx.EVT_LISTBOX, self.onSelectPosition)
        self.pos_list.Bind(wx.EVT_RIGHT_DOWN, self.onPosRightClick)

        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(brow,          0, wx.ALIGN_LEFT|wx.ALL)
        sizer.Add(self.pos_list, 1, ALL_EXP|wx.ALIGN_CENTER, 3)

        pack(panel, sizer)
        panel.SetAutoLayout(1)
        return panel
Esempio n. 42
0
    def __init__(self,
                 parent=None,
                 filelist=None,
                 title='Select a Motor DB File'):

        wx.Dialog.__init__(self, parent, wx.ID_ANY, title=title)

        panel = wx.Panel(self)
        self.colors = GUIColors()
        panel.SetBackgroundColour(self.colors.bg)
        if parent is not None:
            self.SetFont(parent.GetFont())

        flist = []
        if filelist is not None:
            for fname in filelist:
                if os.path.exists(fname):
                    flist.append(fname)

        self.filebrowser = FileBrowser(panel, size=(600, -1))
        self.filebrowser.SetHistory(flist)
        self.filebrowser.SetLabel('File:')
        self.filebrowser.fileMask = MDB_WILDCARD

        if filelist is not None:
            self.filebrowser.SetValue(filelist[0])

        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(wx.StaticText(panel, label=self.msg), 0,
                  wx.ALIGN_CENTER | wx.ALL | wx.GROW, 1)
        sizer.Add(self.filebrowser, 1, wx.ALIGN_CENTER | wx.ALL | wx.GROW, 1)
        sizer.Add(self.CreateButtonSizer(wx.OK | wx.CANCEL), 1,
                  wx.ALIGN_CENTER_VERTICAL | wx.ALL, 1)
        pack(panel, sizer)
        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(panel, 0, 0, 0)
        pack(self, sizer)
Esempio n. 43
0
    def create_Frame(self):
        self.nb = flat_nb.FlatNotebook(self, wx.ID_ANY, agwStyle=FNB_STYLE)

        colors = self.colors
        self.nb.SetActiveTabColour(colors.nb_active)
        self.nb.SetTabAreaColour(colors.nb_area)
        self.nb.SetNonActiveTabTextColour(colors.nb_text)
        self.nb.SetActiveTabTextColour(colors.nb_activetext)
        self.nb.SetBackgroundColour(colors.bg)

        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(self.nb, 1, wx.EXPAND)

        self.create_nbpages()

        self.SetSize((876, 351))
        self.SetMinSize((875, 350))

        pack(self, sizer)
        try:
            self.SetIcon(wx.Icon(ICON_FILE, wx.BITMAP_TYPE_ICO))
        except:
            pass
        self.Refresh()
Esempio n. 44
0
    def __init__(self,
                 parent,
                 image_panel=None,
                 prefix=None,
                 center_cb=None,
                 xhair_cb=None,
                 **kws):
        super(ConfPanel_EpicsAD, self).__init__(parent,
                                                center_cb=center_cb,
                                                xhair_cb=xhair_cb)

        wids = self.wids
        sizer = self.sizer
        self.image_panel = image_panel
        self.SetBackgroundColour('#EEFFE')
        self.title = wx.StaticText(self,
                                   size=(285, 25),
                                   label="Epics AreaDetector")

        for key in ('imagemode', 'triggermode', 'color'):
            self.wids[key] = PVEnumChoice(self, pv=None, size=(135, -1))

        for key in ('exptime', 'gain'):
            self.wids[key] = PVFloatCtrl(self,
                                         pv=None,
                                         size=(135, -1),
                                         minval=0)
        self.wids['gain'].SetMax(20)

        for key in ('start', 'stop'):
            self.wids[key] = wx.Button(self,
                                       -1,
                                       label=key.title(),
                                       size=(65, -1))
            self.wids[key].Bind(wx.EVT_BUTTON, Closure(self.onButton, key=key))

        labstyle = wx.ALIGN_LEFT | wx.EXPAND | wx.ALIGN_BOTTOM
        ctrlstyle = wx.ALIGN_LEFT  #  |wx.ALIGN_BOTTOM
        rlabstyle = wx.ALIGN_RIGHT | wx.RIGHT | wx.TOP | wx.EXPAND
        txtstyle = wx.ALIGN_LEFT | wx.ST_NO_AUTORESIZE | wx.TE_PROCESS_ENTER

        self.wids['fullsize'] = wx.StaticText(self,
                                              -1,
                                              size=(250, -1),
                                              style=txtstyle)

        def txt(label, size=100):
            return wx.StaticText(self,
                                 label=label,
                                 size=(size, -1),
                                 style=labstyle)

        def lin(len=30, wid=2, style=wx.LI_HORIZONTAL):
            return wx.StaticLine(self, size=(len, wid), style=style)

        sizer.Add(self.title, (0, 0), (1, 3), labstyle)
        i = next_row = self.show_position_info(row=1)
        i += 1
        sizer.Add(self.wids['fullsize'], (i, 0), (1, 3), labstyle)
        i += 1
        sizer.Add(txt('Acquire '), (i, 0), (1, 1), labstyle)
        sizer.Add(self.wids['start'], (i, 1), (1, 1), ctrlstyle)
        sizer.Add(self.wids['stop'], (i, 2), (1, 1), ctrlstyle)
        i += 1
        sizer.Add(txt('Image Mode '), (i, 0), (1, 1), labstyle)
        sizer.Add(self.wids['imagemode'], (i, 1), (1, 2), ctrlstyle)

        i += 1
        sizer.Add(txt('Trigger Mode '), (i, 0), (1, 1), labstyle)
        sizer.Add(self.wids['triggermode'], (i, 1), (1, 2), ctrlstyle)

        i += 1
        sizer.Add(txt('Exposure Time '), (i, 0), (1, 1), labstyle)
        sizer.Add(self.wids['exptime'], (i, 1), (1, 2), ctrlstyle)

        i += 1
        sizer.Add(txt('Gain '), (i, 0), (1, 1), labstyle)
        sizer.Add(self.wids['gain'], (i, 1), (1, 2), ctrlstyle)

        i += 1
        sizer.Add(txt('Color Mode'), (i, 0), (1, 1), labstyle)
        sizer.Add(self.wids['color'], (i, 1), (1, 2), ctrlstyle)

        #  show last pixel position, move to center
        pack(self, sizer)
        self.set_prefix(prefix)
Esempio n. 45
0
    def __init__(self, parent, image_panel=None, camera_id=0,
                 center_cb=None, xhair_cb=None, **kws):
        super(ConfPanel_Fly2, self).__init__(parent, center_cb=center_cb,
                                             xhair_cb=xhair_cb)
        self.image_panel = image_panel
        self.camera_id = camera_id
        self.camera = self.image_panel.camera

        wids = self.wids
        sizer = self.sizer

        self.title = self.txt("PyCapture2: ", size=285)
        self.title2 = self.txt(" ", size=285)

        sizer.Add(self.title, (0, 0), (1, 3), LEFT)
        sizer.Add(self.title2,(1, 0), (1, 3), LEFT)
        next_row = self.show_position_info(row=2)

        self.__initializing = True
        i = next_row + 1
        #('Sharpness', '%', 100), ('Hue', 'deg', 100), ('Saturation', '%', 100),
        for dat in (('shutter', 'ms',  50 , 0, 70),
                    ('gain', 'dB',      0, -2, 24),
                    # ('brightness', '%', 0,  0,  6),
                    ('gamma', '',       1, 0.5, 4)):

            key, units, defval, minval, maxval = dat
            wids[key] = FloatCtrl(self, value=defval,
                                  minval=minval, maxval=maxval,
                                  precision=1,
                                  action=self.onValue,
                                  act_on_losefocus=True,
                                  action_kw={'prop': key}, size=(75, -1))
            label = '%s' % (key.title())
            if len(units)> 0:
                label = '%s (%s)' % (key.title(), units)
            sizer.Add(self.txt(label), (i, 0), (1, 1), LEFT)
            sizer.Add(wids[key],  (i, 1), (1, 1), LEFT)

            akey = '%s_auto' % key
            wids[akey] =  wx.CheckBox(self, -1, label='auto')
            wids[akey].SetValue(0)
            wids[akey].Bind(wx.EVT_CHECKBOX, Closure(self.onAuto, prop=key))
            sizer.Add(wids[akey], (i, 2), (1, 1), LEFT)
            i = i + 1

        for color in ('blue', 'red'):
            key = 'wb_%s' % color
            wids[key] = FloatCtrl(self, value=0, maxval=1024,
                                  precision=0,
                                  action=self.onValue,
                                  act_on_losefocus=True,
                                  action_kw={'prop': key}, size=(75, -1))
            label = 'White Balance (%s)' % (color)
            sizer.Add(self.txt(label), (i, 0), (1, 1), LEFT)
            sizer.Add(wids[key],  (i, 1), (1, 1), LEFT)

            if color == 'blue':
                akey = 'wb_auto'
                wids[akey] =  wx.CheckBox(self, -1, label='auto')
                wids[akey].SetValue(0)
                wids[akey].Bind(wx.EVT_CHECKBOX, Closure(self.onAuto, prop=key))
                sizer.Add(wids[akey], (i, 2), (1, 1), LEFT)
            i += 1

        datapush_time = "%.1f" % self.image_panel.datapush_delay
        wids['dpush_time'] =  FloatCtrl(self, value=datapush_time, maxval=1e6,
                                        precision=1, minval=0,
                                        action=self.onValue, act_on_losefocus=True,
                                        action_kw={'prop':'autosave_time'}, size=(75, -1))

        label = 'AutoSave Time (sec)'
        sizer.Add(self.txt(label), (i, 0), (1, 1), LEFT)
        sizer.Add(wids['dpush_time'],  (i, 1), (1, 1), LEFT)

        # wids['datapush'].SetValue(1)
        # wids['datapush'].Bind(wx.EVT_CHECKBOX, self.onEnableDataPush)
        # sizer.Add(wids['datapush'], (i+1, 0), (1, 3), LEFT)

        pack(self, sizer)
        self.__initializing = False
        self.timer = wx.Timer(self)
        self.Bind(wx.EVT_TIMER, self.onTimer, self.timer)
        wx.CallAfter(self.onConnect)
Esempio n. 46
0
    def build_dialog(self, parent, thispos):
        panel = wx.Panel(self)
        colors = GUIColors()

        self.SetFont(parent.GetFont())
        titlefont  = self.GetFont()
        titlefont.PointSize += 2
        titlefont.SetWeight(wx.BOLD)

        panel.SetBackgroundColour(colors.bg)
        sizer = wx.GridBagSizer(10, 4)

        labstyle  = wx.ALIGN_LEFT|wx.ALIGN_CENTER_VERTICAL|wx.ALL
        rlabstyle = wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL|wx.ALL
        tstyle    = wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL
        # title row
        i = 0
        col_labels = ['  PV ', 'Current Value', 'Saved Value']
        if self.mode != 'show': col_labels.append('Move?')
        for titleword in col_labels:
            txt =SimpleText(panel, titleword,
                            font=titlefont,
                            minsize=(100, -1),
                            colour=colors.title,
                            style=tstyle)

            sizer.Add(txt, (0, i), (1, 1), labstyle, 1)
            i = i + 1

        sizer.Add(wx.StaticLine(panel, size=(150, -1),
                                style=wx.LI_HORIZONTAL),
                  (1, 0), (1, 4), wx.ALIGN_CENTER|wx.GROW|wx.ALL, 0)

        self.checkboxes = {}
        for irow, pvpos in enumerate(thispos.pvs):
            # pvname = normalize_pvname(pvpos.pv.name)
            pvname = pvpos.pv.name
            desc = get_pvdesc(pvname)
            if desc != pvname:
                desc = "%s (%s)" % (desc, pvname)
            curr_val = None

            if pvname in self.pvs:
                curr_val = self.pvs[pvname].get(as_string=True)
            elif pvname.endswith('.VAL') and pvname[:4] in self.pvs:
                # pvname = pvname[:-4]
                curr_val = self.pvs[pvname[:-4]].get(as_string=True)
            elif pvname+'.VAL' in self.pvs:
                #pvname = pvname + '.VAL'
                curr_val = self.pvs[pvname+'.VAL'].get(as_string=True)

            if curr_val is None:
                curr_val = 'Unknown'

            save_val = pvpos.value

            label = SimpleText(panel, desc, style=tstyle,
                               colour=colors.pvname)
            curr  = SimpleText(panel, curr_val, style=tstyle)
            saved = SimpleText(panel, save_val, style=tstyle)
            if self.mode != 'show':
                cbox  = wx.CheckBox(panel, -1, "Move")
                cbox.SetValue(True)
                self.checkboxes[pvname] = (cbox, save_val)

            sizer.Add(label, (irow+2, 0), (1, 1), labstyle,  2)
            sizer.Add(curr,  (irow+2, 1), (1, 1), rlabstyle, 2)
            sizer.Add(saved, (irow+2, 2), (1, 1), rlabstyle, 2)
            if self.mode != 'show':
                sizer.Add(cbox,  (irow+2, 3), (1, 1), rlabstyle, 2)

        sizer.Add(wx.StaticLine(panel, size=(150, -1),
                                style=wx.LI_HORIZONTAL),
                  (irow+3, 0), (1, 4), wx.ALIGN_CENTER|wx.GROW|wx.ALL, 0)

        btnsizer = wx.StdDialogButtonSizer()
        btn = wx.Button(panel, wx.ID_OK)
        btn.SetDefault()
        btnsizer.AddButton(btn)
        if self.mode != 'show':
            btnsizer.AddButton(wx.Button(panel, wx.ID_CANCEL))

        btnsizer.Realize()
        sizer.Add(btnsizer, (irow+4, 2), (1, 2),
                  wx.ALIGN_CENTER_VERTICAL|wx.ALL, 1)
        pack(panel, sizer)

        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(panel, 0, 0, 0)
        pack(self, sizer)
Esempio n. 47
0
    def build_dialog(self):
        positions = self.instdb.get_positionlist(self.offline)
        panel = scrolled.ScrolledPanel(self)
        self.checkboxes = OrderedDict()
        sizer = wx.GridBagSizer(len(positions) + 5, 4)
        sizer.SetVGap(2)
        sizer.SetHGap(3)
        bkws = dict(size=(95, -1))
        btn_ok = add_button(panel, "Copy Selected", action=self.onOK, **bkws)
        btn_all = add_button(panel, "Select All", action=self.onAll, **bkws)
        btn_none = add_button(panel, "Select None", action=self.onNone, **bkws)

        brow = wx.BoxSizer(wx.HORIZONTAL)
        brow.Add(btn_all, 0, ALL_EXP | wx.ALIGN_LEFT, 1)
        brow.Add(btn_none, 0, ALL_EXP | wx.ALIGN_LEFT, 1)
        brow.Add(btn_ok, 0, ALL_EXP | wx.ALIGN_LEFT, 1)

        sizer.Add(brow, (0, 0), (1, 4), LEFT_CEN, 2)

        sizer.Add(SimpleText(panel, ' Add Suffix:'), (1, 0), (1, 1), LEFT_CEN,
                  2)

        self.suffix = wx.TextCtrl(panel, value="", size=(150, -1))
        sizer.Add(self.suffix, (1, 1), (1, 3), LEFT_CEN, 2)

        sizer.Add(SimpleText(panel, ' Position Name'), (2, 0), (1, 1),
                  LEFT_CEN, 2)
        sizer.Add(SimpleText(panel, 'Copy?'), (2, 1), (1, 1), LEFT_CEN, 2)
        sizer.Add(SimpleText(panel, ' Position Name'), (2, 2), (1, 1),
                  LEFT_CEN, 2)
        sizer.Add(SimpleText(panel, 'Copy?'), (2, 3), (1, 1), LEFT_CEN, 2)
        sizer.Add(wx.StaticLine(panel, size=(500, 2)), (3, 0), (1, 4),
                  LEFT_CEN, 2)

        irow = 3
        for ip, pname in enumerate(positions):
            cbox = self.checkboxes[pname] = wx.CheckBox(panel, -1, "")
            cbox.SetValue(True)

            if ip % 2 == 0:
                irow += 1
                icol = 0
            else:
                icol = 2
            sizer.Add(SimpleText(panel, "  %s  " % pname), (irow, icol),
                      (1, 1), LEFT_CEN, 2)
            sizer.Add(cbox, (irow, icol + 1), (1, 1), LEFT_CEN, 2)
        irow += 1
        sizer.Add(wx.StaticLine(panel, size=(500, 2)), (irow, 0), (1, 4),
                  LEFT_CEN, 2)

        pack(panel, sizer)
        panel.SetMinSize((700, 550))

        panel.SetupScrolling()

        mainsizer = wx.BoxSizer(wx.VERTICAL)
        mainsizer.Add(panel, 1, ALL_EXP | wx.GROW | wx.ALIGN_LEFT, 1)
        pack(self, mainsizer)

        self.SetMinSize((700, 550))
        self.Raise()
        self.Show()
Esempio n. 48
0
    def __init__(self, parent=None, pos=(-1, -1),
                 inst=None, db=None, epics_pvs=None):

        self.epics_pvs = epics_pvs
        if self.epics_pvs is None:
            self.epics_pvs = {}

        title = 'Add New Instrument'
        if inst is not None:
            title = 'Edit Instrument  %s ' % inst.name

        style = wx.DEFAULT_FRAME_STYLE|wx.TAB_TRAVERSAL
        wx.Frame.__init__(self, None, -1, title,
                          style=style, pos=pos)
        self.Handle_FocusEvents()

        panel = scrolled.ScrolledPanel(self, size=(500, 650), style=wx.GROW|wx.TAB_TRAVERSAL, name='p1')

        self.colors = GUIColors()

        font = self.GetFont()
        if parent is not None:
            font = parent.GetFont()

        titlefont  = font
        titlefont.PointSize += 1
        titlefont.SetWeight(wx.BOLD)

        panel.SetBackgroundColour(self.colors.bg)

        self.parent = parent
        self.db = db
        self.inst = db.get_instrument(inst)
        self.connecting_pvs = {}

        STY  = wx.GROW|wx.ALL|wx.ALIGN_CENTER_VERTICAL
        LSTY = wx.ALIGN_LEFT|wx.GROW|wx.ALL|wx.ALIGN_CENTER_VERTICAL
        RSTY = wx.ALIGN_RIGHT|STY
        CSTY = wx.ALIGN_CENTER|STY
        CEN  = wx.ALIGN_CENTER|wx.GROW|wx.ALL
        LEFT = wx.ALIGN_LEFT|wx.GROW|wx.ALL

        self.etimer = wx.Timer(self)
        self.etimer_count = 0
        self.Bind(wx.EVT_TIMER, self.onTimer, self.etimer)

        sizer = wx.GridBagSizer(12, 3)

        # Name row
        label  = SimpleText(panel, 'Instrument Name: ',
                            minsize=(150, -1), style=LSTY)
        self.name =  wx.TextCtrl(panel, value='', size=(260, -1))

        sizer.Add(label,      (0, 0), (1, 1), LSTY, 2)
        sizer.Add(self.name,  (0, 1), (1, 2), LSTY, 2)
        sizer.Add(wx.StaticLine(panel, size=(195, -1), style=wx.LI_HORIZONTAL),
                  (1, 0), (1, 3), CEN, 2)

        irow = 2
        self.curpvs, self.newpvs = [], {}
        if inst is not None:
            self.name.SetValue(inst.name)
            sizer.Add(SimpleText(panel, 'Current PVs:', font=titlefont,
                                 colour=self.colors.title, style=LSTY),
                      (2, 0), (1, 1), LSTY, 2)
            sizer.Add(SimpleText(panel, 'Display Type:',
                                 colour=self.colors.title, style=CSTY),
                      (2, 1), (1, 1), LSTY, 2)
            sizer.Add(SimpleText(panel, 'Remove?:',
                                 colour=self.colors.title, style=CSTY),
                      (2, 2), (1, 1), RSTY, 2)

            opvs  = db.get_ordered_instpvs(inst)

            for instpvs in self.db.get_ordered_instpvs(inst):
                pv = instpvs.pv
                irow += 1
                if pv.name in self.epics_pvs:
                    pvchoices = get_pvtypes(self.epics_pvs[pv.name], instrument)
                else:
                    pvchoices = get_pvtypes(pv, instrument)

                label= SimpleText(panel, pv.name,  minsize=(175, -1),
                                  style=LSTY)

                try:
                    itype = pvchoices.index(pv.pvtype.name)
                except ValueError:
                    itype = 0

                pvtype = PVTypeChoice(panel, choices=pvchoices)
                pvtype.SetSelection(itype)
                pvtype.SetStringSelection(pv.pvtype.name)
                del_pv = YesNo(panel, defaultyes=False)
                self.curpvs.append((pv.name, label, pvtype, del_pv))

                sizer.Add(label,     (irow, 0), (1, 1), LSTY,  3)
                sizer.Add(pvtype,    (irow, 1), (1, 1), CSTY,  3)
                sizer.Add(del_pv,    (irow, 2), (1, 1), RSTY,  3)

            irow += 1
            sizer.Add(wx.StaticLine(panel, size=(150, -1),
                                    style=wx.LI_HORIZONTAL),
                      (irow, 0), (1, 3), CEN, 0)
            irow += 1


        txt =SimpleText(panel, 'New PVs:', font=titlefont,
                        colour=self.colors.title, style=LSTY)

        sizer.Add(txt, (irow, 0), (1, 1), LEFT, 3)
        sizer.Add(SimpleText(panel, 'Display Type',
                             colour=self.colors.title, style=CSTY),
                  (irow, 1), (1, 1), LSTY, 2)
        sizer.Add(SimpleText(panel, 'Remove?',
                             colour=self.colors.title, style=CSTY),
                  (irow, 2), (1, 1), RSTY, 2)
        # New PVs
        for npv in range(5):
            irow += 1
            name = pvNameCtrl(self, panel, value='', size=(175, -1))
            pvtype = PVTypeChoice(panel)
            del_pv = YesNo(panel, defaultyes=False)
            pvtype.Disable()
            del_pv.Disable()
            sizer.Add(name,     (irow, 0), (1, 1), LSTY,  3)
            sizer.Add(pvtype,   (irow, 1), (1, 1), CSTY,  3)
            sizer.Add(del_pv,   (irow, 2), (1, 1), RSTY,  3)

            self.newpvs[name.GetId()] = dict(index=npv, name=name,
                                             type=pvtype, delpv=del_pv)

        btn_panel = wx.Panel(panel, size=(75, -1))
        btn_sizer = wx.BoxSizer(wx.HORIZONTAL)
        btn_ok     = add_button(btn_panel, 'Done',     size=(70, -1),
                                action=self.OnDone)
        btn_cancel = add_button(btn_panel, 'Cancel', size=(70, -1), action=self.onCancel)

        btn_sizer.Add(btn_ok,     0, wx.ALIGN_LEFT,  2)
        btn_sizer.Add(btn_cancel, 0, wx.ALIGN_RIGHT,  2)
        pack(btn_panel, btn_sizer)

        irow += 1
        sizer.Add(wx.StaticLine(panel, size=(150, -1), style=wx.LI_HORIZONTAL),
                  (irow, 0), (1, 3), CEN, 2)
        sizer.Add(btn_panel, (irow+1, 1), (1, 2), CEN, 2)
        sizer.Add(wx.StaticLine(panel, size=(150, -1), style=wx.LI_HORIZONTAL),
                  (irow+2, 0), (1, 3), CEN, 2)

        set_font_with_children(self, font)

        pack(panel, sizer)
        panel.SetupScrolling()

        mainsizer = wx.BoxSizer(wx.VERTICAL)
        mainsizer.Add(panel, 1, LSTY)
        pack(self, mainsizer)

        self.Layout()
        self.Show()
        self.Raise()
Esempio n. 49
0
    def __init__(self, parent=None, *args, **kwds):
        wx.Frame.__init__(self, None, wx.ID_ANY, '', wx.DefaultPosition,
                          wx.Size(-1, -1), **kwds)

        STY = wx.GROW | wx.ALL | wx.ALIGN_CENTER_VERTICAL
        LSTY = wx.ALIGN_LEFT | wx.ALL | wx.ALIGN_CENTER_VERTICAL
        CEN = wx.ALIGN_CENTER | wx.GROW | wx.ALL

        self.parent = parent
        cam_type = 'ad'
        if parent.cam_type.lower().startswith('web'):
            cam_type = 'web'

        sizer = wx.GridBagSizer(10, 2)
        panel = wx.Panel(self, style=wx.GROW)

        irow = 0
        sizer.Add(wx.StaticLine(panel, size=(150, -1), style=wx.LI_HORIZONTAL),
                  (irow, 0), (1, 2), CEN, 2)

        self.cam_type = wx.Choice(panel,
                                  -1,
                                  size=(150, -1),
                                  choices=CAM_CHOICES)
        self.cam_adform = wx.Choice(panel,
                                    -1,
                                    size=(150, -1),
                                    choices=AD_TYPES)

        self.cam_adform.SetSelection(0)
        self.cam_type.SetSelection({'web': 0, 'ad': 1}[cam_type])

        self.cam_weburl = wx.TextCtrl(panel,
                                      value=parent.cam_weburl,
                                      size=(260, -1))
        self.cam_adpref = wx.TextCtrl(panel,
                                      value=parent.cam_adpref,
                                      size=(260, -1))

        self.image_dir = wx.TextCtrl(panel,
                                     value=parent.imgdir,
                                     size=(260, -1))

        irow += 1
        sizer.Add(SimpleText(panel, 'Image Sub Folder: '), (irow, 0), (1, 1),
                  LSTY, 2)
        sizer.Add(self.image_dir, (irow, 1), (1, 1), LSTY, 2)

        irow += 1
        sizer.Add(SimpleText(panel, 'Camera Type:'), (irow, 0), (1, 1), LSTY,
                  2)
        sizer.Add(self.cam_type, (irow, 1), (1, 1), LSTY, 2)

        irow += 1
        sizer.Add(wx.StaticLine(panel, size=(150, -1), style=wx.LI_HORIZONTAL),
                  (irow, 0), (1, 2), CEN, 2)

        irow += 1
        sizer.Add(SimpleText(panel, 'Web Camera URL: '), (irow, 0), (1, 1),
                  LSTY, 2)
        sizer.Add(self.cam_weburl, (irow, 1), (1, 1), LSTY, 2)

        irow += 1
        sizer.Add(wx.StaticLine(panel, size=(150, -1), style=wx.LI_HORIZONTAL),
                  (irow, 0), (1, 2), CEN, 2)

        irow += 1
        sizer.Add(SimpleText(panel, 'Area Detector Format: '), (irow, 0),
                  (1, 1), LSTY, 2)
        sizer.Add(self.cam_adform, (irow, 1), (1, 1), LSTY, 2)

        irow += 1
        sizer.Add(SimpleText(panel, 'Area Detector Prefix: '), (irow, 0),
                  (1, 1), LSTY, 2)
        sizer.Add(self.cam_adpref, (irow, 1), (1, 1), LSTY, 2)

        irow += 1
        sizer.Add(wx.StaticLine(panel, size=(150, -1), style=wx.LI_HORIZONTAL),
                  (irow, 0), (1, 2), CEN, 2)

        btn_ok = add_button(panel, 'Done', size=(70, -1), action=self.onOK)
        btn_cancel = add_button(panel,
                                'Cancel',
                                size=(70, -1),
                                action=self.onCancel)

        irow += 1
        sizer.Add(btn_ok, (irow, 0), (1, 1), LSTY, 2)
        sizer.Add(btn_cancel, (irow, 1), (1, 1), LSTY, 2)

        pack(panel, sizer)
        mainsizer = wx.BoxSizer(wx.VERTICAL)
        mainsizer.Add(panel, 1, LSTY | STY)
        pack(self, mainsizer)
        self.Layout()
        self.Show()
        self.Raise()
        self.cam_type.Bind(wx.EVT_CHOICE, self.onCameraType)
        self.onCameraType()
Esempio n. 50
0
    def __init__(self, parent=None, pos=(-1, -1),
                 inst=None, db=None, page=None):

        title = 'New Position'
        if inst is not None:
            title = 'New Position for Instrument  %s ' % inst.name

        style = wx.DEFAULT_FRAME_STYLE|wx.TAB_TRAVERSAL
        wx.Frame.__init__(self, None, -1, title, size=(350, 450), 
                          style=style, pos=pos)
        self.Handle_FocusEvents()

        panel = scrolled.ScrolledPanel(self, size=(400, 500), style=wx.GROW|wx.TAB_TRAVERSAL)
        
        colors = GUIColors()

        font = self.GetFont()
        if parent is not None:
            font = parent.GetFont()

        titlefont  = font
        titlefont.PointSize += 1
        titlefont.SetWeight(wx.BOLD)

        panel.SetBackgroundColour(colors.bg)

        self.parent = parent
        self.page = page
        self.db = db
        self.inst = db.get_instrument(inst)

        STY  = wx.GROW|wx.ALL|wx.ALIGN_CENTER_VERTICAL
        LSTY = wx.ALIGN_LEFT|wx.GROW|wx.ALL|wx.ALIGN_CENTER_VERTICAL
        RSTY = wx.ALIGN_RIGHT|STY
        CSTY = wx.ALIGN_CENTER|STY
        CEN  = wx.ALIGN_CENTER|wx.GROW|wx.ALL
        LEFT = wx.ALIGN_LEFT|wx.GROW|wx.ALL


        self.name =  wx.TextCtrl(panel, value='', size=(200, -1))


        sizer = wx.GridBagSizer(12, 3)

        ir = 0
        sizer.Add(SimpleText(panel, " New Position for '%s'" % self.inst.name,
                             font=titlefont,  colour=colors.title),
                  (ir, 0), (1, 2), LSTY, 2)

        ir += 1        
        sizer.Add(SimpleText(panel, 'Position Name:'),  (ir, 0), (1, 1), LSTY, 2)
        sizer.Add(self.name,                            (ir, 1), (1, 2), LSTY, 2)
        ir += 1
        sizer.Add(SimpleText(panel, 'PV Name:'),        (ir, 0), (1, 1), LSTY, 2)
        sizer.Add(SimpleText(panel, 'Position:'),       (ir, 1), (1, 1), LSTY, 2)

        ir += 1
        sizer.Add(wx.StaticLine(panel, size=(195, -1), style=wx.LI_HORIZONTAL),
                  (ir, 0), (1, 3), CEN, 2)

        self.positions = []
        ir += 1
        for p in self.inst.pvs:
            val =  wx.TextCtrl(panel, value='', size=(150, -1))            
            sizer.Add(SimpleText(panel, p.name), (ir, 0), (1, 1), LSTY, 2)
            sizer.Add(val,                       (ir, 1), (1, 1), LSTY, 2)            
            self.positions.append(val)
            ir += 1
            
        sizer.Add(wx.StaticLine(panel, size=(195, -1), style=wx.LI_HORIZONTAL),
                  (ir, 0), (1, 3), CEN, 2)

        btn_panel = wx.Panel(panel, size=(75, -1))
        btn_sizer = wx.BoxSizer(wx.HORIZONTAL)
        btn_ok     = add_button(btn_panel, 'OK',     size=(70, -1),
                                action=self.onOK)
        btn_cancel = add_button(btn_panel, 'Cancel', size=(70, -1), action=self.onCancel)

        btn_sizer.Add(btn_ok,     0, wx.ALIGN_LEFT,  2)
        btn_sizer.Add(btn_cancel, 0, wx.ALIGN_RIGHT,  2)
        pack(btn_panel, btn_sizer)

        ir += 1
        sizer.Add(btn_panel,  (ir, 0), (1, 3), CEN, 2)
        ir += 1
       
        sizer.Add(wx.StaticLine(panel, size=(195, -1), style=wx.LI_HORIZONTAL),
                  (ir, 0), (1, 3), CEN, 2)

        pack(panel, sizer)
        panel.SetupScrolling()
        self.Layout()
        self.Show()
        self.Raise()
Esempio n. 51
0
    def __init__(self, parent=None, pos=(-1, -1), db=None):

        self.parent = parent
        self.db = db

        style    = wx.DEFAULT_FRAME_STYLE|wx.TAB_TRAVERSAL
        labstyle  = wx.ALIGN_LEFT|wx.ALIGN_CENTER_VERTICAL|wx.ALL
        rlabstyle = wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL|wx.ALL
        tstyle    = wx.ALIGN_LEFT|wx.ALIGN_CENTER_VERTICAL

        wx.Frame.__init__(self, None, -1,
                          'Epics Instruments:  Settings')

        font = parent.GetFont()

        titlefont  = self.GetFont()
        titlefont.PointSize += 2
        titlefont.SetWeight(wx.BOLD)

        sizer = wx.GridBagSizer(10, 5)
        panel = wx.Panel(self)
        # title row
        self.colors = GUIColors()
        panel.SetBackgroundColour(self.colors.bg)

        title = SimpleText(panel, 'Positions Settings',
                           font=titlefont,
                           minsize=(130, -1),
                           colour=self.colors.title, style=tstyle)

        self.v_move   = wx.CheckBox(panel, -1, 'Verify Move')# , style=wx.ALIGN_RIGHT)
        self.v_erase  = wx.CheckBox(panel, -1, 'Verify Erase ')# style=wx.ALIGN_RIGHT)
        self.v_owrite = wx.CheckBox(panel, -1, 'Verify Overwrie')#, style=wx.ALIGN_RIGHT)

        self.v_move.SetValue(1==int(self.db.get_info('verify_move')))
        self.v_erase.SetValue(1==int(self.db.get_info('verify_erase')))
        self.v_owrite.SetValue(1==int(self.db.get_info('verify_overwrite')))

        sizer.Add(title,        (0, 0), (1, 1), labstyle|wx.ALL, 5)
        sizer.Add(self.v_move,  (1, 0), (1, 1), labstyle,  5)
        sizer.Add(self.v_erase, (2, 0), (1, 1), labstyle,  5)
        sizer.Add(self.v_owrite,(3, 0), (1, 1), labstyle,  5)


        sizer.Add(wx.StaticLine(panel, size=(2, 50), style=wx.LI_VERTICAL),
                  (0, 2), (4, 1), wx.ALIGN_CENTER|wx.GROW|wx.ALL, 3)


        title = SimpleText(panel, ' Epics Database Connection:',
                           font=titlefont,
                           colour=self.colors.title, style=tstyle)

        label = SimpleText(panel, 'DB Prefix:')
        self.epics_prefix = wx.TextCtrl(panel, -1, value='', size=(160, -1))
        self.epics_use    = wx.CheckBox(panel, -1, 'Use Epics Db')


        self.epics_use.SetValue(1==int(self.db.get_info('epics_use', default=0)))
        self.epics_prefix.SetValue(self.db.get_info('epics_prefix', default=''))

        sizer.Add(title,             (0, 3), (1, 2), labstyle|wx.GROW|wx.ALL, 5)
        sizer.Add(label,             (1, 3), (1, 1), labstyle|wx.ALL, 5)
        sizer.Add(self.epics_prefix, (1, 4), (1, 1), labstyle|wx.GROW|wx.ALL, 5)
        sizer.Add(self.epics_use,    (2, 3), (1, 2), labstyle|wx.GROW|wx.ALL, 5)

        irow = 4
        sizer.Add(wx.StaticLine(panel, size=(150, -1), style=wx.LI_HORIZONTAL),
                  (irow, 0), (1, 5), wx.ALIGN_CENTER|wx.GROW|wx.ALL, 3)

        title = SimpleText(panel, 'Show Instruments:',
                           font=titlefont,
                           minsize=(130, -1),
                           colour=self.colors.title, style=tstyle)
        irow += 1
        sizer.Add(title, (irow, 0), (1, 2), labstyle|wx.ALL, 3)
        self.hideframes = {}
        strlen = 24
        for inst in self.db.get_all_instruments():
            strlen = max(strlen, len(inst.name))

        for inst in self.db.get_all_instruments():
            irow += 1
            isshown = inst.name in self.get_page_map()

            iname = (inst.name + ' '*strlen)[:strlen]
            cb = wx.CheckBox(panel, -1, iname)#, style=wx.ALIGN_RIGHT)
            cb.SetValue(isshown)
            self.hideframes[inst.name] = cb
            sizer.Add(cb, (irow, 0), (1, 1), labstyle,  5)

        irow += 1
        sizer.Add(wx.StaticLine(panel, size=(150, -1), style=wx.LI_HORIZONTAL),
                  (irow, 0), (1, 5), wx.ALIGN_CENTER|wx.GROW|wx.ALL, 5)

        btn_ok     = add_button(panel, 'OK',     size=(70, -1), action=self.OnOK)
        btn_cancel = add_button(panel, 'Cancel', size=(70, -1), action=self.OnCancel)

        irow += 1
        sizer.Add(btn_ok,     (irow, 0), (1, 1), labstyle|wx.ALL,  5)
        sizer.Add(btn_cancel, (irow, 1), (1, 1), labstyle|wx.ALL,  5)

        set_font_with_children(self, font)

        pack(panel, sizer)

        mainsizer = wx.BoxSizer(wx.VERTICAL)
        mainsizer.Add(panel, 1, wx.GROW|wx.ALL, 1)


        pack(self, mainsizer)
        self.Show()
        self.Raise()
Esempio n. 52
0
    def __init__(self, parent=None, pos=(-1, -1),
                 inst=None, db=None):

        self.epics_pvs = {}

        title = 'Add New Instrument'
        if inst is not None:
            title = 'Edit Instrument  %s ' % inst.name

        style = wx.DEFAULT_FRAME_STYLE|wx.TAB_TRAVERSAL
        wx.Frame.__init__(self, None, -1, title,
                          style=style, pos=pos)
        self.Handle_FocusEvents()

        panel = scrolled.ScrolledPanel(self, size=(500, 650), style=wx.GROW|wx.TAB_TRAVERSAL, name='p1')

        self.colors = GUIColors()

        font = self.GetFont()
        if parent is not None:
            font = parent.GetFont()

        titlefont  = font
        titlefont.PointSize += 1
        titlefont.SetWeight(wx.BOLD)

        panel.SetBackgroundColour(self.colors.bg)

        self.parent = parent
        self.db = db
        self.inst = db.get_instrument(inst)
        self.connecting_pvs = {}

        STY  = wx.GROW|wx.ALL|wx.ALIGN_CENTER_VERTICAL
        LSTY = wx.ALIGN_LEFT|wx.GROW|wx.ALL|wx.ALIGN_CENTER_VERTICAL
        RSTY = wx.ALIGN_RIGHT|STY
        CSTY = wx.ALIGN_CENTER|STY
        CEN  = wx.ALIGN_CENTER|wx.GROW|wx.ALL
        LEFT = wx.ALIGN_LEFT|wx.GROW|wx.ALL

        self.etimer = wx.Timer(self)
        self.etimer_count = 0
        self.Bind(wx.EVT_TIMER, self.onTimer, self.etimer)

        sizer = wx.GridBagSizer(12, 3)

        # Name row
        label  = SimpleText(panel, 'Instrument Name: ',
                            minsize=(150, -1), style=LSTY)
        self.name =  wx.TextCtrl(panel, value='', size=(260, -1))

        sizer.Add(label,      (0, 0), (1, 1), LSTY, 2)
        sizer.Add(self.name,  (0, 1), (1, 2), LSTY, 2)
        sizer.Add(wx.StaticLine(panel, size=(195, -1), style=wx.LI_HORIZONTAL),
                  (1, 0), (1, 3), CEN, 2)

        irow = 2
        self.curpvs, self.newpvs = [], {}
        if inst is not None:
            self.name.SetValue(inst.name)
            sizer.Add(SimpleText(panel, 'Current PVs:', font=titlefont,
                                 colour=self.colors.title, style=LSTY),
                      (2, 0), (1, 1), LSTY, 2)
            sizer.Add(SimpleText(panel, 'Display Type:',
                                 colour=self.colors.title, style=CSTY),
                      (2, 1), (1, 1), LSTY, 2)
            sizer.Add(SimpleText(panel, 'Remove?:',
                                 colour=self.colors.title, style=CSTY),
                      (2, 2), (1, 1), RSTY, 2)

            opvs  = db.get_ordered_instpvs(inst)

            for instpvs in self.db.get_ordered_instpvs(inst):
                pv = instpvs.pv
                irow += 1
                pvchoices = get_pvtypes(pv, instrument)

                label= SimpleText(panel, pv.name,  minsize=(175, -1),
                                  style=LSTY)

                try:
                    itype = pvchoices.index(pv.pvtype.name)
                except ValueError:
                    itype = 0

                pvtype = PVTypeChoice(panel, choices=pvchoices)
                pvtype.SetSelection(itype)
                pvtype.SetStringSelection(pv.pvtype.name)
                del_pv = YesNo(panel, defaultyes=False)
                self.curpvs.append((pv.name, label, pvtype, del_pv))

                sizer.Add(label,     (irow, 0), (1, 1), LSTY,  3)
                sizer.Add(pvtype,    (irow, 1), (1, 1), CSTY,  3)
                sizer.Add(del_pv,    (irow, 2), (1, 1), RSTY,  3)

            irow += 1
            sizer.Add(wx.StaticLine(panel, size=(150, -1),
                                    style=wx.LI_HORIZONTAL),
                      (irow, 0), (1, 3), CEN, 0)
            irow += 1


        txt =SimpleText(panel, 'New PVs:', font=titlefont,
                        colour=self.colors.title, style=LSTY)

        sizer.Add(txt, (irow, 0), (1, 1), LEFT, 3)
        sizer.Add(SimpleText(panel, 'Display Type',
                             colour=self.colors.title, style=CSTY),
                  (irow, 1), (1, 1), LSTY, 2)
        sizer.Add(SimpleText(panel, 'Remove?',
                             colour=self.colors.title, style=CSTY),
                  (irow, 2), (1, 1), RSTY, 2)
        # New PVs
        for npv in range(5):
            irow += 1
            name = pvNameCtrl(self, panel, value='', size=(175, -1))
            pvtype = PVTypeChoice(panel)
            del_pv = YesNo(panel, defaultyes=False)
            pvtype.Disable()
            del_pv.Disable()
            sizer.Add(name,     (irow, 0), (1, 1), LSTY,  3)
            sizer.Add(pvtype,   (irow, 1), (1, 1), CSTY,  3)
            sizer.Add(del_pv,   (irow, 2), (1, 1), RSTY,  3)

            self.newpvs[name.GetId()] = dict(index=npv, name=name,
                                             type=pvtype, delpv=del_pv)

        btn_panel = wx.Panel(panel, size=(75, -1))
        btn_sizer = wx.BoxSizer(wx.HORIZONTAL)
        btn_ok     = add_button(btn_panel, 'Done',     size=(70, -1),
                                action=self.OnDone)
        btn_cancel = add_button(btn_panel, 'Cancel', size=(70, -1), action=self.onCancel)

        btn_sizer.Add(btn_ok,     0, wx.ALIGN_LEFT,  2)
        btn_sizer.Add(btn_cancel, 0, wx.ALIGN_RIGHT,  2)
        pack(btn_panel, btn_sizer)

        irow += 1
        sizer.Add(wx.StaticLine(panel, size=(150, -1), style=wx.LI_HORIZONTAL),
                  (irow, 0), (1, 3), CEN, 2)
        sizer.Add(btn_panel, (irow+1, 1), (1, 2), CEN, 2)
        sizer.Add(wx.StaticLine(panel, size=(150, -1), style=wx.LI_HORIZONTAL),
                  (irow+2, 0), (1, 3), CEN, 2)

        set_font_with_children(self, font)

        pack(panel, sizer)
        panel.SetupScrolling()

        mainsizer = wx.BoxSizer(wx.VERTICAL)
        mainsizer.Add(panel, 1, LSTY)
        pack(self, mainsizer)

        self.Layout()
        self.Show()
        self.Raise()
Esempio n. 53
0
    def __init__(self,
                 parent,
                 image_panel=None,
                 camera_id=0,
                 center_cb=None,
                 xhair_cb=None,
                 **kws):
        super(ConfPanel_PySpin, self).__init__(parent,
                                               center_cb=center_cb,
                                               xhair_cb=xhair_cb,
                                               **kws)
        self.image_panel = image_panel
        self.camera_id = camera_id
        self.camera = self.image_panel.camera
        wids = self.wids
        sizer = self.sizer
        with_color_conv = False

        self.title = self.txt("PySpinnaker: ", size=285)
        self.title2 = self.txt(" ", size=285)
        self.title3 = self.txt(" ", size=285)
        btn_start = add_button(self,
                               "Restart Camera",
                               action=self.onRestart,
                               size=(250, -1))
        next_row = self.show_position_info(row=0)

        sizer.Add(self.title, (next_row, 0), (1, 3), LEFT)
        sizer.Add(self.title2, (next_row + 1, 0), (1, 3), LEFT)
        sizer.Add(self.title3, (next_row + 2, 0), (1, 3), LEFT)
        self.__initializing = True
        i = next_row + 3

        for dat in (('exposure', 'ms', 50, 0.03, MAX_EXPOSURE_TIME),
                    ('gain', 'dB', 5, 0, 40)):
            # ('gamma', '',       1, 0.5, 4)):

            key, units, defval, minval, maxval = dat
            wids[key] = FloatCtrl(self,
                                  value=defval,
                                  minval=minval,
                                  maxval=maxval,
                                  precision=2,
                                  action=self.onValue,
                                  act_on_losefocus=True,
                                  action_kw={'prop': key},
                                  size=(75, -1))
            label = '%s' % (key.title())
            if len(units) > 0:
                label = '%s (%s)' % (key.title(), units)
            sizer.Add(self.txt(label), (i, 0), (1, 1), LEFT)
            sizer.Add(wids[key], (i, 1), (1, 1), LEFT)

            if key != 'gamma':
                akey = '%s_auto' % key
                wids[akey] = wx.CheckBox(self, -1, label='auto')
                wids[akey].SetValue(0)
                wids[akey].Bind(wx.EVT_CHECKBOX, Closure(self.onAuto,
                                                         prop=key))
                sizer.Add(wids[akey], (i, 2), (1, 1), LEFT)
            i = i + 1

        for color in ('blue', 'red'):
            key = 'wb_%s' % color
            wids[key] = FloatCtrl(self,
                                  value=0,
                                  minval=0.3,
                                  maxval=4,
                                  precision=3,
                                  action=self.onValue,
                                  act_on_losefocus=True,
                                  action_kw={'prop': key},
                                  size=(75, -1))
            wids[key].Disable()
            label = 'White Balance (%s)' % (color)
            sizer.Add(self.txt(label), (i, 0), (1, 1), LEFT)
            sizer.Add(wids[key], (i, 1), (1, 1), LEFT)
            if color == 'blue':
                akey = 'wb_auto'
                wids[akey] = wx.CheckBox(self, -1, label='auto')
                wids[akey].SetValue(0)
                wids[akey].Bind(wx.EVT_CHECKBOX, Closure(self.onAuto,
                                                         prop=key))
                sizer.Add(wids[akey], (i, 2), (1, 1), LEFT)
            i += 1

        datapush_time = "%.1f" % self.image_panel.datapush_delay
        wids['dpush_time'] = FloatCtrl(self,
                                       value=datapush_time,
                                       maxval=1e6,
                                       precision=1,
                                       minval=0,
                                       action=self.onValue,
                                       act_on_losefocus=True,
                                       action_kw={'prop': 'autosave_time'},
                                       size=(75, -1))

        label = 'AutoSave Time (sec)'
        sizer.Add(self.txt(label), (i, 0), (1, 1), LEFT)
        sizer.Add(wids['dpush_time'], (i, 1), (1, 1), LEFT)
        i = i + 1
        sizer.Add(btn_start, (i, 0), (1, 2), LEFT)

        if with_color_conv:
            conv_choices = ('DEFAULT', 'NO_COLOR_PROCESSING',
                            'NEAREST_NEIGHBOR', 'EDGE_SENSING', 'HQ_LINEAR',
                            'RIGOROUS', 'IPP', 'DIRECTIONAL_FILTER',
                            'WEIGHTED_DIRECTIONAL_FILTER')
            wids['color_conv'] = wx.Choice(self,
                                           -1,
                                           choices=conv_choices,
                                           size=(150, -1))
            wids['color_conv'].Bind(wx.EVT_CHOICE, self.onColorConv)
            i += 1
            sizer.Add(self.txt('Conversion: '), (i, 0), (1, 1), LEFT)
            sizer.Add(wids['color_conv'], (i, 1), (1, 1), LEFT)

        # wids['datapush'].SetValue(1)
        # wids['datapush'].Bind(wx.EVT_CHECKBOX, self.onEnableDataPush)
        # sizer.Add(wids['datapush'], (i+1, 0), (1, 3), LEFT)

        pack(self, sizer)
        self.__initializing = False
        self.read_props_timer = wx.Timer(self)
        self.Bind(wx.EVT_TIMER, self.onTimer, self.read_props_timer)
        wx.CallAfter(self.onConnect)
Esempio n. 54
0
    def __init__(self, parent=None, pos=(-1, -1),
                 inst=None, db=None, page=None):

        title = 'New Position'
        if inst is not None:
            title = 'New Position for Instrument  %s ' % inst.name

        style = wx.DEFAULT_FRAME_STYLE|wx.TAB_TRAVERSAL
        wx.Frame.__init__(self, None, -1, title, size=(350, 450), 
                          style=style, pos=pos)
        self.Handle_FocusEvents()

        panel = scrolled.ScrolledPanel(self, size=(400, 500), style=wx.GROW|wx.TAB_TRAVERSAL)
        
        colors = GUIColors()

        font = self.GetFont()
        if parent is not None:
            font = parent.GetFont()

        titlefont  = font
        titlefont.PointSize += 1
        titlefont.SetWeight(wx.BOLD)

        panel.SetBackgroundColour(colors.bg)

        self.parent = parent
        self.page = page
        self.db = db
        self.inst = db.get_instrument(inst)

        STY  = wx.GROW|wx.ALL|wx.ALIGN_CENTER_VERTICAL
        LSTY = wx.ALIGN_LEFT|wx.GROW|wx.ALL|wx.ALIGN_CENTER_VERTICAL
        RSTY = wx.ALIGN_RIGHT|STY
        CSTY = wx.ALIGN_CENTER|STY
        CEN  = wx.ALIGN_CENTER|wx.GROW|wx.ALL
        LEFT = wx.ALIGN_LEFT|wx.GROW|wx.ALL


        self.name =  wx.TextCtrl(panel, value='', size=(200, -1))


        sizer = wx.GridBagSizer(12, 3)

        ir = 0
        sizer.Add(SimpleText(panel, " New Position for '%s'" % self.inst.name,
                             font=titlefont,  colour=colors.title),
                  (ir, 0), (1, 2), LSTY, 2)

        ir += 1        
        sizer.Add(SimpleText(panel, 'Position Name:'),  (ir, 0), (1, 1), LSTY, 2)
        sizer.Add(self.name,                            (ir, 1), (1, 2), LSTY, 2)
        ir += 1
        sizer.Add(SimpleText(panel, 'PV Name:'),        (ir, 0), (1, 1), LSTY, 2)
        sizer.Add(SimpleText(panel, 'Position:'),       (ir, 1), (1, 1), LSTY, 2)

        ir += 1
        sizer.Add(wx.StaticLine(panel, size=(195, -1), style=wx.LI_HORIZONTAL),
                  (ir, 0), (1, 3), CEN, 2)

        self.positions = []
        ir += 1
        for p in self.inst.pvs:
            val =  wx.TextCtrl(panel, value='', size=(150, -1))            
            sizer.Add(SimpleText(panel, p.name), (ir, 0), (1, 1), LSTY, 2)
            sizer.Add(val,                       (ir, 1), (1, 1), LSTY, 2)            
            self.positions.append(val)
            ir += 1
            
        sizer.Add(wx.StaticLine(panel, size=(195, -1), style=wx.LI_HORIZONTAL),
                  (ir, 0), (1, 3), CEN, 2)

        btn_panel = wx.Panel(panel, size=(75, -1))
        btn_sizer = wx.BoxSizer(wx.HORIZONTAL)
        btn_ok     = add_button(btn_panel, 'OK',     size=(70, -1),
                                action=self.onOK)
        btn_cancel = add_button(btn_panel, 'Cancel', size=(70, -1), action=self.onCancel)

        btn_sizer.Add(btn_ok,     0, wx.ALIGN_LEFT,  2)
        btn_sizer.Add(btn_cancel, 0, wx.ALIGN_RIGHT,  2)
        pack(btn_panel, btn_sizer)

        ir += 1
        sizer.Add(btn_panel,  (ir, 0), (1, 3), CEN, 2)
        ir += 1
       
        sizer.Add(wx.StaticLine(panel, size=(195, -1), style=wx.LI_HORIZONTAL),
                  (ir, 0), (1, 3), CEN, 2)

        pack(panel, sizer)
        panel.SetupScrolling()
        self.Layout()
        self.Show()
        self.Raise()
Esempio n. 55
0
    def __init__(self, parent, image_panel=None, prefix=None,
                 center_cb=None, xhair_cb=None, **kws):
        super(ConfPanel_EpicsAD, self).__init__(parent, center_cb=center_cb,
                                                xhair_cb=xhair_cb)

        wids = self.wids
        sizer = self.sizer

        self.SetBackgroundColour('#EEFFE')
        self.title =  wx.StaticText(self, size=(285, 25),
                                    label="Epics AreaDetector")

        for key in ('imagemode', 'triggermode', 'color'):
            self.wids[key]   = PVEnumChoice(self, pv=None, size=(135, -1))

        for key in ('exptime', 'gain'):
            self.wids[key]   = PVFloatCtrl(self, pv=None, size=(135, -1), minval=0)
        self.wids['gain'].SetMax(20)

        for key in ('start', 'stop'):
            self.wids[key] = wx.Button(self, -1, label=key.title(), size=(65, -1))
            self.wids[key].Bind(wx.EVT_BUTTON, Closure(self.onButton, key=key))

        labstyle  = wx.ALIGN_LEFT|wx.EXPAND|wx.ALIGN_BOTTOM
        ctrlstyle = wx.ALIGN_LEFT #  |wx.ALIGN_BOTTOM
        rlabstyle = wx.ALIGN_RIGHT|wx.RIGHT|wx.TOP|wx.EXPAND
        txtstyle  = wx.ALIGN_LEFT|wx.ST_NO_AUTORESIZE|wx.TE_PROCESS_ENTER


        self.wids['fullsize']= wx.StaticText(self, -1,  size=(250,-1), style=txtstyle)

        def txt(label, size=100):
            return wx.StaticText(self, label=label, size=(size, -1), style=labstyle)

        def lin(len=30, wid=2, style=wx.LI_HORIZONTAL):
            return wx.StaticLine(self, size=(len, wid), style=style)

        sizer.Add(self.title,               (0, 0), (1, 3), labstyle)
        i = next_row = self.show_position_info(row=1)
        i += 1
        sizer.Add(self.wids['fullsize'],    (i, 0), (1, 3), labstyle)
        i += 1
        sizer.Add(txt('Acquire '),          (i, 0), (1, 1), labstyle)
        sizer.Add(self.wids['start'],       (i, 1), (1, 1), ctrlstyle)
        sizer.Add(self.wids['stop'],        (i, 2), (1, 1), ctrlstyle)
        i += 1
        sizer.Add(txt('Image Mode '),       (i, 0), (1, 1), labstyle)
        sizer.Add(self.wids['imagemode'],   (i, 1), (1, 2), ctrlstyle)

        i += 1
        sizer.Add(txt('Trigger Mode '),     (i, 0), (1, 1), labstyle)
        sizer.Add(self.wids['triggermode'], (i, 1), (1, 2), ctrlstyle)

        i += 1
        sizer.Add(txt('Exposure Time '),    (i, 0), (1, 1), labstyle)
        sizer.Add(self.wids['exptime'],     (i, 1), (1, 2), ctrlstyle)

        i += 1
        sizer.Add(txt('Gain '),             (i, 0), (1, 1), labstyle)
        sizer.Add(self.wids['gain'],        (i, 1), (1, 2), ctrlstyle)

        i += 1
        sizer.Add(txt('Color Mode'),        (i, 0), (1, 1), labstyle)
        sizer.Add(self.wids['color'],       (i, 1), (1, 2), ctrlstyle)

        #  show last pixel position, move to center
        pack(self, sizer)
        self.set_prefix(prefix)
Esempio n. 56
0
    def create_frame(self, size=(1600, 800), orientation='landscape'):
        "build main frame"
        self.statusbar = self.CreateStatusBar(2, wx.CAPTION)
        self.statusbar.SetStatusWidths([-4, -1])
        for index in range(2):
            self.statusbar.SetStatusText('', index)
        config = self.config

        opts = dict(writer=self.write_framerate,
                    leftdown_cb=self.onSelectPixel,
                    motion_cb=self.onPixelMotion,
                    xhair_cb=self.onShowCrosshair,
                    center_cb=self.onMoveToCenter,
                    autosave_file=self.autosave_file)
        if self.cam_type.startswith('fly2'):
            opts['camera_id'] = int(self.cam_fly2id)
            opts['output_pv'] = config['camera'].get('output_pv', None)
            ImagePanel, ConfPanel = ImagePanel_Fly2, ConfPanel_Fly2
        elif self.cam_type.startswith('area'):
            opts['prefix'] = self.cam_adpref
            ImagePanel, ConfPanel = ImagePanel_EpicsAD, ConfPanel_EpicsAD
        elif self.cam_type.startswith('webcam'):
            opts['url'] = self.cam_weburl
            ImagePanel, ConfPanel = ImagePanel_URL, ConfPanel_URL

        self.imgpanel  = ImagePanel(self, **opts)
        self.imgpanel.SetMinSize((285, 250))

        if orientation.lower().startswith('land'):
            size = (1600, 800)
            self.cpanel = wx.CollapsiblePane(self, label='Show Controls',
                                             style=wx.CP_DEFAULT_STYLE|wx.CP_NO_TLW_RESIZE)

            self.Bind(wx.EVT_COLLAPSIBLEPANE_CHANGED, self.OnPaneChanged, self.cpanel)

            ppanel = wx.Panel(self.cpanel.GetPane())

            self.pospanel  = PositionPanel(ppanel, self, config=config['scandb'])
            self.pospanel.SetMinSize((250, 700))

            self.ctrlpanel = ControlPanel(ppanel,
                                          groups=config['stage_groups'],
                                          config=config['stages'],
                                          autofocus=self.onAutoFocus)

            self.confpanel = ConfPanel(ppanel,
                                       image_panel=self.imgpanel, **opts)

            msizer = wx.GridBagSizer(2, 2)
            msizer.Add(self.ctrlpanel, (0, 0), (1, 1), ALL_EXP|LEFT_TOP, 1)
            msizer.Add(self.confpanel, (1, 0), (1, 1), ALL_EXP|LEFT_TOP, 1)
            msizer.Add(self.pospanel,  (0, 1), (2, 1), ALL_EXP|LEFT_TOP, 2)

            pack(ppanel, msizer)

            sizer = wx.BoxSizer(wx.HORIZONTAL)
            sizer.AddMany([(self.imgpanel,  5, ALL_EXP|LEFT_CEN, 0),
                           (self.cpanel,    1, ALL_EXP|LEFT_CEN|wx.GROW, 1)])

            pack(self, sizer)
            self.cpanel.Collapse(False)
            self.cpanel.SetLabel('Hide Controls')

        else: # portrait mode
            size = (900, 1500)
            ppanel = wx.Panel(self)
            self.pospanel  = PositionPanel(ppanel, self, config=config['scandb'])
            self.pospanel.SetMinSize((250, 450))
            self.ctrlpanel = ControlPanel(ppanel,
                                          groups=config['stage_groups'],
                                          config=config['stages'],
                                          autofocus=self.onAutoFocus)

            self.confpanel = ConfPanel(ppanel,
                                       image_panel=self.imgpanel, **opts)

            msizer = wx.GridBagSizer(3, 3)
            msizer.Add(self.ctrlpanel, (0, 0), (1, 1), ALL_EXP|LEFT_TOP, 1)
            msizer.Add(self.pospanel,  (0, 1), (2, 1), ALL_EXP|LEFT_TOP, 2)
            msizer.Add(self.confpanel, (0, 2), (1, 1), ALL_EXP|LEFT_TOP, 1)

            pack(ppanel, msizer)

            sizer = wx.BoxSizer(wx.VERTICAL)
            sizer.AddMany([(self.imgpanel,  5, ALL_EXP|LEFT_CEN, 0),
                           (ppanel,    1, ALL_EXP|LEFT_CEN|wx.GROW, 1)])

            pack(self, sizer)

        self.imgpanel.confpanel = self.confpanel
        self.SetSize(size)
        if len(self.iconfile) > 0:
            self.SetIcon(wx.Icon(self.iconfile, wx.BITMAP_TYPE_ICO))

        ex  = [{'shape':'circle', 'color': (255, 0, 0),
                'width': 1.5, 'args': (0.5, 0.5, 0.007)},
               {'shape':'line', 'color': (200, 100, 0),
                'width': 2.0, 'args': (0.7, 0.97, 0.97, 0.97)}]

        self.create_menus()
        self.Bind(wx.EVT_CLOSE, self.onClose)
        self.init_timer = wx.Timer(self)
        self.Bind(wx.EVT_TIMER, self.onInitTimer, self.init_timer)
        self.init_timer.Start(1000)
Esempio n. 57
0
    def create_frame(self, size=(1600, 800), orientation='landscape'):
        "build main frame"
        self.statusbar = self.CreateStatusBar(2, wx.CAPTION)
        self.statusbar.SetStatusWidths([-4, -1])
        for index in range(2):
            self.statusbar.SetStatusText('', index)
        config = self.config

        opts = dict(writer=self.write_framerate,
                    leftdown_cb=self.onSelectPixel,
                    motion_cb=self.onPixelMotion,
                    xhair_cb=self.onShowCrosshair,
                    center_cb=self.onMoveToCenter,
                    autosave_file=self.autosave_file)

        autofocus_cb = self.onAutoFocus

        if self.cam_type.startswith('fly2'):
            opts['camera_id'] = int(self.cam_fly2id)
            opts['output_pv'] = config['camera'].get('output_pv', None)
            ImagePanel, ConfPanel = ImagePanel_Fly2, ConfPanel_Fly2
        elif self.cam_type.startswith('adfly'):
            opts['prefix'] = self.cam_adpref
            ImagePanel, ConfPanel = ImagePanel_Fly2AD, ConfPanel_Fly2AD
            autofocus_cb = None
        elif self.cam_type.startswith('area'):
            opts['prefix'] = self.cam_adpref
            ImagePanel, ConfPanel = ImagePanel_EpicsAD, ConfPanel_EpicsAD
        elif self.cam_type.startswith('webcam'):
            opts['url'] = self.cam_weburl
            ImagePanel, ConfPanel = ImagePanel_URL, ConfPanel_URL

        self.imgpanel = ImagePanel(self, **opts)
        self.imgpanel.SetMinSize((285, 250))

        if orientation.lower().startswith('land'):
            size = (1600, 800)
            self.cpanel = wx.CollapsiblePane(self,
                                             label='Show Controls',
                                             style=wx.CP_DEFAULT_STYLE
                                             | wx.CP_NO_TLW_RESIZE)

            self.Bind(wx.EVT_COLLAPSIBLEPANE_CHANGED, self.OnPaneChanged,
                      self.cpanel)

            ppanel = wx.Panel(self.cpanel.GetPane())

            self.pospanel = PositionPanel(ppanel,
                                          self,
                                          config=config['scandb'])
            self.pospanel.SetMinSize((250, 700))

            self.ctrlpanel = ControlPanel(ppanel,
                                          groups=config['stage_groups'],
                                          config=config['stages'],
                                          autofocus=autofocus_cb)

            self.confpanel = ConfPanel(ppanel,
                                       image_panel=self.imgpanel,
                                       **opts)

            msizer = wx.GridBagSizer(2, 2)
            msizer.Add(self.ctrlpanel, (0, 0), (1, 1), ALL_EXP | LEFT_TOP, 1)
            msizer.Add(self.confpanel, (1, 0), (1, 1), ALL_EXP | LEFT_TOP, 1)
            msizer.Add(self.pospanel, (0, 1), (2, 1), ALL_EXP | LEFT_TOP, 2)

            pack(ppanel, msizer)

            sizer = wx.BoxSizer(wx.HORIZONTAL)
            sizer.AddMany([(self.imgpanel, 5, ALL_EXP | LEFT_CEN, 0),
                           (self.cpanel, 1, ALL_EXP | LEFT_CEN | wx.GROW, 1)])

            pack(self, sizer)
            self.cpanel.Collapse(False)
            self.cpanel.SetLabel('Hide Controls')

        else:  # portrait mode
            size = (900, 1500)
            ppanel = wx.Panel(self)
            self.pospanel = PositionPanel(ppanel,
                                          self,
                                          config=config['scandb'])
            self.pospanel.SetMinSize((250, 450))
            self.ctrlpanel = ControlPanel(ppanel,
                                          groups=config['stage_groups'],
                                          config=config['stages'],
                                          autofocus=autofocus_cb)

            self.confpanel = ConfPanel(ppanel,
                                       image_panel=self.imgpanel,
                                       **opts)

            msizer = wx.GridBagSizer(3, 3)
            msizer.Add(self.ctrlpanel, (0, 0), (1, 1), ALL_EXP | LEFT_TOP, 1)
            msizer.Add(self.pospanel, (0, 1), (2, 1), ALL_EXP | LEFT_TOP, 2)
            msizer.Add(self.confpanel, (0, 2), (1, 1), ALL_EXP | LEFT_TOP, 1)

            pack(ppanel, msizer)

            sizer = wx.BoxSizer(wx.VERTICAL)
            sizer.AddMany([(self.imgpanel, 5, ALL_EXP | LEFT_CEN, 0),
                           (ppanel, 1, ALL_EXP | LEFT_CEN | wx.GROW, 1)])

            pack(self, sizer)

        self.imgpanel.confpanel = self.confpanel
        self.SetSize(size)
        if len(self.iconfile) > 0:
            self.SetIcon(wx.Icon(self.iconfile, wx.BITMAP_TYPE_ICO))

        ex = [{
            'shape': 'circle',
            'color': (255, 0, 0),
            'width': 1.5,
            'args': (0.5, 0.5, 0.007)
        }, {
            'shape': 'line',
            'color': (200, 100, 0),
            'width': 2.0,
            'args': (0.7, 0.97, 0.97, 0.97)
        }]

        self.create_menus()
        self.Bind(wx.EVT_CLOSE, self.onClose)
        self.init_timer = wx.Timer(self)
        self.Bind(wx.EVT_TIMER, self.onInitTimer, self.init_timer)
        self.init_timer.Start(1000)
Esempio n. 58
0
    def __init__(self,
                 parent,
                 image_panel=None,
                 camera_id=0,
                 center_cb=None,
                 xhair_cb=None,
                 **kws):
        super(ConfPanel_Fly2, self).__init__(parent,
                                             center_cb=center_cb,
                                             xhair_cb=xhair_cb)
        self.image_panel = image_panel
        self.camera_id = camera_id
        self.camera = self.image_panel.camera

        wids = self.wids
        sizer = self.sizer

        self.title = self.txt("PyCapture2: ", size=285)
        self.title2 = self.txt(" ", size=285)

        sizer.Add(self.title, (0, 0), (1, 3), LEFT)
        sizer.Add(self.title2, (1, 0), (1, 3), LEFT)
        next_row = self.show_position_info(row=2)

        self.__initializing = True
        i = next_row + 1
        #('Sharpness', '%', 100), ('Hue', 'deg', 100), ('Saturation', '%', 100),
        for dat in (
            ('shutter', 'ms', 50, 0, 70),
            ('gain', 'dB', 0, -2, 24),
                # ('brightness', '%', 0,  0,  6),
            ('gamma', '', 1, 0.5, 4)):

            key, units, defval, minval, maxval = dat
            wids[key] = FloatCtrl(self,
                                  value=defval,
                                  minval=minval,
                                  maxval=maxval,
                                  precision=1,
                                  action=self.onValue,
                                  act_on_losefocus=True,
                                  action_kw={'prop': key},
                                  size=(75, -1))
            label = '%s' % (key.title())
            if len(units) > 0:
                label = '%s (%s)' % (key.title(), units)
            sizer.Add(self.txt(label), (i, 0), (1, 1), LEFT)
            sizer.Add(wids[key], (i, 1), (1, 1), LEFT)

            akey = '%s_auto' % key
            wids[akey] = wx.CheckBox(self, -1, label='auto')
            wids[akey].SetValue(0)
            wids[akey].Bind(wx.EVT_CHECKBOX, Closure(self.onAuto, prop=key))
            sizer.Add(wids[akey], (i, 2), (1, 1), LEFT)
            i = i + 1

        for color in ('blue', 'red'):
            key = 'wb_%s' % color
            wids[key] = FloatCtrl(self,
                                  value=0,
                                  maxval=1024,
                                  precision=0,
                                  action=self.onValue,
                                  act_on_losefocus=True,
                                  action_kw={'prop': key},
                                  size=(75, -1))
            label = 'White Balance (%s)' % (color)
            sizer.Add(self.txt(label), (i, 0), (1, 1), LEFT)
            sizer.Add(wids[key], (i, 1), (1, 1), LEFT)

            if color == 'blue':
                akey = 'wb_auto'
                wids[akey] = wx.CheckBox(self, -1, label='auto')
                wids[akey].SetValue(0)
                wids[akey].Bind(wx.EVT_CHECKBOX, Closure(self.onAuto,
                                                         prop=key))
                sizer.Add(wids[akey], (i, 2), (1, 1), LEFT)
            i += 1

        datapush_time = "%.1f" % self.image_panel.datapush_delay
        wids['dpush_time'] = FloatCtrl(self,
                                       value=datapush_time,
                                       maxval=1e6,
                                       precision=1,
                                       minval=0,
                                       action=self.onValue,
                                       act_on_losefocus=True,
                                       action_kw={'prop': 'autosave_time'},
                                       size=(75, -1))

        label = 'AutoSave Time (sec)'
        sizer.Add(self.txt(label), (i, 0), (1, 1), LEFT)
        sizer.Add(wids['dpush_time'], (i, 1), (1, 1), LEFT)

        # wids['datapush'].SetValue(1)
        # wids['datapush'].Bind(wx.EVT_CHECKBOX, self.onEnableDataPush)
        # sizer.Add(wids['datapush'], (i+1, 0), (1, 3), LEFT)

        pack(self, sizer)
        self.__initializing = False
        self.timer = wx.Timer(self)
        self.Bind(wx.EVT_TIMER, self.onTimer, self.timer)
        wx.CallAfter(self.onConnect)
Esempio n. 59
0
    def create_frame(self, size=(1600, 800), orientation='landscape'):
        "build main frame"
        self.statusbar = self.CreateStatusBar(2, wx.CAPTION)
        self.statusbar.SetStatusWidths([-4, -1])
        for index in range(2):
            self.statusbar.SetStatusText('', index)
        config = self.config

        opts = dict(writer=self.write_framerate,
                    publish_jpeg=bool(self.cam_zmqpush),
                    leftdown_cb=self.onSelectPixel,
                    motion_cb=self.onPixelMotion,
                    xhair_cb=self.onShowCrosshair,
                    center_cb=self.onMoveToCenter,
                    autosave_file=self.autosave_file,
                    lamp=self.lamp)

        autofocus_cb = self.onAutoFocus


        if self.cam_type.startswith('fly2'):
            opts['camera_id'] = int(self.cam_fly2id)
            opts['output_pv'] = config['camera'].get('output_pv', None)
            ImagePanel, ConfPanel = ImagePanel_Fly2, ConfPanel_Fly2
        elif self.cam_type.startswith('pyspin'):
            opts['camera_id'] = int(self.cam_id)
            opts['output_pv'] = config['camera'].get('output_pv', None)
            ImagePanel, ConfPanel = ImagePanel_PySpin, ConfPanel_PySpin
        elif self.cam_type.startswith('adfly'):
            opts['prefix'] = self.cam_adpref
            ImagePanel, ConfPanel = ImagePanel_Fly2AD, ConfPanel_Fly2AD
            autofocus_cb = None
        elif self.cam_type.startswith('area'):
            opts['prefix'] = self.cam_adpref
            ImagePanel, ConfPanel = ImagePanel_EpicsAD, ConfPanel_EpicsAD
        elif self.cam_type.startswith('webcam'):
            opts['url'] = self.cam_weburl
            ImagePanel, ConfPanel = ImagePanel_URL, ConfPanel_URL
        elif self.cam_type.startswith('zmq'):
            ImagePanel, ConfPanel = ImagePanel_ZMQ, ConfPanel_ZMQ
            opts['host'] = self.cam_zmqhost
            opts['port'] = self.cam_zmqport

        self.imgpanel  = ImagePanel(self, **opts)
        self.imgpanel.SetMinSize((285, 250))

        if orientation.lower().startswith('land'):
            size = (1600, 800)
            self.cpanel = wx.CollapsiblePane(self, label='Show Controls',
                                             style=wx.CP_DEFAULT_STYLE|wx.CP_NO_TLW_RESIZE)

            self.Bind(wx.EVT_COLLAPSIBLEPANE_CHANGED, self.OnPaneChanged, self.cpanel)

            ppanel = wx.Panel(self.cpanel.GetPane())
            offline_config = config.get('offline', {})
            self.pospanel  = PositionPanel(ppanel, self, config=config['scandb'],
                                           offline_config=offline_config)
            self.pospanel.SetMinSize((275, 600))

            self.ctrlpanel = ControlPanel(ppanel,
                                          groups=config['stage_groups'],
                                          config=config['stages'],
                                          autofocus=autofocus_cb)

            self.confpanel = ConfPanel(ppanel,
                                       image_panel=self.imgpanel, **opts)

            zpanel = wx.Panel(ppanel)
            zlab1 = wx.StaticText(zpanel, label='ZoomBox size (\u03bCm):',
                                  size=(150, -1), style=txtstyle)
            zlab2 = wx.StaticText(zpanel, label='ZoomBox Sharpness:',
                                  size=(150, -1), style=txtstyle)
            zsharp = wx.StaticText(zpanel, label='=',
                                  size=(100, -1), style=txtstyle)
            self.zoomsize = FloatSpin(zpanel, value=150, min_val=5, increment=5,
                                      action=self.onZoomSize,
                                      size=(80, -1), style=txtstyle)
            self.imgpanel.zoompanel = ZoomPanel(zpanel, imgsize=150,
                                                size=(275, 275),
                                                sharpness_label=zsharp,
                                                **opts)
            zsizer = wx.GridBagSizer(2, 2)
            zsizer.Add(zlab1,         (0, 0), (1, 1), ALL_EXP|LEFT_TOP, 1)
            zsizer.Add(self.zoomsize, (0, 1), (1, 1), ALL_EXP|LEFT_TOP, 1)
            zsizer.Add(zlab2,         (1, 0), (1, 1), ALL_EXP|LEFT_TOP, 1)
            zsizer.Add(zsharp,        (1, 1), (1, 1), ALL_EXP|LEFT_TOP, 1)
            zsizer.Add(self.imgpanel.zoompanel, (2, 0), (1, 2), ALL_EXP|LEFT_TOP, 1)
            zpanel.SetSizer(zsizer)
            zsizer.Fit(zpanel)

            msizer = wx.GridBagSizer(2, 2)
            msizer.Add(self.ctrlpanel, (0, 0), (1, 1), ALL_EXP|LEFT_TOP, 1)
            msizer.Add(self.confpanel, (1, 0), (1, 1), ALL_EXP|LEFT_TOP, 1)
            msizer.Add(zpanel,         (2, 0), (1, 1), ALL_EXP|LEFT_TOP, 2)
            msizer.Add(self.pospanel,  (0, 1), (3, 1), ALL_EXP|LEFT_TOP, 2)
            # msizer.Add((20, 20),       (3, 0), (2, 1), ALL_EXP|LEFT_TOP, 2)

            pack(ppanel, msizer)

            sizer = wx.BoxSizer(wx.HORIZONTAL)
            sizer.AddMany([(self.imgpanel,  5, ALL_EXP|LEFT_CEN, 0),
                           (self.cpanel,    1, ALL_EXP|LEFT_CEN|wx.GROW, 1)])

            pack(self, sizer)
            self.cpanel.Collapse(False)
            self.cpanel.SetLabel('Hide Controls')

        else: # portrait mode
            size = (900, 1500)
            ppanel = wx.Panel(self)
            self.pospanel  = PositionPanel(ppanel, self, config=config['scandb'])
            self.pospanel.SetMinSize((250, 450))
            self.ctrlpanel = ControlPanel(ppanel,
                                          groups=config['stage_groups'],
                                          config=config['stages'],
                                          autofocus=autofocus_cb)

            if len(self.cam_lenses) > 1:
                opts['lens_choices'] = self.cam_lenses
                opts['lens_default'] = self.cam_calibmag
            self.confpanel = ConfPanel(ppanel, image_panel=self.imgpanel, **opts)

            msizer = wx.GridBagSizer(3, 3)
            msizer.Add(self.ctrlpanel, (0, 0), (1, 1), ALL_EXP|LEFT_TOP, 1)
            msizer.Add(self.pospanel,  (0, 1), (2, 1), ALL_EXP|LEFT_TOP, 2)
            msizer.Add(self.confpanel, (0, 2), (1, 1), ALL_EXP|LEFT_TOP, 1)

            pack(ppanel, msizer)

            sizer = wx.BoxSizer(wx.VERTICAL)
            sizer.AddMany([(self.imgpanel,  5, ALL_EXP|LEFT_CEN, 0),
                           (ppanel,    1, ALL_EXP|LEFT_CEN|wx.GROW, 1)])

            pack(self, sizer)

        self.imgpanel.confpanel = self.confpanel
        self.SetSize(size)
        if len(self.iconfile) > 0:
            self.SetIcon(wx.Icon(self.iconfile, wx.BITMAP_TYPE_ICO))

        ex  = [{'shape':'circle', 'color': (255, 0, 0),
                'width': 1.5, 'args': (0.5, 0.5, 0.007)},
               {'shape':'line', 'color': (200, 100, 0),
                'width': 2.0, 'args': (0.7, 0.97, 0.97, 0.97)}]

        self.create_menus()
        self.Bind(wx.EVT_CLOSE, self.onClose)
        self.init_timer = wx.Timer(self)
        self.Bind(wx.EVT_TIMER, self.onInitTimer, self.init_timer)
        self.init_timer.Start(1000)