def test_lib_throbber(self): pnl = wx.Panel(self.frame) images = [ throbImages.catalog[i].GetBitmap() for i in throbImages.index if i not in ['eclouds', 'logo'] ] w = th.Throbber(pnl, -1, images, size=(36, 36))
def init_controls(self): self.label = wx.StaticText(self, wx.ID_ANY, "Amplifier list:") throbber_bitmap = wx.ArtProvider.GetBitmap("amp-launcher-throbber", wx.ART_OTHER) self.throbber = throbber.Throbber(self, -1, bitmap=throbber_bitmap, frames=4, frameWidth=43) self.amp_list = wx.ListView(self, wx.ID_ANY) self.amp_list.InsertColumn(0, "address") self.amp_list.InsertColumn(1, "experiment") self.amp_list.InsertColumn(2, "amplifier") self.amp_list.InsertColumn(3, "status") self.refresh_amp_info()
def InitThrober(self): import wx.lib.throbber as throb import throbImages # this was created using a modified version of img2py # create the throbbers images = [throbImages.catalog[i].getBitmap() for i in throbImages.index if i not in ['eclouds', 'logo']] self.throbber1 = throb.Throbber(self.panScanStatus, -1, images, frameDelay=0.07, pos=wx.Point(136, 8), size=wx.Size(36, 36)) self.throbber1.Start()
def __init__(self, parent): super(LaunchingDialog, self).__init__(parent, style=0) self.t1_passed = False self.mx_alive = False self.failed = True self.timer = wx.Timer(self) self.SetSizer(wx.BoxSizer(wx.VERTICAL)) throbber_bitmap = wx.ArtProvider.GetBitmap("pop-tart-throbber", wx.ART_OTHER) self.throbber = throbber.Throbber(self, -1, bitmap=throbber_bitmap, frames=12, frameWidth=400) self.throbber.Start() self.GetSizer().Add(self.throbber) self.GetSizer().Add(wx.StaticText(self, label="Waiting for amplifier to start up..."), flag=wx.ALL | wx.ALIGN_CENTER, border=8) self.Fit() self.Bind(EVT_EXPERIMENT_READY, self.on_experiment_ready)
def createAni(Parent_, Size_, Delay_, *FrameFileNames_): """ Создание анимированного объекта. @param Parent_: Окно-родитель. @param Size_: Размер. @param Delay_: Задержка м/у кадрами в секундах. @param FrameFileNames_: Файлы-кадры. @return: Возвращает созданный объект или None в случае ошибки. """ try: frames = [createBitmap(frame_file_name) for frame_file_name in FrameFileNames_] throbber = throb.Throbber(Parent_, -1, frames, size=Size_, frameDelay=Delay_) return throbber except: log.fatal(u'Ошибка создания анимированного объекта.') return None
def __init__(self, parent, log): wx.Panel.__init__(self, parent, -1) self.log = log # create the throbbers self.throbbers = { 'plain': { 'throbber': None, 'text': "Plain throbber." }, 'reverse': { 'throbber': None, 'text': "This throbber runs in reverse and faster." }, 'autoreverse': { 'throbber': None, 'text': "This throbber switches direction." }, 'label': { 'throbber': None, 'text': "With a label." }, 'overlay': { 'throbber': None, 'text': "With an overlayed image." }, 'overlay+text': { 'throbber': None, 'text': "With a label and an overlayed image." }, } images = [throbImages.catalog[i].GetBitmap() for i in throbImages.index if i not in ['eclouds', 'logo']] self.throbbers['plain']['throbber'] = \ throb.Throbber(self, -1, images, size=(36, 36),frameDelay = 0.1) self.throbbers['reverse']['throbber'] = \ throb.Throbber(self, -1, images, frameDelay = 0.07) self.throbbers['reverse']['throbber'].Reverse() self.throbbers['autoreverse']['throbber'] = \ throb.Throbber(self, -1, images, frameDelay = 0.1, reverse = True) seq = self.throbbers['autoreverse']['throbber'].sequence seq.append(0) self.throbbers['label']['throbber'] = \ throb.Throbber(self, -1, images, frameDelay = 0.1, label = 'Label') self.throbbers['label']['throbber'].SetFont(wx.Font( pointSize = 10, family = wx.FONTFAMILY_DEFAULT, style = wx.FONTSTYLE_NORMAL, weight = wx.FONTWEIGHT_BOLD )) self.throbbers['overlay']['throbber'] = \ throb.Throbber( self, -1, images, frameDelay = 0.1, overlay = throbImages.catalog['logo'].GetBitmap() ) self.throbbers['overlay+text']['throbber'] = \ throb.Throbber( self, -1, images, frameDelay = 0.1, overlay = throbImages.catalog['logo'].GetBitmap(), label = "Python!" ) self.throbbers['overlay+text']['throbber'].SetFont(wx.Font( pointSize = 8, family = wx.FONTFAMILY_DEFAULT, style = wx.FONTSTYLE_NORMAL, weight = wx.FONTWEIGHT_BOLD )) self.customThrobber = \ throb.Throbber(self, -1, images, size=(36, 36), frameDelay = 0.1, rest = 4, sequence = [ 1, 5, 2, 7, 3, 6, 4, 4, 4, 4, 7, 2, 2, 0 ] ) box = wx.BoxSizer(wx.VERTICAL) sizer = wx.GridBagSizer() box.Add(sizer, 1, wx.EXPAND|wx.ALL, 5) row = 2 # use a list so we can keep our order for t in ['plain', 'reverse', 'autoreverse', 'label', 'overlay', 'overlay+text']: sizer.Add( self.throbbers[t]['throbber'], (row, 0), (1, 1), flag = wx.ALIGN_CENTER|wx.ALL, border=2 ) sizer.Add( wx.StaticText(self, -1, self.throbbers[t]['text']), (row, 1), flag = wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_LEFT ) row += 1 # Add custom throbber to sizer. row += 2 sizer.Add( self.customThrobber, (row, 0), (1, 1), flag = wx.ALIGN_CENTER|wx.ALL, border=2 ) sizer.Add( wx.StaticText(self, -1, 'with custom & manual sequences'), (row, 1), flag = wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_LEFT ) sizer.AddGrowableCol(1) # start and stop buttons startButton = wx.Button(self, -1, "Start") self.Bind(wx.EVT_BUTTON, self.OnStartAnimation, startButton) stopButton = wx.Button(self, -1, "Stop") self.Bind(wx.EVT_BUTTON, self.OnStopAnimation, stopButton) buttonBox = wx.BoxSizer(wx.HORIZONTAL) buttonBox.AddMany([ (startButton, 0, wx.ALIGN_CENTER_HORIZONTAL | wx.ALL, 5), (stopButton, 0, wx.ALIGN_CENTER_HORIZONTAL | wx.ALL, 5), ]) sizer.Add( buttonBox, (len(self.throbbers) + 2, 0), (1, 3), flag = wx.ALIGN_CENTER ) # Buttoms for the custom throbber. nextButton = wx.Button(self, -1, "Next") self.Bind(wx.EVT_BUTTON, self.OnNext, nextButton) prevButton = wx.Button(self, -1, "Previous") self.Bind(wx.EVT_BUTTON, self.OnPrevious, prevButton) incButton = wx.Button(self, -1, "Increment") self.Bind(wx.EVT_BUTTON, self.OnIncrement, incButton) decButton = wx.Button(self, -1, "Decrement") self.Bind(wx.EVT_BUTTON, self.OnDecrement, decButton) revButton = wx.Button(self, -1, "Reverse") self.Bind(wx.EVT_BUTTON, self.OnReverse, revButton) restButton = wx.Button(self, -1, "Rest") self.Bind(wx.EVT_BUTTON, self.OnRest, restButton) startButton = wx.Button(self, -1, "Start") self.Bind(wx.EVT_BUTTON, self.OnStart, startButton) stopButton = wx.Button(self, -1, "Stop") self.Bind(wx.EVT_BUTTON, self.OnStop, stopButton) customBox1 = wx.BoxSizer(wx.HORIZONTAL) customBox1.AddMany([ (nextButton, 0, wx.ALIGN_CENTER_HORIZONTAL | wx.ALL, 5), (prevButton, 0, wx.ALIGN_CENTER_HORIZONTAL | wx.ALL, 5), (incButton, 0, wx.ALIGN_CENTER_HORIZONTAL | wx.ALL, 5), (decButton, 0, wx.ALIGN_CENTER_HORIZONTAL | wx.ALL, 5), (revButton, 0, wx.ALIGN_CENTER_HORIZONTAL | wx.ALL, 5), ]) customBox2 = wx.BoxSizer(wx.HORIZONTAL) customBox2.AddMany([ (restButton, 0, wx.ALIGN_CENTER_HORIZONTAL | wx.ALL, 5), (startButton, 0, wx.ALIGN_CENTER_HORIZONTAL | wx.ALL, 5), (stopButton, 0, wx.ALIGN_CENTER_HORIZONTAL | wx.ALL, 5), ]) sizer.Add( customBox1, (len(self.throbbers) + 5, 0), (1, 3), flag = wx.ALIGN_CENTER ) sizer.Add( customBox2, (len(self.throbbers) + 6, 0), (1, 3), flag = wx.ALIGN_CENTER ) # Layout. self.SetSizer(box) self.SetAutoLayout(True) self.Layout() sizer.SetSizeHints(self) sizer.Fit(self) for t in self.throbbers.keys(): self.throbbers[t]['throbber'].Start() self.Bind(wx.EVT_WINDOW_DESTROY, self.OnDestroy)
def test_lib_throbber(self): pnl = wx.Panel(self.frame) w = th.Throbber(pnl, -1, images, size=(36, 36))
def __init__(self, parent, log): wx.Panel.__init__(self, parent, -1) self.log = log # create the throbbers self.throbbers = { 'plain': { 'throbber': None, 'text': "Plain throbber." }, 'reverse': { 'throbber': None, 'text': "This throbber runs in reverse and faster." }, 'autoreverse': { 'throbber': None, 'text': "This throbber switches direction." }, 'label': { 'throbber': None, 'text': "With a label." }, 'overlay': { 'throbber': None, 'text': "With an overlayed image." }, 'overlay+text': { 'throbber': None, 'text': "With a label and an overlayed image." }, } images = [ throbImages.catalog[i].getBitmap() for i in throbImages.index if i not in ['eclouds', 'logo'] ] self.throbbers['plain']['throbber'] = \ throb.Throbber(self, -1, images, size=(36, 36),frameDelay = 0.1) self.throbbers['reverse']['throbber'] = \ throb.Throbber(self, -1, images, frameDelay = 0.07) self.throbbers['reverse']['throbber'].Reverse() self.throbbers['autoreverse']['throbber'] = \ throb.Throbber(self, -1, images, frameDelay = 0.1, reverse = True) self.throbbers['autoreverse']['throbber'].sequence.append(0) self.throbbers['label']['throbber'] = \ throb.Throbber(self, -1, images, frameDelay = 0.1, label = 'Label') self.throbbers['label']['throbber'].SetFont( wx.Font(pointSize=10, family=wx.DEFAULT, style=wx.NORMAL, weight=wx.BOLD)) self.throbbers['overlay']['throbber'] = \ throb.Throbber( self, -1, images, frameDelay = 0.1, overlay = throbImages.catalog['logo'].getBitmap() ) self.throbbers['overlay+text']['throbber'] = \ throb.Throbber( self, -1, images, frameDelay = 0.1, overlay = throbImages.catalog['logo'].getBitmap(), label = "Python!" ) self.throbbers['overlay+text']['throbber'].SetFont( wx.Font(pointSize=8, family=wx.DEFAULT, style=wx.NORMAL, weight=wx.BOLD)) # this throbber is created using a single, composite image self.otherThrobber = throb.Throbber( self, -1, throbImages.catalog['eclouds'].getBitmap(), frameDelay=0.15, frames=12, frameWidth=48, label="Stop") self.otherThrobber.Bind(wx.EVT_LEFT_DOWN, self.OnClickThrobber) box = wx.BoxSizer(wx.VERTICAL) sizer = wx.GridBagSizer() box.Add(sizer, 1, wx.EXPAND | wx.ALL, 5) sizer.AddGrowableCol(1) sizer.Add(self.otherThrobber, (0, 2), (4, 1), flag=wx.ALIGN_CENTER_VERTICAL) row = 2 # use a list so we can keep our order for t in [ 'plain', 'reverse', 'autoreverse', 'label', 'overlay', 'overlay+text' ]: sizer.Add(self.throbbers[t]['throbber'], (row, 0), (1, 1), flag=wx.ALIGN_CENTER | wx.ALL, border=2) sizer.Add(wx.StaticText(self, -1, self.throbbers[t]['text']), (row, 1), flag=wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_LEFT) row += 1 # start and stop buttons startButton = wx.Button(self, -1, "Start") self.Bind(wx.EVT_BUTTON, self.OnStartAnimation, startButton) stopButton = wx.Button(self, -1, "Stop") self.Bind(wx.EVT_BUTTON, self.OnStopAnimation, stopButton) buttonBox = wx.BoxSizer(wx.HORIZONTAL) buttonBox.AddMany([ (startButton, 0, wx.ALIGN_CENTER_HORIZONTAL | wx.ALL, 5), (stopButton, 0, wx.ALIGN_CENTER_HORIZONTAL | wx.ALL, 5), ]) sizer.Add(buttonBox, (len(self.throbbers) + 3, 0), (1, 3), flag=wx.ALIGN_CENTER) self.SetSizer(box) self.SetAutoLayout(True) self.Layout() sizer.SetSizeHints(self) sizer.Fit(self) for t in self.throbbers.keys(): self.throbbers[t]['throbber'].Start() self.otherThrobber.Start() self.otherThrobber.Reverse() self.Bind(wx.EVT_WINDOW_DESTROY, self.OnDestroy)
def __init__(self, parent, matrox_frame_grabber_wx_event_generator, local_savior_path='.'): """ """ # default constructor using the parent window wx.Panel.__init__(self, parent, -1) self._matrox_frame_grabber_wx_event_generator = matrox_frame_grabber_wx_event_generator self._matrox_frame_grabber = matrox_frame_grabber_wx_event_generator.GetEventGenerator( ) self._matrox_frame_grabber_wx_event_generator.BindWXEvent( "stats_ready", self._OnStatsUpdate) self.movie_number = 0 # If we have a fixation GUI open, grab its reference if parent.fixQ is not None: self.fixQ = parent.fixQ # getting background and foreground colours from the parent panel self.SetBackgroundColour(parent.GetBackgroundColour()) self.SetForegroundColour(parent.GetForegroundColour()) # creating the sizer and defining control dimensions main_sizer = wx.GridBagSizer(vgap=10, hgap=10) border = 0 text_ctrl_width = 40 text_ctrl_height = 15 text_ctrl_size = (text_ctrl_width, text_ctrl_height) # Defining the title font bold_font = self.GetFont() bold_font.SetWeight(wx.BOLD) bold_font.SetPointSize(bold_font.GetPointSize() + 2) self.SetFont(bold_font) ################################################################### # creating controls # ################################################################### # discard and image recording section ####################### blank_icon = wx.Bitmap(local_savior_path + '/icons/blank icon.png', wx.BITMAP_TYPE_PNG) stop_icon = wx.Bitmap( local_savior_path + '/icons/Pause-Hot-icon 42.png', wx.BITMAP_TYPE_PNG) live_icon = wx.Bitmap( local_savior_path + '/icons/play-normal-blue-bright 42.png', wx.BITMAP_TYPE_PNG) record_icon = wx.Bitmap( local_savior_path + '/icons/Record-Pressed-icon 42.png', wx.BITMAP_TYPE_PNG) # creating the throbbers (initially in resting mode) self.mode_icons = [stop_icon, live_icon, record_icon, blank_icon] throbber_delay = 0.35 self.current_mode_throbber = throb.Throbber(self, -1, self.mode_icons, frameDelay=throbber_delay) self.SetCurrentModeIcon('stop') # adding controls to the sizer main_sizer.Add(self.current_mode_throbber, pos=(0, 1), span=(5, 1), flag=wx.ALIGN_CENTER_VERTICAL | wx.ALL, border=0) label_acquisition_frame_rate_title = wx.StaticText( self, label="Acquisition frame rate (FPS): ", style=wx.ALIGN_LEFT) self._acquisition_frame_rate_label = wx.StaticText(self, label='0.0', style=wx.ALIGN_LEFT) self._video_writing_frame_rate_title = wx.StaticText( self, label="Writing frame rate (FPS): ") self._video_writing_rate_label = wx.StaticText(self, label='0.0') self._video_writing_frame_rate_title.Show(False) self._video_writing_rate_label.Show(False) self._video_number_label = wx.StaticText(self, label='Not recording') self._video_frames_written_label = wx.StaticText(self, label='0/0') self._video_frames_written_label.Show(False) main_sizer.Add(label_acquisition_frame_rate_title, pos=(1, 2), span=(1, 1), flag=wx.EXPAND | wx.ALL | wx.ALIGN_LEFT, border=border) main_sizer.Add(self._acquisition_frame_rate_label, pos=(1, 3), span=(1, 1), flag=wx.EXPAND | wx.ALIGN_LEFT | wx.ALL, border=border) # size headers #################################################### self.temp_header_H = wx.StaticText(self, label=" H ") self.temp_header_V = wx.StaticText(self, label=" V ") # adding controls to the sizer main_sizer.Add(self.temp_header_H, pos=(1, 5), span=(1, 1), flag=wx.ALIGN_CENTER | wx.ALL, border=border) main_sizer.Add(self.temp_header_V, pos=(1, 6), span=(1, 1), flag=wx.ALIGN_CENTER | wx.ALL, border=border) # Image size in degrees ########################################## label_text_imaging_fov_in_deg = wx.StaticText( self, label="Field of view (deg):") self.text_imaging_width_in_deg = wx.StaticText(self, label="2.0") self.text_imaging_width_in_deg.SetMinSize((text_ctrl_width, -1)) label_imaging_x_in_deg = wx.StaticText(self, label="x") self.text_imaging_height_in_deg = wx.StaticText(self, label="2.0") # Frame size in pixels ############################################ label_frame_size_in_pix = wx.StaticText(self, label="Image size (pix):") label_frame_size_in_pix.SetMinSize((2 * text_ctrl_width, -1)) self.text_frame_width_in_pix = wx.StaticText(self, label=" ") self.text_frame_width_in_pix.SetMinSize((text_ctrl_width, -1)) label_frame_size_x = wx.StaticText(self, label="x") self.text_frame_height_in_pix = wx.StaticText(self, label=" ") # adding controls to the sizer current_row = 2 main_sizer.Add(self._video_writing_frame_rate_title, pos=(current_row, 2), span=(1, 1), flag=wx.EXPAND | wx.ALL | wx.ALIGN_LEFT, border=border) main_sizer.Add(self._video_writing_rate_label, pos=(current_row, 3), span=(1, 1), flag=wx.EXPAND | wx.ALIGN_LEFT | wx.ALL, border=border) main_sizer.Add(label_text_imaging_fov_in_deg, pos=(current_row, 4), span=(1, 1), border=border) main_sizer.Add(self.text_imaging_width_in_deg, pos=(current_row, 5), span=(1, 1), border=border) main_sizer.Add(label_imaging_x_in_deg, pos=(current_row, 6), span=(1, 1), border=border) main_sizer.Add(self.text_imaging_height_in_deg, pos=(current_row, 7), span=(1, 1), border=border) current_row += 1 main_sizer.Add(self._video_number_label, pos=(current_row, 2), span=(1, 1), flag=wx.EXPAND | wx.ALIGN_LEFT | wx.ALL, border=border) main_sizer.Add(self._video_frames_written_label, pos=(current_row, 3), span=(1, 1), flag=wx.EXPAND | wx.ALIGN_LEFT | wx.ALL, border=border) main_sizer.Add(label_frame_size_in_pix, pos=(current_row, 4), span=(1, 1), border=border) main_sizer.Add(self.text_frame_width_in_pix, pos=(current_row, 5), span=(1, 1), border=border) main_sizer.Add(label_frame_size_x, pos=(current_row, 6), span=(1, 1), border=border) main_sizer.Add(self.text_frame_height_in_pix, pos=(current_row, 7), span=(1, 1), border=border) current_row += 1 main_sizer.AddSizer((0, 0), pos=(current_row, 10), span=(1, 1), flag=wx.EXPAND | wx.ALIGN_CENTER | wx.ALL, border=border) # making some columns and row growables #main_sizer.AddGrowableCol( 0, proportion = 1) main_sizer.AddGrowableCol(2, proportion=.6) main_sizer.AddGrowableCol(3, proportion=.4) # main_sizer.AddGrowableCol( 6, proportion = 2) # main_sizer.AddGrowableCol(12, proportion = 2) # Fitting the current panel to the needs of the sizer. self.SetSizerAndFit(main_sizer) # bind the onclose method wx.GetApp().GetTopWindow().Bind(wx.EVT_CLOSE, self.OnClose, wx.GetApp().GetTopWindow()) self._main_sizer = main_sizer