Can't change font size
#1
Star 
Hello I can't seem to be able to change the font size in this script I made, so it looks like the following
Image
Can anybody help!!!!!!Wink


Code:
import socket
import xbmc, xbmcgui, threading, thread, os, urllib, time
from string import *

try:
    EMULATING = xbmcgui.Emulating
    SCRIPTFOLDER     = "c:\\win32app\\Python24\\CallerId"
except:
    EMULATING = False
    SCRIPTFOLDER = os.getcwd()

# ////////////////////////////////////////USER SETTINGS//////////////////////////////////////////////////////////////////////////////
MYAREACODE     = "250"    # SPECIFY YOUR AREA CODE
DOPAUSE     = 1            # PAUSE PLAYBACK ON INCOMING CALL?
DOINITMSG   = 1         # SHOW AN INITIALISATION MESSAGE WHEN SCRIPT STARTS
DOIMAGE     = 1            # SPECIFY WHETHER OR NOT TO DISPLAY PICTURE WITH DIALOG
DOSOUND        = 1            # SPECIFY WHETHER TO PLAY A SOUND
DELAY         = 5            # SPECIFY DELAY BEFORE CLOSE IN SECONDS
SERVERTYPE     = "YAC"        # SPECIFY "YAC"
OSDTITLE    = "Phone Call..."    # TITLE TO SHOW ON INCOMING CALL DIALOG
SOUNDFILE    = "incoming-a.wav"  # WAV FILE TO PLAY IF DOSOUND IS ENABLED
NAMEPOPUP    = "Name:"  # TO DISPLAY BEFORE NAME
NUMBERPOPUP    = "Number:"  # TO DIASPLAY BEFORE NUMBER
HOUR = str(time.strftime ('%I:'))
HOUR = HOUR.lstrip('0')
MINUTES = str(time.strftime ('%M%p'))
TIME = "(" + HOUR + MINUTES + ")"
YACPORT = 10629
# ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

HOST = ''            # Symbolic name meaning the local host

xOffset = 3        # These are used to give a black shadow effect to text
yOffset = 3        # MattC.  


# ////////////////////////////////////////PACKET DECRYPTION//////////////////////////////////////////////////////////////////////////
class packet:
    def __init__(self, type, param1, param2 = "", param3 = ""):
        self.type = type
        self.param1 = param1
        self.param2 = param2
        self.param3 = param3

def decodepacket(the_string):
    type = ord(the_string[0])
    param1 = (ord(the_string[5]) * 256) + ord(the_string[4])

    param2 = the_string[8:72]
    param3 = the_string[72:]
    for i in range(-63, 0):
        if ord(param2[-i]) == 0: param2 = param2[:-i]
        if ord(param3[-i]) == 0: param3 = param3[:-i]
    return packet(type, param1, param2, param3)

def encodepacket(the_packet):
    r = " "
    r = r + chr(the_packet.type)
    r = r[1:]
    r = r + chr(0)
    r = r + chr(the_packet.param1 - ((the_packet.param1 / 256) * 256))
    r = r + chr(the_packet.param1 / 256)
    r = r + chr(0)

    r = r + the_packet.param2
    for i in range(len(r), 72):
        r = r + chr(0)
    r = r + the_packet.param3
    for i in range(len(r), 136):
        r = r + chr(0)
    return r

def formatnumber( n ):
    if len( n ) == 7:
        return "(" + MYAREACODE + ") " + n[:3] + "-" + n[3:]
    if len( n ) == 10:
        return "(" + n[:3] + ") " + n[3:6] + "-" + n[6:]
    if len( n ) == 11:
        return n[0] + " (" + n[1:4] + ") " + n[4:7] + "-" + n[7:]
    return n

def fileExists(f):
    try:
        file = open(f)
    except IOError:
        exists = 0
    else:
        exists = 1
    return exists
# ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

# ////////////////////////////////////////CALLER ID ACTIVE////////////////////////////////////////////////////////////////////////////
class initialise(xbmcgui.WindowDialog):
    
    def __init__(self):
        if EMULATING: xbmcgui.Window.__init__(self)
        
        w = self.getWidth()
        h = self.getHeight()

        self.a = -1
        self.shown = 1

        self.titleBlack = xbmcgui.ControlLabel(w - (275+xOffset), h - (133+yOffset), 200, 200, 'Caller ID Active', 'font14', '0xff000000')
        self.titleWhite = xbmcgui.ControlLabel(w - 275, h - 133, 200, 200, 'Caller ID Active', 'font14', '0xffffffff')
        self.addControl(self.titleBlack)
        self.addControl(self.titleWhite)

        subThread = threading.Thread(target=self.SubthreadProc, args=())
        subThread.start()
        
    def SubthreadProc(self):
        time.sleep(1)
        if self.shown:
            self.shown = 0
            self.close()

    def onAction(self, action):
        if self.a == action:
            self.shown = 0
            self.close()
        self.a = action
# ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

# ////////////////////////////////////////CALLER ID POPUP////////////////////////////////////////////////////////////////////////////
class caller(xbmcgui.WindowDialog):

    def __init__(self):
        if EMULATING:
            xbmcgui.Window.__init__(self)

        w = self.getWidth()
        h = self.getHeight()


        if name != "": nametodisplay = NAMEPOPUP + name
        if name == "NO NAME" or name == "": nametodisplay = number
        if name == "" and number == "": nametodisplay = data
        if location != "": nametodisplay = nametodisplay + "\n" + location

        if number != "": numbertodisplay = NUMBERPOPUP + number
        if number == "NO number" or number == "": numbertodisplay = name
        if number == "" and number == "": numbertodisplay = data
        if location != "": numbertodisplay = numbertodisplay + "\n" + location


        if not DOIMAGE:
            self.bg = xbmcgui.ControlImage(w - 282, h - 718, 299, 103, SCRIPTFOLDER + "\\Dialog\\dialog.png")
            self.addControl(self.bg)
            
            self.title = xbmcgui.ControlLabel(w - 354, h - 723, 400, 400, boxtitle + TIME, 'font14', '0xffffffff')
            self.addControl(self.title)
        
        else:
            self.frame = xbmcgui.ControlImage(w - 359, h - 718, 299, 103, SCRIPTFOLDER + "\\Dialog\\dialog.png")
            self.addControl(self.frame)
            
            self.title = xbmcgui.ControlLabel(w - 354, h - 723, 400, 400, boxtitle + TIME, 'font14', '0xffffffff')
            self.addControl(self.title)
            
            self.callerid = xbmcgui.ControlLabel(w - 352, h - 690, 200, 200, nametodisplay, 'font14', '0xFFFFFFFF')
            self.addControl(self.callerid)
            
            self.callerid = xbmcgui.ControlLabel(w - 352, h - 660, 200, 200, numbertodisplay, 'font14', '0xFFFFFFFF')
            self.addControl(self.callerid)
            
            filename = replace(number, '(', '')
            filename = replace(filename, ')', '')
            filename = replace(filename, ' ', '')
            filename = replace(filename, '-', '')
            filename = SCRIPTFOLDER + "\\Pictures\\" + filename + '.png'
            
            if not fileExists(filename): filename = SCRIPTFOLDER + "\\Pictures\\default.png"
            self.tn = xbmcgui.ControlImage(w - 139, h - 718, 77, 103, filename)
            self.addControl(self.tn)

        self.a = -1
        self.shown = 1

        if (EMULATING):
            time.sleep(1)
        else:
            if (DOPAUSE and xbmc.Player().isPlaying()):
                value1 = xbmc.Player().getTime()
                time.sleep(1)
                value2 = xbmc.Player().getTime()
                if value1 != value2:
                    xbmc.Player().pause()
            if DOSOUND: xbmc.playSFX(SCRIPTFOLDER + "\\Sounds\\" + SOUNDFILE)

        subThread = threading.Thread(target=self.SubthreadProc, args=())
        subThread.start()

    def SubthreadProc(self):
        time.sleep(DELAY)
        if self.shown:
            self.shown = 0
            self.close()

    def onAction(self, action):
        if self.a == action:
            self.shown = 0
            self.close()
        self.a = action

if SERVERTYPE == "YAC":
    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    s.bind((HOST, YACPORT))


data = ""
name = ""
number = ""
boxtitle = OSDTITLE
picurl = ""
location = ""

if not EMULATING and DOINITMSG:
    w = initialise()
    w.doModal()
    del w

while 1:
    if SERVERTYPE == "YAC":
        s.listen(1)
        conn, addr = s.accept()
        a = conn.recv(1024)
        alist = split(a[5:], "~")
        if len(alist) > 1:
            name = alist[0]
            number = alist[1]
            data = name + "\n" + number

        if picurl != "":
            tmppicurl = replace(number, '(', '')
            tmppicurl = replace(tmppicurl , ')', '')
            tmppicurl = replace(tmppicurl , ' ', '')
            tmppicurl = replace(tmppicurl , '-', '')
            urllib.urlretrieve(picurl, SCRIPTFOLDER + "\\Pictures\\" + tmppicurl + ".png")


    if data != "":
        print(data)
        w = caller()
        w.doModal()
        del w
        if SERVERTYPE == "YAC": conn.close()
        data = ""
        name = ""
        number = ""
        boxtitle = OSDTITLE
        picurl = ""
        location = ""        
# ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Reply
#2
Never mind I figured it out
Reply
#3
Ok new problem, my plan was to use my Myfont http://forum.xbmc.org/showthread.php?tid=65436 to have the same font regardless of the theme but every time I start the script I get this error no module named Myfont. Myfont.py is in scripfolder/resources/lib/Myfont.py. Can any body help!!
Reply

Logout Mark Read Team Forum Stats Members Help
Can't change font size0