def _set_icon_from_execution_results(self, controller): node = self._controller.find_node_by_controller(controller) if not node: return img_index = self._get_icon_index_for(controller) # Always set the static icon self.SetItemImage(node, img_index) if self._animctrl: self._animctrl.Stop() self._animctrl.Animation.Destroy() self._animctrl.Destroy() self._animctrl = None self.DeleteItemWindow(node) if img_index in (RUNNING_IMAGE_INDEX, PAUSED_IMAGE_INDEX): from wx.adv import Animation, AnimationCtrl import os _BASE = os.path.join(os.path.dirname(__file__), '..', 'widgets') if img_index == RUNNING_IMAGE_INDEX: img = os.path.join(_BASE, 'robot-running.gif') else: img = os.path.join(_BASE, 'robot-pause.gif') ani = Animation(img) obj = self rect = (node.GetX() + 20, node.GetY()) # Overlaps robot icon self._animctrl = AnimationCtrl(obj, -1, ani, rect) """ self._animctrl.SetBackgroundColour(obj.GetBackgroundColour()) """ self._animctrl.SetBackgroundColour('white') self.SetItemWindow(node, self._animctrl, False) self._animctrl.Play() # Make visible the running or paused test self.EnsureVisible(node)
def _set_icon_from_execution_results(self, controller): node = self._controller.find_node_by_controller(controller) if not node: return img_index = self._get_icon_index_for(controller) # Always set the static icon self.SetItemImage(node, img_index) # print("DEBUG setIcon img_index=%d" % (img_index)) if wx.VERSION >= (3, 0, 3, '') and self._animctrl: self._animctrl.Stop() self._animctrl.Animation.Destroy() self._animctrl.Destroy() self._animctrl = None if wx.VERSION >= (3, 0, 3, '') and img_index in (RUNNING_IMAGE_INDEX, PAUSED_IMAGE_INDEX): from wx.adv import Animation, AnimationCtrl import os _BASE = os.path.join(os.path.dirname(__file__), '..', 'widgets') if img_index == RUNNING_IMAGE_INDEX: img = os.path.join(_BASE, 'robot-running.gif') else: img = os.path.join(_BASE, 'robot-pause.gif') ani = Animation(img) obj = self rect = (node.GetX() + 20, node.GetY()) # Overlaps robot icon self._animctrl = AnimationCtrl(obj, -1, ani, rect) self._animctrl.SetBackgroundColour(obj.GetBackgroundColour()) try: self.SetItemWindow(node, self._animctrl, False) except TypeError: # DEBUG In case wxPython devel not ready self.SetItemWindow(node, self._animctrl) self._animctrl.Play() # Make visible the running or paused test self.EnsureVisible(node)
def __init__( self, title, parent=None, style=wx.DEFAULT_DIALOG_STYLE): """ :param parent: Can be None, a frame or another dialog box. :type parent: wx.Window :param title: The title of the dialog. :type title: str :param style: The window style. :type style: int """ self.parent = parent wx.Dialog.__init__(self, parent, wx.ID_ANY, title, style=style) # Prevent closing of dialog self.Bind(wx.EVT_CLOSE, lambda event: None) with path(GuiV2.GSMatch2_Core.GUI, "loading_animation.gif") as loading_gif: ani = Animation(name=str(loading_gif)) ctrl = AnimationCtrl(self, -1, ani) ctrl.SetBackgroundColour(self.GetBackgroundColour()) if wx.Platform == "__WXMSW__": self.Fit() ctrl.Play()
def __init__(self, parent, log): self.controls = [None, None, None, None, None] self.timeStart = None self.log = log wx.StatusBar.__init__(self, parent, -1) self.SetFieldsCount(len(self.controls)) self.controls[0] = wx.StaticText(self, label=self.TEXT_GENERAL, style=wx.ST_NO_AUTORESIZE) self.controls[1] = wx.StaticText(self, label=self.TEXT_INFO, style=wx.ST_NO_AUTORESIZE) self.controls[2] = Led(self, label=self.TEXT_GPS) self.controls[3] = wx.Gauge(self, -1, style=wx.GA_HORIZONTAL | wx.GA_SMOOTH) animation = Animation(get_resource('busy.gif')) busy = AnimationCtrl(self, anim=animation) busy.SetToolTip('Updating plot') self.controls[4] = busy self.controls[3].Hide() self.controls[4].Hide() self.SetStatusWidths([-1, -1, -1, -1, busy.GetSize()[0] * 4]) self.Bind(wx.EVT_SIZE, self.__on_size) wx.CallAfter(self.__on_size, None) self.Fit()
def StopAndStart(self, evt): if KeyboardRecorderr0.start: KeyboardRecorderr0.start = 0 redir = RedirectText(self.tex) sys.stdout = redir print '\n> Recording restarted:-)' self.keybdbk.Destroy() ani = Animation(self.panelpic_gif) self.keybdbk = AnimationCtrl(self.panel2, -1, ani) self.keybdbk.Play() self.keybdbk.Bind(wx.EVT_LEFT_DCLICK, self.StopAndStart) self.Sizer.Add(self.keybdbk, 1, wx.EXPAND) self.panel2.SetSizer(self.Sizer) self.panel2.Fit() self.LEDinit() else: KeyboardRecorderr0.start = 1 print '\n> Recording stopped.' sys.stdout = self.temp self.keybdbk.Destroy() self.keybdbk = wx.StaticBitmap(parent=self.panel2, bitmap=self.panelpic) self.keybdbk.Bind(wx.EVT_LEFT_DCLICK, self.StopAndStart) self.Sizer.Add(self.keybdbk, 1, wx.EXPAND) self.panel2.SetSizer(self.Sizer) self.panel2.Fit() self.LEDinit()
def initpanel2(self, event): self.panel2.DestroyChildren() # self.panel2.bacpic = wx.Image('confbac.jpg', wx.BITMAP_TYPE_JPEG, ).Scale(1100,295).ConvertToBitmap() # self.panel2.bk = wx.StaticBitmap(parent=self.panel2, bitmap=self.panel2.bacpic) self.tex = wx.TextCtrl(parent=self.panel2, size=(900, 500), style=wx.TE_MULTILINE | wx.STAY_ON_TOP | wx.TE_READONLY) font = wx.Font(16, wx.ROMAN, wx.NORMAL, wx.NORMAL) self.tex.SetFont(font) self.tex.SetMaxLength(20) self.panelpic_gif = os.path.join(KeyboardRecorderr0.PIC_PATH, 'anikey.gif') self.panelpic = wx.Image( os.path.join(KeyboardRecorderr0.PIC_PATH, 'key.png'), wx.BITMAP_TYPE_PNG).Scale(1005, 305).ConvertToBitmap() ani = Animation(self.panelpic_gif) self.keybdbk = AnimationCtrl(self.panel2, -1, ani) self.keybdbk.Play() self.tex.SetBackgroundColour('black') self.tex.SetForegroundColour('white') self.LEDinit() self.Sizer = wx.BoxSizer(wx.VERTICAL) self.Sizer.Add(self.tex, 0, wx.EXPAND) self.Sizer.Add(self.keybdbk, 1, wx.EXPAND) self.panel2.SetSizer(self.Sizer) self.panel2.Fit() self.temp = sys.stdout redir = RedirectText(self.tex) sys.stdout = redir self.keybdbk.Bind(wx.EVT_LEFT_DCLICK, self.StopAndStart)
def init(self, parent): """ Finishes initializing the editor by creating the underlying toolkit widget. """ self._animate = Animation(self.value) self.control = AnimationCtrl(parent, -1, self._animate) #self.control.SetUseWindowBackgroundColour() self.sync_value(self.factory.playing, 'playing', 'from') self.set_tooltip()
def __init__(self, parent, id): wx.Frame.__init__(self, parent, id, size=(400, 200), style=0) panel = wx.Panel(self) self.LoadingText = wx.StaticText(panel, label="Loading...", pos=(335, 20)) self.LoadingText.SetForegroundColour('white') sizer = wx.BoxSizer(wx.VERTICAL) anim = Animation('123.gif') ctrl = AnimationCtrl(self, id, anim) #ctrl.Play() sizer.Add(ctrl) self.SetSizerAndFit(sizer)
def __init__(self, parent, idx, size=(280, 200), style=wx.TRANSPARENT_WINDOW): """ Panel to simulate the camera view.""" wx.Panel.__init__(self, parent) sizer = wx.BoxSizer(wx.VERTICAL) self.animCtrl = AnimationCtrl(self, -1, Animation(gv.TPSGIP_PATH)) self.animCtrl.Stop() # stop the gif play first. sizer.Add(self.animCtrl) self.SetSizerAndFit(sizer) self.Show()
def __init__(self, parent, log): self.log = log wx.Panel.__init__(self, parent, -1) sizer = wx.FlexGridSizer(cols=3, hgap=5, vgap=5) for name in GIFNames: ani = Animation(opj(name)) ctrl = AnimationCtrl(self, -1, ani) ctrl.SetBackgroundColour(self.GetBackgroundColour()) ctrl.Play() sizer.Add(ctrl, 0, wx.ALL, 10) border = wx.BoxSizer() border.Add(sizer, 1, wx.EXPAND | wx.ALL, 20) self.SetSizer(border)
def buidUISizer(self): """ Build the UI and the return the wx.sizer. """ sizer = wx.BoxSizer(wx.VERTICAL) self.ctrl = AnimationCtrl(self, -1, Animation(gv.TAGIF_PATH)) self.ctrl.Play() sizer.Add(self.ctrl, flag=wx.CENTER | wx.ALIGN_CENTER_HORIZONTAL, border=2) self.stTxt = wx.StaticText( self, -1, "Your computer has been taken over by YC's Trojan, we will release control in 10 sec" ) self.stTxt.SetBackgroundColour(wx.Colour('GREEN')) self.stTxt.SetFont(wx.Font(30, wx.SWISS, wx.NORMAL, wx.NORMAL)) sizer.Add(self.stTxt, flag=wx.ALIGN_CENTER, border=2) return sizer
def __init__(self, parent=None): """ :param parent: Can be None, a frame or another dialog box. :type parent: wx.Window """ wx.Dialog.__init__(self, parent, style=0) with path(GuiV2.GSMatch2_Core.GUI, "loading_animation.gif") as loading_gif: ani = Animation(name=str(loading_gif)) sizer = wx.BoxSizer(wx.VERTICAL) ctrl = AnimationCtrl(self, -1, ani) ctrl.SetBackgroundColour(self.GetBackgroundColour()) sizer.Add(ctrl, 1, wx.EXPAND, 0) self.SetSizer(sizer) ctrl.Play() if wx.Platform == "__WXMSW__": self.Fit() self.CenterOnScreen()
def __init__(self, parent, title: str, gui: 'ChatbotGUI'): # init parent wx.Frame.__init__(self, parent, -1, title=title) # a reference to the chatbot GUI self.gui = gui # grid for splitting the screen into two parts, the gif and I/O elements self.grid = wx.BoxSizer(wx.HORIZONTAL) # user & AI message history self.user_message_history = [] self.ai_message_history = [] # panel for all of the I/O elements self.io_panel = wx.Panel(self) # the sizer for the panel I/O elements self.io_sizer = wx.BoxSizer(wx.VERTICAL) # chat bot animation asset self.chatbot_gif = Animation('talking.gif') # animation controller for the chat bot gif self.chatbot_control = AnimationCtrl(self, -1, self.chatbot_gif) # # I/O elements # # input chat self.input_chat = wx.TextCtrl(self.io_panel, size=wx.Size(200, 200), style=wx.TE_READONLY | wx.TE_MULTILINE) # input chat label self.input_chat_label = wx.StaticText(self.io_panel, label="Chat with AI:") # input chat text box self.input_box = wx.TextCtrl(self.io_panel, style=wx.TE_PROCESS_ENTER, size=wx.Size(200, 20)) # input chat enter button self.chat_button = wx.Button(self.io_panel, label="Send") # input chat label self.output_chat_label = wx.StaticText(self.io_panel, label="AI Responses:") # output chat self.output_chat = wx.TextCtrl(self.io_panel, size=wx.Size(200, 200), style=wx.TE_READONLY | wx.TE_MULTILINE) # start AI gif button self.start_gif = wx.Button(self.io_panel, label="Start GIF", size=wx.Size(200, 100)) # stop gif button self.stop_gif = wx.Button(self.io_panel, label="Stop GIF", size=wx.Size(200, 100)) # # Add and size elements # # add elements to the I/O sizer self.io_sizer.Add(self.input_chat, 0, wx.EXPAND | wx.ALL, 5) self.io_sizer.Add(self.input_chat_label, 0, wx.EXPAND | wx.LEFT | wx.TOP, 5) self.io_sizer.Add(self.input_box, 0, wx.EXPAND | wx.ALL, 5) self.io_sizer.Add(self.chat_button, 0, wx.EXPAND | wx.ALL, 5) self.io_sizer.Add(self.output_chat_label, 0, wx.EXPAND | wx.LEFT | wx.TOP, 5) self.io_sizer.Add(self.output_chat, 0, wx.EXPAND | wx.ALL, 5) self.io_sizer.Add(self.start_gif, 0, wx.EXPAND | wx.ALL, 5) self.io_sizer.Add(self.stop_gif, 0, wx.EXPAND | wx.ALL, 5) # add elements to the main grid sizer self.grid.Add(self.io_panel, 0, wx.EXPAND | wx.ALL) self.grid.Add(self.chatbot_control) # size and fit the sizers self.io_panel.SetSizerAndFit(self.io_sizer) self.SetSizerAndFit(self.grid) # # Bind buttons to functions # self.Bind(wx.EVT_TEXT_ENTER, self.on_send_press) self.Bind(wx.EVT_BUTTON, self.on_send_press, self.chat_button) self.Bind(wx.EVT_BUTTON, self.start_animation, self.start_gif) self.Bind(wx.EVT_BUTTON, self.stop_animation, self.stop_gif)
def __init__(self, parent, title: str, gui: 'ChatbotGUI', gif_path: str, show_timestamp: bool = False): # init parent wx.Frame.__init__(self, parent, -1, title=title) # a reference to the chatbot GUI self.gui = gui # keeps track of the show_timestamp self.show_timestamp = show_timestamp # grid for splitting the screen into two parts, the gif and I/O elements self.grid = wx.BoxSizer(wx.HORIZONTAL) # user & AI message history self.user_message_history = [] self.ai_message_history = [] # panel for all of the I/O elements self.io_panel = wx.Panel(self) # the sizer for the panel I/O elements self.io_sizer = wx.BoxSizer(wx.VERTICAL) # chat bot animation asset self.chatbot_gif = Animation(gif_path) # animation controller for the chat bot gif self.chatbot_control = AnimationCtrl(self, -1, self.chatbot_gif) # # I/O elements # # input chat label self.input_chat_top_label = wx.StaticText(self.io_panel, label="History:") # Your chat history self.input_chat = wx.TextCtrl(self.io_panel, size=wx.Size(400, 290), style=wx.TE_READONLY | wx.TE_MULTILINE) # input chat label self.input_chat_label = wx.StaticText(self.io_panel, label="Input:") # input chat text box self.input_box = wx.TextCtrl(self.io_panel, style=wx.TE_PROCESS_ENTER, size=wx.Size(400, 20)) # input chat enter button self.chat_button = wx.Button(self.io_panel, label="Input text to Funbot!") # input chat label self.output_chat_label = wx.StaticText(self.io_panel, label="Chatlog:") # AI chat History self.output_chat = wx.TextCtrl(self.io_panel, size=wx.Size(400, 290), style=wx.TE_READONLY | wx.TE_MULTILINE) # ai status label self.ai_status_label = wx.StaticText(self.io_panel, label="Status:") # ai status box self.status_box = wx.TextCtrl(self.io_panel, style=wx.TE_READONLY) # # Add and size elements # # add elements to the I/O sizer self.io_sizer.Add(self.input_chat_top_label, 0, wx.EXPAND | wx.LEFT | wx.TOP, 5) self.io_sizer.Add(self.input_chat, 0, wx.EXPAND | wx.ALL, 5) self.io_sizer.Add(self.input_chat_label, 0, wx.EXPAND | wx.LEFT | wx.TOP, 5) self.io_sizer.Add(self.input_box, 0, wx.EXPAND | wx.ALL, 5) self.io_sizer.Add(self.chat_button, 0, wx.EXPAND | wx.ALL, 5) self.io_sizer.Add(self.output_chat_label, 0, wx.EXPAND | wx.LEFT | wx.TOP, 5) self.io_sizer.Add(self.output_chat, 0, wx.EXPAND | wx.ALL, 5) self.io_sizer.Add(self.ai_status_label, 0, wx.EXPAND | wx.LEFT | wx.TOP, 5) self.io_sizer.Add(self.status_box, 0, wx.EXPAND | wx.ALL, 5) # add elements to the main grid sizer self.grid.Add(self.io_panel, 0, wx.EXPAND | wx.ALL) self.grid.Add(self.chatbot_control) # size and fit the sizers self.io_panel.SetSizerAndFit(self.io_sizer) self.SetSizerAndFit(self.grid) # # Bind buttons to functions # self.Bind(wx.EVT_TEXT_ENTER, self.on_send_press) self.Bind(wx.EVT_BUTTON, self.on_send_press, self.chat_button) # bind the event handler for commands evt_command(self, self.on_command)
def build_playlist_cover(self, playlist_dict): cover_name = playlist_dict['cover'] cover_parent = playlist_dict['parent'] cover = Animation('{}/{}.gif'.format(self.asset_dir, cover_name)) cover_ctrl = AnimationCtrl(cover_parent, -1, cover, name=cover_name) return cover_ctrl
def __init__(self, parent, filepath): AnimationCtrl.__init__(self, parent, wx.ID_ANY, Animation(filepath))