Fix position of comments.
[xiph/unicode.git] / xinloe / general.py
blob15c6adb50e713d17ec521ebcadc40d7400da79b0
1 '''
2 Xinloe -- A Python-Based Non-Linear Ogg Editor
3 Copyright (C) 2004 Arc Riley <arc@Xiph.org>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 '''
22 # We'll import all external modules here
24 import os
25 import wx
26 import ogg2
27 import time, string
28 from wxPython.wx import *
29 from wxPython.lib.scrolledpanel import wxScrolledPanel
31 def geticon(name, size=1):
32 sizes=('16x16','22x22','32x32','48x48')
33 f = 'icons/%s/%s.png' % (sizes[size], name)
34 if not os.path.exists(f) :
35 f = 'icons/%s/%s.png' % (sizes[size], 'unknown')
36 return wxImage(f, wxBITMAP_TYPE_PNG).ConvertToBitmap()
38 def gettext(parent, string, size=1):
39 text = wxStaticText(parent, -1, string)
40 font = text.GetFont()
41 font.SetPointSize(font.GetPointSize()+size)
42 text.SetFont(font)
43 return text
45 def timestr(seconds):
46 hours = seconds/3600
47 minutes = (seconds-( hours*3600 ))/60
48 seconds = (seconds-((hours*3600)+(minutes*60)))
49 return '%s:%s:%s' % \
50 (str(hours).zfill(2), str(minutes).zfill(2), str(seconds).zfill(2))
52 def ratestr(bytes, seconds):
53 if seconds == 0 : return '0bps'
54 bps = (bytes * 8.0) / seconds
55 if bps > 1073741823:
56 return '%dgbps' % round(bps/1073741824,2)
57 if bps > 1048575 :
58 return '%dmbps' % round(bps/1048576,1)
59 if bps > 1023 :
60 return '%dkbps' % round(bps/1024,0)
61 return '%dbps' % round(bps,0)
63 def bytestr(bytes):
64 if bytes > 1073741823:
65 return '%dgb' % round(bytes/1073741824,2)
66 if bytes > 1048575 :
67 return '%dmb' % round(bytes/1048576,1)
68 if bytes > 1023 :
69 return '%dkb' % round(bytes/1024,0)
70 return '%db' % round(bytes,0)