def OnImportChannels(self, event: wx.CommandEvent) -> None: """Add all channels in a file.""" filepath = wx.LoadFileSelector('Select file to import', '', parent=self) if not filepath: return try: with open(filepath, 'r') as fh: new_channels = json.load(fh) except: cockpit.gui.ExceptionBox('Failed to read to \'%s\'' % filepath, parent=self) duplicated = [n for n in new_channels.keys() if n in self._channels] if duplicated: answer = wx.MessageBox( 'The import will overwrite the following' ' channels: %s. Do you want to continue?' % ', '.join(duplicated), caption='Duplicated channels on loaded file', parent=self, style=wx.YES_NO) if answer != wx.YES: return menu = event.GetEventObject() for name, channel in new_channels.items(): # Duplicated channels only need to update our dict but new # channels also need a new menu item. if name not in duplicated: self.Bind(wx.EVT_MENU, self.OnApplyChannel, menu.Append(wx.ID_ANY, item=name)) self._channels[name] = channel
def OnOpen(self, event: wx.CommandEvent) -> None: filepath = wx.LoadFileSelector('Select file to open', '', parent=self) if not filepath: return try: cockpit.gui.fileViewerWindow.FileViewer(filepath, parent=self) except Exception as ex: cockpit.gui.ExceptionBox('Failed to open \'%s\'' % filepath, parent=self)
def onOpen(self, event): # wxGlade: MyFrame.<event_handler> openfile = wx.LoadFileSelector('Open a Wave file', '.wav', 'testmorse.wav', None) if (openfile != ""): self.SetTitle("Morse Code Wave File - " + openfile) self.text_ctrl_txt.SetValue("Please Wait Generating....") self.text_ctrl_morsecode.SetValue("Please Wait Generating....") self.morse.sound_info(openfile) print("Generating morse code from audio") self.morse.sound_to_morse(openfile) self.text_ctrl_txt.SetValue(self.morse.morse_text) self.text_ctrl_morsecode.SetValue(self.morse.morse_code) print("Finished with translating audio to morse code")
def OnLoad(self, event): filename = wx.LoadFileSelector("Annotations", "*", "", self) if filename: try: tree = xml.etree.ElementTree.parse(filename) annotations = medipy.io.image_annotation.annotations_from_xml( tree.getroot()) except Exception, e: wx.MessageBox("Cannot load file : {0}".format(e), "Cannot load annotations", wx.OK, self) else: self.image.annotations[:] = annotations self.image.render() self.ui.annotations.Clear() for annotation in self.image.annotations: self.ui.annotations.Append(annotation.label) self.ui.delete.Enable(len(self.image.annotations) != 0) self.ui.save.Enable(len(self.image.annotations) != 0)
def OnImportChannels(self, event: wx.CommandEvent) -> None: """Add all channels in a file.""" filepath = wx.LoadFileSelector('Select file to import', '') if not filepath: return try: new_channels = cockpit.interfaces.channels.LoadFromFile(filepath) except: cockpit.gui.ExceptionBox('Failed to read to \'%s\'' % filepath) current_names = wx.GetApp().Channels.Names duplicated = [n for n in new_channels.Names if n in current_names] if duplicated: answer = wx.MessageBox('The import will overwrite the following' ' channels: %s. Do you want to continue?' % ', '.join(duplicated), caption='Duplicated channels on loaded file', style=wx.YES_NO) if answer != wx.YES: return wx.GetApp().Channels.Update(new_channels)
def on_open_menu(self, event): file_path = wx.LoadFileSelector(u"Zvolte soubor", u"TXT formát (*.txt)|*.txt|Dummy formát text (*.html)|*.html") if file_path: child = DummyEditorChildFrame(self, file_path, (400, 300)) child.Show()
def get_file_to_open(win, oms='', extension='', start=''): """toon een dialoog waarmee een file geopend kan worden om te lezen """ what = shared.get_open_title(win, 'C_SELFIL', oms) return wx.LoadFileSelector(what, extension, default_name=start, parent=win)
def onLoad(self, event): self.viewer.update_file_list(wx.LoadFileSelector("TF Snapshot", ".tf"))