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)
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."
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."
def initWidget(widget): global input, output #input = karamba.getThemeInputBox(widget, "input01") input = karamba.createInputBox(widget,0,0,50,20,"foo") output = karamba.getThemeText(widget, "output01") karamba.changeTextColor(widget, output, 0, 0, 0) karamba.changeTextSize(widget, output, 10) karamba.redrawWidget(widget)
def initWidget(widget): global input, output #input = karamba.getThemeInputBox(widget, "input01") input = karamba.createInputBox(widget, 0, 0, 50, 20, "foo") output = karamba.getThemeText(widget, "output01") karamba.changeTextColor(widget, output, 0, 0, 0) karamba.changeTextSize(widget, output, 10) karamba.redrawWidget(widget)
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
def initWidget(widget): global input1, input2, output, fontSize #input = karamba.getThemeInputBox(widget, "input01") input1 = karamba.createInputBox(widget, 0, 0, 50, 20, "foo") input2 = karamba.createInputBox(widget, 0, 30, 50, 20, "bar") fontSize = karamba.getInputBoxFontSize(widget, input2) output = karamba.getThemeText(widget, "output01") karamba.changeTextColor(widget, output, 0, 0, 0) karamba.changeTextSize(widget, output, 10) karamba.redrawWidget(widget)
def initWidget(widget): global input1, input2, output, fontSize #input = karamba.getThemeInputBox(widget, "input01") input1 = karamba.createInputBox(widget,0,0,50,20,"foo") input2 = karamba.createInputBox(widget,0,30,50,20,"bar") fontSize = karamba.getInputBoxFontSize(widget, input2) output = karamba.getThemeText(widget, "output01") karamba.changeTextColor(widget, output, 0, 0, 0) karamba.changeTextSize(widget, output, 10) karamba.redrawWidget(widget)
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
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"
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"
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."
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."
def initWidget(widget): global graphs, labels graphs[0] = karamba.getThemeGraph(widget, "graphLeft") graphs[1] = karamba.getThemeGraph(widget, "graphDown") graphs[2] = karamba.getThemeGraph(widget, "graphFilled") graphs[3] = karamba.getThemeGraph(widget, "graphMin") labels[0] = karamba.getThemeText(widget, "downValue") labels[1] = karamba.getThemeText(widget, "leftValue") labels[2] = karamba.getThemeText(widget, "filledValue") labels[3] = karamba.getThemeText(widget, "minValue") # most of these values are already present in the theme # these are here to show examples of how to work with the # advanced graphing attributes in python # set fill color for last two graphs karamba.setGraphFillColor(widget, graphs[2], 0, 150, 255, 100) karamba.setGraphFillColor(widget, graphs[3], 0, 150, 255, 100) # setting shouldFill only available in python but it is not # needed if the fill color is set. This call allows the fill # to be easily toggled programmatically. karamba.setGraphShouldFill(widget, graphs[0], 0) karamba.setGraphShouldFill(widget, graphs[1], 0) karamba.setGraphShouldFill(widget, graphs[2], 1) karamba.setGraphShouldFill(widget, graphs[3], 1) karamba.setGraphPlot(widget, graphs[0], "up") karamba.setGraphPlot(widget, graphs[1], "down") karamba.setGraphPlot(widget, graphs[2], "up") karamba.setGraphPlot(widget, graphs[3], "up") karamba.setGraphScroll(widget, graphs[0], "left") karamba.setGraphScroll(widget, graphs[1], "right") karamba.setGraphScroll(widget, graphs[2], "right") karamba.setGraphScroll(widget, graphs[3], "right")
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))
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 ) )
def initWidget(widget): global texts, b texts[0] = karamba.getThemeText(widget, "text0") texts[1] = karamba.getThemeText(widget, "text1") texts[2] = karamba.getThemeText(widget, "text2") texts[3] = karamba.getThemeText(widget, "text3") texts[4] = karamba.getThemeText(widget, "text4") texts[5] = karamba.getThemeText(widget, "text5") texts[6] = karamba.getThemeText(widget, "text6") texts[7] = karamba.getThemeText(widget, "text7") texts[8] = karamba.getThemeText(widget, "text8") texts[9] = karamba.getThemeText(widget, "text9") texts[10] = karamba.getThemeText(widget, "text10")