예제 #1
0
def initWidget(widget):
    global richtext
    global penguin

    karamba.resizeWidget(widget, 360, 520)

    penguin = karamba.createImage(
        widget, 250, 150,
        karamba.getThemePath(widget) + "/penguin_executive.png")
    karamba.hideImage(widget, penguin)

    text = """
<h1>Richtext Example</h1>
<p>A rich text object allows to display a string interpreted as rich text.
To create a rich text object use the command:<br> <p align="center">karamba.createRichText(widget, text)</p>
A simple subset of <a href="kfmclient openURL http://www.selfhtml.org"><font color="black"><i>HTML</i></font></a>-tags
is used to encode the formatting commands.</p>
<p><font size=+2>Some features:</font>
<ul>
<li>Numbered and unnumbered lists</li>
<li>Inline Images <img src=\"""" + karamba.getThemePath(
        widget) + u"""info.png\"</li>
<li>Various <font color="red">different</font><font color="blue"> text</font><font color="green"> colours</font></li>
<li>Hyperlinks: <a href="kfmclient openURL http://netdragon.sourceforge.net"> Superkaramba Homepage</a></li>
<li>Links can also <a href="#trigger">trigger</a> actions in the script</li>
<li><i>Various</i> <b>different</b> <u>caracter</u> <s>styles</s></li>
<li><a href="kfmclient openURL http://www.unicode.org">Unicode</a>: \u03B6 \u03B3 \u03BB \u03A3 \u03A9 </li>
<li>Simple Tables:
<table bgcolor="darkgray" border="1" width="80%">
<tr><th colspan="3">Header</th></tr>
<tr><td>Cell (1,1)</td><td>Cell (1,2)</td><td>Cell (1,3)</td><tr>
<tr><td>Cell (2,1)</td><td>Cell (2,2)</td><td>Cell (2,3)</td><tr>
</table></li>
</ul>
For a complete documentation of all supported tags look at:
<a href="kfmclient openURL http://doc.trolltech.com/3.0/qstylesheet.html">
http://doc.trolltech.com/3.0/qstylesheet.html</a>.
</p><br>
"""

    richtext = karamba.createRichText(widget, text)

    karamba.moveRichText(widget, richtext, 10, 10)

    print "richText Size = ", karamba.getRichTextSize(widget, richtext)

    karamba.setRichTextWidth(widget, richtext, 345)

    #karamba.deleteRichText(widget, richtext)

    karamba.redrawWidget(widget)
예제 #2
0
def initWidget(widget):
    global richtext
    global penguin

    karamba.resizeWidget(widget, 360, 520)

    penguin = karamba.createImage(widget, 250, 150, karamba.getThemePath(widget) + "/penguin_executive.png")
    karamba.hideImage(widget, penguin)


    text = """
<h1>Richtext Example</h1>
<p>A rich text object allows to display a string interpreted as rich text.
To create a rich text object use the command:<br> <p align="center">karamba.createRichText(widget, text)</p>
A simple subset of <a href="kfmclient openURL http://www.selfhtml.org"><font color="black"><i>HTML</i></font></a>-tags
is used to encode the formatting commands.</p>
<p><font size=+2>Some features:</font>
<ul>
<li>Numbered and unnumbered lists</li>
<li>Inline Images <img src=\"""" + karamba.getThemePath(widget) + u"""info.png\"</li>
<li>Various <font color="red">different</font><font color="blue"> text</font><font color="green"> colours</font></li>
<li>Hyperlinks: <a href="kfmclient openURL http://netdragon.sourceforge.net"> Superkaramba Homepage</a></li>
<li>Links can also <a href="#trigger">trigger</a> actions in the script</li>
<li><i>Various</i> <b>different</b> <u>caracter</u> <s>styles</s></li>
<li><a href="kfmclient openURL http://www.unicode.org">Unicode</a>: \u03B6 \u03B3 \u03BB \u03A3 \u03A9 </li>
<li>Simple Tables:
<table bgcolor="darkgray" border="1" width="80%">
<tr><th colspan="3">Header</th></tr>
<tr><td>Cell (1,1)</td><td>Cell (1,2)</td><td>Cell (1,3)</td><tr>
<tr><td>Cell (2,1)</td><td>Cell (2,2)</td><td>Cell (2,3)</td><tr>
</table></li>
</ul>
For a complete documentation of all supported tags look at:
<a href="kfmclient openURL http://doc.trolltech.com/3.0/qstylesheet.html">
http://doc.trolltech.com/3.0/qstylesheet.html</a>.
</p><br>
"""

    richtext = karamba.createRichText(widget, text)

    karamba.moveRichText(widget, richtext, 10, 10)

    print "richText Size = ", karamba.getRichTextSize(widget, richtext)

    karamba.setRichTextWidth(widget, richtext, 345)

    #karamba.deleteRichText(widget, richtext)

    karamba.redrawWidget(widget)
예제 #3
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))
예제 #4
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 ) )
예제 #5
0
파일: eyes.py 프로젝트: Fat-Zer/tdeutils
def widgetUpdated(widget):
	global init
	global linkePupille
	global rechtePupille
	
	global w_width
	global w_height

	global w_x
	global w_y

	global lx
	global ly
	global la
	global lb

	global lp_width
	global lp_height

	global rx
	global ry
	global ra
	global rb

	global rp_width
	global rp_height

	global x_old
	global y_old

	if init == 0:
		theme_path = karamba.getThemePath(widget) + "/"
		
		# read widget coordinates from eyes.theme
		# f = open(theme_path + "eyes.theme")

		# karamba_line = ""
		#while re.compile('KARAMBA').search(karamba_line) == None:
		# 	karamba_line = f.readline()

		#w_x = int(re.compile('X=([0-9]+)').search(karamba_line).group(1))
		#w_y = int(re.compile('Y=([0-9]+)').search(karamba_line).group(1))

		#f.close()

		#karamba.createWidgetMask(widget, theme_path + "pics/mask.png")

		linkePupille = karamba.createImage(widget, 15, 30, theme_path + "pics/pupille.png")
		rechtePupille = karamba.createImage(widget, 100, 30, theme_path + "pics/pupille.png")	
		init = 1

		karamba.redrawWidget(widget)

	# query mouse-cursor position
	x, y = xcursor.position()
	
	#fp = os.popen("./xpos")
	#output = fp.read()
	#x, y = output.split()
	
	#print x, y

	if x != x_old or y != y_old:		
		x_old, y_old = x, y
		# Get Widget Position
		w_x, w_y = karamba.getWidgetPosition(widget)

		# Calc left pupille
		xp, yp = pupille (int(x), int(y), lx, ly, la, lb, w_x, w_y)

		xp = xp - lp_width / 2
		yp = yp - lp_height / 2
		#print xp, yp

		karamba.moveImage(widget, linkePupille, xp, yp)

		# Calc right pupille
		xp, yp = pupille (int(x), int(y), rx, ry, ra, rb, w_x, w_y)

		xp = xp - rp_width / 2
		yp = yp - rp_height / 2
		#print xp, yp

		karamba.moveImage(widget, rechtePupille, xp, yp)

		karamba.redrawWidget(widget)
예제 #6
0
def widgetUpdated(widget):
    global init
    global linkePupille
    global rechtePupille

    global w_width
    global w_height

    global w_x
    global w_y

    global lx
    global ly
    global la
    global lb

    global lp_width
    global lp_height

    global rx
    global ry
    global ra
    global rb

    global rp_width
    global rp_height

    global x_old
    global y_old

    if init == 0:
        theme_path = karamba.getThemePath(widget) + "/"

        # read widget coordinates from eyes.theme
        # f = open(theme_path + "eyes.theme")

        # karamba_line = ""
        #while re.compile('KARAMBA').search(karamba_line) == None:
        # 	karamba_line = f.readline()

        #w_x = int(re.compile('X=([0-9]+)').search(karamba_line).group(1))
        #w_y = int(re.compile('Y=([0-9]+)').search(karamba_line).group(1))

        #f.close()

        #karamba.createWidgetMask(widget, theme_path + "pics/mask.png")

        linkePupille = karamba.createImage(widget, 15, 30,
                                           theme_path + "pics/pupille.png")
        rechtePupille = karamba.createImage(widget, 100, 30,
                                            theme_path + "pics/pupille.png")
        init = 1

        karamba.redrawWidget(widget)

    # query mouse-cursor position
    x, y = xcursor.position()

    #fp = os.popen("./xpos")
    #output = fp.read()
    #x, y = output.split()

    #print x, y

    if x != x_old or y != y_old:
        x_old, y_old = x, y
        # Get Widget Position
        w_x, w_y = karamba.getWidgetPosition(widget)

        # Calc left pupille
        xp, yp = pupille(int(x), int(y), lx, ly, la, lb, w_x, w_y)

        xp = xp - lp_width / 2
        yp = yp - lp_height / 2
        #print xp, yp

        karamba.moveImage(widget, linkePupille, xp, yp)

        # Calc right pupille
        xp, yp = pupille(int(x), int(y), rx, ry, ra, rb, w_x, w_y)

        xp = xp - rp_width / 2
        yp = yp - rp_height / 2
        #print xp, yp

        karamba.moveImage(widget, rechtePupille, xp, yp)

        karamba.redrawWidget(widget)