Exemplo n.º 1
0
def readConfigCPUFormat(widget, theme_cfg):
	global Instances
	id = karamba.readConfigEntry(widget, "id")
	toptext = karamba.getThemeText(widget, "toptext")
	#### Begin reading optional settings from [cpuFormat] ####
	# if one option is missing. Then use defaults
#  	cpu_padding = karamba.readConfigEntry(widget, "cpu_padding")
#  	cpu_decimal_1 = karamba.readConfigEntry(widget, "cpu_decimal_1")
# 	cpu_decimal_0 = karamba.readConfigEntry(widget, "cpu_decimal_0")
# 	hide_0 = karamba.readConfigEntry(widget, "hide_0")
# 	cpu_rem_0 = karamba.readConfigEntry(widget, "cpu_rem_0")
#
# 	if cpu_decimal_1:
# 		cpu_more_one = "%0.1f"
# 	if cpu_decimal_0:
# 		cpu_less_one = "%0.1f"

	showZero = karamba.readConfigEntry(widget, "showZero")
	if showZero == None:
		karamba.setMenuConfigOption(widget, "showZero", 0)
		karamba.writeConfigEntry(widget, "showZero", "false")
		try:
			hide_0 = theme_cfg.getboolean( "cpuFormat" , "hide_0" )
			if hide_0:
				Instances[id].cpuHideZero()

		except ConfigParser.NoOptionError, (strerror):
			print "Warning: " + str(strerror) + ". Skipping option."
Exemplo n.º 2
0
def readConfigCPUFormat(widget, theme_cfg):
    global Instances
    id = karamba.readConfigEntry(widget, "id")
    toptext = karamba.getThemeText(widget, "toptext")
    #### Begin reading optional settings from [cpuFormat] ####
    # if one option is missing. Then use defaults
    #  	cpu_padding = karamba.readConfigEntry(widget, "cpu_padding")
    #  	cpu_decimal_1 = karamba.readConfigEntry(widget, "cpu_decimal_1")
    # 	cpu_decimal_0 = karamba.readConfigEntry(widget, "cpu_decimal_0")
    # 	hide_0 = karamba.readConfigEntry(widget, "hide_0")
    # 	cpu_rem_0 = karamba.readConfigEntry(widget, "cpu_rem_0")
    #
    # 	if cpu_decimal_1:
    # 		cpu_more_one = "%0.1f"
    # 	if cpu_decimal_0:
    # 		cpu_less_one = "%0.1f"

    showZero = karamba.readConfigEntry(widget, "showZero")
    if showZero == None:
        karamba.setMenuConfigOption(widget, "showZero", 0)
        karamba.writeConfigEntry(widget, "showZero", "false")
        try:
            hide_0 = theme_cfg.getboolean("cpuFormat", "hide_0")
            if hide_0:
                Instances[id].cpuHideZero()

        except ConfigParser.NoOptionError, (strerror):
            print "Warning: " + str(strerror) + ". Skipping option."
Exemplo n.º 3
0
def initWidget(widget):
    """ This is called when your widget is initialized"""
    global startButton
    global endButton
    global progressBar
    global curtimefile
    global done      # "done" image widget
    global hours     # these ...
    global minutes   # ... are the...
    global seconds   # widget texts


    # initialize handlers to all meters
    hours = karamba.getThemeText(widget, "hours")
    seconds = karamba.getThemeText(widget, "seconds")
    minutes = karamba.getThemeText(widget, "minutes")
    progressBar = karamba.getThemeBar(widget, "progress")
    karamba.hideBar(widget, progressBar)
    startButton = karamba.getThemeImage(widget, "start")
    karamba.attachClickArea(widget, startButton, "", "", "")
    endButton = karamba.getThemeImage(widget, "end")
    karamba.attachClickArea(widget, endButton, "", "", "")
    done = karamba.getThemeImage(widget, "done")
    karamba.attachClickArea(widget, done, "", "", "")

    # read data from config file
    zerotime_str = str(karamba.readConfigEntry(widget, "zerotime"))
    print "zerotime from config: %s" % zerotime_str
    zerotime.from_string(zerotime_str)
    alarmtime_str= str(karamba.readConfigEntry(widget, "alarmtime"))
    print "alarmtime from config: %s" % alarmtime_str
    alarmtime.from_string(alarmtime_str)


    # set time from last used time
    curtimefile =  os.path.join(os.environ['HOME'], \
                                '.superkaramba', \
                                'stoptimer', \
                                'curtime')
    if os.path.isfile(curtimefile):
        curtimefh = open(curtimefile)
        curtimestring = curtimefh.read()
        curtime.from_string(curtimestring)
        curtimefh.close()
    else:
        if not os.path.isdir( \
         os.path.join(os.environ['HOME'], '.superkaramba')):
            os.mkdir(os.path.join(os.environ['HOME'], '.superkaramba'))
        if not os.path.isdir( \
        os.path.join(os.environ['HOME'], '.superkaramba', 'stoptimer')):
            os.mkdir(os.path.join( \
                     os.environ['HOME'], '.superkaramba', 'stoptimer'))

    showTime(widget, curtime)
Exemplo n.º 4
0
def readConfigThreading(widget):
	global Instances
	id = karamba.readConfigEntry(widget, "id")
	disableThreading = karamba.readConfigEntry(widget, "disableThreading")
	if disableThreading == None or disableThreading == "true":
		karamba.setMenuConfigOption(widget, "disableThreading", 1)
		karamba.writeConfigEntry(widget, "disableThreading", "true")
		disableThreading = True
	else:
		disableThreading = False

	Instances[id].setDisableThreading(disableThreading)
Exemplo n.º 5
0
def readConfigTop(widget, theme_cfg):
	global theme_dir, Instances
	id = karamba.readConfigEntry(widget, "id")

	#### Begin reading the [top] section of the config file ####
	num_procs = karamba.readConfigEntry(widget, "num_procs")
	if num_procs == None or int(num_procs) < 1:
		try:
			num_procs = theme_cfg.getint( "top", "num_procs" )
			Instances[id].setNumProcs(num_procs)
		except ConfigParser.NoOptionError, (strerror):
			print "Warning: " + str(strerror) + ". Using default."
Exemplo n.º 6
0
def readConfigTop(widget, theme_cfg):
    global theme_dir, Instances
    id = karamba.readConfigEntry(widget, "id")

    #### Begin reading the [top] section of the config file ####
    num_procs = karamba.readConfigEntry(widget, "num_procs")
    if num_procs == None or int(num_procs) < 1:
        try:
            num_procs = theme_cfg.getint("top", "num_procs")
            Instances[id].setNumProcs(num_procs)
        except ConfigParser.NoOptionError, (strerror):
            print "Warning: " + str(strerror) + ". Using default."
Exemplo n.º 7
0
def readConfigThreading(widget):
    global Instances
    id = karamba.readConfigEntry(widget, "id")
    disableThreading = karamba.readConfigEntry(widget, "disableThreading")
    if disableThreading == None or disableThreading == "true":
        karamba.setMenuConfigOption(widget, "disableThreading", 1)
        karamba.writeConfigEntry(widget, "disableThreading", "true")
        disableThreading = True
    else:
        disableThreading = False

    Instances[id].setDisableThreading(disableThreading)
Exemplo n.º 8
0
def readConfigFormatting(widget, theme_cfg):
    global Instances
    id = karamba.readConfigEntry(widget, "id")
    toptext = karamba.getThemeText(widget, "toptext")
    #### Begin reading optional settings from [formatting] ####

    alignment = karamba.readConfigEntry(widget, "setCmdJustification")
    if alignment == None or alignment.strip() == "":
        try:
            alignment = theme_cfg.get("formatting", "setCmdJustification")
        except ConfigParser.NoOptionError, (strerror):
            print "Warning: " + str(strerror) + ". Setting option to left."
            alignment = "left"
Exemplo n.º 9
0
def readConfigFormatting(widget, theme_cfg):
	global Instances
	id = karamba.readConfigEntry(widget, "id")
	toptext = karamba.getThemeText(widget, "toptext")
	#### Begin reading optional settings from [formatting] ####

	alignment = karamba.readConfigEntry(widget, "setCmdJustification")
	if alignment == None or alignment.strip() == "":
		try:
			alignment = theme_cfg.get( "formatting", "setCmdJustification" )
		except ConfigParser.NoOptionError, (strerror):
			print "Warning: " + str(strerror) + ". Setting option to left."
			alignment = "left"
Exemplo n.º 10
0
def initWidget(widget):
	global itempointer, diff, clickScrollUp, clickScrollDown, update, browserCommand
	
	getHeise(heise_url[urlpointer])
	createMenu(widget)

	y_pos = 23
	z = 0 
	while z < lines:
   		itempointer.insert(z ,karamba.createText(widget, 14, y_pos, theme_width-18, line_height, ""))
		setStyle(widget, itempointer[z], 1, 17)
		karamba.changeTextColor(widget, itempointer[z], r,g,b)
		y_pos = y_pos + 15
		z = z + 1
	
	karamba.changeTextColor(widget, fill[0], 54,227,123)
#	karamba.changeTextColor(widget, fill[0], 255,255,255)
	# Menuoption "browser"
	karamba.addMenuConfigOption(widget, "browser", "Change your browser")
	browserCommand = karamba.readConfigEntry(widget, "browser") or "konqueror"
	# Up
	clickScrollUp = karamba.createImage(widget, 0, 0, "up.png")
	karamba.moveImage(widget, clickScrollUp, 50, 2)
	karamba.attachClickArea(widget, clickScrollUp, "")

	#Down
	clickScrollDown = karamba.createImage(widget, 0, 0, "down.png")
	karamba.moveImage(widget, clickScrollDown, 22, 3)
	karamba.attachClickArea(widget, clickScrollDown, "")
	
	fillContent(widget, "refresh")
	update = 0
	widgetUpdated(widget)
Exemplo n.º 11
0
def initWidget(widget):
    global Instances, titletext, themePath, theme_dir

    #Using a unique ID for multiple instances of karamTop
    id = karamba.readConfigEntry(widget, "id")
    if id == None:
        id = str(int(time.time() * 100))
        karamba.writeConfigEntry(widget, "id", id)

    # Figure out what theme to use. flatgray is the default
    theme = karamba.readConfigEntry(widget, "karamtop theme")
    if theme == None or theme == "":
        theme = "flatgray"

    theme_dir = "themes/"
    themePath = karamba.getThemePath(widget)
    ### Thanks to liquid weather for dealing with the skz format
    home_directory = os.popen("echo $HOME").readline()[0:-1]
    if themePath[-3:] == "skz":
        skz_file = zipfile.ZipFile(themePath, 'r')
        theme_file = skz_file.read(theme_dir + theme + "/" + theme + ".cfg")
        try:
            os.mknod(home_directory + '/.superkaramba/ktop_theme_conf')
        except (OSError):
            pass

        ktop_file = open(home_directory + '/.superkaramba/ktop_theme_conf',
                         'w')
        ktop_file.write(theme_file)
        ktop_file.close()
        theme_cfg_file = (home_directory + '/.superkaramba/ktop_theme_conf')
        skz_file.close()
    else:
        theme_cfg_file = (themePath + theme_dir + theme + "/" + theme + ".cfg")

    theme_cfg = ConfigParser.ConfigParser()
    theme_cfg.readfp(open(theme_cfg_file))

    toptext = karamba.getThemeText(widget, "toptext")
    ##########################################################
    #### Initialize the Top class ####
    try:
        Instances[id] = None
        Instances[id] = (pytop.Top(widget, toptext))
    except NameError, (strerror):
        Instances = {}
        Instances[id] = (pytop.Top(widget, toptext))
Exemplo n.º 12
0
def initWidget(widget):
    global Instances, titletext, themePath, theme_dir

    #Using a unique ID for multiple instances of karamTop
    id = karamba.readConfigEntry(widget, "id")
    if id == None:
    	id = str( int( time.time() * 100 ) )
	karamba.writeConfigEntry(widget, "id", id)

    # Figure out what theme to use. flatgray is the default
    theme = karamba.readConfigEntry(widget, "karamtop theme")
    if theme == None or theme == "":
	    theme = "flatgray"

    theme_dir = "themes/"
    themePath = karamba.getThemePath(widget)
    ### Thanks to liquid weather for dealing with the skz format
    home_directory = os.popen("echo $HOME").readline()[0:-1]
    if themePath[-3:] == "skz":
	skz_file = zipfile.ZipFile(themePath, 'r')
	theme_file = skz_file.read(theme_dir + theme + "/" + theme + ".cfg")
	try:
		os.mknod(home_directory + '/.superkaramba/ktop_theme_conf')
	except(OSError):
		pass

	ktop_file = open(home_directory + '/.superkaramba/ktop_theme_conf','w')
	ktop_file.write(theme_file)
	ktop_file.close()
	theme_cfg_file = (home_directory + '/.superkaramba/ktop_theme_conf')
	skz_file.close()
    else:
    	theme_cfg_file = ( themePath + theme_dir + theme + "/" + theme + ".cfg" )

    theme_cfg = ConfigParser.ConfigParser()
    theme_cfg.readfp( open( theme_cfg_file ) )

    toptext = karamba.getThemeText(widget, "toptext")
    ##########################################################
    #### Initialize the Top class ####
    try:
	Instances[id] = None
    	Instances[id] = ( pytop.Top( widget, toptext ) )
    except NameError, (strerror):
	Instances = {}
	Instances[id] = ( pytop.Top( widget, toptext ) )
Exemplo n.º 13
0
def getLocale(widget):
	GetLocale = karamba.readConfigEntry(widget, "locale") # have you set any language?
	if GetLocale == None:
		# no language found, using english
		# print "No locale-setting was found. Using English en_US"
		karamba.writeConfigEntry(widget, "locale", "en_US")
		SetLocale = "en_US.ISO8859-1"	
	else:
		# language found! using it
		# print "Locale-setting " + SetLocale + " was found!"
		SetLocale = GetLocale + ".ISO8859-1"
	return SetLocale
Exemplo n.º 14
0
def readConfigMemFormat(widget, theme_cfg):
    global Instances
    id = karamba.readConfigEntry(widget, "id")
    toptext = karamba.getThemeText(widget, "toptext")
    #### Begin reading optional settings from [memFormat] ####
    # if one option is missing. Then use defaults
    try:
        mem_padding = theme_cfg.get("memFormat", "padding").strip()
        kilobytes = theme_cfg.get("cpuFormat", "kilobytes", True)
        megabytes = theme_cfg.get("cpuFormat", "megabytes", True)
        gigabytes = theme_cfg.get("cpuFormat", "gigabytes", True)
        Instances[id].memFormat(mem_padding, kilobytes, megabytes, gigabytes)
    except ConfigParser.NoOptionError, (strerror):
        print "Warning: " + str(strerror) + ". Skipping whole section."
Exemplo n.º 15
0
def readConfigMemFormat(widget, theme_cfg):
	global Instances
	id = karamba.readConfigEntry(widget, "id")
	toptext = karamba.getThemeText(widget, "toptext")
	#### Begin reading optional settings from [memFormat] ####
	# if one option is missing. Then use defaults
	try:
		mem_padding = theme_cfg.get( "memFormat" , "padding" ).strip()
		kilobytes = theme_cfg.get( "cpuFormat" , "kilobytes", True )
		megabytes = theme_cfg.get( "cpuFormat" , "megabytes", True )
		gigabytes = theme_cfg.get( "cpuFormat" , "gigabytes", True )
		Instances[id].memFormat( mem_padding, kilobytes, megabytes, gigabytes)
	except ConfigParser.NoOptionError, (strerror):
		print "Warning: " + str(strerror) + ". Skipping whole section."
Exemplo n.º 16
0
def widgetUpdated(widget):
     global Instances

     id = karamba.readConfigEntry(widget, "id")
     Instances[id].start()
     karamba.redrawWidget(widget)
Exemplo n.º 17
0
def widgetUpdated(widget):
    global Instances

    id = karamba.readConfigEntry(widget, "id")
    Instances[id].start()
    karamba.redrawWidget(widget)
Exemplo n.º 18
0

def readConfigTitleText(widget, theme_cfg):
    titletext = karamba.getThemeText(widget, "titletext")
    #### Read the titletext x and y position from the config file ####
    # required option
    try:
        x, y = theme_cfg.get("karamba", "titletext_pos").split(",", 1)
        karamba.moveText(widget, titletext, int(x), int(y))
    except ConfigParser.NoOptionError, (strerror):
        displayError('Title Text',
                     'Missing parameters for the position of the title text.')
        raise

    #### Begin reading optional settings for titletext ####
    titletext_value = karamba.readConfigEntry(widget, "titletext_value")
    if titletext_value == None:
        try:
            titletext_value = theme_cfg.get("karamba", "titletext_value")
            karamba.changeText(widget, titletext, titletext_value.strip())
        except ConfigParser.NoOptionError, (strerror):
            print "Warning: " + str(strerror) + ". Using default."
    else:
        karamba.changeText(widget, titletext, titletext_value.strip())

    titletext_color = karamba.readConfigEntry(widget, "titletext_color")
    if titletext_color == None or titletext_color == "":
        try:
            r, g, b = theme_cfg.get("karamba", "titletext_color").split(",", 2)
            karamba.changeTextColor(widget, titletext, int(r), int(g), int(b))
        except ConfigParser.NoOptionError, (strerror):
Exemplo n.º 19
0
		x, y, file = theme_cfg.get( "images", image ).split(",", 2)
		karamba.createImage(widget, int(x), int(y), file.strip())

def readConfigTitleText(widget, theme_cfg):
	titletext = karamba.getThemeText(widget, "titletext")
	#### Read the titletext x and y position from the config file ####
	# required option
	try:
		x, y = theme_cfg.get( "karamba", "titletext_pos" ).split(",", 1 )
		karamba.moveText(widget, titletext, int(x), int(y))
	except ConfigParser.NoOptionError, (strerror):
		displayError('Title Text', 'Missing parameters for the position of the title text.')
		raise

	#### Begin reading optional settings for titletext ####
	titletext_value = karamba.readConfigEntry(widget, "titletext_value")
	if titletext_value == None:
		try:
			titletext_value = theme_cfg.get( "karamba", "titletext_value" )
			karamba.changeText(widget, titletext, titletext_value.strip())
		except ConfigParser.NoOptionError, (strerror):
			print "Warning: " + str(strerror) + ". Using default."
	else:
		karamba.changeText(widget, titletext, titletext_value.strip())

	titletext_color = karamba.readConfigEntry(widget, "titletext_color")
	if titletext_color == None or titletext_color == "":
		try:
			r, g, b = theme_cfg.get( "karamba", "titletext_color" ).split(",", 2)
			karamba.changeTextColor(widget, titletext, int(r), int(g), int(b))
		except ConfigParser.NoOptionError, (strerror):