示例#1
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
示例#2
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)
示例#3
0
文件: mpanel.py 项目: pyepics/pyepics
    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)
示例#4
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()
示例#5
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()
示例#6
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()
示例#7
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)
    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)
示例#9
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)
示例#10
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()
示例#11
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
示例#12
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
示例#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
示例#14
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()
示例#15
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
示例#16
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
示例#17
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()
示例#18
0
 def show_position_info(self, row=0):
     img_label = self.txt("Image Size:")
     sel_label = self.txt("Selected Pixel:")
     cen_label = self.txt("Distance to Center(um):")
     ctr_button = add_button(self, "Bring Selected Pixel to Center",
                             action=self.onBringToCenter, size=(240, -1))
     #xhair_button = add_button(self, "Toggle Crosshair at Selected Pixel",
     #                          action=self.onToggleCrosshair, size=(240, -1))
     # xhair_button.Disable()
     sizer = self.sizer
     sizer.Add(img_label,      (row,   0), (1, 1), LEFT)
     sizer.Add(self.img_size,  (row,   1), (1, 2), LEFT)
     sizer.Add(sel_label,      (row+1, 0), (1, 1), LEFT)
     sizer.Add(self.sel_pixel, (row+1, 1), (1, 2), LEFT)
     sizer.Add(cen_label,      (row+2, 0), (1, 1), LEFT)
     sizer.Add(self.cen_dist,  (row+2, 1), (1, 2), LEFT)
     # sizer.Add(xhair_button,   (row+3, 0), (1, 3), wx.ALIGN_LEFT)
     sizer.Add(ctr_button,     (row+3, 0), (1, 3), wx.ALIGN_LEFT)
     return row+3
示例#19
0
 def show_position_info(self, row=0):
     img_label = self.txt("Image Size:")
     sel_label = self.txt("Selected Pixel:")
     cen_label = self.txt("Distance to Center(um):")
     ctr_button = add_button(self,
                             "Bring Selected Pixel to Center",
                             action=self.onBringToCenter,
                             size=(240, -1))
     #xhair_button = add_button(self, "Toggle Crosshair at Selected Pixel",
     #                          action=self.onToggleCrosshair, size=(240, -1))
     # xhair_button.Disable()
     sizer = self.sizer
     sizer.Add(img_label, (row, 0), (1, 1), LEFT)
     sizer.Add(self.img_size, (row, 1), (1, 2), LEFT)
     sizer.Add(sel_label, (row + 1, 0), (1, 1), LEFT)
     sizer.Add(self.sel_pixel, (row + 1, 1), (1, 2), LEFT)
     sizer.Add(cen_label, (row + 2, 0), (1, 1), LEFT)
     sizer.Add(self.cen_dist, (row + 2, 1), (1, 2), LEFT)
     # sizer.Add(xhair_button,   (row+3, 0), (1, 3), wx.ALIGN_LEFT)
     sizer.Add(ctr_button, (row + 3, 0), (1, 3), wx.ALIGN_LEFT)
     return row + 3
示例#20
0
    def show_position_info(self, row=0):
        img_label = self.txt("Image Size:")
        sel_label = self.txt("Selected Pixel:")
        cen_label = self.txt("Distance to Center(um):")
        ctr_button = add_button(self,
                                "Bring Selected Pixel to Center",
                                action=self.onBringToCenter,
                                size=(250, -1))

        sizer = self.sizer
        sizer.Add(img_label, (row, 0), (1, 1), LEFT)
        sizer.Add(self.img_size, (row, 1), (1, 2), LEFT)
        row += 1
        sizer.Add(sel_label, (row, 0), (1, 1), LEFT)
        sizer.Add(self.sel_pixel, (row, 1), (1, 2), LEFT)
        row += 1
        sizer.Add(cen_label, (row, 0), (1, 1), LEFT)
        sizer.Add(self.cen_dist, (row, 1), (1, 2), LEFT)
        row += 1
        sizer.Add(ctr_button, (row, 0), (1, 2), wx.ALIGN_LEFT)
        self.choice_lens = None
        if self.lens_choices is not None and len(self.lens_choices) > 1:
            lenses = ['%ix' % i for i in self.lens_choices]
            ldef = '%ix' % self.lens_default
            default = 1
            if ldef in lenses:
                default = lenses.index(ldef)
            self.choice_lens = Choice(self,
                                      choices=lenses,
                                      default=default,
                                      size=(100, -1))
            row += 1
            _label = self.txt("Current Lens:")
            sizer.Add(_label, (row, 0), (1, 1), wx.ALIGN_LEFT)
            sizer.Add(self.choice_lens, (row, 1), (1, 2), wx.ALIGN_LEFT)

        return row + 1
示例#21
0
    def __init__(self, image_panel=None, config=None, **kws):
        wx.Frame.__init__(self, None, -1, style=wx.DEFAULT_FRAME_STYLE, **kws)
        self.image_panel = image_panel
        img_x, img_y = self.image_panel.full_size
        self.wids = wids = []
        self.config = config

        panel = wx.Panel(self)
        self.SetFont(wx.Font(10, wx.SWISS, wx.NORMAL, wx.BOLD, 0, ""))

        ok_button = add_button(panel,
                               "Apply",
                               action=self.onApply,
                               size=(75, -1))
        done_button = add_button(panel,
                                 "Done",
                                 action=self.onClose,
                                 size=(75, -1))

        try:
            pix_x = float(config['camera']['calib_x'])
            pix_y = float(config['camera']['calib_y'])
        except:
            pix_x = 1.000
            pix_y = 1.000

        olays = config['overlays']
        sbar = [float(x) for x in olays['scalebar'].split()]
        circ = [float(x) for x in olays['circle'].split()]

        ssiz, sx, sy, swid, scolr, scolg, scolb = sbar
        csiz, cx, cy, cwid, ccolr, ccolg, ccolb = circ

        scol = wx.Colour(int(scolr), int(scolg), int(scolb))
        ccol = wx.Colour(int(ccolr), int(ccolg), int(ccolb))

        opts = dict(minval=0, maxval=1, precision=3, size=(60, -1))
        wopts = dict(minval=0, maxval=10, precision=1, size=(60, -1))
        sopts = dict(minval=0, maxval=1000, precision=0, size=(60, -1))
        popts = dict(minval=-1000, maxval=1000, precision=3, size=(60, -1))

        self.pix_x = FloatCtrl(panel, value=pix_x, **popts)
        self.pix_y = FloatCtrl(panel, value=pix_y, **popts)

        self.scalebar_col = csel.ColourSelect(panel,
                                              -1,
                                              "",
                                              scol,
                                              size=(75, 25))
        self.circle_col = csel.ColourSelect(panel, -1, "", ccol, size=(75, 25))

        self.scalebar_size = FloatCtrl(panel, value=ssiz, **sopts)
        self.scalebar_x = FloatCtrl(panel, value=sx, **opts)
        self.scalebar_y = FloatCtrl(panel, value=sy, **opts)
        self.scalebar_wid = FloatCtrl(panel, value=swid, **wopts)

        self.circle_size = FloatCtrl(panel, value=csiz, **sopts)
        self.circle_x = FloatCtrl(panel, value=cx, **opts)
        self.circle_y = FloatCtrl(panel, value=cy, **opts)
        self.circle_wid = FloatCtrl(panel, value=cwid, **wopts)

        sizer = wx.GridBagSizer(10, 7)
        sizer.SetVGap(5)
        sizer.SetHGap(5)

        def txt(label, size=-1):
            return SimpleText(panel, label, size=(size, -1))

        sizer.Add(txt(" Configure Image Overlays: "), (0, 0), (1, 4), CEN, 3)
        sizer.Add(txt(" Pixel Size (um)  X, Y: "), (1, 0), (1, 2), LEFT, 2)
        sizer.Add(self.pix_x, (1, 2), (1, 1), CEN, 1)
        sizer.Add(self.pix_y, (1, 3), (1, 1), CEN, 1)

        sizer.Add(txt(" Object "), (2, 0), (1, 1), LEFT, 2)
        sizer.Add(txt("Color"), (2, 1), (1, 1), LEFT, 2)
        sizer.Add(txt("Size (um)"), (2, 2), (1, 1), LEFT, 2)
        sizer.Add(txt("X (fraction)"), (2, 3), (1, 1), LEFT, 2)
        sizer.Add(txt("Y (fraction)"), (2, 4), (1, 1), LEFT, 2)
        sizer.Add(txt("Line width"), (2, 5), (1, 1), LEFT, 2)

        sizer.Add(txt(" Scalebar "), (3, 0), (1, 1), LEFT, 2)
        sizer.Add(self.scalebar_col, (3, 1), (1, 1), CEN, 1)
        sizer.Add(self.scalebar_size, (3, 2), (1, 1), CEN, 1)
        sizer.Add(self.scalebar_x, (3, 3), (1, 1), CEN, 1)
        sizer.Add(self.scalebar_y, (3, 4), (1, 1), CEN, 1)
        sizer.Add(self.scalebar_wid, (3, 5), (1, 1), CEN, 1)

        sizer.Add(txt(" Target "), (4, 0), (1, 1), LEFT, 2)
        sizer.Add(self.circle_col, (4, 1), (1, 1), CEN, 1)
        sizer.Add(self.circle_size, (4, 2), (1, 1), CEN, 1)
        sizer.Add(self.circle_x, (4, 3), (1, 1), CEN, 1)
        sizer.Add(self.circle_y, (4, 4), (1, 1), CEN, 1)
        sizer.Add(self.circle_wid, (4, 5), (1, 1), CEN, 1)

        sizer.Add(wx.StaticLine(panel, size=(220, 2)), (5, 0), (1, 6),
                  wx.ALL | wx.GROW | wx.ALIGN_CENTER, 1)

        sizer.Add(ok_button, (6, 0), (1, 1),
                  wx.ALL | wx.GROW | wx.ALIGN_CENTER, 1)
        sizer.Add(done_button, (6, 1), (1, 1),
                  wx.ALL | wx.GROW | wx.ALIGN_CENTER, 1)

        panel.SetSizer(sizer)
        sizer.Fit(panel)
        self.SetSize((500, 225))
        self.Bind(wx.EVT_CLOSE, self.onClose)
        self.Show()
        self.Raise()
示例#22
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)
示例#23
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()
示例#24
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()
示例#25
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()
示例#26
0
    def __init__(self,
                 parent,
                 inst,
                 db=None,
                 writer=None,
                 pvlist=None,
                 size=(-1, -1)):
        self.last_draw = 0
        self.inst = inst
        self.pvlist = pvlist
        self.db = db
        self.write_message = writer
        self.pvs = {}
        self.pvdesc = {}
        self.pv_components = OrderedDict()

        wx.Panel.__init__(self, parent, size=size)

        #for p in self.db.get_ordered_instpvs(inst):
        #    self.add_pv(p.pv.name)

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

        splitter = wx.SplitterWindow(self,
                                     -1,
                                     style=wx.SP_3D | wx.SP_BORDER
                                     | wx.SP_LIVE_UPDATE)

        rpanel = wx.Panel(splitter, style=wx.BORDER_SUNKEN, size=(-1, 225))
        self.leftpanel = wx.Panel(splitter,
                                  style=wx.BORDER_SUNKEN,
                                  size=(-1, 325))

        # self.leftsizer = wx.GridBagSizer(12, 4)
        self.leftsizer = wx.BoxSizer(wx.VERTICAL)

        splitter.SetMinimumPaneSize(225)

        toprow = wx.Panel(self.leftpanel)

        self.inst_title = SimpleText(toprow,
                                     ' %s ' % inst.name,
                                     font=titlefont,
                                     colour=colors.title,
                                     minsize=(150, -1),
                                     style=wx.ALIGN_LEFT | wx.ALIGN_BOTTOM)

        self.pos_name = wx.TextCtrl(toprow,
                                    value="",
                                    size=(250, 25),
                                    style=wx.TE_PROCESS_ENTER)
        self.pos_name.Bind(wx.EVT_TEXT_ENTER, self.onSavePosition)

        topsizer = wx.BoxSizer(wx.HORIZONTAL)
        topsizer.Add(self.inst_title, 0,
                     wx.ALIGN_CENTER | wx.ALIGN_CENTER_VERTICAL, 1)
        topsizer.Add(
            SimpleText(toprow,
                       'Save Current Position:',
                       minsize=(180, -1),
                       style=wx.ALIGN_CENTER), 1,
            wx.ALIGN_CENTER_VERTICAL | wx.ALL, 1)

        topsizer.Add(self.pos_name, 0,
                     wx.GROW | wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL, 1)

        pack(toprow, topsizer)
        self.toprow = toprow

        # start a timer to check for when to fill in PV panels
        timer_id = wx.NewId()
        # self.etimer = wx.Timer(self)
        self.etimer2 = wx.Timer(self)
        self.puttimer = wx.Timer(self)
        self.etimer_count = 0
        self.etimer_poll = 25

        # self.Bind(wx.EVT_TIMER, self.OnConnectTimer, self.etimer)
        self.Bind(wx.EVT_TIMER, self.OnEtimer2, self.etimer2)

        self.Bind(wx.EVT_TIMER, self.OnPutTimer, self.puttimer)

        rsizer = wx.BoxSizer(wx.VERTICAL)
        btn_goto = add_button(rpanel,
                              "Go To",
                              size=(70, -1),
                              action=self.OnMove)
        btn_erase = add_button(rpanel,
                               "Erase",
                               size=(70, -1),
                               action=self.onErase)

        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(rpanel, size=(225, -1))
        self.pos_list.SetBackgroundColour(wx.WHITE)
        self.pos_list.Bind(wx.EVT_RIGHT_DOWN, self.onRightClick)
        self.pos_list.Bind(wx.EVT_LISTBOX, self.onPosSelect)
        self.pos_list.Bind(wx.EVT_LEFT_DCLICK, self.OnMove)

        self.pos_list.Clear()
        for pos in inst.positions:
            self.pos_list.Append(pos.name)

        rsizer.Add(brow, 0, wx.ALIGN_LEFT | wx.ALL)
        rsizer.Add(self.pos_list, 1, wx.EXPAND | wx.ALIGN_CENTER, 1)
        pack(rpanel, rsizer)

        splitter.SplitVertically(self.leftpanel, rpanel, -150)

        self.leftpanel.SetMinSize((750, 150))
        rpanel.SetMinSize((150, -1))

        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(splitter, 1, wx.GROW | wx.ALL, 0)
        pack(self, sizer)
        print ' start etimer2 for ', self.inst.name, time.ctime()
        self.etimer2.Start(1)
示例#27
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()
示例#28
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:  Select Instruments to Display')

        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, 'Show Instruments:',
                           font=titlefont,
                           colour=self.colors.title, style=tstyle)
        irow = 0
        sizer.Add(title, (irow, 0), (1, 4), 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()
示例#29
0
    def __init__(self, parent, image_panel=None, camera_id=0, center_cb=None, **kws):
        super(ConfPanel_Fly2, self).__init__(parent, -1, size=(280, 300))
        self.image_panel = image_panel
        self.center_cb = center_cb
        self.camera_id = camera_id
        self.camera = self.image_panel.camera

        def txt(label, size=150):
            return wx.StaticText(self, label=label, size=(size, -1), style=wx.ALIGN_LEFT | wx.EXPAND)

        self.wids = wids = {}
        sizer = wx.GridBagSizer(10, 4)
        sizer.SetVGap(3)
        sizer.SetHGap(5)

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

        sizer.Add(self.title, (0, 0), (1, 3), wx.ALIGN_LEFT | wx.EXPAND)

        self.__initializing = True
        i = 2
        # ('Sharpness', '%', 100), ('Hue', 'deg', 100), ('Saturation', '%', 100),
        for dat in (("shutter", "ms", 70), ("gain", "dB", 24), ("brightness", "%", 6), ("gamma", "", 5)):

            key, units, maxval = dat
            wids[key] = FloatCtrl(
                self,
                value=0,
                maxval=maxval,
                precision=1,
                action=self.onValue,
                act_on_losefocus=True,
                action_kw={"prop": key},
                size=(55, -1),
            )
            label = "%s" % (key.title())
            if len(units) > 0:
                label = "%s (%s)" % (key.title(), units)
            sizer.Add(txt(label), (i, 0), (1, 1), wx.ALIGN_LEFT | wx.EXPAND)
            sizer.Add(wids[key], (i, 1), (1, 1), wx.ALIGN_LEFT | wx.EXPAND)

            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), wx.ALIGN_LEFT | wx.EXPAND)
            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=(55, -1),
            )
            label = "White Balance (%s)" % (color)
            sizer.Add(txt(label), (i, 0), (1, 1), wx.ALIGN_LEFT | wx.EXPAND)
            sizer.Add(wids[key], (i, 1), (1, 1), wx.ALIGN_LEFT | wx.EXPAND)

            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), wx.ALIGN_LEFT | wx.EXPAND)
            i += 1

        #  show last pixel position, move to center
        i += 1
        sizer.Add(txt("Last Pixel Position:", size=285), (i, 0), (1, 3), wx.ALIGN_LEFT | wx.EXPAND)

        i += 1
        self.pixel_coord = wx.StaticText(
            self, label="         \n            ", size=(285, 50), style=wx.ALIGN_LEFT | wx.EXPAND
        )

        sizer.Add(self.pixel_coord, (i, 0), (1, 3), wx.ALIGN_LEFT | wx.EXPAND)

        center_button = add_button(self, "Bring to Center", action=self.onBringToCenter, size=(120, -1))

        i += 1
        sizer.Add(center_button, (i, 0), (1, 2), wx.ALIGN_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)
示例#30
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()
示例#31
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()
示例#32
0
    def __init__(self, parent, image_panel=None, prefix=None, center_cb=None, **kws):
        super(ConfPanel_EpicsAD, self).__init__(parent, -1, size=(280, 300))

        self.wids = {}
        self.prefix = prefix
        if self.prefix.endswith(':'):
            self.prefix = self.prefix[:-1]
        if self.prefix.endswith(':image1'):
            self.prefix = self.prefix[:-7]
        if self.prefix.endswith(':cam1'):
            self.prefix = self.prefix[:-5]

        self.center_cb = center_cb
        self.ad_img = Device(self.prefix + ':image1:',
                             delim='',  attrs=self.img_attrs)
        self.ad_cam = Device(self.prefix + ':cam1:',
                             delim='',  attrs=self.cam_attrs)


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

        for key in ('imagemode', 'triggermode', 'color'):
            self.wids[key]   = PVEnumChoice(self, pv=None, size=(135, -1))
        # for key in ('exptime', 'period', 'numimages', 'gain'):
        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 = wx.GridBagSizer(10, 4)
        sizer.SetVGap(5)
        sizer.SetHGap(5)
        
        sizer.Add(title,                    (0, 0), (1, 3), labstyle)
        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)

        # sizer.Add(txt('# Images '),         (4, 0), (1, 1), labstyle)
        # sizer.Add(self.wids['numimages'],   (4, 1), (1, 2), ctrlstyle)
        # sizer.Add(txt('Period '),           (6, 0), (1, 1), labstyle)
        # sizer.Add(self.wids['period'],      (6, 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
        i += 1
        sizer.Add(txt("Last Pixel Position:", size=285),
                  (i, 0), (1, 3), wx.ALIGN_LEFT|wx.EXPAND)

        i += 1
        self.pixel_coord = wx.StaticText(self, label='         \n            ', 
                                         size=(285, 50), 
                                         style=wx.ALIGN_LEFT|wx.EXPAND)


        sizer.Add(self.pixel_coord, (i, 0), (1, 3), wx.ALIGN_LEFT|wx.EXPAND)
      
        center_button = add_button(self, "Bring to Center", 
                                   action=self.onBringToCenter, size=(120, -1))

        i += 1
        sizer.Add(center_button, (i, 0), (1, 2), wx.ALIGN_LEFT)


        pack(self, sizer)
        wx.CallAfter(self.connect_pvs )
示例#33
0
    def __init__(self, parent, inst, db=None, writer=None,
                 pvlist=None, size=(-1, -1)):
        self.last_draw = 0
        self.inst = inst
        self.pvlist = pvlist
        self.db   = db
        self.write_message = writer
        self.pvs  = {}
        self.pv_components  = OrderedDict()

        wx.Panel.__init__(self, parent, size=size)

        #for p in self.db.get_ordered_instpvs(inst):
        #    self.add_pv(p.pv.name)


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

        splitter = wx.SplitterWindow(self, -1,
                                     style=wx.SP_3D|wx.SP_BORDER|wx.SP_LIVE_UPDATE)

        rpanel = wx.Panel(splitter, style=wx.BORDER_SUNKEN, size=(-1, 225))
        self.leftpanel = wx.Panel(splitter, style=wx.BORDER_SUNKEN, size=(-1,325))

        # self.leftsizer = wx.GridBagSizer(12, 4)
        self.leftsizer = wx.BoxSizer(wx.VERTICAL)

        splitter.SetMinimumPaneSize(225)

        toprow = wx.Panel(self.leftpanel)
        self.inst_title = SimpleText(toprow,  ' %s ' % inst.name,
                                     font=titlefont,
                                     colour=colors.title,
                                     minsize=(150, -1),
                                     style=wx.ALIGN_LEFT|wx.ALIGN_BOTTOM)


        self.pos_name =  wx.TextCtrl(toprow, value="", size=(250, 25),
                                     style= wx.TE_PROCESS_ENTER)
        self.pos_name.Bind(wx.EVT_TEXT_ENTER, self.onSavePosition)

        topsizer = wx.BoxSizer(wx.HORIZONTAL)
        topsizer.Add(self.inst_title, 0, wx.ALIGN_CENTER|wx.ALIGN_CENTER_VERTICAL, 1)
        topsizer.Add(SimpleText(toprow, 'Save Current Position:',
                                minsize=(180, -1),
                                style=wx.ALIGN_CENTER), 1,
                     wx.ALIGN_CENTER_VERTICAL|wx.ALL, 1)

        topsizer.Add(self.pos_name, 0,
                     wx.GROW|wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL, 1)

        pack(toprow, topsizer)
        self.toprow = toprow

        # start a timer to check for when to fill in PV panels
        timer_id = wx.NewId()
        self.conn_timer = wx.Timer(self)
        self.puttimer = wx.Timer(self)
        self.etimer_count = 0
        self.etimer_poll = 25

        # self.Bind(wx.EVT_TIMER, self.OnConnectTimer, self.etimer)
        self.Bind(wx.EVT_TIMER, self.OnConn_Timer, self.conn_timer)

        self.Bind(wx.EVT_TIMER, self.OnPutTimer, self.puttimer)

        rsizer = wx.BoxSizer(wx.VERTICAL)
        btn_goto = add_button(rpanel, "Go To", size=(70, -1),
                              action=self.OnMove)
        btn_show = add_button(rpanel, "Show", size=(70, -1),
                              action=self.OnShowPos)
        btn_erase = add_button(rpanel, "Erase",  size=(70, -1),
                               action=self.onErase)

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

        self.pos_list  = wx.ListBox(rpanel, size=(225, -1))
        self.pos_list.SetBackgroundColour((230, 230, 230))
        self.pos_list.Bind(wx.EVT_RIGHT_DOWN, self.onRightClick)
        self.pos_list.Bind(wx.EVT_LISTBOX, self.onPosSelect)
        self.pos_list.Bind(wx.EVT_LEFT_DCLICK, self.OnMove)

        self.pos_list.Clear()
        for pos in inst.positions:
            self.pos_list.Append(pos.name)

        rsizer.Add(brow,          0, wx.ALIGN_LEFT|wx.ALL)
        rsizer.Add(self.pos_list, 1, wx.EXPAND|wx.ALIGN_CENTER, 1)
        pack(rpanel, rsizer)
        self.pos_list.Disable()

        splitter.SplitVertically(self.leftpanel, rpanel, -150)

        self.leftpanel.SetMinSize((750, 150))
        rpanel.SetMinSize((150, -1))

        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(splitter, 1, wx.GROW|wx.ALL, 0)
        pack(self, sizer)
        self.conn_timer_t0 = time.time()        
        self.conn_timer.Start(1)
示例#34
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()
示例#35
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()
示例#36
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:  Select Instruments to Display')

        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, 'Show Instruments:',
                           font=titlefont,
                           colour=self.colors.title, style=tstyle)
        irow = 0
        sizer.Add(title, (irow, 0), (1, 4), 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()