Exemple #1
0
    def on_button1_mouseClick( self, event ) :
        button = event.target
        #Set the value of 'field1' to the current time
        #when 'button1' is clicked.
        now = time.localtime(time.time())
        field1 = self.components.field1
        print '\n\n\n\n\nfield1=', field1
        field1.text = "it's %s" % time.asctime( now )
        listX = self.components.list
        log.debug( listX.items )
        log.debug( listX.stringSelection )
        listX.stringSelection = "one"

        slider = self.components.aSlider
        log.debug( 'min='+ str( slider.min ) )
        log.debug( 'max=' + str( slider.max ) )
        log.debug( 'value=' + str( slider.value ) )

        # RDS 2001-07-29
        # Test setting StaticText.
        self.components.label.text = self.components.field2.text
        # KEA 2001-07-27
        # test out setting colors
        # three different forms accepted
        # no mapping between names and color yet
        #button.setBackgroundColor('LAVENDER BLUSH')
        button.backgroundColor = 'BLUE'
        #button.setBackgroundColor('#FF0000')
        #rgb = (255, 0, 0)
        button.backgroundColor = (255, 0, 0)
        print button.backgroundColor
    def run(self):
        engine = lyric_engine.Lyric(self.url)

        try:
            log.debug('in UrlThread')
            lyric = engine.get_lyric()
            self.window.thread_finished(lyric)
        except IOError:
            self.window.error_io_erorr()
        except TypeError:
            self.window.error_type_error()
Exemple #3
0
 def buildFileListFromDirectory(self, path, recurse=True):
     self.zip = None
     self.directory = path
     fileList = util.dirwalk(path, ['*'], recurse)
     log.debug('Directory file list: %s' % fileList)
     # self.fileList should be filtered here
     self.fileList = []
     self.fileIndex = -1
     for path in fileList:
         if imageFile(path) or htmlFile(path):
             self.fileList.append(path)
     self.fileList = util.caseinsensitive_sort(self.fileList)
Exemple #4
0
 def on_menuFileOpenSlide_select(self, event):
     if self.fileList is not None and self.fileList != []:
         path = self.fileList[self.fileIndex]
         if imageFile(path):
             log.debug("image: %s" % path)
             viewer = os.path.abspath(
                 os.path.join('..', 'pictureViewer', 'pictureViewer.py'))
             if " " in path:
                 path = '"' + path + '"'
             try:
                 util.runScript(viewer, path)
             except:  # Fail gracefully if displaying fails
                 pass
         elif htmlFile(path):
             log.debug("html: %s" % path)
             import webbrowser
             webbrowser.open(path, 1, 1)
Exemple #5
0
 def buildFileListFromZip(self, path):
     self.zip = zipfile.ZipFile(path)
     self.directory = None
     fileList = self.zip.namelist()
     log.debug('Zip file list: %s' % fileList)
     # self.fileList should be filtered here
     self.fileList = []
     self.fileIndex = -1
     for f in fileList:
         ext = os.path.splitext(f)[-1].lower()
         if ext != '' and ext[0] == '.':
             ext = ext[1:]
         if ext in [
                 'bmp', 'gif', 'jpeg', 'jpg', 'pcx', 'png', 'pnm', 'tif',
                 'tiff', 'xbm', 'xpm'
         ]:
             self.fileList.append(f)
Exemple #6
0
    def editFile(self, filename, lineno=None):
        if filename == '':
            return

        log.debug("filename: " + filename + "  lineno: " + str(lineno))
        # edit Python scripts with codeEditor
        # everything else with textEditor
        # the list of extensions and associated programs to
        # open with should be user settable
        if self.components.chkOpenWithResourceEditor.checked and filename.endswith('.rsrc.py'):
            program = os.path.join("..", "resourceEditor", "resourceEditor.pyw")
            if not os.path.exists(program):
                program = os.path.join("..", "resourceEditor", "resourceEditor.py")
        else:
            program = os.path.join("..", "codeEditor", "codeEditor.pyw")
            if not os.path.exists(program):
                program = os.path.join("..", "codeEditor", "codeEditor.py")
        # throw an exception if program can't be found?
        log.debug('program: ' + program)

        if wx.Platform in ('__WXMAC__', '__WXGTK__'):
            args = [filename]
        else:
            args = ['"' + filename + '"']
        if lineno is not None:
            args.append(str(lineno))
        log.debug(args)
        if ' ' in program:
            program = '"' + program + '"'
        python = sys.executable
        if ' ' in python:
            pythonQuoted = '"' + python + '"'
        else:
            pythonQuoted = python
        os.spawnv(os.P_NOWAIT, python, [pythonQuoted, program] + args)
Exemple #7
0
    def on_initialize(self, event):
        self.changed = 0
        wFldSearch = self.components.fldSearch
        # copy the clipboard to fldSearch when the app starts
        if wFldSearch.canPaste():
            wFldSearch.paste()
        else:
            wFldSearch.text = ''
        #wFldSearch.setSelection(0, len(wFldSearch.text))
        # below is a simpler way of selecting all of the text in a field
        wFldSearch.setSelection(-1, -1)

        self.configPath = os.path.join(configuration.homedir, 'searchexplorer')
        if not os.path.exists(self.configPath):
            os.mkdir(self.configPath)
        basePath = self.application.applicationDirectory
        self.sfFilename = os.path.join(self.configPath, FAVORITES_FILE)
        log.debug('Favourites are in %s' % self.sfFilename)
        if not os.path.exists(self.sfFilename):
            try:
                shutil.copy2(os.path.join(basePath, FAVORITES_FILE),
                             self.sfFilename)
            except IOError:
                dialog.messageDialog(self, 'Unable to load ' + self.sfFilename,
                                     'SearchExplorer exiting')
                sys.exit()
            self.sitesDict = util.readAndEvalFile(self.sfFilename)

        defaultSite = 'Google'
        sites = self.sitesDict.keys()
        # need to implement a case-insensitive sort and use that everywhere
        sites.sort()
        pastSearches = self.sitesDict[defaultSite]['pastSearches']
        pastSearches.sort()

        wListSites = self.components.listSites
        wListSites.items = sites
        wListSites.stringSelection = defaultSite

        self.components.listPastSearches.items = pastSearches
Exemple #8
0
 def openFile(self, path, slideNumber=None):
     self.filename = path
     if htmlFile(self.filename):
         title = os.path.split(self.filename)[-1]
     else:
         if self.zip:
             data = self.zip.read(self.filename)
             tags = EXIF.process_file(StringIO(data))
             log.debug("Getting %s from zip file" % self.filename)
             self.bmp = graphic.Bitmap()
             self.bmp.setImageBits(wx.ImageFromStream(StringIO(data)))
         else:
             if not os.path.exists(self.filename):
                 return
             f = open(self.filename, 'rb')
             tags = EXIF.process_file(f)
             f.close()
             log.debug("Getting %s from file" % self.filename)
             self.bmp = graphic.Bitmap(self.filename)
         if tags.has_key('Image Orientation'):
             # the repr() is something like
             # (0x0112) Short=8 @ 54
             # but the str() is just 1, 8, etc.
             orientation = int(str(tags['Image Orientation']))
         else:
             orientation = 1
         log.debug('Image Orientation: %d' % orientation)
         if tags.has_key('Thumbnail Orientation'):
             log.debug('Thumbnail Orientation: %s' %
                       tags['Thumbnail Orientation'])
         if orientation == 8:
             # need to rotate the image
             # defaults to clockwise, 0 means counter-clockwise
             self.bmp.rotate90(0)
         elif orientation == 6:
             self.bmp.rotate90(1)
         size = self.bmp.getSize()
         title = os.path.split(self.filename)[-1] + "  %d x %d" % size
     if slideNumber is not None:
         title = title + "  Slide: %d of %d" % (slideNumber + 1,
                                                len(self.fileList))
     self.title = title
     self.displayFile()
    def error_io_erorr(self):
        log.debug('IOError')
        self.unlock_input()
#         result = dialog.alertDialog(self, 'IOError', 'Error')
        strings = self.resource.strings
        result = dialog.alertDialog(self, strings.error_IOError, 'Error')
 def error_type_error(self):
     log.debug('TypeError')
     self.unlock_input()
     result = dialog.alertDialog(self, 'this URL is not supported', 'Error')
Exemple #11
0
 def on_field1_textUpdate ( self, event ) :
     log.debug( 'text-update:' + event.target.text )
Exemple #12
0
 def visitIdleEvent(self, aParam):
     log.debug('visitIdleEvent(): ', aParam)
Exemple #13
0
 def on_imagebtn_mouseClick( self, event ) :
     log.debug( 'imagebutton-mouseClick:' + str( event.target ) )
Exemple #14
0
 def on_choice_select( self, event ) :
     log.debug( '\nchoice-selected: ' + str( event.target ) )
Exemple #15
0
 def on_checkbox_mouseClick( self, event ) :
     log.debug( '\ncheckbox-clicked: ' + str( event.target ) )
Exemple #16
0
 def on_radiogroup_select( self, event ) :
     log.debug( event.target )
Exemple #17
0
 def on_field1_keyUp ( self, event ) :
     log.debug( 'key-up:' + str( event ) )