Exemplo n.º 1
0
	def __init__(self, parent, frame_id):
		wx.Dialog.__init__(self, parent, frame_id, "Jadwal (Schedule)", size=(500,500))
		self.db = dbutil.MySQL('localhost', 'root', 'k4g4t4u', 'lampu')
		panel = wx.Panel(self)
		
		self.list_ctrlone = wx.ListCtrl(panel, -1, style=wx.LC_REPORT|wx.SUNKEN_BORDER)
		self.list_ctrlone.InsertColumn(0, "No", width=30)
		self.list_ctrlone.InsertColumn(1, "Id Jadwal", width=100)
		self.list_ctrlone.InsertColumn(2, "Hari", width=100)
		self.list_ctrlone.InsertColumn(3, "Mulai", width=100)
		self.list_ctrlone.InsertColumn(4, "Selesai", width=100)
		self.list_ctrlone.Show(True)
		self.isilistctrl()
		
		self.Bind(wx.EVT_LIST_ITEM_SELECTED, self._is_selected, self.list_ctrlone)
		hari = ['Minggu','Senin','Selasa','Rabu','Kamis','Jumat','Sabtu']
		
		self.frmLbl = wx.StaticText(panel, -1, "Jadwal (Schedule)")
		self.frmLbl.SetFont(wx.Font(18, wx.SWISS, wx.NORMAL, wx.BOLD))
		
		self.lbIdJadwal= wx.StaticText(panel, -1, "Id_Jadwal ")
		self.inIdJadwal = wx.TextCtrl(panel, -1, size=(90, 25),validator = ValidasiInput("angka_saja"))
		self.lbNmJadwal = wx.StaticText(panel, -1, "Hari ")
		self.inNmJadwal = wx.ComboBox(panel, -1, "", size=(150, 25),choices=hari, style=wx.CB_READONLY)
		
		self.lbMulai = wx.StaticText(panel, -1, "Mulai ")
		self.spin1 = wx.SpinButton( panel, -1)
		self.inMulai = masked.TimeCtrl(panel, -1, name="24 hour control", fmt24hr=True,	spinButton = self.spin1)
		
		self.lbSelesai = wx.StaticText(panel, -1, "Selesai ")
		self.spin2 = wx.SpinButton(panel, -1)
		self.inSelesai = masked.TimeCtrl(panel, -1, name="24 hour control", fmt24hr=True,spinButton = self.spin2)
		
		self.inIdJadwal.SetInsertionPoint(0)
		self.AutoIncrementIdJadwal()
		#---button
		self.BtnSave = wx.Button(panel, -1, "Simpan")        
		self.Bind(wx.EVT_BUTTON, self.save, self.BtnSave)
		self.BtnClear = wx.Button(panel, -1, "Bersih")        
		self.Bind(wx.EVT_BUTTON, self.clear, self.BtnClear)
		
		#mengumpulkan semua textctrl
		self._all_textCtrl = [self.inIdJadwal, self.inNmJadwal, self.inMulai, self.inSelesai]
		
		self.MainLayer = wx.BoxSizer(wx.VERTICAL)
		self.entrySizer = wx.BoxSizer(wx.VERTICAL)
		self.stextSz = wx.FlexGridSizer(cols = 2, hgap = 5, vgap = 5)
		self.stextSz.AddGrowableCol(1)
		self.btnSizer= wx.BoxSizer(wx.HORIZONTAL)
		self.mulai= wx.BoxSizer(wx.HORIZONTAL)
		self.selesai= wx.BoxSizer(wx.HORIZONTAL)
		
		self.MainLayer.Fit(self)
		self.MainLayer.SetSizeHints(self)
		panel.SetSizer(self.MainLayer)
		
		self.aturSizer(panel)
Exemplo n.º 2
0
def add_timectrl(parent, **kwargs):
    kwargs['min'] = kwargs.pop('min_value', None)
    kwargs['max'] = kwargs.pop('max_value', None)
    kwargs['spinButton'] = kwargs.pop('spin_btn', None)
    kwargs['fmt24hr'] = kwargs.pop('format_24', True)
    wgt = masked.TimeCtrl(parent, **kwargs)
    return wgt
Exemplo n.º 3
0
    def OnScheduleSetup(self, evt):
        if True:
            self.scheduleDlg = wx.Dialog(self, -1, "Schedule Setup", 
                               style=wx.DEFAULT_DIALOG_STYLE|wx.SAVE, size=(400, 180))
            textDate = wx.StaticText(self.scheduleDlg, -1, "Date:", size=(30,-1))
            self.dpc = wx.GenericDatePickerCtrl(self.scheduleDlg, #size=(120,-1),
                                           style = wx.TAB_TRAVERSAL
                                           | wx.DP_DROPDOWN
                                           | wx.DP_SHOWCENTURY
                                           | wx.DP_ALLOWNONE )

            btn_selectSaved = wx.Button(self.scheduleDlg, -1, "Browse...")
            self.scheduleDlg.Bind(wx.EVT_BUTTON, self.OnSelectSaved, btn_selectSaved)
            st = wx.StaticText(self.scheduleDlg, -1, "Choose:")
            self.tc_saved = wx.TextCtrl(self.scheduleDlg, -1, "", size=(200, -1))
            
            textTime = wx.StaticText(self.scheduleDlg, -1, "Time:", size=(30,-1))
            spin2 = wx.SpinButton(self.scheduleDlg, -1, wx.DefaultPosition, (-1, 25), wx.SP_VERTICAL)
            self.time24 = masked.TimeCtrl(
                            self.scheduleDlg, -1, name="24 hour control", fmt24hr=True,
                            spinButton = spin2
                            )
            sizer = rcs.RowColSizer()

            box0 = wx.BoxSizer(wx.HORIZONTAL)
            box0.Add(st, 0, wx.ALIGN_CENTRE|wx.ALL, 5)
            box0.Add(self.tc_saved, 0, wx.ALIGN_CENTRE|wx.ALL, 5)
            box0.Add(btn_selectSaved, 0, wx.ALIGN_CENTRE|wx.ALL, 5)
            sizer.Add(box0, row=1, col=1, colspan=8)
            
            box1 = wx.BoxSizer(wx.HORIZONTAL)
            box1.Add(textDate, 0, wx.ALIGN_CENTRE|wx.ALL, 5)
            box1.Add(self.dpc, 0, wx.ALIGN_CENTRE|wx.ALL, 5)
            sizer.Add(box1, row=2, col=1, colspan=2)
            
            box2 = wx.BoxSizer(wx.HORIZONTAL)
            box2.Add(textTime, 0, wx.ALIGN_CENTRE|wx.ALL, 5)
            box2.Add(self.time24, 0, wx.ALIGN_CENTRE|wx.ALL, 5)
            box2.Add(spin2, 0, wx.ALIGN_CENTRE|wx.ALL, 5)
            sizer.Add(box2, row=2, col=4, colspan=2)
            
            btnsizer = wx.StdDialogButtonSizer()
            
            if wx.Platform != "__WXMSW__":
                btn = wx.ContextHelpButton(self)
                btnsizer.AddButton(btn)
            
            btnSave = wx.Button(self.scheduleDlg, wx.ID_SAVE)
            btnSave.SetDefault()
            self.scheduleDlg.Bind(wx.EVT_BUTTON, self.OnScheduleSave, btnSave)
            btnsizer.AddButton(btnSave)
            
            btnCancel = wx.Button(self.scheduleDlg, wx.ID_CANCEL)
            btnsizer.AddButton(btnCancel)
            btnsizer.Realize()
            sizer.Add(btnsizer, row=4, col=1, colspan=5)
            self.scheduleDlg.SetSizer(sizer)
            
            scheduleDlgCode = self.scheduleDlg.ShowModal()
            self.scheduleDlg.Destroy()
Exemplo n.º 4
0
    def __init__(self, parent, mode, data, *_args, **_kwargs):
        MyPopupctl.MyPopupControl.__init__(self, *_args, **_kwargs)
        self.win = wx.Window(self, -1, pos=(0, 0), style = 0)
        self.parent = parent
        self.mode = mode
        self.pop_obj = None
        self.selected_items = list()
        if mode == 1:
            self.pop_obj = CalendarCtrl(self.win, -1, pos=(0, 0))
            self.pop_obj.Bind(wx.adv.EVT_CALENDAR, self.on_calendar)
        elif mode == 2:
            if data is not None:
                self.pop_obj = wx.CheckListBox(self.win, -1, (0, 0), wx.DefaultSize, data)
                self.pop_obj.Bind(wx.EVT_CHECKLISTBOX, self.on_checklist_selected)
                self.parent.Bind(wx.EVT_LEFT_UP, self.on_checklist)
        elif mode == 3:
            if data is not None:
                spin = wx.SpinButton(self.win, -1, wx.DefaultPosition, (-1, 20), wx.SP_VERTICAL)
                self.pop_obj = masked.TimeCtrl(
                    self.win,
                    -1,
                    name="time_picker",
                    fmt24hr=True,
                    display_seconds=True,
                    spinButton = spin
                )
                self.pop_obj.SetValue('00:00:00')

        if self.pop_obj is not None:
            bz = self.pop_obj.GetBestSize()
            self.win.SetSize(bz)
            self.SetPopupContent(self.win)
Exemplo n.º 5
0
	def __init__(self,parent, master=None,modelName=None,tellme=None,obj=None,
		nodes=32,usenode='test',doExtract=1,cancelbtn=0, *args, **kwds):
		self.makeMe(master,modelName,tellme,obj,nodes,usenode,doExtract,cancelbtn)
		# begin wxGlade: pwxSubmitJob.__init__
		kwds["style"] = wx.DEFAULT_FRAME_STYLE
		wx.Frame.__init__(self, parent,*args, **kwds)
		self.sizer_7_staticbox = wx.StaticBox(self, -1, "Nodes to use")
		self.sizer_9_staticbox = wx.StaticBox(self, -1, "Use PLC System")
		self.sizer_8_staticbox = wx.StaticBox(self, -1, "Delayed")
		self.sizer_6_staticbox = wx.StaticBox(self, -1, "Script Options")
		self.sizer_3_staticbox = wx.StaticBox(self, -1, "Inputs")
		self.button_1 = wx.Button(self, -1, "Open")
		self.text_ctrl_pathname = wx.TextCtrl(self, -1, "")
		self.spin_ctrl_nodecount = wx.SpinCtrl(self, -1, value=str(self.numNodes), min=0, max=256)
		self.combo_box_plc = wx.ComboBox(self, -1, choices=self.plccAllowed, style=wx.CB_DROPDOWN|wx.CB_SORT)
		self.radio_box_extract = wx.RadioBox(self, -1, "Extract", choices=["None", "EXT400", "EXT300*", "64 Bit"], majorDimension=0, style=wx.RA_SPECIFY_ROWS)
		self.radio_box_use_node = wx.RadioBox(self, -1, "System", choices=["PROD", "TEST"], majorDimension=0, style=wx.RA_SPECIFY_ROWS)
		self.checkbox_deferred = wx.CheckBox(self, -1, "Deferred")
		self.spin_ctrl_dayofyear = wx.DatePickerCtrl(self, -1)
		#self.spin_ctrl_hour = wx.SpinCtrl(self, -1, "", min=0, max=100)
		self.spin_ctrl_hour = masked.TimeCtrl(self, -1,fmt24hr=True)
		self.text_ctrl_jclcommand = wx.TextCtrl(self, -1, "", style=wx.TE_MULTILINE|wx.HSCROLL)
		self.button_submit = wx.Button(self, -1, "Submit Job")
		self.button_save = wx.Button(self, -1, "Save parameters")
		self.button_read = wx.Button(self, -1, "Start Monitor")
		self.button_quit = wx.Button(self, -1, "Quit")

		self.__set_properties()
		self.__do_layout()
		self.bindCommands() 
Exemplo n.º 6
0
    def __init__(self, parent, name='datetimectrl', use_now=False):
        self.name = name
        panel = self.panel = wx.Panel(parent)
        bgcol = wx.Colour(250, 250, 250)

        datestyle = wx.DP_DROPDOWN | wx.DP_SHOWCENTURY | wx.DP_ALLOWNONE

        self.datectrl = wx.DatePickerCtrl(panel,
                                          size=(120, -1),
                                          style=datestyle)
        self.timectrl = masked.TimeCtrl(panel,
                                        -1,
                                        name=name,
                                        limited=False,
                                        fmt24hr=True,
                                        oob_color=bgcol)
        timerheight = self.timectrl.GetSize().height
        spinner = wx.SpinButton(panel, -1, wx.DefaultPosition,
                                (-1, timerheight), wx.SP_VERTICAL)
        self.timectrl.BindSpinButton(spinner)
        sizer = wx.BoxSizer(wx.HORIZONTAL)
        sizer.Add(self.datectrl, 0, wx.ALIGN_CENTER)
        sizer.Add(self.timectrl, 0, wx.ALIGN_CENTER)
        sizer.Add(spinner, 0, wx.ALIGN_LEFT)
        panel.SetSizer(sizer)
        sizer.Fit(panel)
        if use_now:
            self.timectrl.SetValue(wx.DateTime_Now())
Exemplo n.º 7
0
 def init(self, parent):
     """
     Finishes initializing the editor by creating the underlying toolkit
     widget.
     """
     tctl = masked.TimeCtrl(parent, -1, name="12 hour control")
     self.control = tctl
     self.control.Bind(masked.EVT_TIMEUPDATE, self.time_updated)
     return
Exemplo n.º 8
0
 def Create(self, parent, id=wx.ID_ANY, evtHandler=None):
     self._tc = masked.TimeCtrl(parent,
                                id,
                                style=wx.TE_CENTRE,
                                fmt24hr=True,
                                displaySeconds=True,
                                value=self.defaultValue)
     self.SetControl(self._tc)
     if evtHandler:
         self._tc.PushEventHandler(evtHandler)
Exemplo n.º 9
0
    def test_timectrlProperties(self):
        t = m.TimeCtrl(self.frame)

        t.DefaultStyle
        t.NumberOfLines
        t.Hint
        t.InsertionPoint
        t.LastPosition
        t.Margins
        t.StringSelection
        t.Value
Exemplo n.º 10
0
    def SetupHeadSection(self):
        # Sizer with combo boxes to define new action
        comboSizer = wx.BoxSizer()
        cmdChoices = []
        for c in CMD:
            cmdChoices.append(tr(c))
        self.cmdCombo = wx.ComboBox(self, -1, choices=cmdChoices, size=(134,26))
        self.cmdCombo.SetName('cmd')
        typeChoices = []
        for t in TYPE:
            typeChoices.append(tr(t))
        self.typeCombo = wx.ComboBox(self, -1, choices=typeChoices, size=(174,26))
        self.typeCombo.SetName('type')
        self.times = []
        for i in range(256):
            self.times.append(str(i))
        self.timeCombo = wx.ComboBox(self, -1, choices=self.times, size=(77,26))

        self.timeSpin = wx.SpinButton(self,-1,style=wx.SP_VERTICAL)
        self.triggerTime = masked.TimeCtrl(self,-1,format='24HHMM')
        self.triggerTime.BindSpinButton(self.timeSpin)

        self.addBtn = wx.Button(self,-1,label="+", size=(25,25))

        self.Bind(wx.EVT_COMBOBOX, self.ComboSelection, self.cmdCombo)
        self.Bind(wx.EVT_COMBOBOX, self.ComboSelection, self.typeCombo)
        self.Bind(wx.EVT_COMBOBOX, self.ComboSelection, self.timeCombo)
        self.Bind(wx.EVT_BUTTON, self.AddAction, self.addBtn)

        comboSizer.Add(self.cmdCombo, flag = wx.LEFT, border = 10)
        comboSizer.Add(self.typeCombo)
        comboSizer.Add(self.timeCombo)
        comboSizer.Add(self.triggerTime)
        comboSizer.Add(self.timeSpin,flag=wx.RIGHT,border=3)
        comboSizer.Add(self.addBtn, flag = wx.RIGHT | wx.ALIGN_CENTER_VERTICAL, border = 10)
        self.addBtn.Disable()
        self.ResetCombos()

        # Sizer with labels for the combo boxes
        labelSizer = wx.BoxSizer()

        cmdLabel = wx.StaticText(self,-1,label="Command:",size=(self.cmdCombo.GetSize()[0],17))
        triggerLabel = wx.StaticText(self,-1,label="Trigger:",size=(self.typeCombo.GetSize()[0],17))
        self.timeLabel = wx.StaticText(self,-1,label="Delay:",size=(self.timeCombo.GetSize()[0],17))
        specTimeLabel = wx.StaticText(self,-1,label="Time:")

        labelSizer.Add(cmdLabel, flag = wx.LEFT| wx.TOP, border = 6)
        labelSizer.Add(triggerLabel, flag = wx.TOP, border = 6)
        labelSizer.Add(self.timeLabel, flag = wx.TOP, border = 6)
        labelSizer.Add(specTimeLabel, flag = wx.TOP, border = 6)

        self.headSizer.Add(labelSizer)
        self.headSizer.Add(comboSizer)
Exemplo n.º 11
0
    def test_timectrlIsValid(self):
        t = m.TimeCtrl(self.frame, -1, "18:25:18")

        theTime = t.GetValue(as_wxDateTime=True)
        self.assertEqual(theTime.hour, 18,
                         "Hour: %s instead of '18'" % theTime.hour)
        self.assertEqual(theTime.minute, 25,
                         "Minutes: %s instead of '18'" % theTime.minute)
        self.assertEqual(theTime.second, 18,
                         "Seconds: %s instead of '18'" % theTime.second)

        self.assertEqual(t.IsInBounds(), True)
        self.assertEqual(t.GetCtrlParameter('validBackgroundColour'),
                         t.GetBackgroundColour())
Exemplo n.º 12
0
    def __init__(self, *args, **kwds):
        label = kwds.pop('label', '')
        self.onChangeClient = kwds.pop('on_change', self.onChangeClientDefault)
        super(ASDateHour, self).__init__(*args, **kwds)

        self.txt = wx.StaticText(self, wx.ID_ANY, label) if label else None
        self.ctl_date = ADV.DatePickerCtrl(self,
                                           wx.ID_ANY,
                                           style=ADV.DP_DROPDOWN)
        self.ctl_time = MSK.TimeCtrl(self, wx.ID_ANY, format='24HHMM')

        self.__set_properties()
        self.__do_layout()

        self.Bind(ADV.EVT_DATE_CHANGED, self.onChange, self.ctl_date)
        self.Bind(MSK.EVT_TIMEUPDATE, self.onChange, self.ctl_time)
Exemplo n.º 13
0
    def __init__(self,
                 parent,
                 value,
                 message='',
                 externinfo=None,
                 size=(-1, -1),
                 enabledflag=None):
        """create an Time input control

        @type value: string
        @para m value: initial value (hh:mm:ss)
        @type externinfo: None
        @param externinfo: not used
        @type size: tuple
        @param size: control's size
        """
        IElement.__init__(self, parent, 'time', message, externinfo, size,
                          enabledflag)

        import wx.lib.masked as masked

        obj = masked.TimeCtrl(parent, -1, name="timectrl", fmt24hr=True)
        h = obj.GetSize().height
        spin2 = wx.SpinButton(parent,
                              -1,
                              wx.DefaultPosition,
                              size=(-1, h),
                              style=wx.SP_VERTICAL)
        obj.BindSpinButton(spin2)
        self.box = wx.BoxSizer(wx.HORIZONTAL)
        self.box.Add(obj, 0, wx.ALIGN_CENTRE)
        self.box.Add(spin2, 0, wx.ALIGN_CENTRE)

        self.obj = obj

        self.setValue(value)
Exemplo n.º 14
0
    def __init__(self,
                 parent,
                 id=wx.ID_ANY,
                 pos=wx.DefaultPosition,
                 size=wx.Size(933, 372),
                 style=wx.TAB_TRAVERSAL,
                 name=wx.EmptyString):
        wx.Panel.__init__(self,
                          parent,
                          id=id,
                          pos=pos,
                          size=size,
                          style=style,
                          name=name)

        bSizer1 = wx.BoxSizer(wx.VERTICAL)

        bSizer2 = wx.BoxSizer(wx.HORIZONTAL)

        bSizer3 = wx.BoxSizer(wx.VERTICAL)

        self.log_filePicker = wx.FilePickerCtrl(
            self, wx.ID_ANY, wx.EmptyString,
            _(u"Выберите файл журнала сообщений"), _(u"*.log"),
            wx.DefaultPosition, wx.DefaultSize, wx.FLP_DEFAULT_STYLE)
        bSizer3.Add(self.log_filePicker, 0, wx.ALL | wx.EXPAND, 5)

        dtSizer = wx.BoxSizer(wx.HORIZONTAL)

        self.start_checkBox = wx.CheckBox(self, wx.ID_ANY, _(u"On"),
                                          wx.DefaultPosition, wx.DefaultSize,
                                          0)
        dtSizer.Add(self.start_checkBox, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL,
                    5)

        self.start_datePicker = wx.adv.DatePickerCtrl(self, wx.ID_ANY,
                                                      wx.DefaultDateTime,
                                                      wx.DefaultPosition,
                                                      wx.DefaultSize,
                                                      wx.adv.DP_DEFAULT)
        self.start_datePicker.Enable(False)

        dtSizer.Add(self.start_datePicker, 1, wx.ALL | wx.EXPAND, 5)

        self.start_timeControl = masked.TimeCtrl(self, -1, fmt24hr=True)
        self.start_timeControl.Enable(False)

        dtSizer.Add(self.start_timeControl, 1, wx.ALL | wx.EXPAND, 5)

        self.start_spinBtn = wx.SpinButton(self, wx.ID_ANY, wx.DefaultPosition,
                                           wx.DefaultSize, 0)
        self.start_spinBtn.Enable(False)

        dtSizer.Add(self.start_spinBtn, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL,
                    0)

        self.m_staticText1 = wx.StaticText(self, wx.ID_ANY, _(u"-"),
                                           wx.DefaultPosition, wx.DefaultSize,
                                           0)
        self.m_staticText1.Wrap(-1)

        dtSizer.Add(self.m_staticText1, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL,
                    5)

        self.stop_checkBox = wx.CheckBox(self, wx.ID_ANY, _(u"On"),
                                         wx.DefaultPosition, wx.DefaultSize, 0)
        dtSizer.Add(self.stop_checkBox, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL,
                    5)

        self.stop_datePicker = wx.adv.DatePickerCtrl(self, wx.ID_ANY,
                                                     wx.DefaultDateTime,
                                                     wx.DefaultPosition,
                                                     wx.DefaultSize,
                                                     wx.adv.DP_DEFAULT)
        self.stop_datePicker.Enable(False)

        dtSizer.Add(self.stop_datePicker, 1, wx.ALL | wx.EXPAND, 5)

        self.stop_timeControl = masked.TimeCtrl(self, -1, fmt24hr=True)
        self.stop_timeControl.Enable(False)

        dtSizer.Add(self.stop_timeControl, 1, wx.ALL | wx.EXPAND, 5)

        self.stop_spinBtn = wx.SpinButton(self, wx.ID_ANY, wx.DefaultPosition,
                                          wx.DefaultSize, 0)
        self.stop_spinBtn.Enable(False)

        dtSizer.Add(self.stop_spinBtn, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 0)

        bSizer3.Add(dtSizer, 0, wx.EXPAND, 5)

        bSizer5 = wx.BoxSizer(wx.HORIZONTAL)

        self.info_checkBox = wx.CheckBox(self, wx.ID_ANY, _(u"Information"),
                                         wx.DefaultPosition, wx.DefaultSize, 0)
        self.info_checkBox.SetFont(
            wx.Font(wx.NORMAL_FONT.GetPointSize(), wx.FONTFAMILY_DEFAULT,
                    wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD, False,
                    wx.EmptyString))
        self.info_checkBox.SetForegroundColour(wx.Colour(9, 79, 9))

        bSizer5.Add(self.info_checkBox, 0, wx.ALL, 5)

        self.warning_checkBox = wx.CheckBox(self, wx.ID_ANY, _(u"Warning"),
                                            wx.DefaultPosition, wx.DefaultSize,
                                            0)
        self.warning_checkBox.SetFont(
            wx.Font(wx.NORMAL_FONT.GetPointSize(), wx.FONTFAMILY_DEFAULT,
                    wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD, False,
                    wx.EmptyString))
        self.warning_checkBox.SetForegroundColour(wx.Colour(120, 120, 9))

        bSizer5.Add(self.warning_checkBox, 0, wx.ALL, 5)

        self.error_checkBox = wx.CheckBox(self, wx.ID_ANY, _(u"Error"),
                                          wx.DefaultPosition, wx.DefaultSize,
                                          0)
        self.error_checkBox.SetFont(
            wx.Font(wx.NORMAL_FONT.GetPointSize(), wx.FONTFAMILY_DEFAULT,
                    wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD, False,
                    wx.EmptyString))
        self.error_checkBox.SetForegroundColour(wx.Colour(79, 9, 9))

        bSizer5.Add(self.error_checkBox, 0, wx.ALL, 5)

        self.fatal_checkBox = wx.CheckBox(self, wx.ID_ANY,
                                          _(u"Critical error"),
                                          wx.DefaultPosition, wx.DefaultSize,
                                          0)
        self.fatal_checkBox.SetFont(
            wx.Font(wx.NORMAL_FONT.GetPointSize(), wx.FONTFAMILY_DEFAULT,
                    wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD, False,
                    wx.EmptyString))
        self.fatal_checkBox.SetForegroundColour(wx.Colour(120, 9, 9))

        bSizer5.Add(self.fatal_checkBox, 0, wx.ALL, 5)

        self.debug_checkBox = wx.CheckBox(self, wx.ID_ANY, _(u"Debug"),
                                          wx.DefaultPosition, wx.DefaultSize,
                                          0)
        self.debug_checkBox.SetFont(
            wx.Font(wx.NORMAL_FONT.GetPointSize(), wx.FONTFAMILY_DEFAULT,
                    wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD, False,
                    wx.EmptyString))
        self.debug_checkBox.SetForegroundColour(wx.Colour(9, 9, 79))

        bSizer5.Add(self.debug_checkBox, 0, wx.ALL, 5)

        self.service_checkBox = wx.CheckBox(self, wx.ID_ANY,
                                            _(u"Service messages"),
                                            wx.DefaultPosition, wx.DefaultSize,
                                            0)
        self.service_checkBox.SetFont(
            wx.Font(wx.NORMAL_FONT.GetPointSize(), wx.FONTFAMILY_DEFAULT,
                    wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD, False,
                    wx.EmptyString))
        self.service_checkBox.SetForegroundColour(wx.Colour(9, 79, 79))

        bSizer5.Add(self.service_checkBox, 0, wx.ALL, 5)

        bSizer3.Add(bSizer5, 1, wx.EXPAND, 5)

        bSizer8 = wx.BoxSizer(wx.HORIZONTAL)

        filter_checkListChoices = []
        self.filter_checkList = wx.CheckListBox(self, wx.ID_ANY,
                                                wx.DefaultPosition,
                                                wx.DefaultSize,
                                                filter_checkListChoices, 0)
        bSizer8.Add(self.filter_checkList, 1, wx.ALL | wx.EXPAND, 5)

        logic_radioBoxChoices = [_(u"AND"), _(u"OR")]
        self.logic_radioBox = wx.RadioBox(self, wx.ID_ANY,
                                          _(u"Selection logic"),
                                          wx.DefaultPosition, wx.DefaultSize,
                                          logic_radioBoxChoices, 1,
                                          wx.RA_SPECIFY_COLS)
        self.logic_radioBox.SetSelection(0)
        bSizer8.Add(self.logic_radioBox, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL,
                    5)

        bSizer3.Add(bSizer8, 0, wx.EXPAND, 5)

        bSizer2.Add(bSizer3, 1, wx.EXPAND, 5)

        self.refresh_bpButton = wx.BitmapButton(self, wx.ID_ANY, wx.NullBitmap,
                                                wx.DefaultPosition,
                                                wx.DefaultSize,
                                                wx.BU_AUTODRAW | 0)

        self.refresh_bpButton.SetDefault()
        self.refresh_bpButton.SetBitmap(
            wx.ArtProvider.GetBitmap(u"gtk-refresh", wx.ART_CMN_DIALOG))
        bSizer2.Add(self.refresh_bpButton, 0,
                    wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5)

        bSizer1.Add(bSizer2, 0, wx.EXPAND, 5)

        self.msg_listCtrl = wx.ListCtrl(self, wx.ID_ANY, wx.DefaultPosition,
                                        wx.DefaultSize, wx.LC_REPORT)
        bSizer1.Add(self.msg_listCtrl, 1, wx.ALL | wx.EXPAND, 5)

        self.SetSizer(bSizer1)
        self.Layout()

        # Connect Events
        self.start_checkBox.Bind(wx.EVT_CHECKBOX, self.onStartCheckBox)
        self.stop_checkBox.Bind(wx.EVT_CHECKBOX, self.onStopCheckBox)
        self.refresh_bpButton.Bind(wx.EVT_BUTTON, self.onRefreshButtonClick)
        self.msg_listCtrl.Bind(wx.EVT_LIST_ITEM_ACTIVATED,
                               self.onMsgListItemActivated)
Exemplo n.º 15
0
    def __init__(self, parent):
        wx.Panel.__init__(self, parent)
        self.ExifData = imageTamper.getExifDataFromPicture("")

        # Image Label
        imageLabel = wx.StaticText(self, wx.ALIGN_CENTRE_HORIZONTAL, label="Select an Image to modify:")

        # File picker control
        self.filePickerControl = wx.FilePickerCtrl(self)
        self.filePickerControl.Bind(wx.EVT_FILEPICKER_CHANGED, self.showImage)

        # Control to show image
        self.imageControl = wx.StaticBitmap(self,-1, wx.Bitmap(0,0))

        # Divider to separate content
        dividerLine = wx.StaticLine(self, wx.ID_ANY, size=(350, 2), style=wx.LI_HORIZONTAL)

        # Latitude random button
        latRandomButton = wx.Button(self, label='Random')
        latRandomButton.Bind(wx.EVT_BUTTON, self.latRandomUpdate)

        # Control to set latitude
        self.latControl = wx.SpinCtrlDouble(self, -1, '')
        self.latControl.Bind(wx.EVT_SPINCTRLDOUBLE, lambda event: self.ExifData.setLat(self.latControl.GetValue()))
        self.latControl.SetRange(0.00, 90.00)
        self.latControl.SetValue(0.00)

        # Latitude Label
        latLabel = wx.StaticText(self, wx.ALIGN_CENTRE_HORIZONTAL, label="Latitude")

        # Latitude panel
        latPanel = wx.BoxSizer()
        latPanel.Add(latRandomButton, proportion=0,  flag=wx.ALL,  border=5)
        latPanel.Add(self.latControl, proportion=0,  flag=wx.ALL,  border=5)
        latPanel.Add(latLabel, proportion=1, flag=wx.RIGHT|wx.BOTTOM|wx.TOP, border=10 )

        # Latitude Direction random button
        latDirectionRandomButton = wx.Button(self, label='Random')
        latDirectionRandomButton.Bind(wx.EVT_BUTTON, self.latDirectionRandomUpdate)

        # Control to set latitude Direction
        self.latNDirectionControl = wx.RadioButton(self, label="N", style = wx.RB_GROUP)
        self.latSDirectionControl = wx.RadioButton(self, label="S")
        self.latNDirectionControl.Bind(wx.EVT_RADIOBUTTON, lambda event: self.ExifData.setLatRef('N')) 
        self.latSDirectionControl.Bind(wx.EVT_RADIOBUTTON, lambda event: self.ExifData.setLatRef('S')) 
        self.latNDirectionControl.SetValue(True)

        # Latitude Direction Label
        latDirectionLabel = wx.StaticText(self, wx.ALIGN_CENTRE_HORIZONTAL, label="Latitude Direction")

        # Latitude Direction panel
        latDirectionPanel = wx.BoxSizer()
        latDirectionPanel.Add(latDirectionRandomButton, proportion=0,  flag=wx.ALL,  border=5)
        latDirectionPanel.Add(self.latNDirectionControl, proportion=0,  flag=wx.ALL,  border=5)
        latDirectionPanel.Add(self.latSDirectionControl, proportion=0,  flag=wx.ALL,  border=5)
        latDirectionPanel.Add(latDirectionLabel, proportion=1, flag=wx.RIGHT|wx.BOTTOM|wx.TOP, border=10 )

        # Longitude random button
        lonRandomButton = wx.Button(self, label='Random')
        lonRandomButton.Bind(wx.EVT_BUTTON, self.lonRandomUpdate)

        # Longitude value control
        self.lonControl = wx.SpinCtrlDouble(self, -1, '')
        self.lonControl.Bind(wx.EVT_SPINCTRLDOUBLE,lambda event: self.ExifData.setLon(self.lonControl.GetValue()))
        self.lonControl.SetRange(0.0000, 180.0000)
        self.lonControl.SetValue(0)

        # Logitude label
        lonLabel = wx.StaticText(self, label="Longitude")

        # Longitude panel
        lonPanel = wx.BoxSizer()
        lonPanel.Add(lonRandomButton, proportion=0,  flag=wx.ALL,  border=5)
        lonPanel.Add(self.lonControl, proportion=0,  flag=wx.ALL,  border=5)
        lonPanel.Add(lonLabel, proportion=1, flag=wx.RIGHT|wx.BOTTOM|wx.TOP, border=10 )

        # Longitude Direction random button
        lonDirectionRandomButton = wx.Button(self, label='Random')
        lonDirectionRandomButton.Bind(wx.EVT_BUTTON, self.lonDirectionRandomUpdate)

        # Control to set Longitude Direction
        self.lonWDirectionControl = wx.RadioButton(self, label="W", style = wx.RB_GROUP)
        self.lonEDirectionControl = wx.RadioButton(self, label="E")
        self.lonWDirectionControl.Bind(wx.EVT_RADIOBUTTON, lambda event: self.ExifData.setLonRef('W')) 
        self.lonEDirectionControl.Bind(wx.EVT_RADIOBUTTON, lambda event: self.ExifData.setLonRef('E')) 
        self.lonWDirectionControl.SetValue(True)

        # Longitude Direction Label
        lonDirectionLabel = wx.StaticText(self, wx.ALIGN_CENTRE_HORIZONTAL, label="Longitude Direction")

        # Longitude Direction panel
        lonDirectionPanel = wx.BoxSizer()
        lonDirectionPanel.Add(lonDirectionRandomButton, proportion=0,  flag=wx.ALL,  border=5)
        lonDirectionPanel.Add(self.lonWDirectionControl, proportion=0,  flag=wx.ALL,  border=5)
        lonDirectionPanel.Add(self.lonEDirectionControl, proportion=0,  flag=wx.ALL,  border=5)
        lonDirectionPanel.Add(lonDirectionLabel, proportion=1, flag=wx.RIGHT|wx.BOTTOM|wx.TOP, border=10 )

        # Time random button
        timeRandomButton = wx.Button(self, label='Random')
        timeRandomButton.Bind(wx.EVT_BUTTON, self.timeRandomUpdate)

        # Time value control
        self.timeControl = masked.TimeCtrl(self, value='00:00:00', name="Time", fmt24hr=True)
        self.timeControl.Bind(wx.lib.masked.EVT_TIMEUPDATE, lambda event: self.ExifData.setTime(self.timeControl.GetValue())) 

        # Time label
        timeLabel = wx.StaticText(self, label="Time")

        # Time panel
        timePanel = wx.BoxSizer()
        timePanel.Add(timeRandomButton, proportion=0,  flag=wx.ALL,  border=5)
        timePanel.Add(self.timeControl, proportion=0,  flag=wx.ALL,  border=5)
        timePanel.Add(timeLabel, proportion=1, flag=wx.RIGHT|wx.BOTTOM|wx.TOP, border=10 )

        # Date random button
        dateRandomButton = wx.Button(self, label='Random')
        dateRandomButton.Bind(wx.EVT_BUTTON, self.dateRandomUpdate)

        # Date value control
        self.dateControl = wx.adv.DatePickerCtrl(self, wx.ID_ANY, wx.DefaultDateTime)
        self.dateControl.Bind(wx.adv.EVT_DATE_CHANGED, lambda event: self.ExifData.setDate(self.dateControl.GetValue()))  

        # Date label
        dateLabel = wx.StaticText(self, label="Date")

        # Date panel
        datePanel = wx.BoxSizer()
        datePanel.Add(dateRandomButton, proportion=0,  flag=wx.ALL,  border=5)
        datePanel.Add(self.dateControl, proportion=0,  flag=wx.ALL,  border=5)
        datePanel.Add(dateLabel, proportion=1, flag=wx.RIGHT|wx.BOTTOM|wx.TOP, border=10 )

        # Date label
        fileLabel = wx.StaticText(self, label="Enter a file or path and file for your new image:")

        # New File control
        self.newFileControl = wx.TextCtrl(self,size = (315,25))

        # Save Button
        self.saveButton = wx.Button(self, label='Save')
        self.saveButton.Bind(wx.EVT_BUTTON, self.saveFile)
        self.saveButton.Disable()

        # Vertical organizer
        vertBox = wx.BoxSizer(wx.VERTICAL)
        vertBox.Add(imageLabel, proportion=0, flag=wx.LEFT|wx.TOP, border=10)
        vertBox.Add(self.filePickerControl, proportion=0, flag=wx.LEFT, border=10)
        vertBox.Add(self.imageControl, proportion=0, flag=wx.LEFT, border=10)
        vertBox.Add(dividerLine, proportion=0, flag=wx.BOTTOM|wx.TOP, border=10)
        vertBox.Add(latPanel, proportion=0, flag=wx.LEFT, border=5)
        vertBox.Add(latDirectionPanel, proportion=0, flag=wx.LEFT, border=5)
        vertBox.Add(lonPanel, proportion=0,  flag=wx.LEFT,  border=5)
        vertBox.Add(lonDirectionPanel, proportion=0, flag=wx.LEFT, border=5)
        vertBox.Add(timePanel, proportion=0,  flag=wx.LEFT,  border=5)
        vertBox.Add(datePanel, proportion=0,  flag=wx.LEFT,  border=5)
        vertBox.Add(fileLabel, proportion=0,  flag=wx.LEFT|wx.TOP, border=10)
        vertBox.Add(self.newFileControl, proportion=0, flag=wx.LEFT, border=10)
        vertBox.Add(self.saveButton, proportion=0, flag=wx.LEFT|wx.TOP, border=10)


        # Finally, I use the SetSizer function to automatically size the windows based on the
        # the definitions above
        self.SetSizer(vertBox)

        #Update layout controls to be correctly sized on load
        self.Layout()
Exemplo n.º 16
0
    def __init__(self, parent, id=wx.ID_ANY):
        wx.Dialog.__init__(self,
                           parent,
                           id,
                           _("Start Race at Time:"),
                           style=wx.DEFAULT_DIALOG_STYLE | wx.TAB_TRAVERSAL)

        font = wx.Font(24, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL,
                       wx.FONTWEIGHT_NORMAL)

        self.startSeconds = None
        self.timer = None
        self.futureRaceTime = None

        race = Model.getRace()
        autoStartLabel = wx.StaticText(self,
                                       label=_('Automatically Start Race at:'))

        # Make sure we don't suggest a start time in the past.
        value = race.scheduledStart
        startSeconds = Utils.StrToSeconds(value) * 60
        nowSeconds = GetNowSeconds()
        if startSeconds < nowSeconds:
            startOffset = 3 * 60
            startSeconds = nowSeconds - nowSeconds % startOffset
            startSeconds = nowSeconds + startOffset
            value = u'{:02d}:{:02d}'.format(startSeconds // (60 * 60),
                                            (startSeconds // 60) % 60)

        self.autoStartTime = masked.TimeCtrl(self,
                                             fmt24hr=True,
                                             display_seconds=False,
                                             value=value,
                                             size=wx.Size(60, -1))

        self.pagesLabel = wx.StaticText(self,
                                        label=_('After Start, Switch to:'))
        mainWin = Utils.getMainWin()
        if mainWin:
            pageNames = [name for a, b, name in mainWin.attrClassName]
        else:
            pageNames = [
                _('Actions'),
                _('Record'),
                _('Results'),
                _('Passings'),
                _('RiderDetail'),
                _('Chart'),
                _('Animation'),
                _('Recommendations'),
                _('Categories'),
                _('Properties'),
                _('Primes'),
                _('Situation'),
                _('LapCounter'),
            ]
        pageNames = pageNames[1:]  # Skip the Actions screen.
        self.pages = wx.Choice(self, choices=pageNames)
        self.pages.SetSelection(0)  # Record screen.

        self.countdown = CountdownClock(self, size=(400, 400), tFuture=None)
        self.Bind(EVT_COUNTDOWN, self.onCountdown)

        self.okBtn = wx.Button(self, wx.ID_OK, label=_('Start at Above Time'))
        self.Bind(wx.EVT_BUTTON, self.onOK, self.okBtn)

        self.start30 = wx.Button(self, label=_('Start in 30s'))
        self.start30.Bind(wx.EVT_BUTTON,
                          lambda event: self.startInFuture(event, 30))
        self.start60 = wx.Button(self, label=_('Start in 60s'))
        self.start60.Bind(wx.EVT_BUTTON,
                          lambda event: self.startInFuture(event, 60))

        self.cancelBtn = wx.Button(self, wx.ID_CANCEL)
        self.Bind(wx.EVT_BUTTON, self.onCancel, self.cancelBtn)

        vs = wx.BoxSizer(wx.VERTICAL)

        border = 8
        hs = wx.BoxSizer(wx.HORIZONTAL)
        hs.Add(autoStartLabel,
               border=border,
               flag=wx.LEFT | wx.TOP | wx.BOTTOM | wx.ALIGN_CENTER_VERTICAL)
        hs.Add(self.autoStartTime,
               border=border,
               flag=wx.RIGHT | wx.TOP | wx.BOTTOM | wx.ALIGN_CENTER_VERTICAL)
        hs.Add(self.pagesLabel,
               border=border,
               flag=wx.LEFT | wx.TOP | wx.BOTTOM | wx.ALIGN_CENTER_VERTICAL)
        hs.Add(self.pages,
               border=border,
               flag=wx.RIGHT | wx.TOP | wx.BOTTOM | wx.ALIGN_BOTTOM
               | wx.ALIGN_CENTER_VERTICAL)
        vs.Add(hs)

        hs = wx.BoxSizer(wx.HORIZONTAL)
        hs.Add(self.okBtn, border=border, flag=wx.ALL)
        hs.Add(self.start30, border=border, flag=wx.TOP | wx.BOTTOM | wx.RIGHT)
        hs.Add(self.start60, border=border, flag=wx.TOP | wx.BOTTOM | wx.RIGHT)
        self.okBtn.SetDefault()
        hs.AddStretchSpacer()
        hs.Add(self.cancelBtn, border=border, flag=wx.ALL)
        vs.Add(hs, flag=wx.EXPAND)

        vs.Add(self.countdown,
               1,
               border=border,
               flag=wx.ALL | wx.ALIGN_CENTRE | wx.EXPAND)

        self.SetSizerAndFit(vs)

        self.CentreOnParent(wx.BOTH)
        wx.CallAfter(self.SetFocus)

        wx.CallLater(100, self.autoStartTime.SetSize, (48, -1))
Exemplo n.º 17
0
    def __init__(self, parent, log):

        scrolled.ScrolledPanel.__init__(self, parent, -1)
        self.log = log

        box_label = wx.StaticBox(self, -1, "Change Controls through API")
        buttonbox = wx.StaticBoxSizer(box_label, wx.HORIZONTAL)

        text1 = wx.StaticText(self, -1, "12-hour format:")
        self.time12 = masked.TimeCtrl(self, -1, name="12 hour control")
        h = self.time12.GetSize().height
        spin1 = wx.SpinButton(self, -1, wx.DefaultPosition, (-1, h),
                              wx.SP_VERTICAL)
        self.time12.BindSpinButton(spin1)

        text2 = wx.StaticText(self, -1, "24-hour format:")
        spin2 = wx.SpinButton(self, -1, wx.DefaultPosition, (-1, h),
                              wx.SP_VERTICAL)
        self.time24 = masked.TimeCtrl(self,
                                      -1,
                                      name="24 hour control",
                                      fmt24hr=True,
                                      spinButton=spin2)

        text3 = wx.StaticText(self, -1, "No seconds\nor spin button:")
        self.spinless_ctrl = masked.TimeCtrl(self,
                                             -1,
                                             name="spinless control",
                                             display_seconds=False)

        grid = wx.FlexGridSizer(cols=2, hgap=10, vgap=5)
        grid.Add(text1, 0, wx.ALIGN_RIGHT)
        hbox1 = wx.BoxSizer(wx.HORIZONTAL)
        hbox1.Add(self.time12, 0, wx.ALIGN_CENTRE)
        hbox1.Add(spin1, 0, wx.ALIGN_CENTRE)
        grid.Add(hbox1, 0, wx.LEFT)

        grid.Add(text2, 0, wx.ALIGN_RIGHT | wx.TOP | wx.BOTTOM)
        hbox2 = wx.BoxSizer(wx.HORIZONTAL)
        hbox2.Add(self.time24, 0, wx.ALIGN_CENTRE)
        hbox2.Add(spin2, 0, wx.ALIGN_CENTRE)
        grid.Add(hbox2, 0, wx.LEFT)

        grid.Add(text3, 0, wx.ALIGN_RIGHT | wx.TOP | wx.BOTTOM)
        grid.Add(self.spinless_ctrl, 0, wx.LEFT)

        buttonChange = wx.Button(self, -1, "Change Controls")
        self.radio12to24 = wx.RadioButton(
            self, -1, "Copy 12-hour time to 24-hour control",
            wx.DefaultPosition, wx.DefaultSize, wx.RB_GROUP)

        self.radio24to12 = wx.RadioButton(
            self, -1, "Copy 24-hour time to 12-hour control")

        self.radioWx = wx.RadioButton(
            self, -1, "Set controls to 'now' using wxDateTime")
        self.radioMx = wx.RadioButton(
            self, -1, "Set controls to 'now' using mxDateTime")

        radio_vbox = wx.BoxSizer(wx.VERTICAL)
        radio_vbox.Add(self.radio12to24, 0, wx.ALIGN_CENTER_VERTICAL | wx.ALL,
                       5)
        radio_vbox.Add(self.radio24to12, 0, wx.ALIGN_CENTER_VERTICAL | wx.ALL,
                       5)
        radio_vbox.Add(self.radioWx, 0, wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5)
        radio_vbox.Add(self.radioMx, 0, wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5)

        buttonbox.Add(buttonChange, 0, wx.ALIGN_CENTRE | wx.ALL, 5)
        buttonbox.Add(radio_vbox, 0, wx.ALIGN_CENTRE | wx.ALL, 5)

        hbox = wx.BoxSizer(wx.HORIZONTAL)
        hbox.Add(grid, 0, wx.ALIGN_LEFT | wx.ALL, 15)
        hbox.Add(buttonbox, 0, wx.ALIGN_RIGHT | wx.BOTTOM, 20)

        box_label = wx.StaticBox(self, -1, "Bounds Control")
        boundsbox = wx.StaticBoxSizer(box_label, wx.HORIZONTAL)
        self.set_bounds = wx.CheckBox(self, -1, "Set time bounds:")

        minlabel = wx.StaticText(self, -1, "minimum time:")
        self.min = masked.TimeCtrl(self, -1, name="min", display_seconds=False)
        self.min.Enable(False)

        maxlabel = wx.StaticText(self, -1, "maximum time:")
        self.max = masked.TimeCtrl(self, -1, name="max", display_seconds=False)
        self.max.Enable(False)

        self.limit_check = wx.CheckBox(self, -1, "Limit control")

        label = wx.StaticText(self, -1, "Resulting time control:")
        self.target_ctrl = masked.TimeCtrl(self, -1, name="new")

        grid2 = wx.FlexGridSizer(cols=2)
        grid2.Add((20, 0), 0, wx.ALIGN_LEFT | wx.ALL, 5)
        grid2.Add((20, 0), 0, wx.ALIGN_LEFT | wx.ALL, 5)

        grid2.Add(self.set_bounds, 0, wx.ALIGN_LEFT | wx.ALL, 5)
        grid3 = wx.FlexGridSizer(cols=2, hgap=5, vgap=5)
        grid3.Add(minlabel, 0, wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL)
        grid3.Add(self.min, 0, wx.ALIGN_LEFT)
        grid3.Add(maxlabel, 0, wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL)
        grid3.Add(self.max, 0, wx.ALIGN_LEFT)
        grid2.Add(grid3, 0, wx.ALIGN_LEFT)

        grid2.Add(self.limit_check, 0, wx.ALIGN_LEFT | wx.ALL, 5)
        grid2.Add((20, 0), 0, wx.ALIGN_LEFT | wx.ALL, 5)

        grid2.Add((20, 0), 0, wx.ALIGN_LEFT | wx.ALL, 5)
        grid2.Add((20, 0), 0, wx.ALIGN_LEFT | wx.ALL, 5)
        grid2.Add(label, 0, wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.ALL,
                  5)
        grid2.Add(self.target_ctrl, 0, wx.ALIGN_LEFT | wx.ALL, 5)
        boundsbox.Add(grid2, 0, wx.ALIGN_CENTER | wx.EXPAND | wx.ALL, 5)

        vbox = wx.BoxSizer(wx.VERTICAL)
        vbox.Add((20, 20))
        vbox.Add(hbox, 0, wx.ALIGN_LEFT | wx.ALL, 5)
        vbox.Add(boundsbox, 0, wx.ALIGN_LEFT | wx.ALL, 5)

        outer_box = wx.BoxSizer(wx.VERTICAL)
        outer_box.Add(vbox, 0, wx.ALIGN_LEFT | wx.ALL, 5)

        # Turn on mxDateTime option only if we can import the module:
        try:
            from mx import DateTime
        except ImportError:
            self.radioMx.Enable(False)

        self.SetAutoLayout(True)
        self.SetSizer(outer_box)
        outer_box.Fit(self)
        self.SetupScrolling()

        self.Bind(wx.EVT_BUTTON, self.OnButtonClick, buttonChange)
        self.Bind(masked.EVT_TIMEUPDATE, self.OnTimeChange, self.time12)
        self.Bind(masked.EVT_TIMEUPDATE, self.OnTimeChange, self.time24)
        self.Bind(masked.EVT_TIMEUPDATE, self.OnTimeChange, self.spinless_ctrl)
        self.Bind(wx.EVT_CHECKBOX, self.OnBoundsCheck, self.set_bounds)
        self.Bind(wx.EVT_CHECKBOX, self.SetTargetMinMax, self.limit_check)
        self.Bind(masked.EVT_TIMEUPDATE, self.SetTargetMinMax, self.min)
        self.Bind(masked.EVT_TIMEUPDATE, self.SetTargetMinMax, self.max)
        self.Bind(masked.EVT_TIMEUPDATE, self.OnTimeChange, self.target_ctrl)
Exemplo n.º 18
0
    def __init__(self, parent):
        sc.SizedDialog.__init__(self,
                                None,
                                -1,
                                u"闹钟编辑",
                                style=wx.DEFAULT_DIALOG_STYLE)

        pane = self.GetContentsPane()
        pane.SetSizerType("form")

        # row 1
        wx.StaticText(pane, -1, u"名称:")
        self.TextCtrlAlarmType = wx.TextCtrl(pane, -1, u"起床了")
        self.TextCtrlAlarmType.SetSizerProps(expand=True)

        # row 2
        wx.StaticText(pane, -1, u"时间:")

        # here's how to add a 'nested sizer' using sized_controls
        timePane = sc.SizedPanel(pane, -1)
        timePane.SetSizerType("horizontal")
        timePane.SetSizerProps(expand=True)
        self.TimeCtrlAlarmTime = masked.TimeCtrl(timePane,
                                                 -1,
                                                 name="24 hour control",
                                                 fmt24hr=True)
        h = self.TimeCtrlAlarmTime.GetSize().height
        spin = wx.SpinButton(timePane, -1, wx.DefaultPosition, (-1, h),
                             wx.SP_VERTICAL)
        self.TimeCtrlAlarmTime.BindSpinButton(spin)

        #row
        wx.StaticText(pane, -1, u"声音文件:")
        filePane = sc.SizedPanel(pane, -1)
        filePane.SetSizerType("horizontal")
        filePane.SetSizerProps(expand=True)

        self.TextCtrlAlarmFile = wx.TextCtrl(filePane, -1, "", size=(100, 24))
        SelectFileBtn = wx.Button(filePane, -1, "...", size=(23, 23))
        #SelectFileBtn.SetSizerProps(expand=True)
        #self.TextCtrlAlarmFile.SetSizerProps(expand=True)
        self.Bind(wx.EVT_BUTTON, self.OnSelectSoundFile, SelectFileBtn)

        # row
        wx.StaticText(pane, -1, u"类型:")

        # here's how to add a 'nested sizer' using sized_controls
        radioPane = sc.SizedPanel(pane, -1)
        radioPane.SetSizerType("horizontal")
        radioPane.SetSizerProps(expand=True)

        # make these children of the radioPane to have them use
        # the horizontal layout
        self.EveryDayBtn = wx.RadioButton(radioPane, -1, u"每天提醒")
        self.OnceBtn = wx.RadioButton(radioPane, -1, u"提醒一次")

        # add dialog buttons
        self.SetButtonSizer(self.CreateStdDialogButtonSizer(wx.OK | wx.CANCEL))

        # a little trick to make sure that you can't resize the dialog to
        # less screen space than the controls need
        self.Fit()
        self.SetMinSize(self.GetSize())
    def gui(self):

        self.inputfile = FileBrowseButton(
            self,
            id=wx.ID_ANY,
            labelText='Input File',
            buttonText='Browse',
            startDirectory='C:\Users\labadmin\Desktop\OptoGenetics\Data_Folder',
            toolTip='Type filename or click browse to choose input file',
            dialogTitle='Choose an input file',
            size=(300, -1),
            fileMask='*.*',
            fileMode=wx.ALL,
            name='input browse button')

        #        self.outputPrompt = wx.StaticText(self, wx.ID_ANY, "Output File Prefix: ")
        #        self.outputfile = wx.TextCtrl(self, wx.ID_ANY, name='outputprefix')

        self.datePrompt = wx.StaticText(self, wx.ID_ANY, "Start Date: ")
        self.startDate = wx.DatePickerCtrl(self,
                                           wx.ID_ANY,
                                           style=wx.DP_DROPDOWN
                                           | wx.DP_SHOWCENTURY)

        self.timePrompt = wx.StaticText(self, wx.ID_ANY, "Start Time: ")
        self.spinbtn = wx.SpinButton(self, wx.ID_ANY, wx.DefaultPosition,
                                     (-1, 20), wx.SP_VERTICAL)
        self.startTime = masked.TimeCtrl(self,
                                         wx.ID_ANY,
                                         name='time: \n24 hour control',
                                         fmt24hr=True,
                                         spinButton=self.spinbtn)

        #        self.fpsPrompt = wx.StaticText(self, wx.ID_ANY, "Frame Rate (fps): ")
        #        self.fps = wx.TextCtrl(self, wx.ID_ANY)

        self.startBtn = wx.Button(self, wx.ID_STOP, label="Start")

        self.statusbar = wx.wx.TextCtrl(self,
                                        wx.ID_ANY,
                                        size=(1000, 20),
                                        value="",
                                        style=wx.TE_READONLY)

        self.Bind(wx.EVT_BUTTON, self.onStart, self.startBtn)

        mainSizer = wx.BoxSizer(wx.VERTICAL)
        #        spacerSizer = wx.BoxSizer(wx.HORIZONTAL)
        inSizer = wx.BoxSizer(wx.HORIZONTAL)
        outSizer = wx.BoxSizer(wx.HORIZONTAL)
        dateSizer = wx.BoxSizer(wx.HORIZONTAL)
        timeSizer = wx.BoxSizer(wx.HORIZONTAL)
        #        fpsSizer = wx.BoxSizer(wx.HORIZONTAL)

        inSizer.Add(self.inputfile, 1, wx.LEFT | wx.EXPAND, 10)

        #        outSizer.Add(self.outputPrompt, 0, wx.LEFT, 10)
        #        outSizer.Add(self.outputfile, 0, wx.LEFT, 10)

        dateSizer.Add(self.datePrompt, 0, wx.LEFT | wx.EXPAND, 10)
        dateSizer.Add(self.startDate, 0, wx.LEFT | wx.EXPAND, 10)

        #        timeSizer.AddSpacer(8)
        timeSizer.Add(self.timePrompt, 0, wx.LEFT | wx.EXPAND, 10)
        timeSizer.Add(self.startTime, 0, wx.LEFT | wx.EXPAND, 7)
        timeSizer.Add(self.spinbtn, 0, wx.LEFT | wx.EXPAND, 4)
        #        self.addWidgets(timeSizer, [self.timePrompt, self.startTime, self.spinbtn])
        #        timeSizer.Add(self.startTime, 0, wx.LEFT, 10)

        #        fpsSizer.Add(self.fpsPrompt, 0, wx.LEFT | wx.EXPAND, 10)
        #        fpsSizer.Add(self.fps, 0, wx.LEFT | wx.EXPAND, 10)

        mainSizer.Add(inSizer, 0, wx.LEFT | wx.EXPAND, 10)
        mainSizer.Add(outSizer, 0, wx.LEFT | wx.EXPAND, 10)
        mainSizer.Add(dateSizer, 0, wx.LEFT | wx.EXPAND, 10)
        mainSizer.Add(timeSizer, 0, wx.LEFT | wx.EXPAND, 10)
        #        mainSizer.Add(fpsSizer, 0, wx.LEFT | wx.EXPAND, 10)
        mainSizer.Add(self.startBtn, 0, wx.CENTER, 10)
        mainSizer.AddSpacer(20)
        mainSizer.Add(self.statusbar, 0, wx.CENTER | wx.EXPAND, 10)
        mainSizer.AddSpacer(20)
        self.SetSizer(mainSizer)
Exemplo n.º 20
0
    def __init__(
        self,
        parent: MainFrame,
        download_item: DownloadItem,
        _dark_mode: bool = False,
    ):
        super().__init__(parent,
                         wx.ID_ANY,
                         title=_("Clip Multimedia"),
                         style=wx.DEFAULT_DIALOG_STYLE)
        self.download_item = download_item
        clip_start, clip_end = self._get_timespans()

        self._dark_mode = _dark_mode

        # Create components
        self.panel = wx.Panel(self)
        sizer = wx.BoxSizer(wx.VERTICAL)
        h_time_box = wx.BoxSizer(wx.HORIZONTAL)

        start_label = wx.StaticText(self.panel, wx.ID_ANY,
                                    _("Clip start") + ":")
        h_time_box.Add(start_label, 0, wx.ALIGN_CENTRE | wx.ALL, 5)
        h_time_box.AddStretchSpacer(1)
        self.clip_start = masked.TimeCtrl(self.panel,
                                          wx.ID_ANY,
                                          value=clip_start,
                                          fmt24hr=True,
                                          name="startTime")
        height = self.clip_start.GetSize().height
        spin1 = wx.SpinButton(self.panel, wx.ID_ANY, wx.DefaultPosition,
                              (-1, height), wx.SP_VERTICAL)
        self.clip_start.BindSpinButton(spin1)
        hbox1 = wx.BoxSizer(wx.HORIZONTAL)
        hbox1.Add(self.clip_start, 0, wx.ALIGN_CENTRE)
        hbox1.Add(spin1, 0, wx.ALIGN_CENTRE)

        h_time_box.Add(hbox1, 0, wx.EXPAND | wx.ALL, 5)
        sizer.Add(h_time_box, 0, wx.EXPAND | wx.ALL, 5)

        h_time_box = wx.BoxSizer(wx.HORIZONTAL)

        end_label = wx.StaticText(self.panel, wx.ID_ANY, _("Clip end") + ":")
        h_time_box.Add(end_label, 0, wx.ALIGN_CENTRE | wx.ALL, 5)
        h_time_box.AddStretchSpacer(1)
        spin2 = wx.SpinButton(self.panel, wx.ID_ANY, wx.DefaultPosition,
                              (-1, height), wx.SP_VERTICAL)
        self.clip_end = masked.TimeCtrl(
            self.panel,
            wx.ID_ANY,
            value=clip_end,
            fmt24hr=True,
            name="endTime",
            spinButton=spin2,
        )
        hbox2 = wx.BoxSizer(wx.HORIZONTAL)
        hbox2.Add(self.clip_end, 0, wx.ALIGN_CENTRE)
        hbox2.Add(spin2, 0, wx.ALIGN_CENTRE)

        h_time_box.Add(hbox2, 0, wx.EXPAND | wx.ALL, 5)
        sizer.Add(h_time_box, 0, wx.EXPAND | wx.ALL, 5)

        line = wx.StaticLine(self.panel,
                             wx.ID_ANY,
                             size=(-1, -1),
                             style=wx.LI_HORIZONTAL)
        sizer.Add(line, 0, wx.EXPAND | wx.TOP, 5)

        buttons_sizer = wx.StdDialogButtonSizer()

        btn = wx.Button(self.panel, wx.ID_OK)
        btn.Bind(wx.EVT_BUTTON, self._on_close)
        btn.SetDefault()

        buttons_sizer.AddButton(btn)

        btn = wx.Button(self.panel, wx.ID_CANCEL)
        buttons_sizer.AddButton(btn)
        buttons_sizer.Realize()

        sizer.Add(buttons_sizer, 0, wx.ALIGN_CENTER_HORIZONTAL | wx.ALL, 5)

        self.panel.SetSizer(sizer)
        # Set Dark Theme
        dark_mode(self.panel, self._dark_mode)

        self.SetSize(self.FRAME_SIZE)
        self.Center()
        # TODO: Make better decision
        self._clean_options()
Exemplo n.º 21
0
    def widgets(self):

        # TODO: get coordinate values by clicking the mouse
        # TODO: add PySolo single ROI drawing

        # ------------------------------------------------------------------------------------------------------------ Title
        self.title = wx.StaticText(self, -1, "\n %s" % self.mon_name)  # title
        font = wx.Font(12, wx.DEFAULT, wx.NORMAL, wx.BOLD)
        self.title.SetFont(font)

        # -------------------------------------------------------------------------------------------- video display options
        self.previewPanel = VM.monitorPanel(self,
                                            mon_ID=self.mon_ID,
                                            panelType='preview',
                                            loop=True)

        self.previewSizeLabel = wx.StaticText(
            self, wx.ID_ANY, 'frame size =')  # ------ preview frame size
        self.previewSize = wx.TextCtrl(self,
                                       wx.ID_ANY,
                                       str(self.preview_size),
                                       style=wx.TE_PROCESS_ENTER,
                                       name='previewSize')

        self.previewFPSLabel = wx.StaticText(
            self, wx.ID_ANY, 'preview fps =')  # --------- preview video fps
        self.previewFPS = wx.TextCtrl(self,
                                      wx.ID_ANY,
                                      str(self.preview_fps),
                                      style=wx.TE_PROCESS_ENTER,
                                      name='previewFPS')

        self.lineThicknessLabel = wx.StaticText(
            self, wx.ID_ANY,
            'ROI line thickness =')  # --------- preview ROI line thickness
        self.lineThickness = wx.TextCtrl(self,
                                         wx.ID_ANY,
                                         str(self.line_thickness),
                                         style=wx.TE_PROCESS_ENTER,
                                         name='lineThickness')

        # ---------------------------------------------------------------------------------------  Save Configuration Button
        self.btnSaveCfg = wx.Button(self,
                                    wx.ID_ANY,
                                    label='Save Configuration',
                                    size=(130, 25))
        if self.source != '':
            self.btnSaveCfg.Enable(
                True)  # don't allow save if no source is selected
        else:
            self.btnSaveCfg.Enable(False)

            # ---------------------------------------------------------------------------------------  Delete Monitor Button
        self.btnRemoveMonitor = wx.Button(self,
                                          wx.ID_ANY,
                                          label='Delete Monitor',
                                          size=(130, 25))
        if self.monitors == 1:  # don't allow last monitor to be deleted
            self.btnRemoveMonitor.Enable(False)
        else:
            self.btnRemoveMonitor.Enable(True)

        # -------------------------------------------------------------------------------------------------------- source
        self.txt_source = wx.StaticText(self, wx.ID_ANY, "Source:  ")
        if self.source is not None:
            self.currentSource = wx.TextCtrl(
                self, wx.ID_ANY, self.source,
                style=wx.TE_READONLY)  # get current source
        else:
            self.currentSource = wx.TextCtrl(
                self, wx.ID_ANY, 'None Selected',
                style=wx.TE_READONLY)  # get current source

            # -------------------------------------------------------------------------------  Webcam selection combobox
        #        if len(gbl.webcams_inuse) >= gbl.webcams:                          # only one webcam implemented at this time
        #            self.WebcamsList = ['No more webcams available.']
        #        else:
        #        self.WebcamsList = ['Webcam %s' % (int(w) + 1) for w in range(gbl.webcams)]
#        self.WebcamsList = ['Webcam 1']

# ------------------------------------------------------------------------------------------- source options
        self.source_IDs = [wx.ID_ANY, wx.ID_ANY, wx.ID_ANY]
        self.sources = [
            'placeholder for webcams',
            #                         (wx.ComboBox(self, id=self.source_IDs[0], choices=self.WebcamsList, name='sources0',  # webcam
            #                                     style=wx.EXPAND | wx.CB_DROPDOWN | wx.CB_READONLY | wx.CB_SORT)),
            (
                FileBrowseButton(
                    self,
                    id=self.source_IDs[1],  # video file
                    name='sources1',
                    buttonText='Browse',
                    toolTip=
                    'Type filename or click browse to choose video file',
                    dialogTitle='Choose a video file',
                    startDirectory=self.data_folder,
                    wildcard='*.*',
                    style=wx.ALL,
                    changeCallback=self.onChangeSource1)),
            (
                DirBrowseButton(
                    self,
                    id=self.source_IDs[2],
                    name='sources2',  # folder of images
                    style=wx.DD_DIR_MUST_EXIST,
                    startDirectory=self.data_folder,
                    changeCallback=self.onChangeSource2))
        ]

        # --------------------------------------------------------------------------------  source type radio buttons
        #        self.rbs = [(wx.RadioButton(self, wx.ID_ANY, 'Camera', style=wx.RB_GROUP)),
        self.rbs = [
            'placeholder for camera radiobutton',
            (wx.RadioButton(self, wx.ID_ANY, 'File')),
            (wx.RadioButton(self, wx.ID_ANY, 'Folder'))
        ]

        # ------------------------------------------------------------------------------------------------ mask file browser
        wildcard = 'PySolo Video mask file (*.msk)|*.msk|' \
                   'All files (*.*)|*.*'  # adding space in here will mess it up!

        if self.mask_file is None:
            startDirectory = self.data_folder  # Default directory for file dialog startup
            initialValue = 'None Selected'
        elif os.path.isfile(self.mask_file):
            startDirectory = os.path.split(
                self.mask_file)[0]  # Default directory for file dialog startup
            initialValue = self.mask_file
        else:
            startDirectory = self.data_folder  # Default directory for file dialog startup
            initialValue = 'None Selected'

        self.pickMaskBrowser = FileBrowseButton(
            self,
            id=wx.ID_ANY,
            labelText='Mask File:         ',
            buttonText='Browse',
            toolTip='Type filename or click browse to choose mask file',
            dialogTitle='Choose a mask file',
            startDirectory=startDirectory,
            initialValue=initialValue,
            wildcard=wildcard,
            style=wx.ALL,
            changeCallback=self.onMaskBrowse,
            name='pickMaskBrowser')

        # -------------------------------------------------------------------------------------------- output folder browser
        if self.data_folder is None:
            startDirectory = self.data_folder = gbl.cfg_path  # Default directory is config directory
        elif os.path.isdir(self.data_folder):
            startDirectory = self.data_folder  # Default directory from config file
        else:
            startDirectory = self.data_folder = gbl.cfg_path  # Default directory is config directory

        self.pickOutputBrowser = DirBrowseButton(
            self,
            id=wx.ID_ANY,
            style=wx.TAB_TRAVERSAL,
            labelText='Output Folder:  ',
            dialogTitle='Choose an output folder',
            startDirectory=self.data_folder,
            value=gbl.data_folder,
            changeCallback=self.onChangeOutput,
            name='pickOutputBrowser')

        # ------------------------------------------------------------------------------------------------- video attributes
        self.sourceFPSLabel = wx.StaticText(
            self, wx.ID_ANY, 'Speed (fps) =')  # ---------------- source fps
        self.sourceFPS = wx.TextCtrl(self,
                                     wx.ID_ANY,
                                     str(self.source_fps),
                                     style=wx.TE_PROCESS_ENTER,
                                     name='sourceFPS')

        self.txtDate = wx.StaticText(self, wx.ID_ANY,
                                     "Date: ")  # ---------------- start date
        self.startDate = wx.DatePickerCtrl(
            self,
            wx.ID_ANY,
            dt=self.start_datetime,
            style=wx.DP_DROPDOWN | wx.DP_SHOWCENTURY | wx.TE_PROCESS_ENTER,
            name='start_date')

        self.txtTime = wx.StaticText(
            self, wx.ID_ANY, 'Time (24-hr): ')  # ---------------- start time
        self.btnSpin = wx.SpinButton(self, wx.ID_ANY, wx.DefaultPosition,
                                     (-1, 20), wx.SP_VERTICAL)
        starttime = gbl.wxdatetime2timestring(self.start_datetime)
        self.startTime = masked.TimeCtrl(self,
                                         wx.ID_ANY,
                                         value=starttime,
                                         name='time: \n24 hour control',
                                         fmt24hr=True,
                                         spinButton=self.btnSpin,
                                         style=wx.TE_PROCESS_ENTER)

        self.instruction = wx.StaticText(
            self, wx.ID_ANY,
            'Clicking on the video will change top left coordinate values.')
        """
    # ------------------------------------------------------------------------------------------------ activate tracking
        self.trackBox = wx.CheckBox(self, wx.ID_ANY, 'Activate Tracking')
        self.trackBox.Enable(True)
        self.trackBox.SetValue(str(self.track))

    # ---------------------------------------------------------------------------------------- sleep deprivation monitor
        self.isSDMonitor = wx.CheckBox(self, wx.ID_ANY, 'Sleep Deprivation Monitor')
        self.isSDMonitor.Enable(True)
        self.isSDMonitor.SetValue(str(self.issdmonitor))

    # ---------------------------------------------------------------------------------------------------- tracking type
        self.trackChoice = [(wx.RadioButton(self, wx.ID_ANY, 'Activity as distance traveled', style=wx.RB_GROUP)),
                            (wx.RadioButton(self, wx.ID_ANY, 'Activity as midline crossings count')),
                            (wx.RadioButton(self, wx.ID_ANY, 'Only position of flies'))]

        for count in range(0, len(self.trackChoice)):
            self.trackChoice[count].Enable(True)
            if self.trackType == count:
                self.trackChoice[count].SetValue(True)
            else:
                self.trackChoice[count].SetValue(False)
        """

        # -------------------------------------------------------------------------------------------- instructional diagram
        self.diagram = wx.Bitmap(
            os.path.join(gbl.exec_dir, 'maskmakerdiagram.bmp'),
            wx.BITMAP_TYPE_BMP)
        self.diagramctl = wx.StaticBitmap(self, -1, self.diagram)

        # --------------------------------------------------------------------------------------- ROI Coordinates Input Grid
        self.rowLabels = [
            wx.StaticText(self, -1, ' '),
            wx.StaticText(self, -1, 'Number'),  # row labels
            wx.StaticText(self, -1, 'Top Left'),
            wx.StaticText(self, -1, 'Span'),
            wx.StaticText(self, -1, 'Gap'),
            wx.StaticText(self, -1, 'Tilt')
        ]
        self.X = []
        self.Y = []
        self.X.append(wx.StaticText(
            self, wx.ID_ANY, "Columns (X)"))  # column header for columns
        self.Y.append(wx.StaticText(self, wx.ID_ANY,
                                    "Rows (Y)"))  # column header for rows
        for cnt in range(0, 5):
            self.X.append(NumCtrl(self, wx.ID_ANY, 0))
            self.Y.append(NumCtrl(self, wx.ID_ANY, 0))

        # ------------------------------------------------------------------------------------ mask generator & save buttons
        self.btnMaskGen = wx.Button(self,
                                    wx.ID_ANY,
                                    label="Generate Mask",
                                    size=(130, 25))
        self.btnMaskGen.Enable(True)

        self.btnSaveMask = wx.Button(self,
                                     wx.ID_ANY,
                                     label="Save Mask",
                                     size=(130, 25))
        self.btnSaveMask.Enable(True)
Exemplo n.º 22
0
	def __init__( self, chipName, parseTagTime, parent, id = wx.ID_ANY, fileSuffix = 'txt' ):
		wx.Dialog.__init__( self, parent, id, u'{} {}'.format(chipName, _('Import')),
						style=wx.DEFAULT_DIALOG_STYLE|wx.THICK_FRAME|wx.TAB_TRAVERSAL )
		
		self.chipName = chipName
		self.parseTagTime = parseTagTime
		self.fileSuffix = fileSuffix
		todoList = [
			u'{} {}'.format(chipName, _('Import Data File')),
			u'',
			_('You must first "New" a race and fill in the details.'),
			_('You must also configure a "Tag" field in your Sign-On Excel Sheet and link the sheet to the race.'),
			_('This is required so CrossMgr can link the tags in the import file back to rider numbers and info.'),
			u'',
			_('Race Data:'),
			_('If the first chip read is NOT the start of the race, you will need to enter the start time manually.'),
			_('Otherwise the import will use the first chip read as the race start.'),
			u'',
			_('TimeTrial Data:'),
			_("The first chip read for each rider will be interpreted as the rider's start time."),
			u'',
			_('Warning: Importing from chip data could replace all the data in this race.'),
			_('Proceed with caution.'),
		]
		intro = u'\n'.join(todoList)
		
		gs = wx.FlexGridSizer( rows=0, cols=3, vgap=10, hgap=5 )
		gs.Add( wx.StaticText(self, label = u'{} {}:'.format(chipName, _('Data File'))), 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_RIGHT )
		self.chipDataFile = wx.TextCtrl( self, -1, '', size=(450,-1) )
		defaultPath = Utils.getFileName()
		if not defaultPath:
			defaultPath = Utils.getDocumentsDir()
		else:
			defaultPath = os.path.join( os.path.split(defaultPath)[0], '' )
		self.chipDataFile.SetValue( defaultPath )
		gs.Add( self.chipDataFile, 1, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT|wx.GROW)

		btn = wx.Button( self, label=_('Browse') + u'...' )
		btn.Bind( wx.EVT_BUTTON, self.onBrowseChipReaderDataFile )
		gs.Add( btn, 0, wx.ALIGN_CENTER_VERTICAL )
		
		gs.AddSpacer(1)
		self.dataType = wx.StaticText( self, label = _("Data Is:") )
		gs.Add( self.dataType, 1, wx.ALIGN_LEFT )
		gs.AddSpacer(1)

		gs.Add( wx.StaticText(self, label = _('Data Policy:') ), 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_RIGHT )
		self.importPolicy = wx.Choice( self, choices = [
				_('Clear All Existing Data Before Import'),
				_('Merge New Data with Existing')
			] )
		self.importPolicy.SetSelection( 0 )
		gs.Add( self.importPolicy, 1, wx.ALIGN_LEFT )
		gs.AddSpacer(1)
        
		gs.Add( wx.StaticText(self, label = _('Import Data Time Adjustment:') ), 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_RIGHT )
		self.timeAdjustment = HighPrecisionTimeEdit( self, size=(120,-1) )
		self.behindAhead = wx.Choice( self, choices=[_('Behind'), _('Ahead')] )
		if JChip.readerComputerTimeDiff:
			rtAdjust = JChip.readerComputerTimeDiff.total_seconds()
			if rtAdjust >= 0.0:
				self.behindAhead.SetSelection( 0 )
			else:
				self.behindAhead.SetSelection( 1 )
				rtAdjust *= -1.0
			self.timeAdjustment.SetSeconds( rtAdjust )
		else:
			self.behindAhead.SetSelection( 0 )
		hb = wx.BoxSizer()
		hb.Add( self.behindAhead, flag=wx.ALIGN_BOTTOM|wx.BOTTOM, border=4 )
		hb.Add( self.timeAdjustment, flag=wx.ALL, border=4 )
		gs.Add( hb, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT )
		gs.AddSpacer(1)
		
		self.manualStartTime = wx.CheckBox(self, label = _('Race Start Time (if NOT first recorded time):') )
		self.Bind( wx.EVT_CHECKBOX, self.onChangeManualStartTime, self.manualStartTime )
		gs.Add( self.manualStartTime, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_RIGHT )
		self.raceStartTime = masked.TimeCtrl( self, fmt24hr=True, value="10:00:00" )
		self.raceStartTime.Enable( False )
		gs.Add( self.raceStartTime, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT)
		gs.AddSpacer(1)
		
		with Model.LockRace() as race:
			isTimeTrial = getattr(race, 'isTimeTrial', False) if race else False

		if isTimeTrial:
			self.manualStartTime.Enable( False )
			self.manualStartTime.Show( False )
			self.raceStartTime.Enable( False )
			self.raceStartTime.Show( False )
			self.dataType.SetLabel( _('Data will be imported for a Time Trial') )
		else:
			self.dataType.SetLabel( _('Data will be imported for a Race') )
			
		self.okBtn = wx.Button( self, wx.ID_OK )
		self.Bind( wx.EVT_BUTTON, self.onOK, self.okBtn )

		self.cancelBtn = wx.Button( self, wx.ID_CANCEL )
		self.Bind( wx.EVT_BUTTON, self.onCancel, self.cancelBtn )
		
		bs = wx.BoxSizer( wx.VERTICAL )
		
		border = 4
		
		hs = wx.BoxSizer( wx.HORIZONTAL )
		
		try:
			image = wx.Image( os.path.join(Utils.getImageFolder(), '{}Logo.png'.format(chipName)), wx.BITMAP_TYPE_PNG )
		except Exception as e:
			image = wx.EmptyImage( 32, 32, True )
		hs.Add( wx.StaticBitmap(self, bitmap = image.ConvertToBitmap()), 0 )
		hs.Add( wx.StaticText(self, label = intro), 1, wx.EXPAND|wx.LEFT, border*2 )
		
		bs.Add( hs, 1, wx.EXPAND|wx.ALL, border )
		
		#-------------------------------------------------------------------
		bs.AddSpacer( border )
		
		bs.Add( gs, 0, wx.EXPAND | wx.ALL, border )
		
		buttonBox = wx.BoxSizer( wx.HORIZONTAL )
		buttonBox.AddStretchSpacer()
		buttonBox.Add( self.okBtn, flag = wx.RIGHT, border = border )
		self.okBtn.SetDefault()
		buttonBox.Add( self.cancelBtn )
		bs.Add( buttonBox, 0, wx.EXPAND | wx.ALL, border )
		
		self.SetSizerAndFit(bs)
		bs.Fit( self )
		
		self.CentreOnParent(wx.BOTH)
		wx.CallAfter( self.SetFocus )
Exemplo n.º 23
0
    def InitUI(self):
        if self.mode == "DEBUG":
            print "In EnvironmentConditionsPanel"

        self.locale = wx.Locale(self.lang)

        self.layoutSizer = wx.BoxSizer(wx.VERTICAL)

        #Levels Txt and Ctrl
        levelsSizer = wx.BoxSizer(wx.HORIZONTAL)
        levelsTxt = wx.StaticText(self,
                                  label=self.levelsTxtLbl,
                                  style=wx.ALIGN_CENTRE_HORIZONTAL)
        self.levelsCtrl = wx.TextCtrl(self,
                                      style=wx.TE_PROCESS_ENTER,
                                      size=(100, -1))
        levelsSizer.Add(levelsTxt, 0, wx.EXPAND | wx.RIGHT | wx.TOP, 5)
        levelsSizer.Add(self.levelsCtrl, 1, wx.EXPAND | wx.LEFT, 5)

        #Cloud Cover Text and Combo
        cloudCoverSizer = wx.BoxSizer(wx.HORIZONTAL)
        cloudCoverTxt = wx.StaticText(self,
                                      label=self.cloudCoverTxtLbl,
                                      style=wx.ALIGN_CENTRE_HORIZONTAL)
        self.cloudCoverCmbo = wx.ComboBox(self,
                                          choices=self.cloudCoverList,
                                          style=wx.CB_READONLY,
                                          size=(100, -1))
        self.cloudCoverCmbo.Bind(wx.EVT_MOUSEWHEEL, self.do_nothing)
        cloudCoverSizer.Add(cloudCoverTxt, 0, wx.EXPAND | wx.RIGHT | wx.TOP, 5)
        cloudCoverSizer.Add(self.cloudCoverCmbo, 1, wx.EXPAND | wx.LEFT, 5)

        #Precipitation Text and Combo
        precipSizer = wx.BoxSizer(wx.HORIZONTAL)
        precipTxt = wx.StaticText(self,
                                  label=self.precipTxtLbl,
                                  style=wx.ALIGN_CENTRE_HORIZONTAL)
        self.precipCmbo = wx.ComboBox(self,
                                      choices=self.precipList,
                                      style=wx.CB_READONLY,
                                      size=(100, -1))
        self.precipCmbo.Bind(wx.EVT_MOUSEWHEEL, self.do_nothing)
        precipSizer.Add(precipTxt, 0, wx.EXPAND | wx.RIGHT | wx.TOP, 5)
        precipSizer.Add(self.precipCmbo, 1, wx.EXPAND | wx.LEFT, 5)

        #Wind Magnitude Text, Combo
        windMagSizer = wx.BoxSizer(wx.HORIZONTAL)
        windMagTxt = wx.StaticText(self,
                                   label=self.windMagTxtLbl,
                                   style=wx.ALIGN_CENTRE_HORIZONTAL)
        self.windMagCmbo = wx.ComboBox(self,
                                       choices=self.windMagList,
                                       style=wx.CB_READONLY,
                                       size=(100, -1))
        self.windMagCmbo.Bind(wx.EVT_MOUSEWHEEL, self.do_nothing)
        windMagSizer.Add(windMagTxt, 0, wx.EXPAND | wx.RIGHT | wx.TOP, 5)
        windMagSizer.Add(self.windMagCmbo, 1, wx.EXPAND | wx.LEFT, 5)

        #Wind Mag Speed Text and Ctrl
        windMagSpeedSizer = wx.BoxSizer(wx.HORIZONTAL)
        windMagSpeedTxt = wx.StaticText(self,
                                        label=self.windMagSpeedTxtLbl,
                                        style=wx.ALIGN_CENTRE_HORIZONTAL)
        self.windMagCtrl = MyTextCtrl(self, size=(80, -1))
        self.windMagCtrl.Bind(wx.EVT_TEXT, NumberControl.FloatNumberControl)
        self.windMagCtrl.Bind(wx.EVT_KILL_FOCUS, NumberControl.Sig3)
        windMagSpeedSizer.Add(windMagSpeedTxt, 0,
                              wx.EXPAND | wx.RIGHT | wx.TOP, 5)
        windMagSpeedSizer.Add(self.windMagCtrl, 1, wx.EXPAND | wx.LEFT, 5)

        #Wind Direction Text and Cmbo
        windDirSizer = wx.BoxSizer(wx.HORIZONTAL)
        windDirTxt = wx.StaticText(self,
                                   label=self.windDirTxtLbl,
                                   style=wx.ALIGN_CENTRE_HORIZONTAL)
        self.windDirCmbo = wx.ComboBox(self,
                                       choices=self.windDirList,
                                       style=wx.CB_READONLY,
                                       size=(100, -1))
        self.windDirCmbo.Bind(wx.EVT_MOUSEWHEEL, self.do_nothing)
        windDirSizer.Add(windDirTxt, 0, wx.EXPAND | wx.RIGHT | wx.TOP, 5)
        windDirSizer.Add(self.windDirCmbo, 1, wx.EXPAND | wx.LEFT, 5)

        #Battery Voltage Text and Ctrl
        batterySizer = wx.BoxSizer(wx.HORIZONTAL)
        batteryTxt = wx.StaticText(self,
                                   label=self.batteryVoltageTxtLbl,
                                   style=wx.ALIGN_CENTRE_HORIZONTAL)
        self.batteryCtrl = MyTextCtrl(self,
                                      style=wx.TE_PROCESS_ENTER,
                                      size=(100, -1))
        self.batteryCtrl.Bind(wx.EVT_TEXT, NumberControl.FloatNumberControl)
        self.batteryCtrl.Bind(wx.EVT_KILL_FOCUS, NumberControl.Round1)
        batterySizer.Add(batteryTxt, 0, wx.EXPAND | wx.RIGHT | wx.TOP, 5)
        batterySizer.Add(self.batteryCtrl, 1, wx.EXPAND | wx.LEFT, 5)

        #Gas Pressure Sizer
        gasPressureSizer = wx.BoxSizer(wx.HORIZONTAL)
        gasPressureV1 = wx.BoxSizer(wx.VERTICAL)
        gasPressureV2 = wx.BoxSizer(wx.VERTICAL)
        gasPressureV3 = wx.BoxSizer(wx.VERTICAL)

        gasPressV1H1 = wx.BoxSizer(wx.HORIZONTAL)
        gasPressV1H2 = wx.BoxSizer(wx.HORIZONTAL)
        gasPressV1H3 = wx.BoxSizer(wx.HORIZONTAL)
        gasPressV1H4 = wx.BoxSizer(wx.HORIZONTAL)

        gasPressV2H1 = wx.BoxSizer(wx.HORIZONTAL)
        gasPressV2H2 = wx.BoxSizer(wx.HORIZONTAL)
        gasPressV2H3 = wx.BoxSizer(wx.HORIZONTAL)
        gasPressV2H4 = wx.BoxSizer(wx.HORIZONTAL)

        gasPressV3H1 = wx.BoxSizer(wx.HORIZONTAL)
        gasPressV3H2 = wx.BoxSizer(wx.HORIZONTAL)
        gasPressV3H3 = wx.BoxSizer(wx.HORIZONTAL)
        gasPressV3H4 = wx.BoxSizer(wx.HORIZONTAL)

        gasPressureV1.Add(gasPressV1H1, 0, wx.EXPAND)
        gasPressureV1.Add(gasPressV1H2, 0, wx.EXPAND)
        gasPressureV1.Add(gasPressV1H3, 0, wx.EXPAND | wx.TOP, 5)
        gasPressureV1.Add(gasPressV1H4, 0, wx.EXPAND | wx.TOP, 5)

        gasPressureV2.Add(gasPressV2H1, 0, wx.EXPAND)
        gasPressureV2.Add(gasPressV2H2, 0, wx.EXPAND)
        gasPressureV2.Add(gasPressV2H3, 0, wx.EXPAND | wx.TOP, 5)
        gasPressureV2.Add(gasPressV2H4, 0, wx.EXPAND | wx.TOP, 5)

        gasPressureV3.Add(gasPressV3H1, 0, wx.EXPAND)
        gasPressureV3.Add(gasPressV3H2, 0, wx.EXPAND)
        gasPressureV3.Add(gasPressV3H3, 0, wx.EXPAND | wx.TOP, 5)
        gasPressureV3.Add(gasPressV3H4, 0, wx.EXPAND | wx.TOP, 5)

        gasPressureSizer.Add(gasPressureV1, 0, wx.EXPAND)
        gasPressureSizer.Add(gasPressureV2, 1, wx.EXPAND)
        gasPressureSizer.Add(gasPressureV3, 1, wx.EXPAND)

        arrivalTxt = wx.StaticText(self,
                                   label=self.arrivalLbl,
                                   style=wx.ALIGN_CENTRE_HORIZONTAL)
        departureTxt = wx.StaticText(self,
                                     label=self.departLbl,
                                     style=wx.ALIGN_CENTRE_HORIZONTAL)
        font = wx.Font(wx.FontInfo(8).FaceName("Helvetica").Bold())
        arrivalTxt.SetFont(font)
        departureTxt.SetFont(font)

        arrivalTxt.SetForegroundColour((164, 64, 43))
        departureTxt.SetForegroundColour((164, 64, 43))

        gasPressV1H1.Add((-255, -255), 1, wx.EXPAND)
        gasPressV2H1.Add(arrivalTxt, 1, wx.EXPAND)
        gasPressV3H1.Add(departureTxt, 1, wx.EXPAND)

        ###########################################

        #Gas Text and Ctrl

        gasSysTxt = wx.StaticText(
            self,
            label=self.gasSystemTxtLbl)  #, style=wx.ALIGN_CENTRE_HORIZONTAL)

        gasSysAtTxt = wx.StaticText(self, label=self.intakeTimeLbl)
        gasSysAt2Txt = wx.StaticText(self, label=self.intakeTimeLbl)
        font2 = wx.Font(wx.FontInfo(7))
        gasSysTxt.SetFont(font2)

        #v1h1
        self.gasSysCtrl = MyTextCtrl(self,
                                     style=wx.TE_PROCESS_ENTER,
                                     size=(40, -1))
        self.gasSysCtrl.Bind(wx.EVT_TEXT, NumberControl.FloatNumberControl)
        self.gasSysCtrl.Bind(wx.EVT_KILL_FOCUS, NumberControl.Sig3)
        self.gasArrTime = DropdownTime(False, parent=self, size=(-1, -1))

        #v2h1
        self.bpmrotCtrl = MyTextCtrl(self,
                                     style=wx.TE_PROCESS_ENTER,
                                     size=(40, -1))
        self.bpmrotCtrl.Bind(wx.EVT_TEXT, NumberControl.FloatNumberControl)
        self.bpmrotCtrl.Bind(wx.EVT_KILL_FOCUS, NumberControl.Sig2)
        self.bpmrotArrTime = DropdownTime(False, parent=self, size=(-1, -1))

        #v1h3
        feedTxt = wx.StaticText(
            self, label=self.feedTxtLbl)  #, style=wx.ALIGN_CENTRE_HORIZONTAL)
        feedAtTxt = wx.StaticText(self, label=self.intakeTimeLbl)
        feedAt2Txt = wx.StaticText(self, label=self.intakeTimeLbl)
        self.feedCtrl = MyTextCtrl(self,
                                   style=wx.TE_PROCESS_ENTER,
                                   size=(40, -1))
        self.feedCtrl.Bind(wx.EVT_TEXT, NumberControl.FloatNumberControl)
        self.feedCtrl.Bind(wx.EVT_KILL_FOCUS, NumberControl.Sig2)
        self.feedArrTime = DropdownTime(False, parent=self, size=(-1, -1))

        #v1h2
        self.gasSysDepCtrl = MyTextCtrl(self,
                                        style=wx.TE_PROCESS_ENTER,
                                        size=(40, -1))
        self.gasSysDepCtrl.Bind(wx.EVT_TEXT, NumberControl.FloatNumberControl)
        self.gasSysDepCtrl.Bind(wx.EVT_KILL_FOCUS, NumberControl.Sig3)

        self.gasDepTime = DropdownTime(False, parent=self, size=(-1, -1))

        #v2h2
        self.bpmrotDepCtrl = MyTextCtrl(self,
                                        style=wx.TE_PROCESS_ENTER,
                                        size=(40, -1))
        self.bpmrotDepCtrl.Bind(wx.EVT_TEXT, NumberControl.FloatNumberControl)
        self.bpmrotDepCtrl.Bind(wx.EVT_KILL_FOCUS, NumberControl.Sig2)

        self.bpmrotDepTime = DropdownTime(False, parent=self, size=(-1, -1))

        #v3h2
        self.feedDepCtrl = MyTextCtrl(self,
                                      style=wx.TE_PROCESS_ENTER,
                                      size=(40, -1))
        self.feedDepCtrl.Bind(wx.EVT_TEXT, NumberControl.FloatNumberControl)
        self.feedDepCtrl.Bind(wx.EVT_KILL_FOCUS, NumberControl.Sig2)

        self.feedDepTime = DropdownTime(False, parent=self, size=(-1, -1))

        #v0h0
        self.bpmrotCmbo = wx.ComboBox(self,
                                      choices=self.bpmrotTxtLbl,
                                      style=wx.CB_READONLY,
                                      size=(50, -1))
        self.bpmrotCmbo.Bind(wx.EVT_MOUSEWHEEL, self.do_nothing)

        gasPressV1H2.Add(gasSysTxt, 0, wx.EXPAND | wx.TOP, 20)
        gasPressV2H2.Add(self.gasSysCtrl, 0, wx.EXPAND | wx.LEFT, 5)
        gasPressV2H2.Add(gasSysAtTxt, 0, wx.LEFT, 5)
        gasPressV2H2.Add(self.gasArrTime, 0)

        gasPressV3H2.Add(self.gasSysDepCtrl, 0, wx.EXPAND | wx.LEFT, 5)
        gasPressV3H2.Add(gasSysAt2Txt, 0, wx.LEFT, 5)
        gasPressV3H2.Add(self.gasDepTime, 0)

        #Feed Ctrl
        gasPressV1H3.Add(feedTxt, 0, wx.EXPAND | wx.RIGHT | wx.TOP, 5)
        gasPressV2H3.Add(self.feedCtrl, 0, wx.EXPAND | wx.LEFT, 5)
        gasPressV2H3.Add(feedAtTxt, 0, wx.LEFT, 5)
        gasPressV2H3.Add(self.feedArrTime, 0)

        gasPressV3H3.Add(self.feedDepCtrl, 0, wx.EXPAND | wx.LEFT, 5)
        gasPressV3H3.Add(feedAt2Txt, 0, wx.LEFT, 5)
        gasPressV3H3.Add(self.feedDepTime, 0)

        #BPM/ROT Cmbo and Ctrl
        bpmrotAtTxt = wx.StaticText(self, label=self.intakeTimeLbl)
        bpmrotAt2Txt = wx.StaticText(self, label=self.intakeTimeLbl)

        gasPressV1H4.Add(self.bpmrotCmbo, 0, wx.EXPAND | wx.TOP, 10)
        gasPressV2H4.Add(self.bpmrotCtrl, 0, wx.EXPAND | wx.LEFT, 5)
        gasPressV2H4.Add(bpmrotAtTxt, 0, wx.LEFT, 5)
        gasPressV2H4.Add(self.bpmrotArrTime, 0)

        gasPressV3H4.Add(self.bpmrotDepCtrl, 0, wx.EXPAND | wx.LEFT, 5)
        gasPressV3H4.Add(bpmrotAt2Txt, 0, wx.LEFT, 5)
        gasPressV3H4.Add(self.bpmrotDepTime, 0)

        #Intake/Orifice checkboxes
        intakeOrificeSizerH = wx.BoxSizer(wx.HORIZONTAL)

        intakeSizer = wx.BoxSizer(wx.HORIZONTAL)
        self.intakeCB = wx.CheckBox(self, label=self.intakeTxtLbl)
        self.intakeCB.Bind(wx.EVT_CHECKBOX, self.OnIntakeCheck)
        intakeSizer.Add(self.intakeCB, 1, wx.EXPAND)

        intakeTimeSizer = wx.BoxSizer(wx.HORIZONTAL)
        self.intakeTimeTxt = wx.StaticText(self,
                                           label=self.intakeTimeLbl,
                                           style=wx.ALIGN_CENTRE_HORIZONTAL,
                                           size=(-1, 10))
        self.intakeTimeTxt.Hide()
        self.intakeTimeCtrl = masked.TimeCtrl(self,
                                              2,
                                              size=(-1, 10),
                                              displaySeconds=False,
                                              style=wx.TE_CENTRE,
                                              fmt24hr=True)
        self.intakeTimeCtrl.Bind(wx.EVT_KEY_DOWN, self.OnResetTime)
        self.intakeTimeCtrl.Hide()
        intakeTimeSizer.Add(self.intakeTimeTxt, 0, wx.EXPAND)
        intakeTimeSizer.Add(self.intakeTimeCtrl, 1, wx.EXPAND)

        orificeSizer = wx.BoxSizer(wx.HORIZONTAL)
        self.orificeCB = wx.CheckBox(self, label=self.orificeTxtLbl)
        self.orificeCB.Bind(wx.EVT_CHECKBOX, self.OnOrificeCheck)
        orificeSizer.Add(self.orificeCB, 1, wx.EXPAND)

        orificeTimeSizer = wx.BoxSizer(wx.HORIZONTAL)
        self.orificeTimeTxt = wx.StaticText(self,
                                            label=self.intakeTimeLbl,
                                            style=wx.ALIGN_CENTRE_HORIZONTAL,
                                            size=(-1, 10))
        self.orificeTimeTxt.Hide()
        self.orificeTimeCtrl = masked.TimeCtrl(self,
                                               2,
                                               size=(-1, 10),
                                               displaySeconds=False,
                                               style=wx.TE_CENTRE,
                                               fmt24hr=True)
        self.orificeTimeCtrl.Bind(wx.EVT_KEY_DOWN, self.OnResetTime)
        self.orificeTimeCtrl.Hide()
        orificeTimeSizer.Add(self.orificeTimeTxt, 0, wx.EXPAND)
        orificeTimeSizer.Add(self.orificeTimeCtrl, 1, wx.EXPAND)

        intakeOrificeSizerH.Add(intakeSizer, 1, wx.EXPAND)
        intakeOrificeSizerH.Add(orificeSizer, 1, wx.EXPAND)

        self.intakeOrificeTimeSizerH = wx.BoxSizer(wx.HORIZONTAL)
        self.intakeOrificeTimeSizerH.Add(intakeTimeSizer, 1, wx.EXPAND)
        self.intakeOrificeTimeSizerH.Add(orificeTimeSizer, 1, wx.EXPAND)

        #Program/Data checkboxes
        programDataSizerH = wx.BoxSizer(wx.HORIZONTAL)

        programSizer = wx.BoxSizer(wx.HORIZONTAL)
        self.programCB = wx.CheckBox(self,
                                     label=self.programTxtLbl,
                                     size=(85, -1))
        programSizer.Add(self.programCB, 1, wx.EXPAND)

        dataSizer = wx.BoxSizer(wx.HORIZONTAL)
        self.dataCB = wx.CheckBox(self, label=self.dataTxtLbl, size=(-1, -1))
        self.dataCB.Bind(wx.EVT_CHECKBOX, self.OnDownloadedData)
        dataSizer.Add(self.dataCB, 1, wx.EXPAND)

        programDataSizerH.Add(programSizer, 1, wx.EXPAND)
        programDataSizerH.Add(dataSizer, 1, wx.EXPAND)

        #Data period From/To
        dataPeriodSizer = wx.BoxSizer(wx.VERTICAL)
        dataPeriodTxt = wx.StaticText(self, label=self.dataPeriodTxtLbl)

        dataPeriodRangeSizer = wx.BoxSizer(wx.HORIZONTAL)
        dataPeriodFromTxt = wx.StaticText(self,
                                          label=self.dataPeriodFromTxtLbl,
                                          style=wx.ALIGN_CENTRE_HORIZONTAL)
        self.dataPeriodFromPicker = adv.DatePickerCtrl(
            self, style=wx.adv.DP_DROPDOWN, size=(30, -1))
        self.dataPeriodFromPicker.Enable(False)
        dataPeriodToTxt = wx.StaticText(self,
                                        label=self.dataPeriodToTxtLbl,
                                        style=wx.ALIGN_CENTRE_HORIZONTAL)
        self.dataPeriodToPicker = adv.DatePickerCtrl(self,
                                                     style=wx.adv.DP_DROPDOWN,
                                                     size=(30, -1))
        self.dataPeriodToPicker.Enable(False)

        dataPeriodRangeSizer.Add(dataPeriodFromTxt, 0,
                                 wx.EXPAND | wx.TOP | wx.RIGHT, 5)
        dataPeriodRangeSizer.Add(self.dataPeriodFromPicker, 1, wx.EXPAND)
        dataPeriodRangeSizer.Add(dataPeriodToTxt, 0,
                                 wx.EXPAND | wx.TOP | wx.RIGHT, 5)
        dataPeriodRangeSizer.Add(self.dataPeriodToPicker, 1, wx.EXPAND)

        dataPeriodSizer.Add(dataPeriodTxt, 0, wx.EXPAND)
        dataPeriodSizer.Add(dataPeriodRangeSizer, 1, wx.EXPAND)

        #Station Health Remark
        stationHealthRemarkPanel = wx.Panel(self, style=wx.NO_BORDER)
        stationRemarkSizer = wx.BoxSizer(wx.HORIZONTAL)
        stationHealthRemarkPanel.SetSizer(stationRemarkSizer)
        stationHealthTxt = wx.StaticText(stationHealthRemarkPanel,
                                         label=self.stnRemarkLbl,
                                         style=wx.ALIGN_CENTRE_HORIZONTAL)
        self.stationHealthRemarksCtrl = wx.TextCtrl(
            stationHealthRemarkPanel,
            style=wx.TE_PROCESS_ENTER | wx.TE_MULTILINE | wx.TE_BESTWRAP,
            size=(-1, -1))
        stationRemarkSizer.Add(stationHealthTxt, 0)
        stationRemarkSizer.Add(self.stationHealthRemarksCtrl, 1, wx.EXPAND)

        #Add all to layout Sizer
        self.layoutSizer.Add(levelsSizer, 0,
                             wx.EXPAND | wx.LEFT | wx.TOP | wx.RIGHT, 5)
        self.layoutSizer.Add(cloudCoverSizer, 0,
                             wx.EXPAND | wx.LEFT | wx.TOP | wx.RIGHT, 5)
        self.layoutSizer.Add(precipSizer, 0,
                             wx.EXPAND | wx.LEFT | wx.TOP | wx.RIGHT, 5)
        self.layoutSizer.Add(windMagSizer, 0,
                             wx.EXPAND | wx.LEFT | wx.TOP | wx.RIGHT, 5)
        self.layoutSizer.Add(windMagSpeedSizer, 0,
                             wx.EXPAND | wx.LEFT | wx.TOP | wx.RIGHT, 5)
        self.layoutSizer.Add(windDirSizer, 0,
                             wx.EXPAND | wx.LEFT | wx.TOP | wx.RIGHT, 5)
        self.layoutSizer.Add(batterySizer, 0,
                             wx.EXPAND | wx.LEFT | wx.TOP | wx.RIGHT, 5)

        self.layoutSizer.Add(gasPressureSizer, 1,
                             wx.EXPAND | wx.LEFT | wx.TOP | wx.RIGHT, 5)

        # self.layoutSizer.Add(gasSysSizer, 0, wx.EXPAND|wx.LEFT|wx.TOP|wx.RIGHT, 5)
        # self.layoutSizer.Add(machineSizerH, 0, wx.EXPAND|wx.LEFT|wx.TOP|wx.RIGHT, 5)
        self.layoutSizer.Add(intakeOrificeSizerH, 0,
                             wx.EXPAND | wx.LEFT | wx.TOP | wx.RIGHT, 5)
        self.layoutSizer.Add(self.intakeOrificeTimeSizerH, 0,
                             wx.EXPAND | wx.LEFT | wx.TOP | wx.RIGHT, 5)

        self.layoutSizer.Add(programDataSizerH, 0,
                             wx.EXPAND | wx.LEFT | wx.TOP | wx.RIGHT, 5)
        self.layoutSizer.Add((1, 10))
        self.layoutSizer.Add(dataPeriodSizer, 0,
                             wx.EXPAND | wx.LEFT | wx.TOP | wx.RIGHT, 5)

        self.layoutSizer.Add(stationHealthRemarkPanel, 0,
                             wx.EXPAND | wx.LEFT | wx.TOP | wx.RIGHT, 5)

        self.SetSizer(self.layoutSizer)
Exemplo n.º 24
0
 def __init__(self, parent):
     wx.Dialog.__init__(self, parent, title='Create a Reminder')
     periods = ['One Time Only', 'Daily', 'Weekly', 'Monthly', 'Anually']
     sizer = wx.BoxSizer(wx.VERTICAL)
     self.calen_ctrl = wx.adv.GenericCalendarCtrl(self, -1,
                                                  wx.DateTime.Today(), size=(300, 200), pos=(5, 5),
                                                  style=wx.adv.CAL_SHOW_HOLIDAYS)
     self.calen_ctrl.Enable(False)
     self.stext4 = wx.StaticText(self, -1, '  Title:')
     self.title_box = wx.TextCtrl(self, -1, '', size=(-1, -1))
     self.stext5 = wx.StaticText(self, -1, '  Contents:')
     self.message_box = wx.TextCtrl(
         self, -1, '', size=(-1, -1), style=wx.TE_MULTILINE)
     self.message_box.Enable(False)
     self.stext3 = wx.StaticText(self, -1, '  Set Date and Time of Day')
     self.time_ctrl = masked.TimeCtrl(
         self, -1, name='time of day', display_seconds=False)
     self.time_ctrl.Enable(False)
     self.stext1 = wx.StaticText(self, -1, '  Reacuring Period:')
     self.periods_combo = wx.ComboBox(
         self, choices=periods, style=wx.CB_READONLY | wx.CB_DROPDOWN)
     # self.periods_combo.SetValue('Daily')
     self.periods_combo.Enable(False)
     self.stext2 = wx.StaticText(self, -1, '  Reminder Type:')
     self.message_type_combo = wx.ComboBox(
         self, choices=['Notification', 'Question'], style=wx.CB_READONLY | wx.CB_DROPDOWN)
     # self.message_type_combo.SetValue('Notification')
     self.message_type_combo.Enable(False)
     self.reminder_verify = wx.TextCtrl(self, -1, '', size=(-1, -1),
                                        style=wx.TE_MULTILINE | wx.TE_READONLY)
     self.ok_button = wx.Button(self, id=wx.ID_OK, label='Ok')
     self.ok_button.Enable(False)
     self.ok_button.Bind(wx.EVT_BUTTON, self.OnDialogButton)
     cancel_button = wx.Button(self, id=wx.ID_CANCEL, label='Cancel')
     cancel_button.Bind(wx.EVT_BUTTON, self.OnDialogButton)
     sizer.Add(self.stext4, 0, wx.ALL | wx.EXPAND, 5)
     sizer.Add(self.title_box, 0, wx.ALL | wx.EXPAND, 5)
     sizer.Add(self.stext5, 0, wx.ALL | wx.EXPAND, 5)
     sizer.Add(self.message_box, 0, wx.ALL | wx.EXPAND, 5)
     sizer.Add(self.stext3, 0, wx.ALL | wx.EXPAND, 5)
     sizer.Add(self.time_ctrl, 0, wx.ALL | wx.EXPAND, 5)
     sizer.Add(self.calen_ctrl, 0, wx.ALL | wx.EXPAND, 5)
     sizer.Add(self.stext1, 0, wx.ALL | wx.EXPAND, 5)
     sizer.Add(self.periods_combo, 0, wx.ALL | wx.EXPAND, 5)
     sizer.Add(self.stext2, 0, wx.ALL | wx.EXPAND, 5)
     sizer.Add(self.message_type_combo, 0, wx.ALL | wx.EXPAND, 5)
     sizer.Add(self.reminder_verify, 0, wx.ALL | wx.EXPAND, 5)
     bsizer = wx.BoxSizer(wx.HORIZONTAL)
     bsizer.AddSpacer(50)
     bsizer.Add(self.ok_button, 0, wx.ALL, 5)
     bsizer.Add(cancel_button, 0, wx.ALL, 5)
     sizer.Add(bsizer, 0, wx.ALL | wx.EXPAND, 5)
     sizer.Fit(self)
     self.SetSizer(sizer)
     self.CenterOnScreen()
     self.Show()
     self.title_box.Bind(wx.EVT_TEXT, self.on_event_title_box)
     self.message_box.Bind(wx.EVT_TEXT, self.on_event_message_box)
     self.time_ctrl.Bind(wx.EVT_TEXT, self.on_event_time_ctrl)
     self.calen_ctrl.Bind(wx.adv.EVT_CALENDAR, self.on_event_calen_ctrl)
     self.periods_combo.Bind(wx.EVT_TEXT, self.on_event_periods_combo)
     self.message_type_combo.Bind(
         wx.EVT_TEXT, self.on_event_message_type_combo)
Exemplo n.º 25
0
Arquivo: test.py Projeto: hick/admin
    def __init__(self, parent, aid=None):
        wx.Dialog.__init__(self, parent, -1, '提醒项', size=(700, 300))

        panel = wx.Panel(self)
        self._aid = aid

        ### 先确定数据值(添加和编辑不一样)
        if aid == None:
            title = u'默认值'
            content = u'默认内容'
            ### 默认时间和日期目前没有用
            alarm_date = '2010-05-12'
            alarm_time = '19:20'
        else:
            title = u'获取值 %s' % aid
            content = u'默认内容 %s' % aid
            alarm_date = u'获取值 %s' % aid
            alarm_time = u'获取值 %s' % aid

        ### 首先创建各个显示控件
        # 行: 标题
        LabelTitle = wx.StaticText(panel, -1, u"提醒名称: ")
        InputTitle = wx.TextCtrl(panel, -1, title, size=(400, 20))

        # 行: 内容
        LabelContent = wx.StaticText(panel, -1, u"提醒内容: ")
        InputContent = wx.TextCtrl(panel,
                                   -1,
                                   content,
                                   size=(400, 200),
                                   style=wx.TE_MULTILINE)
        # 行: 时间
        LabelDatetime = wx.StaticText(panel, -1, u"提醒时间: ")
        InputDate = wx.DatePickerCtrl(panel,
                                      size=(90, -1),
                                      style=wx.DP_DROPDOWN | wx.DP_SHOWCENTURY)
        InputTimeSpin = wx.SpinButton(panel, -1, wx.DefaultPosition, (-1, 23),
                                      wx.SP_VERTICAL)
        InputTime = masked.TimeCtrl(panel,
                                    -1,
                                    name="24 hour control",
                                    fmt24hr=True,
                                    spinButton=InputTimeSpin,
                                    display_seconds=False)
        # 设置值
        InputTime.SetValue(wx.DateTime_Now())

        # 按钮
        ButtonSave = wx.Button(panel, -1, u"保存")
        ButtonCancel = wx.Button(panel, -1, u"取消")

        # 对象寄存
        self.InputTitle = InputTitle
        self.InputContent = InputContent
        self.InputDate = InputDate
        self.InputTime = InputTime

        ### 事件绑定
        self.Bind(wx.EVT_DATE_CHANGED, self.onDateChanged, InputDate)  # 日期变化
        self.Bind(masked.EVT_TIMEUPDATE, self.onTimeChanged, InputTime)  # 时间变化
        self.Bind(wx.EVT_BUTTON, self.onSave, ButtonSave)
        self.Bind(wx.EVT_BUTTON, self.onCloseDlg, ButtonCancel)

        ### 布局的基本结构: 一个垂直 boxsizer组织全局,
        mainSizer = wx.BoxSizer(wx.VERTICAL)

        # 注意 sizer 命名规范更方便和位置对应起来(subSizer 表示一级 size 的子 sizer)
        subSizer = wx.FlexGridSizer(cols=2, hgap=5, vgap=5)
        # 行: 标题
        subSizer.Add(LabelTitle, 0, wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL)
        subSizer.Add(InputTitle, 1, wx.ALIGN_CENTER_VERTICAL)
        # 行: 内容
        subSizer.Add(LabelContent, 0,
                     wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL)
        subSizer.Add(InputContent, 1)
        # 行: 日期和时间(再套一个水平 sizer)
        subSizer.Add(LabelDatetime, 0,
                     wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL)
        subDatetimeSizer = wx.BoxSizer(wx.HORIZONTAL)
        subDatetimeSizer.Add(InputDate, 0)
        subDatetimeSizer.Add(InputTime, 0)
        subDatetimeSizer.Add(InputTimeSpin, 0)
        subSizer.Add(subDatetimeSizer, 0)

        mainSizer.Add(subSizer, 0, wx.EXPAND | wx.ALL, 10)

        # 按钮放在水平sizer
        subBtnSizer = wx.BoxSizer(wx.HORIZONTAL)
        subBtnSizer.Add(ButtonSave, 0)
        subBtnSizer.Add((20, 20), 1)  # 按钮之间增加间隙
        subBtnSizer.Add(ButtonCancel, 0)
        mainSizer.Add(subBtnSizer, 1, wx.ALIGN_CENTER | wx.BOTTOM, 10)

        panel.SetSizer(mainSizer)

        mainSizer.Fit(self)
        mainSizer.SetSizeHints(self)
        self.Center()
Exemplo n.º 26
0
    def __init__(self, parent, mon_num, cfg):

        wx.Panel.__init__(self,
                          parent,
                          wx.ID_ANY,
                          pos=(20, 20),
                          size=(-1, 250),
                          style=wx.SUNKEN_BORDER | wx.TAB_TRAVERSAL)

        self.parent = parent
        self.cfg = cfg
        self.cfg_dict = self.cfg.cfg_dict
        self.n_cams = self.cfg_dict[0]['webcams']
        self.mon_num = mon_num  # TODO: do webcams have configurations?
        self.start_datetime = self.cfg_dict[mon_num]['start_datetime']

        #  ###########################################################         Create items for configuration panel display
        # ---------------------------------------------------------------------------  monitor selection combobox
        self.txt_source = wx.StaticText(self, wx.ID_ANY, "Source:  ")

        self.n_mons = self.cfg_dict[0]['monitors']
        if self.n_mons < 1:
            self.n_mons = 1  # there must be at least one monitor
        self.monitorList = [
            'Monitor %s' % (int(m)) for m in range(1, self.n_mons + 1)
        ]  # make list

        self.currentSource = wx.TextCtrl(self,
                                         wx.ID_ANY,
                                         self.cfg_dict[mon_num]['source'],
                                         style=wx.TE_READONLY,
                                         size=(350, -1))  # get current source

        self.mon_choice = wx.ComboBox(self,
                                      wx.ID_ANY,
                                      choices=self.monitorList,
                                      size=(150, -1),
                                      style=wx.CB_DROPDOWN | wx.CB_READONLY
                                      | wx.CB_SORT)  # mon_num is 1-indexed
        self.mon_choice.Selection = self.mon_num - 1  # initial selection is monitor 1
        self.Bind(wx.EVT_COMBOBOX, self.onChangeMonitor, self.mon_choice)

        # -----------------------------------------------------------------------------  Play & Stop Buttons
        self.btnPlay = wx.Button(self, wx.ID_FORWARD, label="Play")
        self.Bind(wx.EVT_BUTTON, self.onPlay, self.btnPlay)
        if self.currentSource != '': self.btnPlay.Enable(True)
        else: self.btnPlay.Enable(False)

        self.btnStop = wx.Button(self, wx.ID_STOP, label="Stop")
        self.Bind(wx.EVT_BUTTON, self.onStop, self.btnStop)
        self.btnStop.Enable(False)

        # ---------------------------------------------------------------------------------  Add & Remove Monitor Buttons
        self.btnAdd = wx.Button(self, wx.ID_ANY, label='Add Monitor')
        self.Bind(wx.EVT_BUTTON, self.onAddMonitor, self.btnAdd)
        if self.n_mons < 9: self.btnAdd.Enable(True)
        else: self.btnAdd.Enable(False)

        self.btnDel = wx.Button(self, wx.ID_ANY, label='Remove Monitor')
        self.Bind(wx.EVT_BUTTON, self.onRemoveMonitor, self.btnDel)
        if self.n_mons > 0: self.btnDel.Enable(True)
        else: self.btnDel.Enable(False)

        # ------------------------------------------------------------------------------  Video Input Selectors
        # Select source Sizer named section

        self.rb1 = wx.RadioButton(self, wx.ID_ANY, 'Camera',
                                  style=wx.RB_GROUP)  # select camera source
        self.rb2 = wx.RadioButton(self, wx.ID_ANY,
                                  'File')  # select video file source
        self.rb3 = wx.RadioButton(self, wx.ID_ANY, 'Folder')

        # Webcam selection combobox
        self.WebcamsList = [
            'Webcam %s' % (int(w) + 1) for w in range(self.n_cams)
        ]

        self.source1 = wx.ComboBox(self,
                                   wx.ID_ANY,
                                   size=(300, -1),
                                   choices=self.WebcamsList,
                                   style=wx.EXPAND | wx.CB_DROPDOWN
                                   | wx.CB_READONLY | wx.CB_SORT)

        self.source2 = FileBrowseButton(
            self,
            id=wx.ID_ANY,
            labelText='',
            buttonText='Browse',
            toolTip='Type filename or click browse to choose video file',
            dialogTitle='Choose a video file',
            size=(300, -1),
            startDirectory=self.cfg_dict[self.mon_num]['datafolder'],
            fileMask='*.*',
            fileMode=wx.ALL,
            changeCallback=self.onChangeSource2,
            name='videoBrowseButton')

        self.source3 = DirBrowseButton(
            self,
            id=wx.ID_ANY,  # TODO: does this start in right directory?
            labelText='',
            size=(300, -1),
            style=wx.DD_DIR_MUST_EXIST,
            startDirectory=self.cfg_dict[self.mon_num]['datafolder'][0],
            changeCallback=self.onChangeSource3,
            name='dirBrowseButton')

        self.Bind(wx.EVT_BUTTON, self.onChangeSource1, self.rb1)
        self.Bind(wx.EVT_BUTTON, self.onChangeSource2, self.rb2)
        self.Bind(wx.EVT_BUTTON, self.onChangeSource3, self.rb3)

        self.Bind(wx.EVT_COMBOBOX, self.onChangeSource1, self.source1)
        self.Bind(wx.EVT_TEXT, self.onChangeSource2, self.source2)
        self.Bind(wx.EVT_TEXT, self.onChangeSource3, self.source3)

        # select folder containing 2D images
        self.controls = []  # list of radio buttons and sources
        self.controls.append((self.rb1, self.source1))
        self.controls.append((self.rb2, self.source2))
        self.controls.append((self.rb3, self.source3))
        """
        for radio, source in self.controls:
            self.Bind(wx.EVT_RADIOBUTTON, self.onChangeSource, radio)
            self.Bind(wx.EVT_TEXT, self.onChangeSource, source)
            radio.Enable(True)
            source.Enable(True)
        """
        # ------------------------------------------------------------------------  apply to monitor button
        self.applyButton = wx.Button(self, wx.ID_APPLY)
        self.applyButton.SetToolTip(wx.ToolTip('Apply to Monitor'))
        self.Bind(wx.EVT_BUTTON, self.onApplySource, self.applyButton)

        # ----------------------------------------------------------------------------------- start date
        self.txt_date = wx.StaticText(self, wx.ID_ANY, "Date:")
        self.start_date = wx.DatePickerCtrl(
            self,
            wx.ID_ANY,  # dt=self.start_datetime,
            style=wx.DP_DROPDOWN | wx.DP_SHOWCENTURY)
        #        self.Bind(wx.EVT_DATE_CHANGED, self.onDateTimeChanged, self.start_date)

        # ----------------------------------------------------------------------------------- start time
        self.txt_time = wx.StaticText(self, wx.ID_ANY, 'Time: (24-hr)')
        self.spinbtn = wx.SpinButton(self, wx.ID_ANY, wx.DefaultPosition,
                                     (-1, 20), wx.SP_VERTICAL)
        self.start_time = masked.TimeCtrl(self,
                                          wx.ID_ANY,
                                          value=self.start_datetime,
                                          name='time: \n24 hour control',
                                          fmt24hr=True,
                                          spinButton=self.spinbtn)
        #        self.Bind(masked.EVT_TIMEUPDATE, self.onDateTimeChanged, self.start_time)

        # ----------------------------------------------------------------------------------- frame rate
        self.fpsTxt = wx.StaticText(self, wx.ID_ANY,
                                    'Speed in frames per second:')
        self.fps = wx.TextCtrl(self, wx.ID_ANY)

        # ------------------------------------------------------------------------------------- activate tracking
        self.track = wx.CheckBox(self, wx.ID_ANY, 'Activate Tracking')
        #         self.track.Bind (wx.EVT_CHECKBOX, self.ontrack)

        # --------------------------------------------------------------------------------- sleep deprivation monitor
        """
        self.isSDMonitor = wx.CheckBox(self, wx.ID_ANY, 'Sleep Deprivation Monitor')
#        self.isSDMonitor.Bind ( wx.EVT_CHECKBOX, self.onSDMonitor)
        self.isSDMonitor.Enable(True)
        """

        # -------------------------------------------------------------------------------------------- tracking type
        self.trackDistance = wx.RadioButton(self,
                                            wx.ID_ANY,
                                            'Activity as distance traveled',
                                            style=wx.RB_GROUP)
        self.trackVirtualBM = wx.RadioButton(
            self, wx.ID_ANY, 'Activity as midline crossings count')
        self.trackPosition = wx.RadioButton(self, wx.ID_ANY,
                                            'Only position of flies')

        # ------------------------------------------------------------------------------------------choose mask file
        wildcard = 'PySolo Video mask file (*.msk)|*.msk|' \
                   'All files (*.*)|*.*'                # adding space in here will mess it up!
        self.pickMaskBrowser = FileBrowseButton(
            self,
            id=wx.ID_ANY,
            labelText='Select Mask File:',
            buttonText='Browse',
            toolTip='Type filename or click browse to choose mask file',
            dialogTitle='Choose a mask file',
            startDirectory=self.cfg_dict[self.mon_num]['datafolder'][0],
            fileMask=wildcard,
            fileMode=wx.ALL,
            changeCallback=None,
            name='maskBrowseButton')

        # ------------------------------------------------------------------------------------------choose output folder
        self.pickOutputBrowser = DirBrowseButton(
            self,
            id=wx.ID_ANY,
            style=wx.TAB_TRAVERSAL,
            labelText='Select Output Folder',
            dialogTitle='Choose an output folder',
            startDirectory=self.cfg_dict[self.mon_num]['datafolder'][0],
            name='OutputBrowseButton')

        # ---------------------------------------------------------------------------------  Save Button
        self.btnSave = wx.Button(self,
                                 wx.ID_ANY,
                                 label='Save Settings',
                                 size=(200, 50))
        self.Bind(wx.EVT_BUTTON, self.onSaveSettings, self.btnSave)
        if self.currentSource != '': self.btnSave.Enable(True)
        else: self.btnSave.Enable(False)

        self.update_cfgpanel(self.mon_num)  # update fields from cfg_dict

        # ######################################################        make  Labelled boxes
        sb_selectmonitor = wx.StaticBox(
            self, wx.ID_ANY, 'Select Monitor')  # monitor selection box
        sbSizer_selectmonitor = wx.StaticBoxSizer(sb_selectmonitor,
                                                  wx.VERTICAL)
        selectmonitorSizer_row1 = wx.BoxSizer(wx.HORIZONTAL)
        selectmonitorSizer_row2 = wx.BoxSizer(wx.HORIZONTAL)
        selectmonitorSizer_row3 = wx.BoxSizer(wx.HORIZONTAL)

        sb_videofile = wx.StaticBox(
            self, wx.ID_ANY,
            "Select Video Source")  # input video selection box
        sbSizer_videofile = wx.StaticBoxSizer(sb_videofile, wx.VERTICAL)
        sourceGridSizer = wx.FlexGridSizer(0, 2, 5, 5)

        sb_datetime = wx.StaticBox(
            self, wx.ID_ANY,
            "Video Start Date and Time")  # date time fps (top-left)
        sbSizer_datetime = wx.StaticBoxSizer(sb_datetime, wx.VERTICAL)
        dt_Sizer = wx.FlexGridSizer(3, 2, 5, 5)

        sb_track_txt = wx.StaticBox(
            self, wx.ID_ANY, "Set Tracking Parameters")  # tracking (top-right)
        sbSizer_trackoptions = wx.StaticBoxSizer(sb_track_txt, wx.HORIZONTAL)

        sb_calcbox = wx.StaticBox(
            self, wx.ID_ANY, 'Calculate fly activity as...')  # tracking type
        calcbox_sizer = wx.StaticBoxSizer(sb_calcbox, wx.VERTICAL)

        sb_mask_txt = wx.StaticBox(
            self, wx.ID_ANY, "Select Files")  # mask file and output folder
        sb_mask_sizer = wx.StaticBoxSizer(sb_mask_txt, wx.VERTICAL)

        sb_Save_sizer = wx.BoxSizer(wx.VERTICAL)

        # ##################################       Put items in boxes
        # ------------------------------------------------------------------------------- Put items in select monitor box
        selectmonitorSizer_row1.Add(self.mon_choice, 2, wx.ALIGN_TOP | wx.ALL,
                                    2)  # monitor dropdown box
        selectmonitorSizer_row1.Add(self.btnPlay, 1, wx.ALIGN_TOP | wx.ALL,
                                    2)  # play
        selectmonitorSizer_row1.Add(self.btnStop, 1, wx.ALIGN_TOP | wx.ALL,
                                    2)  # stop

        selectmonitorSizer_row2.Add(self.btnAdd, 2, wx.ALL, 2)
        selectmonitorSizer_row2.Add(self.btnDel, 2, wx.ALL, 2)
        selectmonitorSizer_row2.AddStretchSpacer(2)

        selectmonitorSizer_row3.Add(self.txt_source, 0,
                                    wx.EXPAND | wx.ALIGN_CENTER, 2)
        selectmonitorSizer_row3.Add(self.currentSource, 3,
                                    wx.EXPAND | wx.ALIGN_CENTER,
                                    2)  # current source

        sbSizer_selectmonitor.Add(selectmonitorSizer_row1, 1,
                                  wx.EXPAND | wx.ALIGN_LEFT,
                                  2)  # monitor selection box
        sbSizer_selectmonitor.Add(selectmonitorSizer_row2, 1,
                                  wx.EXPAND | wx.ALIGN_LEFT, 2)
        sbSizer_selectmonitor.AddSpacer(10)
        sbSizer_selectmonitor.Add(selectmonitorSizer_row3, 1,
                                  wx.EXPAND | wx.ALIGN_LEFT, 2)

        # ------------------------------------------------------------------------------ Put items in video source box
        for radio, source in self.controls:  # video source selections
            sourceGridSizer.Add(radio, 0, wx.ALL, 2)
            sourceGridSizer.Add(source, 0, wx.ALL | wx.EXPAND, 5)

        sbSizer_videofile.Add(sourceGridSizer, 0, wx.ALL | wx.ALIGN_RIGHT, 2)
        sbSizer_videofile.Add(self.applyButton, 0, wx.ALL | wx.ALIGN_RIGHT,
                              2)  # apply source button

        # ------------------------------------------------------------------------------ Put items in date time fps box
        dt_Sizer.Add(self.txt_date, 0, wx.ALL, 2)  # calendar
        dt_Sizer.Add(self.start_date, 0, wx.ALL, 2)

        dt_Sizer.Add(self.txt_time, 0, wx.ALL, 2)
        self.addWidgets(dt_Sizer, [self.start_time, self.spinbtn])  # clock

        dt_Sizer.Add(self.fpsTxt, 0, wx.EXPAND | wx.ALL, 2)
        dt_Sizer.Add(self.fps, 0, wx.EXPAND | wx.ALL, 2)

        sbSizer_datetime.Add(dt_Sizer, 0, wx.ALL, 2)

        # ------------------------------------------------------------------------------- Tracking Type
        calcbox_sizer.Add(self.trackDistance, 0,
                          wx.ALIGN_LEFT | wx.LEFT | wx.RIGHT | wx.TOP, 2)
        calcbox_sizer.Add(self.trackVirtualBM, 0,
                          wx.ALIGN_LEFT | wx.LEFT | wx.RIGHT | wx.TOP, 2)
        calcbox_sizer.Add(self.trackPosition, 0,
                          wx.ALIGN_LEFT | wx.LEFT | wx.RIGHT | wx.TOP, 2)

        # ------------------------------------------------------------------------------- Put items in tracking box
        sbSizer_trackoptions.Add(self.track, 0,
                                 wx.ALIGN_LEFT | wx.LEFT | wx.RIGHT | wx.TOP,
                                 2)
        #        sbSizer_trackoptions.Add (self.isSDMonitor, 0, wx.ALIGN_LEFT|wx.LEFT|wx.RIGHT|wx.TOP, 2 )

        # -------------------------------------------------------------------------------- Mask file
        sb_mask_sizer.Add(self.pickMaskBrowser, wx.EXPAND | wx.BOTTOM | wx.ALL,
                          2)
        sb_mask_sizer.Add(self.pickOutputBrowser,
                          wx.EXPAND | wx.BOTTOM | wx.ALL, 2)

        # -------------------------------------------------------------------------------- Save Add Remove buttons
        sb_Save_sizer.Add(self.btnSave, 0,
                          wx.ALIGN_CENTER | wx.ALIGN_BOTTOM | wx.ALL, 2)

        # -------------------------------------------------------------------------------- assemble left side
        leftSideSizer = wx.BoxSizer(wx.VERTICAL)  # left side of main
        leftSideSizer.Add(sbSizer_selectmonitor, 0,
                          wx.EXPAND | wx.TOP | wx.ALL, 2)
        leftSideSizer.AddSpacer(10)
        leftSideSizer.Add(sbSizer_videofile, 1, wx.EXPAND | wx.BOTTOM | wx.ALL,
                          2)

        # -------------------------------------------------------------------------------------  assemble right side top
        rightSideTopLeftSizer = wx.BoxSizer(wx.HORIZONTAL)  # top of right side
        rightSideTopLeftSizer.Add(sbSizer_datetime, 1,
                                  wx.EXPAND | wx.TOP | wx.ALL, 2)

        rightSideTopRightSizer = wx.BoxSizer(wx.VERTICAL)
        rightSideTopRightSizer.Add(sbSizer_trackoptions, 1,
                                   wx.EXPAND | wx.TOP | wx.ALL, 2)
        rightSideTopRightSizer.Add(calcbox_sizer, 1,
                                   wx.EXPAND | wx.TOP | wx.ALL, 2)

        rightSideTopSizer = wx.BoxSizer(wx.HORIZONTAL)
        rightSideTopSizer.Add(rightSideTopLeftSizer, 1,
                              wx.EXPAND | wx.TOP | wx.ALL, 2)
        rightSideTopSizer.Add(rightSideTopRightSizer, 1,
                              wx.EXPAND | wx.TOP | wx.ALL, 2)

        # -------------------------------------------------------------------------------------  assemble right side
        rightSideSizer = wx.BoxSizer(wx.VERTICAL)
        rightSideSizer.Add(rightSideTopSizer, 0, wx.EXPAND | wx.TOP | wx.ALL,
                           2)
        rightSideSizer.AddSpacer(15)
        rightSideSizer.Add(sb_mask_sizer, 0, wx.EXPAND | wx.TOP | wx.ALL, 2)
        rightSideSizer.AddSpacer(15)
        rightSideSizer.Add(sb_Save_sizer, 0,
                           wx.EXPAND | wx.ALIGN_BOTTOM | wx.ALL, 2)

        # -------------------------------------------------------------------------------------- assemble whole panel
        configPanelSizer = wx.BoxSizer(wx.HORIZONTAL)  # main
        configPanelSizer.Add(leftSideSizer, 0, wx.EXPAND | wx.TOP | wx.ALL, 2)
        configPanelSizer.AddSpacer(15)
        configPanelSizer.Add(rightSideSizer, 0, wx.EXPAND | wx.TOP | wx.ALL, 2)

        self.SetSizer(configPanelSizer)
        self.Layout()
Exemplo n.º 27
0
    def __init__(self, windowtitle, entries):
        wx.Dialog.__init__(self,
                           None,
                           title=windowtitle,
                           style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER)
        self.entries = entries
        self.widgets = []
        self.response = []
        self.notebook = None

        if entries[0][0] != 'wxnotebook':
            self.sizer = wx.FlexGridSizer(cols=2)
            self.panel = self
        else:
            self.sizer = None
            self.notebook = wx.Notebook(self)
            #wait for the notebook entry...
            pass
        disableditems = []
        for entry in entries:
            #for readability...
            _widget = entry[0]
            _label = entry[1]
            _range = entry[2]
            _default = entry[3]
            _typ = entry[4]
            if len(entry) > 5:
                _extra = entry[5:]
            if entry[0] == 'wxnotebook':
                if self.sizer != None:
                    self.sizer.Fit(self.panel)
                    self.sizer.Layout()
                self.panel = wx.Panel(self.notebook)
                self.widgets.append(self.panel)
                self.sizer = wx.FlexGridSizer(cols=2)
                self.widgets[-1].SetSizer(self.sizer)
                self.notebook.AddPage(self.widgets[-1], _label, False)
            elif entry[0] == 'wxcombo':
                self.widgets.append(
                    wx.ComboBox(self.panel,
                                choices=_range.split('|'),
                                value=""))
                self.widgets[-1].SetValue(str(_default))
                self.sizer.Add(
                    wx.StaticText(self.panel, label=_label), 1,
                    wx.ALL | wx.CENTER | wx.EXPAND | wx.ALIGN_CENTER_VERTICAL,
                    5)
                self.sizer.Add(
                    self.widgets[-1], 1,
                    wx.ALL | wx.CENTER | wx.EXPAND | wx.ALIGN_CENTER_VERTICAL,
                    5)
            elif entry[0] == 'wxentry':
                self.widgets.append(
                    wx.TextCtrl(self.panel, value=str(_default)))
                self.widgets[-1].SetValue(str(_default))
                self.sizer.Add(
                    wx.StaticText(self.panel, label=_label), 1,
                    wx.ALL | wx.CENTER | wx.EXPAND | wx.ALIGN_CENTER_VERTICAL,
                    5)
                self.sizer.Add(
                    self.widgets[-1], 1,
                    wx.ALL | wx.CENTER | wx.EXPAND | wx.ALIGN_CENTER_VERTICAL,
                    5)
            elif entry[0] == 'wxspin':
                if _typ == 'int':
                    self.widgets.append(wx.SpinCtrl(self.panel,\
                                                    min=int(_range.split('|')[0]),\
                                                    max=int(_range.split('|')[1]),\
                                                    value=str(_default)))
                elif _typ == 'float':
                    self.widgets.append(wx.SpinCtrlDouble(self.panel,-1, \
                                                    min=float(_range.split('|')[0]),\
                                                    max=float(_range.split('|')[1]),\
                                                    inc=float(_range.split('|')[2]),\
                                                    value=str(_default)))
                    self.widgets[-1].SetDigits(get_digits(
                        _range.split('|')[2]))
                self.sizer.Add(
                    wx.StaticText(self.panel, label=_label), 1,
                    wx.ALL | wx.CENTER | wx.EXPAND | wx.ALIGN_CENTER_VERTICAL,
                    5)
                self.sizer.Add(
                    self.widgets[-1], 1,
                    wx.ALL | wx.CENTER | wx.EXPAND | wx.ALIGN_CENTER_VERTICAL,
                    5)
            elif entry[0] == 'wxhscale':
                self.widgets.append(wx.Slider(self.panel, minValue=int(_range.split('|')[0]),\
                                                            maxValue=int(_range.split('|')[1]),\
                                                            value=int(_default),\
                                                            size=(250, -1),\
                                                            style=wx.SL_HORIZONTAL|wx.SL_AUTOTICKS|wx.SL_LABELS))
                self.sizer.Add(
                    wx.StaticText(self.panel, label=_label), 1,
                    wx.ALL | wx.CENTER | wx.EXPAND | wx.ALIGN_CENTER_VERTICAL,
                    5)
                self.sizer.Add(
                    self.widgets[-1], 1,
                    wx.ALL | wx.CENTER | wx.EXPAND | wx.ALIGN_CENTER_VERTICAL,
                    5)
            elif entry[0] == 'wxcheck':
                self.widgets.append(wx.CheckBox(self.panel, label=''))
                self.widgets[-1].SetValue(_default)
                self.sizer.Add(
                    wx.StaticText(self.panel, label=_label), 1,
                    wx.ALL | wx.CENTER | wx.EXPAND | wx.ALIGN_CENTER_VERTICAL,
                    5)
                self.sizer.Add(
                    self.widgets[-1], 1,
                    wx.ALL | wx.CENTER | wx.EXPAND | wx.ALIGN_CENTER_VERTICAL,
                    5)
                if _range != None:
                    self.widgets[-1].SetName(_range)
                    self.widgets[-1].Bind(wx.EVT_CHECKBOX, self.OnCheckbox)
                    #_range='1|2|3|4' items 1,2,3,4 should be disabled when check is false
                    for x in _range.split('|'):
                        if int(x) > 0 and _default == False:
                            disableditems.append(int(x))
                        elif int(x) < 0 and _default == True:
                            disableditems.append(int(math.fabs(int(x))))
            elif entry[0] == 'wxradio':
                self.widgets.append(
                    wx.RadioBox(self.panel,
                                label='',
                                choices=_range.split('|'),
                                style=wx.RA_SPECIFY_COLS,
                                majorDimension=1))
                self.widgets[-1].SetSelection(
                    _range.split('|').index(_default))
                self.sizer.Add(
                    wx.StaticText(self.panel, label=_label), 1,
                    wx.ALL | wx.CENTER | wx.EXPAND | wx.ALIGN_CENTER_VERTICAL,
                    5)
                self.sizer.Add(
                    self.widgets[-1], 1,
                    wx.ALL | wx.CENTER | wx.EXPAND | wx.ALIGN_CENTER_VERTICAL,
                    5)
            elif entry[0] == 'wxcolor':
                self.widgets.append(wx.ColourPickerCtrl(self.panel))
                self.widgets[-1].SetColour(autocolor(_default, 'str'))
                self.sizer.Add(
                    wx.StaticText(self.panel, label=_label), 1,
                    wx.ALL | wx.CENTER | wx.EXPAND | wx.ALIGN_CENTER_VERTICAL,
                    5)
                self.sizer.Add(
                    self.widgets[-1], 1,
                    wx.ALL | wx.CENTER | wx.EXPAND | wx.ALIGN_CENTER_VERTICAL,
                    5)
            elif entry[0] == 'wxdate':
                self.widgets.append(wx.adv.DatePickerCtrl(self.panel))
                dt = wx.DateTime().Today()
                dt.SetYear(int(_default.split('-')[0]))
                dt.SetMonth(int(_default.split('-')[1]))
                dt.SetDay(int(_default.split('-')[2]))
                self.widgets[-1].SetValue(dt)
                self.sizer.Add(
                    wx.StaticText(self.panel, label=_label), 1,
                    wx.ALL | wx.CENTER | wx.EXPAND | wx.ALIGN_CENTER_VERTICAL,
                    5)
                self.sizer.Add(
                    self.widgets[-1], 1,
                    wx.ALL | wx.CENTER | wx.EXPAND | wx.ALIGN_CENTER_VERTICAL,
                    5)
            elif entry[0] == 'wxcalendar':
                self.widgets.append(wx.adv.CalendarCtrl(self.panel))
                dt = wx.DateTime().Today()
                dt.SetYear(int(_default.split('-')[0]))
                dt.SetMonth(int(_default.split('-')[1]) - 1)
                dt.SetDay(int(_default.split('-')[2]))
                self.widgets[-1].SetDate(dt)
                self.sizer.Add(
                    wx.StaticText(self.panel, label=_label), 1,
                    wx.ALL | wx.CENTER | wx.EXPAND | wx.ALIGN_CENTER_VERTICAL,
                    5)
                self.sizer.Add(
                    self.widgets[-1], 1,
                    wx.ALL | wx.CENTER | wx.EXPAND | wx.ALIGN_CENTER_VERTICAL,
                    5)
            elif entry[0] == 'wxtime':
                self.widgets.append(wxmasked.TimeCtrl(self.panel,
                                                      fmt24hr=True))
                self.widgets[-1].SetValue(_default)
                self.sizer.Add(
                    wx.StaticText(self.panel, label=_label), 1,
                    wx.ALL | wx.CENTER | wx.EXPAND | wx.ALIGN_CENTER_VERTICAL,
                    5)
                self.sizer.Add(
                    self.widgets[-1], 1,
                    wx.ALL | wx.CENTER | wx.EXPAND | wx.ALIGN_CENTER_VERTICAL,
                    5)
            elif entry[0] == 'wxlabel':
                self.widgets.append(wx.StaticText(self.panel, label=_default))
                self.sizer.Add(
                    wx.StaticText(self.panel, label=_label), 1,
                    wx.ALL | wx.CENTER | wx.EXPAND | wx.ALIGN_CENTER_VERTICAL,
                    5)
                self.sizer.Add(
                    self.widgets[-1], 1,
                    wx.ALL | wx.CENTER | wx.EXPAND | wx.ALIGN_CENTER_VERTICAL,
                    5)
            elif entry[0] == 'wximage':
                img = wx.Image(_default)
                img.Rescale(int(_range.split('|')[0]),
                            int(_range.split('|')[1]))
                bmp = wx.Bitmap(img)
                self.widgets.append(
                    wx.StaticBitmap(self.panel,
                                    -1,
                                    bmp,
                                    wx.DefaultPosition,
                                    style=wx.BITMAP_TYPE_PNG))
                self.sizer.Add(
                    wx.StaticText(self.panel, label=_label), 1,
                    wx.ALL | wx.CENTER | wx.EXPAND | wx.ALIGN_CENTER_VERTICAL,
                    5)
                self.sizer.Add(
                    self.widgets[-1], 1,
                    wx.ALL | wx.CENTER | wx.EXPAND | wx.ALIGN_CENTER_VERTICAL,
                    5)
            elif entry[0] == 'wximage64':
                img = wx.ImageFromStream(
                    cStringIO.StringIO(base64.b64decode(b64)))
                img.Rescale(int(_range.split('|')[0]),
                            int(_range.split('|')[1]))
                bmp = wx.BitmapFromImage(img)
                self.widgets.append(
                    wx.StaticBitmap(self.panel,
                                    -1,
                                    bmp,
                                    wx.DefaultPosition,
                                    style=wx.BITMAP_TYPE_PNG))
                self.sizer.Add(
                    wx.StaticText(self.panel, label=_label), 1,
                    wx.ALL | wx.CENTER | wx.EXPAND | wx.ALIGN_CENTER_VERTICAL,
                    5)
                self.sizer.Add(
                    self.widgets[-1], 1,
                    wx.ALL | wx.CENTER | wx.EXPAND | wx.ALIGN_CENTER_VERTICAL,
                    5)
            elif entry[0] == 'wxlist':
                self.widgets.append(
                    wx.ListBox(self.panel, choices=_range.split('|')))
                self.widgets[-1].SetSelection(
                    _range.split('|').index(_default))
                self.sizer.Add(
                    wx.StaticText(self.panel, label=_label), 1,
                    wx.ALL | wx.CENTER | wx.EXPAND | wx.ALIGN_CENTER_VERTICAL,
                    5)
                self.sizer.Add(
                    self.widgets[-1], 1,
                    wx.ALL | wx.CENTER | wx.EXPAND | wx.ALIGN_CENTER_VERTICAL,
                    5)
            elif entry[0] == 'wxfile':
                if len(_range) != 0:
                    self.widgets.append(
                        wx.FilePickerCtrl(self.panel, wildcard=_range))
                else:
                    self.widgets.append(
                        wx.FilePickerCtrl(self.panel,
                                          wildcard=_range,
                                          style=wx.FLP_SAVE))
                self.widgets[-1].SetPath(_default)
                self.sizer.Add(
                    wx.StaticText(self.panel, label=_label), 1,
                    wx.ALL | wx.CENTER | wx.EXPAND | wx.ALIGN_CENTER_VERTICAL,
                    5)
                self.sizer.Add(
                    self.widgets[-1], 1,
                    wx.ALL | wx.CENTER | wx.EXPAND | wx.ALIGN_CENTER_VERTICAL,
                    5)
            elif entry[0] == 'wxdir':
                self.widgets.append(wx.DirPickerCtrl(self.panel))
                self.widgets[-1].SetPath(_default)
                self.sizer.Add(
                    wx.StaticText(self.panel, label=_label), 1,
                    wx.ALL | wx.CENTER | wx.EXPAND | wx.ALIGN_CENTER_VERTICAL,
                    5)
                self.sizer.Add(
                    self.widgets[-1], 1,
                    wx.ALL | wx.CENTER | wx.EXPAND | wx.ALIGN_CENTER_VERTICAL,
                    5)
            elif entry[0] == 'wxchecklist':
                self.widgets.append(
                    wx.CheckListBox(self.panel, choices=_range.split('|')))
                #try co convert _default to list of int
                if _default.split('|')[0].isdigit():
                    indexes = [int(i) for i in _default.split('|')]
                    self.widgets[-1].SetCheckedItems(indexes)
                else:
                    indexes = [
                        _range.split('|').index(item)
                        for item in _default.split('|')
                    ]
                    self.widgets[-1].SetCheckedItems(indexes)
                self.sizer.Add(
                    wx.StaticText(self.panel, label=_label), 1,
                    wx.ALL | wx.CENTER | wx.EXPAND | wx.ALIGN_CENTER_VERTICAL,
                    5)
                self.sizer.Add(
                    self.widgets[-1], 1,
                    wx.ALL | wx.CENTER | wx.EXPAND | wx.ALIGN_CENTER_VERTICAL,
                    5)
            # any argument after typ_ is considered as tooltip, then  extra argument
            if len(entry) > 5:
                self.widgets[-1].SetToolTip(wx.ToolTip(entry[5]))
        hbox = wx.BoxSizer(wx.VERTICAL)
        if self.notebook == None:
            self.sizer.Fit(self)
            hbox.Add(self.sizer,
                     proportion=1,
                     flag=wx.ALL | wx.EXPAND,
                     border=5)
        else:
            if self.sizer != None:
                self.sizer.Fit(self.panel)
                self.sizer.Layout()
            hbox.Add(self.notebook,
                     proportion=1,
                     flag=wx.ALL | wx.EXPAND,
                     border=5)
        #disabled any items marked as disabled by checkboxes
        for i in disableditems:
            self.widgets[i].Disable()
        okBtn = wx.Button(self, wx.ID_OK, "OK")
        okBtn.SetDefault()
        cancelButton = wx.Button(self, wx.ID_CANCEL, "Cancel")
        vbox = wx.BoxSizer(wx.HORIZONTAL)
        vbox.Add(okBtn, proportion=1, flag=wx.ALL | wx.EXPAND, border=5)
        vbox.Add(cancelButton, proportion=1, flag=wx.ALL | wx.EXPAND, border=5)
        hbox.Add(vbox, flag=wx.EXPAND)
        self.SetSizer(hbox)
        self.sizer.Layout()
        hbox.Layout()
        self.sizer.Fit(self)
        hbox.Fit(self)
        self.ProcessEvent(wx.SizeEvent((-1, -1)))
Exemplo n.º 28
0
 def test_timectrlCtor(self):
     t = m.TimeCtrl(self.frame)
     t = m.TimeCtrl(self.frame, -1, "18:00:00")
     t = m.TimeCtrl(self.frame, style=wx.TE_READONLY)
Exemplo n.º 29
0
    def __init__(self, parent):

        wx.Dialog.__init__(self,
                           parent,
                           id=wx.ID_ANY,
                           title=u"Data Filter",
                           pos=wx.Point(599, 384),
                           size=wx.Size(382, 500),
                           style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER)

        self.SetSizeHintsSz(wx.Size(358, 452), wx.DefaultSize)

        bSizer1 = wx.BoxSizer(wx.VERTICAL)

        bSizer3 = wx.BoxSizer(wx.VERTICAL)

        bsValueThresh = wx.BoxSizer(wx.HORIZONTAL)

        self.rbThreshold = wx.RadioButton(self, wx.ID_ANY, wx.EmptyString,
                                          wx.Point(10, 8), wx.DefaultSize,
                                          wx.RB_GROUP)
        self.rbThreshold.SetValue(True)
        bsValueThresh.Add(self.rbThreshold, 0, wx.ALL, 5)

        sbThreshold = wx.StaticBoxSizer(
            wx.StaticBox(self, wx.ID_ANY, u"Value Threshold"), wx.VERTICAL)

        fgSizer1 = wx.FlexGridSizer(0, 2, 0, 0)
        fgSizer1.SetFlexibleDirection(wx.HORIZONTAL)
        fgSizer1.SetNonFlexibleGrowMode(wx.FLEX_GROWMODE_SPECIFIED)

        self.lblChangegt = wx.StaticText(self, wx.ID_ANY, u"Value >",
                                         wx.DefaultPosition, wx.DefaultSize, 0)
        self.lblChangegt.Wrap(-1)
        fgSizer1.Add(self.lblChangegt, 0, wx.ALL, 5)

        self.txtThreshValGT = wx.TextCtrl(self, wx.ID_ANY,
                                          wx.EmptyString, wx.DefaultPosition,
                                          wx.Size(248, -1), 0)
        fgSizer1.Add(self.txtThreshValGT, 1, wx.ALL | wx.EXPAND, 5)

        self.lblChangelt = wx.StaticText(self, wx.ID_ANY, u"Value <",
                                         wx.DefaultPosition, wx.DefaultSize, 0)
        self.lblChangelt.Wrap(-1)
        fgSizer1.Add(self.lblChangelt, 0, wx.ALL, 5)

        self.txtThreshValLT = wx.TextCtrl(self, wx.ID_ANY,
                                          wx.EmptyString, wx.DefaultPosition,
                                          wx.Size(248, -1), 0)
        fgSizer1.Add(self.txtThreshValLT, 1, wx.ALL | wx.EXPAND, 5)

        sbThreshold.Add(fgSizer1, 0, wx.EXPAND, 5)

        bsValueThresh.Add(sbThreshold, 1, 0, 5)

        bSizer3.Add(bsValueThresh, 1, wx.EXPAND, 5)

        bsGaps = wx.BoxSizer(wx.HORIZONTAL)

        self.rbDataGaps = wx.RadioButton(self, wx.ID_ANY, wx.EmptyString,
                                         wx.DefaultPosition, wx.DefaultSize, 0)
        bsGaps.Add(self.rbDataGaps, 1, wx.ALL, 5)

        sbGaps = wx.StaticBoxSizer(wx.StaticBox(self, wx.ID_ANY, u"Data Gaps"),
                                   wx.VERTICAL)

        fgSizer2 = wx.FlexGridSizer(0, 2, 0, 0)
        fgSizer2.SetFlexibleDirection(wx.HORIZONTAL)
        fgSizer2.SetNonFlexibleGrowMode(wx.FLEX_GROWMODE_SPECIFIED)

        self.lblGapsVal = wx.StaticText(self, wx.ID_ANY, u"Value:",
                                        wx.DefaultPosition, wx.DefaultSize, 0)
        self.lblGapsVal.Wrap(-1)
        fgSizer2.Add(self.lblGapsVal, 0, wx.ALL, 5)

        self.txtGapsVal = wx.TextCtrl(self, wx.ID_ANY, wx.EmptyString,
                                      wx.DefaultPosition, wx.Size(230, -1), 0)
        fgSizer2.Add(self.txtGapsVal, 0, wx.ALL, 5)

        self.lblGapsTime = wx.StaticText(self, wx.ID_ANY, u"Time Period:",
                                         wx.DefaultPosition, wx.DefaultSize, 0)
        self.lblGapsTime.Wrap(-1)
        fgSizer2.Add(self.lblGapsTime, 0, wx.ALL, 5)

        cbGapTimeChoices = [u"second", u"minute", u"hour", u"day"]
        self.cbGapTime = wx.ComboBox(self, wx.ID_ANY,
                                     u"second", wx.DefaultPosition,
                                     wx.Size(230, -1), cbGapTimeChoices,
                                     wx.CB_READONLY)
        fgSizer2.Add(self.cbGapTime, 0, wx.ALL, 5)

        sbGaps.Add(fgSizer2, 1, wx.EXPAND, 5)

        bsGaps.Add(sbGaps, 0, 0, 5)

        bSizer3.Add(bsGaps, 0, 0, 5)

        bsDate = wx.BoxSizer(wx.HORIZONTAL)

        self.rbDate = wx.RadioButton(self, wx.ID_ANY, wx.EmptyString,
                                     wx.DefaultPosition, wx.DefaultSize, 0)
        bsDate.Add(self.rbDate, 0, wx.ALL, 5)

        sbDate = wx.StaticBoxSizer(wx.StaticBox(self, wx.ID_ANY, u"Date"),
                                   wx.VERTICAL)

        fgSizer3 = wx.FlexGridSizer(0, 4, 0, 0)
        fgSizer3.SetFlexibleDirection(wx.HORIZONTAL)
        fgSizer3.SetNonFlexibleGrowMode(wx.FLEX_GROWMODE_SPECIFIED)

        self.lblDateAfter = wx.StaticText(self, wx.ID_ANY, u"Start:",
                                          wx.DefaultPosition, wx.DefaultSize,
                                          0)
        self.lblDateAfter.Wrap(-1)
        fgSizer3.Add(self.lblDateAfter, 0, wx.ALL, 5)

        self.dpAfter = wx.DatePickerCtrl(self, wx.ID_ANY, wx.DefaultDateTime,
                                         wx.DefaultPosition, wx.Size(150, -1),
                                         wx.DP_DROPDOWN | wx.DP_SHOWCENTURY)
        fgSizer3.Add(self.dpAfter, 0, wx.ALL, 5)

        self.sbAfter = wx.SpinButton(self, wx.ID_ANY, wx.DefaultPosition,
                                     wx.Size(15, -1), 0)

        self.tpAfter = masked.TimeCtrl(self,
                                       wx.ID_ANY,
                                       pos=wx.DefaultPosition,
                                       size=wx.Size(80, -1),
                                       name="24 hour control",
                                       fmt24hr=True,
                                       spinButton=self.sbAfter,
                                       oob_color="White")
        # self.tpAfter.Wrap( -1 )
        fgSizer3.Add(self.tpAfter, 0, wx.ALL, 5)

        fgSizer3.Add(self.sbAfter, 0, wx.ALL, 5)

        self.lblDateBefore = wx.StaticText(self, wx.ID_ANY, u"End: ",
                                           wx.DefaultPosition, wx.DefaultSize,
                                           0)
        self.lblDateBefore.Wrap(-1)
        fgSizer3.Add(self.lblDateBefore, 0, wx.ALL, 5)

        self.dpBefore = wx.DatePickerCtrl(self, wx.ID_ANY, wx.DefaultDateTime,
                                          wx.DefaultPosition, wx.Size(150, -1),
                                          wx.DP_DROPDOWN | wx.DP_SHOWCENTURY)
        fgSizer3.Add(self.dpBefore, 0, wx.ALL, 5)
        self.sbBefore = wx.SpinButton(self, wx.ID_ANY, wx.DefaultPosition,
                                      wx.Size(15, -1), wx.SP_WRAP)
        self.tpBefore = masked.TimeCtrl(self,
                                        wx.ID_ANY,
                                        pos=wx.DefaultPosition,
                                        size=wx.Size(80, -1),
                                        name="24 hour control",
                                        fmt24hr=True,
                                        spinButton=self.sbBefore,
                                        oob_color='White')
        fgSizer3.Add(self.tpBefore, 0, wx.ALL, 5)
        fgSizer3.Add(self.sbBefore, 0, wx.ALL, 5)
        sbDate.Add(fgSizer3, 1, wx.EXPAND, 5)

        bsDate.Add(sbDate, 1, wx.EXPAND, 5)

        bSizer3.Add(bsDate, 0, wx.EXPAND, 5)

        bsValChange = wx.BoxSizer(wx.HORIZONTAL)

        self.rbVChangeThresh = wx.RadioButton(self, wx.ID_ANY, wx.EmptyString,
                                              wx.DefaultPosition,
                                              wx.DefaultSize, 0)
        bsValChange.Add(self.rbVChangeThresh, 0, wx.ALL, 5)

        sbValChange = wx.StaticBoxSizer(
            wx.StaticBox(self, wx.ID_ANY, u"Value Change Threshold"),
            wx.VERTICAL)

        fgSizer4 = wx.FlexGridSizer(0, 2, 0, 0)
        fgSizer4.SetFlexibleDirection(wx.HORIZONTAL)
        fgSizer4.SetNonFlexibleGrowMode(wx.FLEX_GROWMODE_SPECIFIED)

        self.lblChangeGT = wx.StaticText(self, wx.ID_ANY, u"Value >",
                                         wx.DefaultPosition, wx.DefaultSize, 0)
        self.lblChangeGT.Wrap(-1)
        fgSizer4.Add(self.lblChangeGT, 0, wx.ALL, 5)

        self.txtVChangeGT = wx.TextCtrl(self, wx.ID_ANY,
                                        wx.EmptyString, wx.DefaultPosition,
                                        wx.Size(248, -1), 0)
        fgSizer4.Add(self.txtVChangeGT, 0, wx.ALL, 5)

        self.lblChangeLT = wx.StaticText(self, wx.ID_ANY, u"Value <",
                                         wx.DefaultPosition, wx.DefaultSize, 0)
        self.lblChangeLT.Wrap(-1)
        fgSizer4.Add(self.lblChangeLT, 0, wx.ALL, 5)

        self.txtVChangeLT = wx.TextCtrl(self, wx.ID_ANY,
                                        wx.EmptyString, wx.DefaultPosition,
                                        wx.Size(248, -1), 0)
        fgSizer4.Add(self.txtVChangeLT, 0, wx.ALL, 5)

        sbValChange.Add(fgSizer4, 1, wx.EXPAND, 5)

        bsValChange.Add(sbValChange, 1, 0, 5)

        bSizer3.Add(bsValChange, 1, wx.EXPAND, 5)

        self.chkToggleFilterSelection = wx.CheckBox(
            self, wx.ID_ANY, u"Filter from previous filter",
            wx.DefaultPosition, wx.DefaultSize, 0)
        bSizer3.Add(self.chkToggleFilterSelection, 1, wx.ALL | wx.EXPAND, 5)

        bsButtons = wx.BoxSizer(wx.HORIZONTAL)

        self.btnOK = wx.Button(self, wx.ID_ANY, u"OK", wx.DefaultPosition,
                               wx.Size(64, 23), 0)
        bsButtons.Add(self.btnOK, 1, wx.ALL | wx.EXPAND, 5)

        self.btnCancel = wx.Button(self, wx.ID_ANY, u"Cancel",
                                   wx.DefaultPosition, wx.Size(64, 23), 0)
        bsButtons.Add(self.btnCancel, 1, wx.ALL | wx.EXPAND, 5)

        self.btnApply = wx.Button(self, wx.ID_ANY, u"Apply",
                                  wx.DefaultPosition, wx.Size(64, 23), 0)
        bsButtons.Add(self.btnApply, 1, wx.ALL | wx.EXPAND, 5)

        self.btnClear = wx.Button(self, wx.ID_ANY, u"Clear Filter",
                                  wx.DefaultPosition, wx.Size(64, 23), 0)
        bsButtons.Add(self.btnClear, 1, wx.ALL | wx.EXPAND, 5)

        bSizer3.Add(bsButtons, 1, wx.EXPAND, 0)

        bSizer1.Add(bSizer3, 1, wx.EXPAND, 5)

        self.SetSizer(bSizer1)
        self.Layout()

        self.Centre(wx.BOTH)  # Connect Events
        self.txtThreshValGT.Bind(wx.EVT_SET_FOCUS, self.onSetFocus)
        self.txtThreshValLT.Bind(wx.EVT_SET_FOCUS, self.onSetFocus)
        self.txtGapsVal.Bind(wx.EVT_SET_FOCUS, self.onSetFocus)
        self.cbGapTime.Bind(wx.EVT_SET_FOCUS, self.onSetFocus)
        self.dpAfter.Bind(wx.EVT_SET_FOCUS, self.onSetFocus)
        self.tpAfter.Bind(wx.EVT_SET_FOCUS, self.onSetFocus)
        self.sbAfter.Bind(wx.EVT_SET_FOCUS, self.onSetFocus)
        self.dpBefore.Bind(wx.EVT_SET_FOCUS, self.onSetFocus)
        self.tpBefore.Bind(wx.EVT_SET_FOCUS, self.onSetFocus)
        self.sbBefore.Bind(wx.EVT_SET_FOCUS, self.onSetFocus)
        self.txtVChangeGT.Bind(wx.EVT_SET_FOCUS, self.onSetFocus)
        self.txtVChangeLT.Bind(wx.EVT_SET_FOCUS, self.onSetFocus)
        self.chkToggleFilterSelection.Bind(wx.EVT_CHECKBOX, self.onCheckBox)
        self.btnClear.Bind(wx.EVT_BUTTON, self.onBtnClearButton)
        self.btnOK.Bind(wx.EVT_BUTTON, self.onBtnOKButton)
        self.btnCancel.Bind(wx.EVT_BUTTON, self.onBtnCancelButton)
        self.btnApply.Bind(wx.EVT_BUTTON, self.onBtnApplyButton)
Exemplo n.º 30
0
  def setupPanel(self):
#--
    panel = wx.Panel(self, -1,size=(330,480))
    panel.SetBackgroundColour('white')
    #v1
    box = wx.StaticBox(panel,-1,u'抓取设置')
    boxsizerv1 = wx.StaticBoxSizer(box,wx.VERTICAL)
    btnv1 = wx.Button(panel, -1, u'关注用户新作')
    btnv2 = wx.Button(panel, -1, u'综合排行')
    btnv3 = wx.Button(panel, -1, u'插画排行')
    btnv4 = wx.Button(panel, -1, u'漫画排行')
    btnv5 = wx.Button(panel, -1, u'动图排行')

    panel.Bind(wx.EVT_BUTTON, self.OnButton1, btnv1)
    panel.Bind(wx.EVT_BUTTON, self.OnButton2, btnv2)
    panel.Bind(wx.EVT_BUTTON, self.OnButton3, btnv3)
    panel.Bind(wx.EVT_BUTTON, self.OnButton4, btnv4)
    panel.Bind(wx.EVT_BUTTON, self.OnButton5, btnv5)

    boxsizerv1.Add(btnv1, proportion=0, flag=wx.ALL, border=5)
    boxsizerv1.Add(btnv2, proportion=0, flag=wx.ALL, border=5)
    boxsizerv1.Add(btnv3, proportion=0, flag=wx.ALL, border=5)
    boxsizerv1.Add(btnv4, proportion=0, flag=wx.ALL, border=5)
    boxsizerv1.Add(btnv5, proportion=0, flag=wx.ALL, border=5)
    #v2
    boxsizerv2 = wx.BoxSizer(wx.VERTICAL)
    box = wx.StaticBox(panel,-1,u'用户信息')

    boxsizerv3 = wx.StaticBoxSizer(box,wx.VERTICAL)
    boxsizerh2 = wx.BoxSizer(wx.HORIZONTAL)
    boxsizerh3 = wx.BoxSizer(wx.HORIZONTAL)
    text1 = wx.StaticText(panel,-1,u'用户名:')
    self.textfiled1 = wx.TextCtrl(panel, -1, username, size=(76,-1))

    boxsizerh2.Add(text1,proportion=0, flag=wx.ALL, border=5)
    boxsizerh2.Add(self.textfiled1,proportion=0, flag=wx.ALL, border=5)

    text2 = wx.StaticText(panel,-1,u'   密码:')
    self.textfiled2 = wx.TextCtrl(panel, -1, password, style=wx.TE_PASSWORD, size=(76,-1))
    boxsizerh3.Add(text2,proportion=0, flag=wx.ALL, border=5)
    boxsizerh3.Add(self.textfiled2,proportion=0, flag=wx.ALL, border=5)
    boxsizerv3.Add(boxsizerh2)
    boxsizerv3.Add(boxsizerh3)

    box = wx.StaticBox(panel,-1,u'时间设置')
    boxsizerv4 = wx.StaticBoxSizer(box,wx.VERTICAL)

    text1 = wx.StaticText( panel, -1, u'开始时间:')
    self.time1 = masked.TimeCtrl( panel, -1,value=starttime, name="start time",fmt24hr=True, )
    h = self.time1.GetSize().height
    spin1 = wx.SpinButton( panel, -1, wx.DefaultPosition, (-1,h), wx.SP_VERTICAL )
    self.time1.BindSpinButton( spin1 )

    text2 = wx.StaticText( panel, -1, u'结束时间:')
    spin2 = wx.SpinButton( panel, -1, wx.DefaultPosition, (-1,h), wx.SP_VERTICAL )
    self.time2 = masked.TimeCtrl(panel, -1, value=endtime, name="end time", fmt24hr=True,spinButton = spin2)

    grid = wx.FlexGridSizer( cols=2, hgap=10, vgap=5 )
    grid.Add( text1, 0, wx.ALIGN_RIGHT )
    hbox1 = wx.BoxSizer( wx.HORIZONTAL )
    hbox1.Add( self.time1, 0, wx.ALIGN_CENTRE )
    hbox1.Add( spin1, 0, wx.ALIGN_CENTRE )
    grid.Add( hbox1, 0, wx.LEFT )

    grid.Add( text2, 0, wx.ALIGN_RIGHT|wx.TOP|wx.BOTTOM )
    hbox2 = wx.BoxSizer( wx.HORIZONTAL )
    hbox2.Add( self.time2, 0, wx.ALIGN_CENTRE )
    hbox2.Add( spin2, 0, wx.ALIGN_CENTRE )
    grid.Add( hbox2, 0, wx.LEFT )
    boxsizerv4.Add(grid)

    box = wx.StaticBox(panel,-1,u'图片大小')
    boxsizerv5 = wx.StaticBoxSizer(box,wx.VERTICAL)
    sampleList = [u'原图', u'中等', u'缩略图']
    self.ch = wx.Choice(panel, -1, size=(135, 27), choices = sampleList)
    self.ch.SetSelection(picsize)
    boxsizerv5.Add(self.ch)


    boxsizerv2.Add(boxsizerv3)
    boxsizerv2.Add(boxsizerv4)
    boxsizerv2.Add(boxsizerv5)


    boxsizerh1 = wx.BoxSizer(wx.HORIZONTAL)
    boxsizerh1.Add((10,20))
    boxsizerh1.Add(boxsizerv1)
    boxsizerh1.Add((40,20))
    boxsizerh1.Add(boxsizerv2)

    text1 = wx.StaticText( panel, wx.ID_ANY, u"图片存放目录:", wx.DefaultPosition, wx.DefaultSize, 0 )

    self.dirPicker = wx.DirPickerCtrl( panel, wx.ID_ANY, picdir, u"选择源文件夹", wx.DefaultPosition, wx.DefaultSize, wx.DIRP_DEFAULT_STYLE )
    boxsizerh2 = wx.BoxSizer(wx.HORIZONTAL)
    boxsizerh2.Add(text1, 0, wx.ALL, 10)
    boxsizerh2.Add(self.dirPicker, 0, wx.ALL, 5)

    boxsizerh3 = wx.BoxSizer(wx.HORIZONTAL)
    text1 = wx.StaticText( panel, wx.ID_ANY, u"总大小限制(MB):", wx.DefaultPosition, wx.DefaultSize, 0 )
 #   self.text = wx.TextCtrl(panel, -1, limitroom, (20, 50), (60, -1))

    self.sc = wx.SpinCtrl(panel, -1, "", size=(70, 25))
    self.sc.SetRange(1,2048000000)
    self.sc.SetValue(limitroom)


 #   self.Bind(wx.EVT_SPIN, self.OnSpin, self.spin)
    boxsizerh3.Add((7,10))
    boxsizerh3.Add(text1, 0, wx.ALL, 3)
    boxsizerh3.Add(self.sc, 0, wx.ALL, 0)
#    boxsizerh3.Add(self.spin, 0, wx.ALL, 0)

    text1 = wx.StaticText( panel, wx.ID_ANY, u"开机自动启动:", wx.DefaultPosition, wx.DefaultSize, 0 )
    self.checkbox = wx.CheckBox(panel, -1)
    self.checkbox.SetValue(autoboot)
    boxsizerh3.Add((20,10))
    boxsizerh3.Add(text1, 0, wx.ALL, 3)
    boxsizerh3.Add(self.checkbox, 0, wx.ALL, 4)

    boxsizerh4 = wx.BoxSizer(wx.HORIZONTAL)
    text1 = wx.StaticText( panel, wx.ID_ANY, u"抓取间隔(分):     ", wx.DefaultPosition, wx.DefaultSize, 0 )

    self.sc2 = wx.SpinCtrl(panel, -1, "", size=(70, 25))
    self.sc2.SetRange(1,360)
    self.sc2.SetValue(timeinterval)

    boxsizerh4.Add((7,10))
    boxsizerh4.Add(text1, 0, wx.ALL, 3)
    boxsizerh4.Add(self.sc2, 0, wx.ALL, 0)

    boxsizerh5 = wx.BoxSizer(wx.HORIZONTAL)
    boxsizerh5.Add((20,5))
    btnh0 = wx.Button(panel, -1, u'立刻开始')
    self.Bind(wx.EVT_BUTTON, self.OnButtonBegin, btnh0)
    boxsizerh5.Add(btnh0, proportion=0, flag=wx.ALL, border=5)

    btnh1 = wx.Button(panel, -1, u'确定')
    self.Bind(wx.EVT_BUTTON, self.OnButtonOK, btnh1)
    boxsizerh5.Add(btnh1, proportion=0, flag=wx.ALL, border=5)
    btnh2 = wx.Button(panel, -1, u'取消')
    self.Bind(wx.EVT_BUTTON, self.OnButtonCancel, btnh2)
    boxsizerh5.Add(btnh2, proportion=0, flag=wx.ALL, border=5)


    boxsizerv0 = wx.BoxSizer(wx.VERTICAL)
    boxsizerv0.Add(boxsizerh1)
    boxsizerv0.Add((10,10))
    boxsizerv0.Add(boxsizerh2)
    boxsizerv0.Add((10,10))
    boxsizerv0.Add(boxsizerh3)
    boxsizerv0.Add((10,10))
    boxsizerv0.Add(boxsizerh4)
    boxsizerv0.Add((10,10))
    boxsizerv0.Add(boxsizerh5)


    panel.SetSizer(boxsizerv0)